Skip to contentSkip to conversation

eudev: fix error handling init script

PATCH New Carlos Santos 5 participants 11 messages Jan 30, 2018 – Oct 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 eudev: fix error handling init script

Replace (echo "msg" && exit 1) by { echo "msg"; exit 1; }.

The (list) compound command runs in a subshell, so the "exit" interrupts the subshell, not the main script. Examples:

    $ sh -c "echo 1; (exit 1); echo 2"
    1
    2
    $ sh -c "echo 1; { exit 1; }; echo 2"
    1
    $
---
 package/eudev/S10udev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/eudev/S10udev +1 -1
index 8382bec2bb..654a04df36 100755
@@ -29,7 +29,7 @@ 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"
Signature · 1 line
2.14.3
#1 lore raw

PATCH 2/3 eudev: fix printf usage in init script

Using a variable in a printf format string may lead to undesirable results if the variable contains format controls, so replace

printf "foo $var bar"

by

printf "foo %s bar" "$var"

---
 package/eudev/S10udev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/eudev/S10udev +1 -1
index 654a04df36..640fec625b 100755
@@ -27,7 +27,7 @@ test -r $UDEV_CONFIG || exit 6
 
 case "$1" in
     start)
-        printf "Populating ${udev_root:-/dev} using udev: "
+        printf "Populating %s using udev: " "${udev_root:-/dev}"
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || { echo "FAIL"; exit 1; }
         udevadm trigger --type=subsystems --action=add
Signature · 1 line
2.14.3
#2 lore raw

PATCH 2/3 eudev: fix printf usage in init script

Hello,

Quoted 5 lines · Carlos Santos

Using a variable in a printf format string may lead to undesirable results if the variable contains format controls, so replace

printf "foo $var bar"

Quoted 8 lines

by

printf "foo %s bar" "$var"

---
 package/eudev/S10udev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH 2/3 eudev: fix printf usage in init script

In reply to Carlos Santos
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Carlos" == Carlos Santos <[email protected]> writes:

Using a variable in a printf format string may lead to undesirable results if the variable contains format controls, so replace

Quoted 7 lines

printf "foo $var bar"

by

printf "foo %s bar" "$var"

Committed to 2017.02.x and 2017.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 3/3 eudev: generate hwdb.bin at system startup

In reply to 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 but this does not work on with read-only /etc, so we need these changes:

- Add the BR2_PACKAGE_EUDEV_HWDB_BIN_PATH config, allowing the user to set the location of hwdb.bin.
- Patch the configuration script, allowing to set the hwdb.bin path by means of an environment variable (udevhwdbbinpath).
- Pass the value set in BR2_PACKAGE_EUDEV_HWDB_BIN_PATH to the configure script by means of the udevhwdbbinpath variable.
- Make the S10udev init script run "udevadm hwdb --update" to recreate hwdb.bin or print an error message if the operation fails (e.g. no write permission on the filesystem).

---
 package/eudev/Config.in |  9 +++++++++
 package/eudev/S10udev   |  8 +++++++-
 package/eudev/eudev.mk  | 13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
package/eudev/Config.in +9 -0
index 2220265a55..a589a14af3 100644
@@ -32,6 +32,15 @@ config BR2_PACKAGE_EUDEV_ENABLE_HWDB
 	help
 	  Enables hardware database installation to /etc/udev/hwdb.d
 
+config BR2_PACKAGE_EUDEV_HWDB_BIN_PATH
+	string "hwdb.bin path"
+	default "/etc/udev/hwdb.bin"
+	help
+	  Location of the hwdb.bin file, which is re-generated at system
+	  startup. The default is /etc/udev/hwdb.bin but you may want to
+	  move it elsewhere (e.g. /var/run/udev/hwdb.bin) if /etc is in
+	  a read-only filesystem.
+
 endif
 
 comment "eudev needs eudev /dev management"
package/eudev/S10udev +7 -1
index 640fec625b..026ab6ae49 100755
@@ -25,14 +25,20 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
+UDEV_HWDB_BIN=%%UDEV_HWDB_BIN%%
+
 case "$1" in
     start)
         printf "Populating %s using udev: " "${udev_root:-/dev}"
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || { echo "FAIL"; exit 1; }
+        echo "done"
         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; }
+        echo "done"
+        printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+        udevadm hwdb --update || { echo "FAIL" && exit 1; }
         echo "done"
         ;;
     stop)
package/eudev/eudev.mk +12 -1
index d08b9bb0c9..25745008d2 100644
@@ -47,8 +47,19 @@ else
 EUDEV_CONF_OPTS += --disable-selinux
 endif
 
+define EUDEV_POST_PATCH
+	$(SED) 's,$${udevconfdir}/hwdb.bin,$${udevhwdbbinpath:-$${udevconfdir}/hwdb.bin},' \
+		$(@D)/configure
+endef
+EUDEV_POST_PATCH_HOOKS += EUDEV_POST_PATCH
+
+EUDEV_CONF_ENV += udevhwdbbinpath=$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH)
+
 define EUDEV_INSTALL_INIT_SYSV
-	$(INSTALL) -D -m 0755 package/eudev/S10udev $(TARGET_DIR)/etc/init.d/S10udev
+	$(INSTALL) -D -m 0755 package/eudev/S10udev \
+		$(TARGET_DIR)/etc/init.d/S10udev
+	$(SED) 's,%%UDEV_HWDB_BIN%%,$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH),' \
+		$(TARGET_DIR)/etc/init.d/S10udev
 endef
 
 # Required by default rules for input devices
Signature · 1 line
2.14.3
#5 lore raw

PATCH 3/3 eudev: generate hwdb.bin at system startup

Quoted 8 lines

From: "Carlos Santos" <[email protected]>
To: "buildroot" <[email protected]>
Cc: "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>
Sent: Tuesday, January 30, 2018 2:07:20 AM
Subject: [Buildroot] [PATCH 3/3] eudev: generate hwdb.bin at system startup

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

Ping. ;-)

https://patchwork.ozlabs.org/patch/867381/

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
#6 lore raw

PATCH 3/3 eudev: generate hwdb.bin at system startup

In reply to Carlos Santos

Carlos, Yann,

Quoted 9 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 but this does not work on with read-only /etc, so we need these changes:

Quoted 10 lines

- Add the BR2_PACKAGE_EUDEV_HWDB_BIN_PATH config, allowing the user to set the location of hwdb.bin.
- Patch the configuration script, allowing to set the hwdb.bin path by means of an environment variable (udevhwdbbinpath).
- Pass the value set in BR2_PACKAGE_EUDEV_HWDB_BIN_PATH to the configure script by means of the udevhwdbbinpath variable.
- Make the S10udev init script run "udevadm hwdb --update" to recreate hwdb.bin or print an error message if the operation fails (e.g. no write permission on the filesystem).

(aarch qemu target)

Quoted 12 lines
---
 package/eudev/Config.in |  9 +++++++++
 package/eudev/S10udev   |  8 +++++++-
 package/eudev/eudev.mk  | 13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
package/eudev/Config.in +0 -0
index 2220265a55..a589a14af3 100644

package/eudev/Config.in config BR2_PACKAGE_EUDEV_ENABLE_HWDB · line 35

Quoted 4 lines
package/eudev/Config.in +1 -0
@@ -32,6 +32,15 @@ config BR2_PACKAGE_EUDEV_ENABLE_HWDB
        help
          Enables hardware database installation to /etc/udev/hwdb.d
 
+config BR2_PACKAGE_EUDEV_HWDB_BIN_PATH

Should this depend on BR2_PACKAGE_EUDEV_ENABLE_HWDB? What does it do if you don't enable this option or have a write-able location for the .bin?

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf

Quoted 16 lines
package/eudev/Config.in +8 -0
+       string "hwdb.bin path"
+       default "/etc/udev/hwdb.bin"
+       help
+         Location of the hwdb.bin file, which is re-generated at system
+         startup. The default is /etc/udev/hwdb.bin but you may want to
+         move it elsewhere (e.g. /var/run/udev/hwdb.bin) if /etc is in
+         a read-only filesystem.
+
 endif
 
 comment "eudev needs eudev /dev management"
package/eudev/S10udev +0 -0
index 640fec625b..026ab6ae49 100755
@@ -25,14 +25,20 @@ UDEV_CONFIG=/etc/udev/udev.conf

This section of the patch no-longer applies (cosmetic changes required).

Quoted 8 lines
package/eudev/S10udev +2 -0
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
+UDEV_HWDB_BIN=%%UDEV_HWDB_BIN%%
+
 case "$1" in
     start)
         printf "Populating %s using udev: " "${udev_root:-/dev}"

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

Quoted 10 lines
package/eudev/S10udev +5 -1
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || { echo "FAIL"; exit 1; }
+        echo "done"
         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; }
+        echo "done"
+        printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+        udevadm hwdb --update || { echo "FAIL" && exit 1; }

Yann had a good point on IRC, this probably could be prebuild offline.

Quoted 15 lines
package/eudev/S10udev +0 -0
         echo "done"
         ;;
     stop)
