apteryx pushed a commit to branch elogind-updates in repository guix. commit 2b79d3089c462e082c1ef7fc2482c88f6d92dcf1 Author: Maxim Cournoyer <maxim.courno...@gmail.com> AuthorDate: Thu Feb 6 10:17:20 2025 +0900
gnu: eudev: Build with udevrulesdir pointing to /etc/udev/rules.d. 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. Fixes: https://issues.guix.gnu.org/63508 Reported-by: Felix Lechner <felix.lech...@lease-up.com> Change-Id: Ib8698f4b452f6fd0951bcd71831705b1be85e6e0 --- gnu/local.mk | 1 - gnu/packages/linux.scm | 31 +++++++++++++++----- gnu/packages/patches/eudev-rules-directory.patch | 37 ------------------------ gnu/services/base.scm | 1 - 4 files changed, 23 insertions(+), 47 deletions(-) diff --git a/gnu/local.mk b/gnu/local.mk index c3e11132b4..fda2f48ca7 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1252,7 +1252,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 a6bffa2bb9..97d25bb973 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -4900,12 +4900,14 @@ to the in-kernel OOM killer.") (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 @@ -4949,7 +4951,20 @@ to the in-kernel OOM killer.") ;; 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 @@ -4957,9 +4972,9 @@ to the in-kernel OOM killer.") ;; 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 @@ -4977,7 +4992,7 @@ to the in-kernel OOM killer.") ;; 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 4d2a0bda3e..88ca3636e3 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2555,7 +2555,6 @@ item of PACKAGES." (list udevd) #:environment-variables (cons* - "EUDEV_RULES_DIRECTORY=/etc/udev/rules.d" (string-append "LINUX_MODULE_DIRECTORY=" (getenv "LINUX_MODULE_DIRECTORY")) (default-environment-variables)))))