From patchwork Tue Jan 30 04:07:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 867382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVtBq2w9Tz9sNV for ; Tue, 30 Jan 2018 15:07:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 44224871BB; Tue, 30 Jan 2018 04:07:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l7SZQ8rdkRub; Tue, 30 Jan 2018 04:07:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A67A087357; Tue, 30 Jan 2018 04:07:42 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 458A81C2AD1 for ; Tue, 30 Jan 2018 04:07:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4299C8746C for ; Tue, 30 Jan 2018 04:07:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vfOh3gkR17Jn for ; Tue, 30 Jan 2018 04:07:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.ind.br (mx.datacom.ind.br [177.66.5.10]) by whitealder.osuosl.org (Postfix) with ESMTPS id 78BD487357 for ; Tue, 30 Jan 2018 04:07:37 +0000 (UTC) Received: from mail.datacom.ind.br (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTPS id 3204E16AAA24; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTP id 21BAD16AAA1D; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from mail.datacom.ind.br ([127.0.0.1]) by localhost (mail.datacom.ind.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Q3V640loCW4c; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from p7-1130br.casantos.org (unknown [191.35.193.33]) by mail.datacom.ind.br (Postfix) with ESMTPSA id B581016AA9D2; Tue, 30 Jan 2018 02:07:18 -0200 (-02) From: Carlos Santos To: buildroot@buildroot.org Date: Tue, 30 Jan 2018 02:07:18 -0200 Message-Id: <20180130040720.20172-1-casantos@datacom.ind.br> X-Mailer: git-send-email 2.14.3 Subject: [Buildroot] [PATCH 1/3] eudev: fix error handling init script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bernd Kuhls , Eric Le Bihan MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 $ Signed-off-by: Carlos Santos --- package/eudev/S10udev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/eudev/S10udev b/package/eudev/S10udev index 8382bec2bb..654a04df36 100755 --- a/package/eudev/S10udev +++ b/package/eudev/S10udev @@ -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" From patchwork Tue Jan 30 04:07:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 867383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVtBr2TbWz9sDB for ; Tue, 30 Jan 2018 15:07:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 0352D2FAC7; Tue, 30 Jan 2018 04:07:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BvGhlxmHfTYr; Tue, 30 Jan 2018 04:07:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 3F7232F0E2; Tue, 30 Jan 2018 04:07:44 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 0E2B51C2AD1 for ; Tue, 30 Jan 2018 04:07:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0B01487357 for ; Tue, 30 Jan 2018 04:07:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hhgAWEJZNhCX for ; Tue, 30 Jan 2018 04:07:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.ind.br (mx.datacom.ind.br [177.66.5.10]) by whitealder.osuosl.org (Postfix) with ESMTPS id 778C1871BB for ; Tue, 30 Jan 2018 04:07:37 +0000 (UTC) Received: from mail.datacom.ind.br (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTPS id 9DEAA16AAA1F; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTP id 8856816AA9D2; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from mail.datacom.ind.br ([127.0.0.1]) by localhost (mail.datacom.ind.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CyDxHbpwuNqq; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from p7-1130br.casantos.org (unknown [191.35.193.33]) by mail.datacom.ind.br (Postfix) with ESMTPSA id 2ABCD16AAA1F; Tue, 30 Jan 2018 02:07:19 -0200 (-02) From: Carlos Santos To: buildroot@buildroot.org Date: Tue, 30 Jan 2018 02:07:19 -0200 Message-Id: <20180130040720.20172-2-casantos@datacom.ind.br> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180130040720.20172-1-casantos@datacom.ind.br> References: <20180130040720.20172-1-casantos@datacom.ind.br> Subject: [Buildroot] [PATCH 2/3] eudev: fix printf usage in init script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bernd Kuhls , Eric Le Bihan MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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" Signed-off-by: Carlos Santos --- package/eudev/S10udev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/eudev/S10udev b/package/eudev/S10udev index 654a04df36..640fec625b 100755 --- a/package/eudev/S10udev +++ b/package/eudev/S10udev @@ -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 From patchwork Tue Jan 30 04:07:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 867381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVtBp3XHQz9sDB for ; Tue, 30 Jan 2018 15:07:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 74DF087DC9; Tue, 30 Jan 2018 04:07:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VIYAJIvTqkom; Tue, 30 Jan 2018 04:07:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id DF63787D92; Tue, 30 Jan 2018 04:07:39 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id C08CA1C2AD1 for ; Tue, 30 Jan 2018 04:07:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BD2812F0E2 for ; Tue, 30 Jan 2018 04:07:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z9VMH8RRa+vr for ; Tue, 30 Jan 2018 04:07:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.ind.br (mx.datacom.ind.br [177.66.5.10]) by silver.osuosl.org (Postfix) with ESMTPS id E0A842EFD4 for ; Tue, 30 Jan 2018 04:07:36 +0000 (UTC) Received: from mail.datacom.ind.br (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTPS id 0D21316AAA1D; Tue, 30 Jan 2018 02:07:20 -0200 (-02) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTP id EEA9C16AA9D2; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from mail.datacom.ind.br ([127.0.0.1]) by localhost (mail.datacom.ind.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zbn2U-Q_7PzC; Tue, 30 Jan 2018 02:07:19 -0200 (-02) Received: from p7-1130br.casantos.org (unknown [191.35.193.33]) by mail.datacom.ind.br (Postfix) with ESMTPSA id 90B1516AAA1D; Tue, 30 Jan 2018 02:07:19 -0200 (-02) From: Carlos Santos To: buildroot@buildroot.org Date: Tue, 30 Jan 2018 02:07:20 -0200 Message-Id: <20180130040720.20172-3-casantos@datacom.ind.br> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180130040720.20172-1-casantos@datacom.ind.br> References: <20180130040720.20172-1-casantos@datacom.ind.br> Subject: [Buildroot] [PATCH 3/3] eudev: generate hwdb.bin at system startup X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bernd Kuhls , Eric Le Bihan MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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). Signed-off-by: Carlos Santos Tested-by: Matt Weber --- package/eudev/Config.in | 9 +++++++++ package/eudev/S10udev | 8 +++++++- package/eudev/eudev.mk | 13 ++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/package/eudev/Config.in b/package/eudev/Config.in index 2220265a55..a589a14af3 100644 --- a/package/eudev/Config.in +++ b/package/eudev/Config.in @@ -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" diff --git a/package/eudev/S10udev b/package/eudev/S10udev index 640fec625b..026ab6ae49 100755 --- a/package/eudev/S10udev +++ b/package/eudev/S10udev @@ -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) diff --git a/package/eudev/eudev.mk b/package/eudev/eudev.mk index d08b9bb0c9..25745008d2 100644 --- a/package/eudev/eudev.mk +++ b/package/eudev/eudev.mk @@ -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