Blame 0012-dracut-functions-new-function-inst_any-d-dest-f1-f2-.patch

Harald Hoyer 55891e
From 3378a54f15016c86e4c8c2ecafcaa45f0119fc00 Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= <aidecoe@aidecoe.name>
Harald Hoyer 55891e
Date: Sun, 21 Aug 2011 12:47:13 +0200
Harald Hoyer 55891e
Subject: [PATCH] dracut-functions: new function: inst_any [-d dest] f1 [f2
Harald Hoyer 55891e
 [f3 ...]]
Harald Hoyer 55891e
Harald Hoyer 55891e
---
Harald Hoyer 55891e
 dracut-functions |   28 ++++++++++++++++++++++++++++
Harald Hoyer 55891e
 1 files changed, 28 insertions(+), 0 deletions(-)
Harald Hoyer 55891e
Harald Hoyer 55891e
diff --git a/dracut-functions b/dracut-functions
Harald Hoyer 55891e
index d7f2e5f..43a6843 100755
Harald Hoyer 55891e
--- a/dracut-functions
Harald Hoyer 55891e
+++ b/dracut-functions
Harald Hoyer 55891e
@@ -537,6 +537,34 @@ inst_hook() {
Harald Hoyer 55891e
     inst_simple "$3" "/lib/dracut/hooks/${1}/${2}${3##*/}"
Harald Hoyer 55891e
 }
Harald Hoyer 55891e
 
Harald Hoyer 55891e
+# install any of listed files
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# If first argument is '-d' and second some destination path, first accessible
Harald Hoyer 55891e
+# source is installed into this path, otherwise it will installed in the same
Harald Hoyer 55891e
+# path as source.  If none of listed files was installed, function return 1.
Harald Hoyer 55891e
+# On first successful installation it returns with 0 status.
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# Example:
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# inst_any -d /bin/foo /bin/bar /bin/baz
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# Lets assume that /bin/baz exists, so it will be installed as /bin/foo in
Harald Hoyer 55891e
+# initramfs.
Harald Hoyer 55891e
+inst_any() {
Harald Hoyer 55891e
+    local to f
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    [[ $1 = '-d' ]] && to="$2" && shift 2
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    for f in "$@"; do
Harald Hoyer 55891e
+        if [[ -e $f ]]; then
Harald Hoyer 55891e
+            [[ $to ]] && inst "$f" "$to" && return 0
Harald Hoyer 55891e
+            inst "$f" && return 0
Harald Hoyer 55891e
+        fi
Harald Hoyer 55891e
+    done
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    return 1
Harald Hoyer 55891e
+}
Harald Hoyer 55891e
+
Harald Hoyer 55891e
 dracut_install() {
Harald Hoyer 55891e
     local _optional=no
Harald Hoyer 55891e
     if [[ $1 = '-o' ]]; then