Patchwork initramfs-framework: udev: Handle alternative binary paths

login
register
mail settings
Submitter Otavio Salvador
Date Nov. 22, 2012, 4:54 p.m.
Message ID <1353603291-8788-1-git-send-email-otavio@ossystems.com.br>
Download mbox | patch
Permalink /patch/39493/
State New
Headers show

Comments

Otavio Salvador - Nov. 22, 2012, 4:54 p.m.
This allows use of udev daemon for different installation destinations
so allowing use of udev's from systemd code for initramfs.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 .../initrdscripts/initramfs-framework/udev         |   25 ++++++++++++++++----
 .../initrdscripts/initramfs-framework_1.0.bb       |    2 +
 2 files changed, 22 insertions(+), 5 deletions(-)
Otavio Salvador - Nov. 22, 2012, 5:38 p.m.
On Thu, Nov 22, 2012 at 2:54 PM, Otavio Salvador
<otavio@ossystems.com.br> wrote:
> This allows use of udev daemon for different installation destinations
> so allowing use of udev's from systemd code for initramfs.
>
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
>  .../initrdscripts/initramfs-framework/udev         |   25 ++++++++++++++++----
>  .../initrdscripts/initramfs-framework_1.0.bb       |    2 +
>  2 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev
> index 9ea8aa3..8be0595 100644
> --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev
> +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev
> @@ -1,10 +1,25 @@
>  #!/bin/sh
> -# Copyright (C) 2011 O.S. Systems Software LTDA.
> +# Copyright (C) 2011, 2012 O.S. Systems Software LTDA.
>  # Licensed on MIT
>
> +udev_daemon() {
> +       OPTIONS="/sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd"
> +
> +       for o in $OPTIONS; do
> +               if [ -x "$o" ]; then
> +                       echo $o
> +                       return 0
> +               fi
> +       done
> +
> +       return 1
> +}
> +
> +_UDEV_DAEMON=`udev_daemon`
> +
>  udev_enabled() {
> -       if [ ! -e /sbin/udevd ]; then
> -               debug "/sbin/udev doesn't exist"
> +       if [ ! -z "$_UDEV_DAEMON" ]; then

This is wrong and I send the wrong version of the patch by mistake. I
will send a v2 fixing it.

> +               msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs."
>                 return 1
>         fi
>
> @@ -14,9 +29,9 @@ udev_enabled() {
>  udev_run() {
>         mkdir -p /run
>
> -       udevd --daemon > /dev/null
> +       $_UDEV_DAEMON --daemon
>         udevadm trigger --action=add
>         udevadm settle
>
> -       killall udevd 2>/dev/null
> +       killall `basename $_UDEV_DAEMON` 2>/dev/null
>  }
> diff --git a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
> index 58e41d4..45d6592 100644
> --- a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
> +++ b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
> @@ -3,6 +3,8 @@ LICENSE = "MIT"
>  LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
>  RDEPENDS = "busybox"
>
> +PR = "r1"
> +
>  inherit allarch
>
>  SRC_URI = "file://init \
> --
> 1.7.2.5
>

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev
index 9ea8aa3..8be0595 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework/udev
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev
@@ -1,10 +1,25 @@ 
 #!/bin/sh
-# Copyright (C) 2011 O.S. Systems Software LTDA.
+# Copyright (C) 2011, 2012 O.S. Systems Software LTDA.
 # Licensed on MIT
 
+udev_daemon() {
+	OPTIONS="/sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd"
+
+	for o in $OPTIONS; do
+		if [ -x "$o" ]; then
+			echo $o
+			return 0
+		fi
+	done
+
+	return 1
+}
+
+_UDEV_DAEMON=`udev_daemon`
+
 udev_enabled() {
-	if [ ! -e /sbin/udevd ]; then
-		debug "/sbin/udev doesn't exist"
+	if [ ! -z "$_UDEV_DAEMON" ]; then
+		msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs."
 		return 1
 	fi
 
@@ -14,9 +29,9 @@  udev_enabled() {
 udev_run() {
 	mkdir -p /run
 
-	udevd --daemon > /dev/null
+	$_UDEV_DAEMON --daemon
 	udevadm trigger --action=add
 	udevadm settle
 
-	killall udevd 2>/dev/null
+	killall `basename $_UDEV_DAEMON` 2>/dev/null
 }
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
index 58e41d4..45d6592 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
@@ -3,6 +3,8 @@  LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 RDEPENDS = "busybox"
 
+PR = "r1"
+
 inherit allarch
 
 SRC_URI = "file://init \