Skip to contentSkip to conversation

eudev: generate /etc/udev/hwdb.bin at system startup

PATCH New Carlos Santos 2 participants 5 messages Jan 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eudev: generate /etc/udev/hwdb.bin at system startup

Programs that use libudev (e.g. lsusb, from usbutils) need the hwdb.bin file to work properly.

If BR2_PACKAGE_EUDEV_ENABLE_HWDB is selected then the eudev installation populates /etc/udev/hwdb.d/ but does not genarete /etc/udev/hwdb.bin. It must be created running "udevadm hwdb --update" on the target device.

---
 package/eudev/S10udev | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
package/eudev/S10udev +10 -2
index 8382bec2bb..5c25e51317 100755
@@ -25,14 +25,22 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
+UDEV_HWDB_BIN=/etc/udev/hwdb.bin
+UDEV_HWDB_D=/etc/udev/hwdb.d
+
 case "$1" in
     start)
         printf "Populating ${udev_root:-/dev} using udev: "
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
-        $UDEV_BIN -d || (echo "FAIL" && exit 1)
+        $UDEV_BIN -d || { echo "FAIL" && exit 1; }
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit 1; }
+        [ -d "$UDEV_HWDB_D" ] && {
+            echo "done"
+            printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+            udevadm hwdb --update || { echo "FAIL" && exit 1; }
+        }
         echo "done"
         ;;
     stop)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/1 eudev: generate /etc/udev/hwdb.bin at system startup

Hi Carlos,

Quoted 19 lines · Carlos Santos

Programs that use libudev (e.g. lsusb, from usbutils) need the hwdb.bin file to work properly.

If BR2_PACKAGE_EUDEV_ENABLE_HWDB is selected then the eudev installation populates /etc/udev/hwdb.d/ but does not genarete /etc/udev/hwdb.bin. It must be created running "udevadm hwdb --update" on the target device.

---
 package/eudev/S10udev | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
package/eudev/S10udev +0 -0
index 8382bec2bb..5c25e51317 100755
@@ -25,14 +25,22 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 35

Quoted 10 lines
package/eudev/S10udev +4 -1
 
+UDEV_HWDB_BIN=/etc/udev/hwdb.bin
+UDEV_HWDB_D=/etc/udev/hwdb.d
+
 case "$1" in
     start)
         printf "Populating ${udev_root:-/dev} using udev: "
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
-        $UDEV_BIN -d || (echo "FAIL" && exit 1)
+        $UDEV_BIN -d || { echo "FAIL" && exit 1; }

How is this change related to hwdb.bin generation?

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 42

Quoted 8 lines
package/eudev/S10udev +5 -1
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit 1; }
+        [ -d "$UDEV_HWDB_D" ] && {
+            echo "done"
+            printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+            udevadm hwdb --update || { echo "FAIL" && exit 1; }

Wouldn't that break read-only /etc?

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 46

Quoted 4 lines
package/eudev/S10udev +1 -0
+        }
         echo "done"
         ;;
     stop)

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 eudev: generate /etc/udev/hwdb.bin at system startup

Quoted 30 lines

From: "Baruch Siach" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: "buildroot" <[email protected]>, "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>
Sent: Monday, January 29, 2018 3:36:03 AM
Subject: Re: [Buildroot] [PATCH] eudev: generate /etc/udev/hwdb.bin at system startup

Hi Carlos,

Quoted 20 lines · Carlos Santos

Programs that use libudev (e.g. lsusb, from usbutils) need the hwdb.bin file to work properly.

If BR2_PACKAGE_EUDEV_ENABLE_HWDB is selected then the eudev installation populates /etc/udev/hwdb.d/ but does not genarete /etc/udev/hwdb.bin. It must be created running "udevadm hwdb --update" on the target device.

---
 package/eudev/S10udev | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
package/eudev/S10udev +0 -0
index 8382bec2bb..5c25e51317 100755
@@ -25,14 +25,22 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
Quoted 11 lines

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 35

Quoted 9 lines
package/eudev/S10udev +4 -1
+UDEV_HWDB_BIN=/etc/udev/hwdb.bin
+UDEV_HWDB_D=/etc/udev/hwdb.d
+
 case "$1" in
     start)
         printf "Populating ${udev_root:-/dev} using udev: "
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
-        $UDEV_BIN -d || (echo "FAIL" && exit 1)
+        $UDEV_BIN -d || { echo "FAIL" && exit 1; }

How is this change related to hwdb.bin generation?

It fixes the logic. ( ... ) runs in a subshell, so the exit does not interrupt the of the parent script. Example:

    $ cat /tmp/foo
    #!/bin/sh
    echo 1
    (echo 2 && exit 1)
    echo 3
    $ /tmp/foo
    1
    2
    3
    $ cat /tmp/bar
    #!/bin/sh
    echo 1
    { echo 2 && exit 1; }
    echo 3
    $ /tmp/bar
    1
    2
    $
