Blame 0003-base-dracut-lib.sh-add-dev_unit_name.patch

Harald Hoyer 38a2dd
From c4b572b5ca767aec6cc8b5ba98b5fc76c991f690 Mon Sep 17 00:00:00 2001
Harald Hoyer 38a2dd
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 38a2dd
Date: Thu, 4 Apr 2013 12:51:33 +0200
Harald Hoyer 38a2dd
Subject: [PATCH] base/dracut-lib.sh: add dev_unit_name()
Harald Hoyer 38a2dd
Harald Hoyer 38a2dd
add helper function to convert device path to systemd unit names
Harald Hoyer 38a2dd
---
Harald Hoyer 38a2dd
 modules.d/99base/dracut-lib.sh | 14 ++++++++++----
Harald Hoyer 38a2dd
 1 file changed, 10 insertions(+), 4 deletions(-)
Harald Hoyer 38a2dd
Harald Hoyer 38a2dd
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
index e456b01..79fc953 100755
Harald Hoyer 38a2dd
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
@@ -818,6 +818,15 @@ wait_for_mount()
Harald Hoyer 38a2dd
     } >> "$hookdir/emergency/90-${_name}.sh"
Harald Hoyer 38a2dd
 }
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
+dev_unit_name()
Harald Hoyer 38a2dd
+{
Harald Hoyer 38a2dd
+    _name="${1%%/}"
Harald Hoyer 38a2dd
+    _name="${_name##/}"
Harald Hoyer 38a2dd
+    _name="$(str_replace "$_name" '-' '\x2d')"
Harald Hoyer 38a2dd
+    _name="$(str_replace "$_name" '/' '-')"
Harald Hoyer 38a2dd
+    echo "$_name"
Harald Hoyer 38a2dd
+}
Harald Hoyer 38a2dd
+
Harald Hoyer 38a2dd
 # wait_for_dev <dev>
Harald Hoyer 38a2dd
 #
Harald Hoyer 38a2dd
 # Installs a initqueue-finished script,
Harald Hoyer 38a2dd
@@ -835,10 +844,7 @@ wait_for_dev()
Harald Hoyer 38a2dd
     } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
     if [ -n "$DRACUT_SYSTEMD" ]; then
Harald Hoyer 38a2dd
-        _name="${1%%/}"
Harald Hoyer 38a2dd
-        _name="${_name##/}"
Harald Hoyer 38a2dd
-        _name="$(str_replace "$_name" '-' '\x2d')"
Harald Hoyer 38a2dd
-        _name="$(str_replace "$_name" '/' '-')"
Harald Hoyer 38a2dd
+        _name=$(dev_unit_name "$1")
Harald Hoyer 38a2dd
         if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device ]; then
Harald Hoyer 38a2dd
             [ -d ${PREFIX}/etc/systemd/system/initrd.target.requires ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.requires
Harald Hoyer 38a2dd
             ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device