package/eudev/eudev.mk +4 -0
index d08b9bb0c9..25745008d2 100644
@@ -47,8 +47,19 @@ else
 EUDEV_CONF_OPTS += --disable-selinux
 endif
 
+define EUDEV_POST_PATCH
+       $(SED) 's,$${udevconfdir}/hwdb.bin,$${udevhwdbbinpath:-$${udevconfdir}/hwdb.bin},' \
+               $(@D)/configure
+endef

package/eudev/eudev.mk else · line 62

Quoted 10 lines
package/eudev/eudev.mk +8 -1
+EUDEV_POST_PATCH_HOOKS += EUDEV_POST_PATCH
+
+EUDEV_CONF_ENV += udevhwdbbinpath=$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH)
+
 define EUDEV_INSTALL_INIT_SYSV
-       $(INSTALL) -D -m 0755 package/eudev/S10udev $(TARGET_DIR)/etc/init.d/S10udev
+       $(INSTALL) -D -m 0755 package/eudev/S10udev \
+               $(TARGET_DIR)/etc/init.d/S10udev
+       $(SED) 's,%%UDEV_HWDB_BIN%%,$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH),' \
+               $(TARGET_DIR)/etc/init.d/S10udev

Instead of a SED approach, could we add a /etc/defaults/udev cfg file instead and just set the value in that file if present. Otherwise default the value? (Like what was done in the recent S01logging suggested updates).

Matt

#7 lore raw

PATCH 3/3 eudev: generate hwdb.bin at system startup

Quoted 64 lines

From: "Matthew Weber" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: "buildroot" <[email protected]>, "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>, "Yann Morin" <[email protected]>
Sent: Monday, October 15, 2018 4:55:51 PM
Subject: Re: [Buildroot] [PATCH 3/3] eudev: generate hwdb.bin at system startup

Carlos, Yann,

Quoted 9 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 but this does not work on with read-only /etc, so we need these changes:

Quoted 10 lines

- Add the BR2_PACKAGE_EUDEV_HWDB_BIN_PATH config, allowing the user to set the location of hwdb.bin.
- Patch the configuration script, allowing to set the hwdb.bin path by means of an environment variable (udevhwdbbinpath).
- Pass the value set in BR2_PACKAGE_EUDEV_HWDB_BIN_PATH to the configure script by means of the udevhwdbbinpath variable.
- Make the S10udev init script run "udevadm hwdb --update" to recreate hwdb.bin or print an error message if the operation fails (e.g. no write permission on the filesystem).

(aarch qemu target)

Quoted 12 lines
---
 package/eudev/Config.in |  9 +++++++++
 package/eudev/S10udev   |  8 +++++++-
 package/eudev/eudev.mk  | 13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
package/eudev/Config.in +0 -0
index 2220265a55..a589a14af3 100644

package/eudev/Config.in config BR2_PACKAGE_EUDEV_ENABLE_HWDB · line 35

Quoted 4 lines
package/eudev/Config.in +1 -0
@@ -32,6 +32,15 @@ config BR2_PACKAGE_EUDEV_ENABLE_HWDB
        help
          Enables hardware database installation to /etc/udev/hwdb.d
 
+config BR2_PACKAGE_EUDEV_HWDB_BIN_PATH

Should this depend on BR2_PACKAGE_EUDEV_ENABLE_HWDB? What does it do if you don't enable this option or have a write-able location for the .bin?

Quoted 10 lines
package/eudev/Config.in +8 -0
+       string "hwdb.bin path"
+       default "/etc/udev/hwdb.bin"
+       help
+         Location of the hwdb.bin file, which is re-generated at system
+         startup. The default is /etc/udev/hwdb.bin but you may want to
+         move it elsewhere (e.g. /var/run/udev/hwdb.bin) if /etc is in
+         a read-only filesystem.
+
 endif
 
Quoted 8 lines

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf

Quoted 6 lines
package/eudev/Config.in +0 -0
 comment "eudev needs eudev /dev management"
package/eudev/S10udev +0 -0
index 640fec625b..026ab6ae49 100755
@@ -25,14 +25,20 @@ UDEV_CONFIG=/etc/udev/udev.conf

This section of the patch no-longer applies (cosmetic changes required).

I will update the patch accordingly.

Quoted 13 lines
Quoted 13 lines
package/eudev/S10udev +3 -0
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
+UDEV_HWDB_BIN=%%UDEV_HWDB_BIN%%
+
 case "$1" in
     start)
         printf "Populating %s using udev: " "${udev_root:-/dev}"
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || { echo "FAIL"; exit 1; }
+        echo "done"
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
Quoted 8 lines

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

