summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-03-03 19:36:13 +0100
committerDave Reisner <dreisner@archlinux.org>2012-03-04 17:59:39 +0100
commit7b8e68af09e20fd95656b8909f4fc027440c1c30 (patch)
treea4b7d605767e46198c5ea470ee28c8bdbb4d032a /functions
parent57e275a08d46f976ab2a2edf9b7b507bbca1d1ca (diff)
downloadmkinitcpio-7b8e68af09e20fd95656b8909f4fc027440c1c30.tar.gz
mkinitcpio-7b8e68af09e20fd95656b8909f4fc027440c1c30.tar.xz
add support for HOOKDIR/INSTDIR as arrays
This is a really ugly patch, but allows mkinitcpio to read hooks from multiple locations, namely: /usr/lib/initcpio/{install,hooks} /lib/initcpio/{install,hooks} Preference is given to the first, and all files included with mkinitcpio are moved there. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions18
1 files changed, 16 insertions, 2 deletions
diff --git a/functions b/functions
index c85806a..5485578 100644
--- a/functions
+++ b/functions
@@ -337,7 +337,7 @@ parse_hook() {
# prior to the start of hook processing, and after each hook's build
# function is run.
- local item=
+ local item= script=
for item in $MODULES; do
if [[ ${item:(-1)} = '?' ]]; then
@@ -355,7 +355,21 @@ parse_hook() {
add_file "$item"
done
- [[ $SCRIPT ]] && add_file "$HOOKDIR/$SCRIPT" "/hooks/$SCRIPT"
+ if [[ $SCRIPT ]]; then
+ script=$(find_in_dirs "$SCRIPT" "${HOOKDIR[@]}") &&
+ add_file "$script" "/hooks/$SCRIPT"
+ fi
+}
+
+find_in_dirs() {
+ for dir in "${@:2}"; do
+ if [[ -e $dir/$1 ]]; then
+ printf '%s' "$dir/$1"
+ return 0
+ fi
+ done
+
+ return 1
}
# vim: set ft=sh ts=4 sw=4 et: