summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2025-02-06 10:17:20 +0900
committerChristopher Baines <mail@cbaines.net>2025-04-11 12:42:47 +0100
commitdedeb905019105109cb0f3c9552a8383e960e999 (patch)
treec1ef4e3fa4bc1793a777b8cd7aab15e7da58c34f
parentc17c6b982024bdbe0decb80689a62bb09ab5f36e (diff)
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.lechner@lease-up.com> Change-Id: Ib8698f4b452f6fd0951bcd71831705b1be85e6e0
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/linux.scm31
-rw-r--r--gnu/packages/patches/eudev-rules-directory.patch37
-rw-r--r--gnu/services/base.scm1
4 files changed, 23 insertions, 47 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index bcfa38108c..ce45787ef4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1251,7 +1251,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 4d4b53e290..b147f74d39 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4897,12 +4897,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
@@ -4946,7 +4948,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
@@ -4954,9 +4969,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
@@ -4974,7 +4989,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 fe7ac28b39..490376d446 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2562,7 +2562,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)))))