dracut/0012-dracut-functions-new-function-inst_any-d-dest-f1-f2-.patch
2011-10-19 15:30:00 +02:00

50 lines
1.4 KiB
Diff

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