diff mbox series

[bug#66099,gnome-team,v8,1/6] gnu: eudev: Update to 3.2.14.

Message ID abfc98b789e09b5eca59caea068bb455d2186ac2.1696610746.git.vivien@planete-kraus.eu
State New
Headers show
Series Update eudev, udev-service-type, upower | expand

Commit Message

Vivien Kraus Sept. 19, 2023, 11:23 a.m. UTC
Everything that eudev searches in "sysconf" is actually searched under
/gnu/store/.../etc/udev, as autoconf defines sysconfdir under $prefix by
default. The udev-service-type however prepares every file in /etc/udev,
without a prefix. To use /etc/udev as the sysconfdir, we must set it as a
configure flag.

Eudev has a hardware database that installs descriptions of hardware in /etc,
but they can also be installed in <prefix>/lib instead. The manual page
recommends to install all hardware description files into <prefix of
eudev>/lib/udev/hwdb.d, but this directory will be read-only when installing
another hardware-providing package.

udevadm hwdb --update searches for hardware files in /etc/udev/hwdb.d, then
<prefix of eudev>/lib/udev/hwdb.d, then UDEV_HWDB_PATH. Each package providing
hardware descriptions should install them into their respective
<prefix>/lib/udev/hwdb.d, and the udev-service-type is responsible to collect
the relevant hardware descriptions and put them all in /etc/udev/hwdb.d.

The build system tries, but fails, to install hardware files into /etc. A fix
makes it install the hardware files into <prefix>/lib instead. Another file,
an empty /etc/udev.conf, is expected to be installed in /etc/udev, but it is
not needed in guix.

The hwdb.bin file used to be generated in <prefix>/etc/udev/hwdb.bin, but
since the sysconf dir is now directly /etc, the hwdb.bin index will not be
found under <prefix>/etc/udev/hwdb.bin.

* gnu/packages/linux.scm (eudev): Update to 3.2.14.
[modules]: Import (guix build utils).
[#:phases] <allow-eudev-hwdb>: New phase.
<install-in-lib>: New phase.
<build-hwdb>: Remove phase.
[#:configure-flags]: Set sysconfdir to avoid a prefix.
[native-search-paths]: Add UDEV_HWDB_PATH.
* gnu/packages/patches/eudev-rules-directory.patch: Rebase it.
---
 gnu/packages/linux.scm                        | 57 +++++++++++++------
 .../patches/eudev-rules-directory.patch       |  9 +--
 2 files changed, 45 insertions(+), 21 deletions(-)

Comments

Liliana Marie Prikler Oct. 6, 2023, 6:35 p.m. UTC | #1
Am Dienstag, dem 19.09.2023 um 13:23 +0200 schrieb Vivien Kraus:
> Everything that eudev searches in "sysconf" is actually searched
> under /gnu/store/.../etc/udev, as autoconf defines sysconfdir under
> $prefix by default. The udev-service-type however prepares every file
> in /etc/udev, without a prefix. To use /etc/udev as the sysconfdir,
> we must set it as a configure flag.
This comment remains more confusing than helpful.  I get what you're
trying to express (or at least I hope I do), but I could easily read it
the wrong way.  Basically, what you're trying to express is that we set
sysconfdir to /etc/udev so that eudev uses the hwdb from udev-service-
type rather than the one in its own package.  This is fine – although
there are better ways to do so, see below – but the way it's
communicated here, is… strange.

> Eudev has a hardware database that installs descriptions of hardware
> in /etc, but they can also be installed in <prefix>/lib instead. The
> manual page recommends to install all hardware description files into
> <prefix of eudev>/lib/udev/hwdb.d, but this directory will be read-
> only when installing another hardware-providing package.
This should be "Eudev now has a hardware database /etc made up of
descriptions installed in /lib/udev/hwdb.d, and more generally,
UDEV_HWDB_PATH."  We should probably also patch our own manuals to not
make that recommendation.  Perhaps close off with mentioning hwdb --
update.

> The build system tries, but fails, to install hardware files into
> /etc. A fix makes it install the hardware files into <prefix>/lib
> instead. Another file, an empty /etc/udev.conf, is expected to be
> installed in /etc/udev, but it is not needed in guix.
Gratuitous information that's more confusing than helpful.

> The hwdb.bin file used to be generated in <prefix>/etc/udev/hwdb.bin,
> but since the sysconf dir is now directly /etc, the hwdb.bin index
> will not be found under <prefix>/etc/udev/hwdb.bin.
While we choose to do this via sysconfdir, the proper fix would be to
read the path to the hwdb file from /etc/udev/udev.conf and fall back
to $prefix/etc/udev/hwdb.bin if it's undefined.  That saves us some
hacks.

> * gnu/packages/linux.scm (eudev): Update to 3.2.14.
> [modules]: Import (guix build utils).
> [#:phases] <allow-eudev-hwdb>: New phase.
> <install-in-lib>: New phase.
> <build-hwdb>: Remove phase.
> [#:configure-flags]: Set sysconfdir to avoid a prefix.
> [native-search-paths]: Add UDEV_HWDB_PATH.
> * gnu/packages/patches/eudev-rules-directory.patch: Rebase it.
> ---
Cheers
diff mbox series

Patch

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 85e3d9845d..c33036b6e0 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4262,10 +4262,9 @@  (define-public earlyoom
     (license license:expat)))
 
 (define-public eudev
-  ;; The post-systemd fork, maintained by Gentoo.
   (package
     (name "eudev")
-    (version "3.2.11")
+    (version "3.2.14")
     (source (origin
               (method git-fetch)
               (uri (git-reference (url "https://github.com/gentoo/eudev")
@@ -4273,8 +4272,9 @@  (define-public eudev
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0dzaqwjnl55f69ird57wb6skahc6l7zs1slsrzqqfhww33icp6av"))
-              (patches (search-patches "eudev-rules-directory.patch"))))
+                "1f6lz57igi7iw2ls3fpzgw42bfznam4nf9368h7x8yf1mb737yxz"))
+              (patches (search-patches "eudev-rules-directory.patch"))
+              (modules '((guix build utils)))))
     (build-system gnu-build-system)
     (arguments
      (list
@@ -4285,6 +4285,31 @@  (define-public eudev
               (substitute* "man/make.sh"
                 (("/usr/bin/xsltproc")
                  (search-input-file (or native-inputs inputs) "/bin/xsltproc")))))
+          (add-before 'bootstrap 'install-in-lib
+            (lambda _
+              ;; When the udev-service-type instantiates /etc, it collects
+              ;; hardware files from the <package>/lib/udev/hwdb.d directories
+              ;; of different packages.  Since we set sysconfdir to /etc, the
+              ;; only package-dependent location we can install hwdb files is
+              ;; in <package>/lib/udev/hwdb.d.  Eudev is configured to install
+              ;; these files in sysconfdir, but they should be placed into
+              ;; udevlibexecdir.
+              (copy-file "hwdb/Makefile.am" "hwdb/files.am")
+              (call-with-output-file "hwdb/Makefile.am"
+                (lambda (port)
+                  (format port "udevhwdblibdir = $(udevlibexecdir)/hwdb.d\n")
+                  (format port "include ./files.am")))
+              (substitute* "hwdb/files.am"
+                (("dist_udevhwdb_DATA =")
+                 "dist_udevhwdblib_DATA ="))
+              ;; Do not install the empty udev.conf template.
+              (substitute* "src/udev/Makefile.am"
+                (("dist_udevconf_DATA =")
+                 "dist_noinst_DATA ="))
+              ;; Do not ensure that /etc/udev/rules.d exists.
+              (substitute* "rules/Makefile.am"
+                (("\\$\\(MKDIR_P\\) \\$\\(DESTDIR\\)\\$\\(udevconfdir\\)/rules\\.d")
+                 "true"))))
           (add-after 'install 'move-static-library
             (lambda _
               (let ((source (string-append #$output "/lib/libudev.a"))
@@ -4296,19 +4321,17 @@  (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")))))
-          (add-after 'install 'build-hwdb
-            (lambda _
-              ;; Build OUT/etc/udev/hwdb.bin.  This allows 'lsusb' and
-              ;; similar tools to display product names.
-              ;;
-              ;; XXX: This can't be done when cross-compiling. Find another way
-              ;; to generate hwdb.bin for cross-built systems.
-              #$@(if (%current-target-system)
-                     #~(#t)
-                     #~((invoke (string-append #$output "/bin/udevadm")
-                                "hwdb" "--update"))))))
-       #:configure-flags #~(list "--enable-manpages")))
+                   "old_library=''\n"))))))
+      #:configure-flags
+      #~(list "--enable-manpages"
+              ;; By default, autoconf uses $prefix/etc. The udev-service-type
+              ;; makes sure /etc is set up with rules and hardware file
+              ;; descriptions.
+              "--sysconfdir=/etc")))
+    (native-search-paths
+      (list (search-path-specification
+              (variable "UDEV_HWDB_PATH")
+              (files '("lib/udev/hwdb.d")))))
     (native-inputs
      (list autoconf
            automake
diff --git a/gnu/packages/patches/eudev-rules-directory.patch b/gnu/packages/patches/eudev-rules-directory.patch
index 54fc01c6d5..c4b1cfae39 100644
--- a/gnu/packages/patches/eudev-rules-directory.patch
+++ b/gnu/packages/patches/eudev-rules-directory.patch
@@ -4,9 +4,9 @@  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.
 
---- eudev-3.1.5/src/udev/udev-rules.c	2015-10-13 06:22:14.000000000 +0800
-+++ eudev-3.1.5/src/udev/udev-rules.c	2015-10-16 20:45:38.491934336 +0800
-@@ -47,15 +47,11 @@
+--- a/src/udev/udev-rules.c
++++ b/src/udev/udev-rules.c
+@@ -48,16 +48,11 @@ struct uid_gid {
          };
  };
  
@@ -20,11 +20,12 @@  this hack.
 -        "/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 {
-@@ -1704,6 +1700,9 @@
+@@ -1718,6 +1713,9 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
  
          udev_rules_check_timestamp(rules);