From 7b8e68af09e20fd95656b8909f4fc027440c1c30 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 3 Mar 2012 13:36:13 -0500 Subject: 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 --- functions | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'functions') 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: -- cgit v1.2.3-24-g4f1b