Prior to this change, only the udev rules installed to eudev's prefix were
consulted by tools such as udevadm, leading to problems such as when
configuring network interfaces, or attempting to override its default rules.
While our custom eudev patch adding support for the EUDEV_RULES_DIRECTORY
environment variable could have been refined to take precedence over the
package's configured udevrulesdir, this was not pursued for the following
reasons:
1. Due to eudev's using inotify to detect new rules, the EUDEV_RULES_DIRECTORY
is fixed in Guix System, per commit e9fa17eb98 ("services: udev: Use a fixed
location for the rules directory and config.")
2. Users would have had to set EUDEV_RULES_DIRECTORY to the fixed directory
themselves to have udevadm work as expected, which is inconvenient.
3. This simple solution is already implemented and tested in NixPkgs.
* gnu/packages/linux.scm (eudev) [source]: Remove custom patch.
[arguments] <#:make-flags>: New argument.
<#:phases>: Override install phase to alter installation make flags.
* gnu/services/base.scm (udev-shepherd-service): Do not set
EUDEV_RULES_DIRECTORY environment variable.
* gnu/packages/patches/eudev-rules-directory.patch: Delete file.
* gnu/local.mk (dist_patch_DATA): De-register it.
Reported-by: Felix Lechner <felix.lechner@lease-up.com>
Change-Id: Ib8698f4b452f6fd0951bcd71831705b1be85e6e0
---
Changes in v5:
- Use #:make-flags to configure udev-rules.d prefix
- Remove now unused eudev patch
gnu/local.mk | 1 -
gnu/packages/linux.scm | 31 ++++++++++++----
.../patches/eudev-rules-directory.patch | 37 -------------------
gnu/services/base.scm | 1 -
4 files changed, 23 insertions(+), 47 deletions(-)
delete mode 100644 gnu/packages/patches/eudev-rules-directory.patch
Toggle diff (135 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 83abc86fe2..16978da169 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1240,7 +1240,6 @@ dist_patch_DATA = \
%D%/packages/patches/erlang-man-path.patch \
%D%/packages/patches/esmini-use-pkgconfig.patch \
%D%/packages/patches/esmtp-add-lesmtp.patch \
- %D%/packages/patches/eudev-rules-directory.patch \
%D%/packages/patches/exercism-disable-self-update.patch \
%D%/packages/patches/expat-CVE-2024-45490.patch \
%D%/packages/patches/expat-CVE-2024-45491.patch \
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index e95d8587b4..f4e9e30a75 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4543,12 +4543,14 @@ (define-public eudev
(file-name (git-file-name name version))
(sha256
(base32
- "1f6lz57igi7iw2ls3fpzgw42bfznam4nf9368h7x8yf1mb737yxz"))
- (patches (search-patches "eudev-rules-directory.patch"))
- (modules '((guix build utils)))))
+ "1f6lz57igi7iw2ls3fpzgw42bfznam4nf9368h7x8yf1mb737yxz"))))
(build-system gnu-build-system)
(arguments
(list
+ ;; The binary should be built to look for its rules under
+ ;; /etc/udev/rules.d, which is where the udev-shepherd-service keeps
+ ;; them.
+ #:make-flags #~(list "udevrulesdir=/etc/udev/rules.d")
#:phases
#~(modify-phases %standard-phases
(add-before 'bootstrap 'patch-file-names
@@ -4592,7 +4594,20 @@ (define-public eudev
;; such that Libtool looks for it in the usual places.
(substitute* (string-append #$output "/lib/libudev.la")
(("old_library=.*")
- "old_library=''\n"))))))
+ "old_library=''\n")))))
+ (replace 'install
+ (lambda* (#:key make-flags #:allow-other-keys #:rest args)
+ ;; Although the runtime udevrulesdir is set to
+ ;; /etc/udev/rules.d, the package should provide its default
+ ;; rules under $libdir/udev/rules.d.
+ (let* ((default-udev-rules.d (string-append #$output
+ "/lib/udev/rules.d"))
+ (make-flags (cons (string-append "udevrulesdir="
+ default-udev-rules.d)
+ (delete "udevrulesdir=/etc/udev/rules.d"
+ make-flags))))
+ (apply (assoc-ref %standard-phases 'install)
+ `(,@args #:make-flags ,make-flags))))))
#:configure-flags
#~(list "--enable-manpages"
;; By default, autoconf uses $prefix/etc. The udev-service-type
@@ -4600,9 +4615,9 @@ (define-public eudev
;; descriptions.
"--sysconfdir=/etc")))
(native-search-paths
- (list (search-path-specification
- (variable "UDEV_HWDB_PATH")
- (files '("lib/udev/hwdb.d")))))
+ (list (search-path-specification
+ (variable "UDEV_HWDB_PATH")
+ (files '("lib/udev/hwdb.d")))))
(native-inputs
(list autoconf
automake
@@ -4620,7 +4635,7 @@ (define-public eudev
;; When linked against libblkid, eudev can populate /dev/disk/by-label
;; and similar; it also installs the '60-persistent-storage.rules' file,
;; which contains the rules to do that.
- (list `(,util-linux "lib") ;for blkid
+ (list `(,util-linux "lib") ;for blkid
kmod))
(outputs '("out" "static"))
(home-page "https://github.com/eudev-project/eudev")
diff --git a/gnu/packages/patches/eudev-rules-directory.patch b/gnu/packages/patches/eudev-rules-directory.patch
deleted file mode 100644
index c4b1cfae39..0000000000
--- a/gnu/packages/patches/eudev-rules-directory.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-Add $EUDEV_RULES_DIRECTORY to the list of rules directories.
-
-The old udev 182 supported $UDEV_CONFIG_FILE, which in turn allowed
-the search path to be customized, but eudev no longer has this, hence
-this hack.
-
---- a/src/udev/udev-rules.c
-+++ b/src/udev/udev-rules.c
-@@ -48,16 +48,11 @@ struct uid_gid {
- };
- };
-
--static const char* const rules_dirs[] = {
-+static const char* rules_dirs[] = {
- UDEV_CONF_DIR "/rules.d",
- UDEV_RULES_DIR,
-- UDEV_ROOT_RUN "/udev/rules.d",
- UDEV_LIBEXEC_DIR "/rules.d",
--#ifdef HAVE_SPLIT_USR
-- "/lib/udev/rules.d",
-- "/usr/lib/udev/rules.d",
--#endif
-- "/usr/local/lib/udev/rules.d",
-+ NULL, /* placeholder for $EUDEV_RULES_DIRECTORY */
- NULL};
-
- struct udev_rules {
-@@ -1718,6 +1713,9 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
-
- udev_rules_check_timestamp(rules);
-
-+ /* Allow the user to specify an additional rules directory. */
-+ rules_dirs[3] = getenv("EUDEV_RULES_DIRECTORY");
-+
- r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
- if (r < 0) {
- log_error_errno(r, "failed to enumerate rules files: %m");
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 654e9479f2..36fef00457 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2545,7 +2545,6 @@ (define (udev-shepherd-service config)
(list udevd)
#:environment-variables
(cons*
- "EUDEV_RULES_DIRECTORY=/etc/udev/rules.d"
(string-append "LINUX_MODULE_DIRECTORY="
(getenv "LINUX_MODULE_DIRECTORY"))
(default-environment-variables)))))
--
2.48.1