summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-02 19:26:29 +0200
committerDave Reisner <dreisner@archlinux.org>2012-05-02 19:26:29 +0200
commit25e8e2078610025ce52d90b55997d413f0b88bd4 (patch)
tree4e02a466b312c2e023281165aa3a16495cd03cf8
parentbd858a51e41cbcbbff67430508494553aeffdd27 (diff)
downloadmkinitcpio-25e8e2078610025ce52d90b55997d413f0b88bd4.tar.gz
mkinitcpio-25e8e2078610025ce52d90b55997d413f0b88bd4.tar.xz
ensure that cmdline added hooks are run properly in early init
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--install/base3
-rwxr-xr-xmkinitcpio16
2 files changed, 15 insertions, 4 deletions
diff --git a/install/base b/install/base
index ca77071..7eff431 100644
--- a/install/base
+++ b/install/base
@@ -1,6 +1,8 @@
#!/bin/bash
build() {
+ local dir applet
+
for dir in new_root proc sys dev run tmp usr/bin; do
add_dir "/$dir"
done
@@ -44,7 +46,6 @@ build() {
# sanitize of any extra whitespace
read -r -a modules <<< "$MODULES"
- read -r -a hooks <<< "$HOOKS"
{
(( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]%\?}"
diff --git a/mkinitcpio b/mkinitcpio
index fb1db85..084dff7 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -104,6 +104,13 @@ get_kernver() {
return 1
}
+compute_hookset() {
+ for h in $HOOKS "${ADDHOOKS[@]}"; do
+ in_array "$h" "${SKIPHOOKS[@]}" && continue
+ hooks+=("$h")
+ done
+}
+
. "$FUNCTIONS"
trap 'cleanup 130' INT
@@ -312,7 +319,11 @@ if [[ ! -f "$CONFIG" ]]; then
fi
. "$CONFIG"
-if [[ -z ${HOOKS//[[:space:]]} && -z ${ADDHOOKS[@]} ]]; then
+# after returning, hooks are populated into the array 'hooks'
+# HOOKS should not be referenced from here on
+compute_hookset
+
+if (( ${#hooks[*]} == 0 )); then
die "Invalid config: No hooks found"
fi
@@ -352,8 +363,7 @@ for var in MODULES BINARIES FILES; do
declare "cfg_$var=${!var}"
done
-for hook in ${HOOKS} "${ADDHOOKS[@]}"; do
- in_array "$hook" "${SKIPHOOKS[@]}" && continue
+for hook in "${hooks[@]}"; do
unset MODULES BINARIES FILES SCRIPT
build() { error "$hook: no build function..."; return 1; }