Permalink
Browse files

ensure that cmdline added hooks are run properly in early init

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
  • Loading branch information...
1 parent bd858a5 commit 25e8e2078610025ce52d90b55997d413f0b88bd4 @falconindy committed May 2, 2012
Showing with 15 additions and 4 deletions.
  1. +2 −1 install/base
  2. +13 −3 mkinitcpio
View
@@ -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[*]%\?}"
View
@@ -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; }

0 comments on commit 25e8e20

Please sign in to comment.