Quoted 11 lines

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 42

Quoted 9 lines
package/eudev/S10udev +5 -1
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit
 1; }
+        [ -d "$UDEV_HWDB_D" ] && {
+            echo "done"
+            printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+            udevadm hwdb --update || { echo "FAIL" && exit 1; }

Wouldn't that break read-only /etc?

The script may require some customization, as already explained in its opening comments, which is beyond the scope of this change.

Notice that a read-only /etc does not break the init script. It breaks the "udevadm hwdb --update" command, as well as any command that assume a rw filesystem (and there is a lot of them).

---8<---

Signature · 4 lines
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens
#3 lore raw

PATCH 1/1 eudev: generate /etc/udev/hwdb.bin at system startup

Quoted 6 lines

From: "Carlos Santos" <[email protected]>
To: "Baruch Siach" <[email protected]>
Cc: "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>, "buildroot" <[email protected]>
Sent: Monday, January 29, 2018 8:37:23 AM
Subject: Re: [Buildroot] [PATCH] eudev: generate /etc/udev/hwdb.bin at system startup

---8<---

Quoted 9 lines
Quoted 2 lines

Wouldn't that break read-only /etc?

The script may require some customization, as already explained in its opening comments, which is beyond the scope of this change.

Notice that a read-only /etc does not break the init script. It breaks the "udevadm hwdb --update" command, as well as any command that assume a rw filesystem (and there is a lot of them).

Addendum: the solution would be overriding the udevhwdbbin variable in the configuration script, pointing to some read-write path (e.g. /run/udev/data/, which is under a tmpfs by default).

Signature · 4 lines
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens
#4 lore raw

PATCH 1/1 eudev: generate /etc/udev/hwdb.bin at system startup

In reply to Carlos Santos

Hi Carlos,

Quoted 55 lines · Carlos Santos
Quoted 30 lines

From: "Baruch Siach" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: "buildroot" <[email protected]>, "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>
Sent: Monday, January 29, 2018 3:36:03 AM
Subject: Re: [Buildroot] [PATCH] eudev: generate /etc/udev/hwdb.bin at system startup

Hi Carlos,

Quoted 20 lines · Carlos Santos

Programs that use libudev (e.g. lsusb, from usbutils) need the hwdb.bin file to work properly.

If BR2_PACKAGE_EUDEV_ENABLE_HWDB is selected then the eudev installation populates /etc/udev/hwdb.d/ but does not genarete /etc/udev/hwdb.bin. It must be created running "udevadm hwdb --update" on the target device.

---
 package/eudev/S10udev | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
package/eudev/S10udev +0 -0
index 8382bec2bb..5c25e51317 100755
@@ -25,14 +25,22 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
Quoted 11 lines

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf · line 35

Quoted 9 lines
package/eudev/S10udev +4 -1
+UDEV_HWDB_BIN=/etc/udev/hwdb.bin
+UDEV_HWDB_D=/etc/udev/hwdb.d
+
 case "$1" in
     start)
         printf "Populating ${udev_root:-/dev} using udev: "
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
-        $UDEV_BIN -d || (echo "FAIL" && exit 1)
+        $UDEV_BIN -d || { echo "FAIL" && exit 1; }

How is this change related to hwdb.bin generation?

It fixes the logic. ( ... ) runs in a subshell, so the exit does not interrupt the of the parent script. Example:

    $ cat /tmp/foo
    #!/bin/sh
    echo 1
    (echo 2 && exit 1)
    echo 3
    $ /tmp/foo
    1
    2
    3
    $ cat /tmp/bar
Quoted 8 lines
    #!/bin/sh
    echo 1
    { echo 2 && exit 1; }
    echo 3
    $ /tmp/bar
    1
    2
    $

Thanks for the explanation. I think this should better be done in a separate patch with this explanation in the commit log.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
package/eudev/S10udev +5 -1
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit
 1; }
+        [ -d "$UDEV_HWDB_D" ] && {
+            echo "done"
+            printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+            udevadm hwdb --update || { echo "FAIL" && exit 1; }
Quoted 8 lines
Quoted 1 line

Wouldn't that break read-only /etc?

The script may require some customization, as already explained in its opening comments, which is beyond the scope of this change.

Notice that a read-only /etc does not break the init script. It breaks the "udevadm hwdb --update" command, as well as any command that assume a rw filesystem (and there is a lot of them).

It might make sense to detect read-only /etc at the beginning of this script like we do in package/initscripts/init.d/S20urandom. But I agree that this is also a separate issue.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -