Subject: [bug#66099] [PATCH gnome-team v9 7/7] services: udev: Install hardware files in /lib/udev/hardware.

From: Vivien Kraus <[email-masked]>
Date: Sun, 8 Oct 2023 12:00:39 +0200

* gnu/packages/libusb.scm (libmtp) [#:phases] <move-hardware-files>: New phase.
* gnu/packages/xdisorg.scm (libwacom) [#:phases]
<set-hardware-installation-directory>: New phase.
* gnu/packages/freedesktop.scm (libfprint) [#:configure-flags]: Change the
hardware directory.
* gnu/packages/linux.scm (eudev): [#:phases] <install-in-lib>: Change the
installation directory.
[native-search-paths]: change the search directory.
* gnu/services/base.scm (file->udev-hardware): Change the directory name.
(file->udev-hardware): Same.
(udev-etc): Same.
---
 gnu/packages/freedesktop.scm |  2 +-
 gnu/packages/gnome.scm       |  2 +-
 gnu/packages/libusb.scm      |  8 +++++++-
 gnu/packages/linux.scm       | 16 ++++++++--------
 gnu/packages/xdisorg.scm     |  9 ++++++++-
 gnu/services/base.scm        |  6 +++---
 6 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 85ba5ba147..cae9fadae8 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -2209,7 +2209,7 @@ (define-public libfprint
     (arguments
      (list #:configure-flags
            #~(list (string-append "-Dudev_hwdb_dir=" #$output
-                                  "/lib/udev/hwdb.d")
+                                  "/lib/udev/hardware")
                    (string-append "-Dc_link_args=-Wl,-rpath="
                                   (search-input-directory %build-inputs
                                                           "lib/nss"))
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 3f773aae8a..164e822f6c 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -5760,7 +5760,7 @@ (define-public upower
               ;; in /gnu/store.
               "-Dhistorydir=/var/lib/upower"
               (string-append "-Dudevrulesdir=" #$output "/bin/udev/rules.d")
-              (string-append "-Dudevhwdbdir=" #$output "/lib/udev/hwdb.d"))
+              (string-append "-Dudevhwdbdir=" #$output "/lib/udev/hardware"))
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'adjust-test-suite
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index e615b81ea3..23342dedcb 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -584,7 +584,13 @@ (define-public libmtp
     (arguments
      (list #:configure-flags
            #~(list "--disable-static"
-                   (string-append "--with-udev=" #$output "/lib/udev"))))
+                   (string-append "--with-udev=" #$output "/lib/udev"))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'install 'move-hardware-files
+                 (lambda _
+                   (rename-file (string-append #$output "/lib/udev/hwdb.d")
+                                (string-append #$output "/lib/udev/hardware")))))))
     (home-page "https://libmtp.sourceforge.net/")
     (synopsis "Library implementing the Media Transfer Protocol")
     (description "Libmtp implements an MTP (Media Transfer Protocol)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index f552ccccae..be6500539c 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4288,16 +4288,16 @@ (define-public eudev
           (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.
+              ;; hardware files from the <package>/lib/udev/hardware
+              ;; 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/hardware.  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 "hardwarelibdir = $(udevlibexecdir)/hwdb.d\n")
+                  (format port "hardwarelibdir = $(udevlibexecdir)/hardware\n")
                   (format port "include ./files.am")))
               (substitute* "hwdb/files.am"
                 (("dist_udevhwdb_DATA =")
@@ -4331,7 +4331,7 @@ (define-public eudev
     (native-search-paths
       (list (search-path-specification
               (variable "UDEV_HWDB_PATH")
-              (files '("lib/udev/hwdb.d")))))
+              (files '("lib/udev/hardware")))))
     (native-inputs
      (list autoconf
            automake
diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm
index f86608497d..573342e23b 100644
--- a/gnu/packages/xdisorg.scm
+++ b/gnu/packages/xdisorg.scm
@@ -1432,7 +1432,14 @@ (define-public libwacom
     (build-system meson-build-system)
     (arguments
      (list
-      #:configure-flags #~(list "--default-library=shared")))
+      #:configure-flags #~(list "--default-library=shared")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'set-hardware-installation-directory
+            (lambda _
+              (substitute* "meson.build"
+                (("dir_udev / 'hwdb.d'")
+                 "dir_udev / 'hardware'")))))))
     (native-inputs
      (list pkg-config
            ;; For tests.
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 32a89fb190..07b8b3b1a0 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2233,7 +2233,7 @@ (define (udev-rule file-name contents)
 
 (define (udev-hardware file-name contents)
   "Return a directory with a udev hardware file FILE-NAME containing CONTENTS."
-  (udev-configuration-file "hwdb.d" file-name contents))
+  (udev-configuration-file "hardware" file-name contents))
 
 (define (file->udev-configuration-file subdirectory file-name file)
   "Return a directory with a udev configuration file FILE-NAME which is a copy
@@ -2260,7 +2260,7 @@ (define (file->udev-rule file-name file)
 
 (define (file->udev-hardware file-name file)
   "Return a directory with a udev hardware file FILE-NAME which is a copy of FILE."
-  (file->udev-configuration-file "hwdb.d" file-name file))
+  (file->udev-configuration-file "hardware" file-name file))
 
 (define kvm-udev-rule
   ;; Return a directory with a udev rule that changes the group of /dev/kvm to
@@ -2371,7 +2371,7 @@ (define (udev-etc config)
   (match-record config <udev-configuration>
     (udev rules hardware)
     (let* ((hardware
-            (udev-configurations-union "hwdb.d" (cons* udev hardware)))
+            (udev-configurations-union "hardware" (cons* udev hardware)))
            (hwdb.bin
             (computed-file
              "hwdb.bin"
-- 
2.41.0