diff mbox series

[bug#66099,gnome-team,v4,1/4] gnu: eudev: Update libudev version to 251.

Message ID b30bb395d6765a800b1377ac04443aba75260167.1696191643.git.vivien@planete-kraus.eu
State New
Headers show
Series Update eudev and upower | expand

Commit Message

Vivien Kraus Sept. 19, 2023, 11:23 a.m. UTC
Support for version 251 is only provided as a pull request for now:

https://github.com/eudev-project/eudev/pull/253

This pull request is included as a patch, without the version bump.

Eudev now has a hardware database that installs descriptions of hardware in
/etc, but they should go to /lib prior to being used. A new phase moves the
hwdb files from /etc to /lib.

Some commits have been added since 3.2.12, in order to support search paths
for udev hwdb, and fixing a regression.

* gnu/packages/linux.scm (eudev): Update to a post-v3.2.12 commit.
[#:phases] <allow-eudev-hwdb>: New phase.
<build-hwdb>: Update accordingly.
[native-search-paths]: Add UDEV_HWDB_PATH and UDEV_HWDB_BIN.
* gnu/packages/patches/eudev-libudev-251-compat.patch: New file.
* gnu/packages/linux.scm (eudev): Use it here.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/patches/eudev-rules-directory.patch: Rebase it.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/linux.scm                        |  39 ++++---
 .../patches/eudev-libudev-251-compat.patch    | 110 ++++++++++++++++++
 .../patches/eudev-rules-directory.patch       |   9 +-
 4 files changed, 141 insertions(+), 18 deletions(-)
 create mode 100644 gnu/packages/patches/eudev-libudev-251-compat.patch

Comments

Liliana Marie Prikler Oct. 2, 2023, 5:12 p.m. UTC | #1
Am Dienstag, dem 19.09.2023 um 13:23 +0200 schrieb Vivien Kraus:
> +    (native-search-paths
> +      (list (search-path-specification
> +              (variable "UDEV_HWDB_PATH")
> +              (files '("lib/udev/hwdb.d")))
Question for understanding this correctly: Is UDEV_HWDB_PATH honoured
for more than just UDEV_HWDB_BIN below or is this a "first file wins"
kind of deal?

> +            ;; Never install a hwdb.bin file, always let the udev-
> hwdb-bin
> +            ;; profile hook generate it.
> +            (search-path-specification
> +              (variable "UDEV_HWDB_BIN")
> +              (files '("lib/udev/hwdb.bin"))
> +              (file-type 'regular)
> +              (separator #f))))
As stated in my reply to Maxim, we probably don't want to set this in a
profile hook, but rather on a system/home config level.

Cheers
Vivien Kraus Oct. 2, 2023, 7:33 p.m. UTC | #2
Hi!

Le lundi 02 octobre 2023 à 19:12 +0200, Liliana Marie Prikler a écrit :
> Am Dienstag, dem 19.09.2023 um 13:23 +0200 schrieb Vivien Kraus:
> > +    (native-search-paths
> > +      (list (search-path-specification
> > +              (variable "UDEV_HWDB_PATH")
> > +              (files '("lib/udev/hwdb.d")))
> Question for understanding this correctly: Is UDEV_HWDB_PATH honoured
> for more than just UDEV_HWDB_BIN below or is this a "first file wins"
> kind of deal?

Every entry in UDEV_HWDB_PATH is search for files named "*.hwdb". All
files from any entry in UDEV_HWDB_PATH is used to generate hwdb.bin,
but if two files have the same name in different directories, then only
the first file is considered. This is just for udevadm hwdb --update.

UDEV_HWDB_BIN is the single location for a hwdb.bin for libudev at run-
time. Since hwdb.bin is a complete index, eudev only loads 1 instance
in memory, so there is no need for it to be a search path. This is a
simple environment variable.

I will update the udev-service-type instead of a profile hook.

Best regards,

Vivien
Maxim Cournoyer Oct. 4, 2023, 1 a.m. UTC | #3
Hi,

Vivien Kraus <vivien@planete-kraus.eu> writes:

> Hi!
>
> Le lundi 02 octobre 2023 à 19:12 +0200, Liliana Marie Prikler a écrit :
>> Am Dienstag, dem 19.09.2023 um 13:23 +0200 schrieb Vivien Kraus:
>> > +    (native-search-paths
>> > +      (list (search-path-specification
>> > +              (variable "UDEV_HWDB_PATH")
>> > +              (files '("lib/udev/hwdb.d")))
>> Question for understanding this correctly: Is UDEV_HWDB_PATH honoured
>> for more than just UDEV_HWDB_BIN below or is this a "first file wins"
>> kind of deal?
>
> Every entry in UDEV_HWDB_PATH is search for files named "*.hwdb". All
> files from any entry in UDEV_HWDB_PATH is used to generate hwdb.bin,
> but if two files have the same name in different directories, then only
> the first file is considered. This is just for udevadm hwdb --update.
>
> UDEV_HWDB_BIN is the single location for a hwdb.bin for libudev at run-
> time. Since hwdb.bin is a complete index, eudev only loads 1 instance
> in memory, so there is no need for it to be a search path. This is a
> simple environment variable.
>
> I will update the udev-service-type instead of a profile hook.

As discussed in #guix, this approach sounds good to me!  Thanks to
Liliana for suggesting it.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 72c9954492..b9880332f3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1127,6 +1127,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/esmini-use-pkgconfig.patch		\
   %D%/packages/patches/esmtp-add-lesmtp.patch		\
   %D%/packages/patches/eudev-rules-directory.patch		\
+  %D%/packages/patches/eudev-libudev-251-compat.patch		\
   %D%/packages/patches/exercism-disable-self-update.patch	\
   %D%/packages/patches/extempore-unbundle-external-dependencies.patch	\
   %D%/packages/patches/extundelete-e2fsprogs-1.44.patch		\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 85e3d9845d..254cca715e 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4263,18 +4263,22 @@  (define-public earlyoom
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
+  (define commit
+    "2e4dd05900e7b42d96cd7bdd5689c8ee431fb000")
+  (define revision "1")
   (package
     (name "eudev")
-    (version "3.2.11")
+    (version (git-version "3.2.12" revision commit))
     (source (origin
               (method git-fetch)
               (uri (git-reference (url "https://github.com/gentoo/eudev")
-                                  (commit (string-append "v" version))))
+                                  (commit commit)))
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0dzaqwjnl55f69ird57wb6skahc6l7zs1slsrzqqfhww33icp6av"))
-              (patches (search-patches "eudev-rules-directory.patch"))))
+                "0kl2lmp759wix83pxnax2p9954b6w3j8zqzgxl99nm6brl8cx11i"))
+              (patches (search-patches "eudev-rules-directory.patch"
+                                       "eudev-libudev-251-compat.patch"))))
     (build-system gnu-build-system)
     (arguments
      (list
@@ -4297,18 +4301,25 @@  (define-public eudev
                 (substitute* (string-append #$output "/lib/libudev.la")
                   (("old_library=.*")
                    "old_library=''\n")))))
-          (add-after 'install 'build-hwdb
+          (add-after 'install 'allow-eudev-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"))))))
+              ;; eudev distributes the hwdb, but each file has to be enabled
+              ;; by being copied under /lib/udev/hwdb.d. We accept all of
+              ;; them.
+              (symlink (string-append #$output "/etc/udev/hwdb.d")
+                       (string-append #$output "/lib/udev/hwdb.d")))))
        #:configure-flags #~(list "--enable-manpages")))
+    (native-search-paths
+      (list (search-path-specification
+              (variable "UDEV_HWDB_PATH")
+              (files '("lib/udev/hwdb.d")))
+            ;; Never install a hwdb.bin file, always let the udev-hwdb-bin
+            ;; profile hook generate it.
+            (search-path-specification
+              (variable "UDEV_HWDB_BIN")
+              (files '("lib/udev/hwdb.bin"))
+              (file-type 'regular)
+              (separator #f))))
     (native-inputs
      (list autoconf
            automake
diff --git a/gnu/packages/patches/eudev-libudev-251-compat.patch b/gnu/packages/patches/eudev-libudev-251-compat.patch
new file mode 100644
index 0000000000..b24893d79c
--- /dev/null
+++ b/gnu/packages/patches/eudev-libudev-251-compat.patch
@@ -0,0 +1,110 @@ 
+From ca8607912b6da3ce87ecd8a7209f23840fec5a90 Mon Sep 17 00:00:00 2001
+Message-ID: <ca8607912b6da3ce87ecd8a7209f23840fec5a90.1696185684.git.vivien@planete-kraus.eu>
+From: Vivien Kraus <vivien@planete-kraus.eu>
+Date: Sun, 1 Oct 2023 20:40:40 +0200
+Subject: [PATCH] Squashed commit of the following:
+
+commit dacff83d872c1dcb563439f98c9b974e244fcd46
+Author: Boian Bonev <bbonev@ipacct.com>
+Date:   Fri Aug 11 23:14:02 2023 +0000
+
+    Export dummies for
+
+     - udev_device_has_current_tag
+     - udev_device_get_current_tags_list_entry
+
+    since the current eudev device database does not support the concept of
+    current tags
+
+commit 7d2123ead5a15d4b2aff70eafc6f7b9b2f6527ac
+Author: Boian Bonev <bbonev@ipacct.com>
+Date:   Fri Aug 11 22:08:27 2023 +0000
+
+    Bump udev version to 251
+---
+ configure.ac                 |  2 +-
+ src/libudev/libudev-device.c | 11 +++++++++++
+ src/libudev/libudev.h        |  2 ++
+ src/libudev/libudev.sym      |  6 ++++++
+ 4 files changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3e31b0ebc..069fdfb87 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,6 +1,6 @@
+ AC_PREREQ([2.68])
+ AC_INIT([eudev],[3.2.12],[https://github.com/gentoo/eudev/issues])
+-AC_SUBST(UDEV_VERSION, 243)
++AC_SUBST(UDEV_VERSION, 251)
+ AC_CONFIG_SRCDIR([src/udev/udevd.c])
+ 
+ AC_USE_SYSTEM_EXTENSIONS
+diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
+index d6bc4032a..312d9ee84 100644
+--- a/src/libudev/libudev-device.c
++++ b/src/libudev/libudev-device.c
+@@ -1825,6 +1825,12 @@ _public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_dev
+         return udev_list_get_entry(&udev_device->tags_list);
+ }
+ 
++_public_ struct udev_list_entry *udev_device_get_current_tags_list_entry(struct udev_device *udev_device)
++{
++        // TODO: eudev database does not support current tags
++        return udev_device_get_tags_list_entry(udev_device);
++}
++
+ /**
+  * udev_device_has_tag:
+  * @udev_device: udev device
+@@ -1848,6 +1854,11 @@ _public_ int udev_device_has_tag(struct udev_device *udev_device, const char *ta
+         return false;
+ }
+ 
++_public_ int udev_device_has_current_tag(struct udev_device *udev_device, const char *tag) {
++        // TODO: eudev database does not support current tags
++        return udev_device_has_tag(udev_device, tag);
++}
++
+ #define ENVP_SIZE                        128
+ #define MONITOR_BUF_SIZE                4096
+ static int update_envp_monitor_buf(struct udev_device *udev_device)
+diff --git a/src/libudev/libudev.h b/src/libudev/libudev.h
+index e4bc18970..62fab107f 100644
+--- a/src/libudev/libudev.h
++++ b/src/libudev/libudev.h
+@@ -100,6 +100,7 @@ int udev_device_get_is_initialized(struct udev_device *udev_device);
+ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device);
+ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device);
+ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device);
++struct udev_list_entry *udev_device_get_current_tags_list_entry(struct udev_device *udev_device);
+ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device);
+ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key);
+ const char *udev_device_get_driver(struct udev_device *udev_device);
+@@ -110,6 +111,7 @@ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device
+ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
+ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);
+ int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
++int udev_device_has_current_tag(struct udev_device *udev_device, const char *tag);
+ 
+ /*
+  * udev_monitor
+diff --git a/src/libudev/libudev.sym b/src/libudev/libudev.sym
+index 76726fca7..d56c2aeab 100644
+--- a/src/libudev/libudev.sym
++++ b/src/libudev/libudev.sym
+@@ -118,3 +118,9 @@ global:
+         udev_queue_flush;
+         udev_queue_get_fd;
+ } LIBUDEV_199;
++
++LIBUDEV_247 {
++global:
++        udev_device_has_current_tag;
++        udev_device_get_current_tags_list_entry;
++} LIBUDEV_215;
+
+base-commit: 2e4dd05900e7b42d96cd7bdd5689c8ee431fb000
+-- 
+2.41.0
+
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);