Quoted 6 lines
package/eudev/S10udev +4 -1
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit
 1; }
+        echo "done"
+        printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+        udevadm hwdb --update || { echo "FAIL" && exit 1; }

Yann had a good point on IRC, this probably could be prebuild offline.

Does "offline" mean "at build time" or "asynchronous to the initialization"?

Quoted 24 lines
Quoted 24 lines
package/eudev/S10udev +0 -0
         echo "done"
         ;;

stop)

package/eudev/eudev.mk +8 -1
index d08b9bb0c9..25745008d2 100644
@@ -47,8 +47,19 @@ else
 EUDEV_CONF_OPTS += --disable-selinux
 endif
 
+define EUDEV_POST_PATCH
+       $(SED)
 's,$${udevconfdir}/hwdb.bin,$${udevhwdbbinpath:-$${udevconfdir}/hwdb.bin},' \
+               $(@D)/configure
+endef
+EUDEV_POST_PATCH_HOOKS += EUDEV_POST_PATCH
+
+EUDEV_CONF_ENV += udevhwdbbinpath=$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH)
+
 define EUDEV_INSTALL_INIT_SYSV
-       $(INSTALL) -D -m 0755 package/eudev/S10udev

$(TARGET_DIR)/etc/init.d/S10udev
+ $(INSTALL) -D -m 0755 package/eudev/S10udev \

Quoted 8 lines

package/eudev/eudev.mk else · line 62

Quoted 3 lines
package/eudev/eudev.mk +3 -0
+               $(TARGET_DIR)/etc/init.d/S10udev
+       $(SED) 's,%%UDEV_HWDB_BIN%%,$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH),' \
+               $(TARGET_DIR)/etc/init.d/S10udev

Instead of a SED approach, could we add a /etc/defaults/udev cfg file instead and just set the value in that file if present. Otherwise default the value? (Like what was done in the recent S01logging suggested updates).

I like this approach. I will update the patch to implement it.

Signature · 3 lines
Carlos Santos (Casantos) - DATACOM, P&D
?Marched towards the enemy, spear upright, armed with the certainty
that only the ignorant can have.? ? Epitaph of a volunteer
#8 lore raw

PATCH 3/3 eudev: generate hwdb.bin at system startup

Carlos,

Quoted 98 lines · Carlos Santos
Quoted 65 lines

From: "Matthew Weber" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: "buildroot" <[email protected]>, "Bernd Kuhls" <[email protected]>, "Eric Le Bihan" <[email protected]>, "Yann Morin" <[email protected]>
Sent: Monday, October 15, 2018 4:55:51 PM
Subject: Re: [Buildroot] [PATCH 3/3] eudev: generate hwdb.bin at system startup

Carlos, Yann,

Quoted 9 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 but this does not work on with read-only /etc, so we need these changes:

Quoted 10 lines

- Add the BR2_PACKAGE_EUDEV_HWDB_BIN_PATH config, allowing the user to set the location of hwdb.bin.
- Patch the configuration script, allowing to set the hwdb.bin path by means of an environment variable (udevhwdbbinpath).
- Pass the value set in BR2_PACKAGE_EUDEV_HWDB_BIN_PATH to the configure script by means of the udevhwdbbinpath variable.
- Make the S10udev init script run "udevadm hwdb --update" to recreate hwdb.bin or print an error message if the operation fails (e.g. no write permission on the filesystem).

(aarch qemu target)

Quoted 12 lines
---
 package/eudev/Config.in |  9 +++++++++
 package/eudev/S10udev   |  8 +++++++-
 package/eudev/eudev.mk  | 13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
package/eudev/Config.in +0 -0
index 2220265a55..a589a14af3 100644

package/eudev/Config.in config BR2_PACKAGE_EUDEV_ENABLE_HWDB · line 35

Quoted 4 lines
package/eudev/Config.in +1 -0
@@ -32,6 +32,15 @@ config BR2_PACKAGE_EUDEV_ENABLE_HWDB
        help
          Enables hardware database installation to /etc/udev/hwdb.d
 
+config BR2_PACKAGE_EUDEV_HWDB_BIN_PATH

Should this depend on BR2_PACKAGE_EUDEV_ENABLE_HWDB? What does it do if you don't enable this option or have a write-able location for the .bin?

Quoted 10 lines
package/eudev/Config.in +8 -0
+       string "hwdb.bin path"
+       default "/etc/udev/hwdb.bin"
+       help
+         Location of the hwdb.bin file, which is re-generated at system
+         startup. The default is /etc/udev/hwdb.bin but you may want to
+         move it elsewhere (e.g. /var/run/udev/hwdb.bin) if /etc is in
+         a read-only filesystem.
+
 endif
 
Quoted 8 lines

package/eudev/S10udev UDEV_CONFIG=/etc/udev/udev.conf

Quoted 6 lines
package/eudev/Config.in +0 -0
 comment "eudev needs eudev /dev management"
package/eudev/S10udev +0 -0
index 640fec625b..026ab6ae49 100755
@@ -25,14 +25,20 @@ UDEV_CONFIG=/etc/udev/udev.conf

This section of the patch no-longer applies (cosmetic changes required).

I will update the patch accordingly.

Quoted 13 lines
Quoted 13 lines
package/eudev/S10udev +3 -0
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
+UDEV_HWDB_BIN=%%UDEV_HWDB_BIN%%
+
 case "$1" in
     start)
         printf "Populating %s using udev: " "${udev_root:-/dev}"
         printf '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || { echo "FAIL"; exit 1; }
+        echo "done"
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
Quoted 8 lines

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

Quoted 6 lines
package/eudev/S10udev +4 -1
-        udevadm settle --timeout=30 || echo "udevadm settle failed"
+        udevadm settle --timeout=30 || { echo "udevadm settle failed" && exit
 1; }
+        echo "done"
+        printf "Compiling hardware database information $UDEV_HWDB_BIN: "
+        udevadm hwdb --update || { echo "FAIL" && exit 1; }

Yann had a good point on IRC, this probably could be prebuild offline.

Quoted 2 lines

Does "offline" mean "at build time" or "asynchronous to the initialization"?

Build time via adding eudev as a host tool.

Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
package/eudev/S10udev +0 -0
         echo "done"
         ;;

stop)

package/eudev/eudev.mk +8 -1
index d08b9bb0c9..25745008d2 100644
@@ -47,8 +47,19 @@ else
 EUDEV_CONF_OPTS += --disable-selinux
 endif
 
+define EUDEV_POST_PATCH
+       $(SED)
 's,$${udevconfdir}/hwdb.bin,$${udevhwdbbinpath:-$${udevconfdir}/hwdb.bin},' \
+               $(@D)/configure
+endef
+EUDEV_POST_PATCH_HOOKS += EUDEV_POST_PATCH
+
+EUDEV_CONF_ENV += udevhwdbbinpath=$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH)
+
 define EUDEV_INSTALL_INIT_SYSV
-       $(INSTALL) -D -m 0755 package/eudev/S10udev

$(TARGET_DIR)/etc/init.d/S10udev
+ $(INSTALL) -D -m 0755 package/eudev/S10udev \

Quoted 8 lines

package/eudev/eudev.mk else · line 62

Quoted 3 lines
package/eudev/eudev.mk +3 -0
+               $(TARGET_DIR)/etc/init.d/S10udev
+       $(SED) 's,%%UDEV_HWDB_BIN%%,$(BR2_PACKAGE_EUDEV_HWDB_BIN_PATH),' \
+               $(TARGET_DIR)/etc/init.d/S10udev

Instead of a SED approach, could we add a /etc/defaults/udev cfg file instead and just set the value in that file if present. Otherwise default the value? (Like what was done in the recent S01logging suggested updates).

Quoted 2 lines

I like this approach. I will update the patch to implement it.

Matt

#9 lore raw

PATCH 1/3 eudev: fix error handling init script

In reply to Carlos Santos

Hello,

Quoted 12 lines · Carlos Santos

Replace (echo "msg" && exit 1) by { echo "msg"; exit 1; }.

The (list) compound command runs in a subshell, so the "exit" interrupts the subshell, not the main script. Examples:

    $ sh -c "echo 1; (exit 1); echo 2"
    1
    2
    $ sh -c "echo 1; { exit 1; }; echo 2"
    1
    $
Quoted 4 lines
---
 package/eudev/S10udev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#10 lore raw

PATCH 1/3 eudev: fix error handling init script

In reply to Carlos Santos
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Carlos" == Carlos Santos <[email protected]> writes:

Replace (echo "msg" && exit 1) by { echo "msg"; exit 1; }. The (list) compound command runs in a subshell, so the "exit" interrupts the subshell, not the main script. Examples:

Quoted 8 lines
    $ sh -c "echo 1; (exit 1); echo 2"
    1
    2
    $ sh -c "echo 1; { exit 1; }; echo 2"
    1
    $

Committed to 2017.02.x and 2017.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard