Skip to content

Commit

Permalink
ensure that cmdline added hooks are run properly in early init
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
  • Loading branch information
falconindy committed May 2, 2012
1 parent bd858a5 commit 25e8e20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion install/base
@@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash


build() { build() {
local dir applet

for dir in new_root proc sys dev run tmp usr/bin; do for dir in new_root proc sys dev run tmp usr/bin; do
add_dir "/$dir" add_dir "/$dir"
done done
Expand Down Expand Up @@ -44,7 +46,6 @@ build() {


# sanitize of any extra whitespace # sanitize of any extra whitespace
read -r -a modules <<< "$MODULES" read -r -a modules <<< "$MODULES"
read -r -a hooks <<< "$HOOKS"


{ {
(( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]%\?}" (( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]%\?}"
Expand Down
16 changes: 13 additions & 3 deletions mkinitcpio
Expand Up @@ -104,6 +104,13 @@ get_kernver() {
return 1 return 1
} }


compute_hookset() {
for h in $HOOKS "${ADDHOOKS[@]}"; do
in_array "$h" "${SKIPHOOKS[@]}" && continue
hooks+=("$h")
done
}

. "$FUNCTIONS" . "$FUNCTIONS"


trap 'cleanup 130' INT trap 'cleanup 130' INT
Expand Down Expand Up @@ -312,7 +319,11 @@ if [[ ! -f "$CONFIG" ]]; then
fi fi
. "$CONFIG" . "$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" die "Invalid config: No hooks found"
fi fi


Expand Down Expand Up @@ -352,8 +363,7 @@ for var in MODULES BINARIES FILES; do
declare "cfg_$var=${!var}" declare "cfg_$var=${!var}"
done done


for hook in ${HOOKS} "${ADDHOOKS[@]}"; do for hook in "${hooks[@]}"; do
in_array "$hook" "${SKIPHOOKS[@]}" && continue
unset MODULES BINARIES FILES SCRIPT unset MODULES BINARIES FILES SCRIPT
build() { error "$hook: no build function..."; return 1; } build() { error "$hook: no build function..."; return 1; }


Expand Down

0 comments on commit 25e8e20

Please sign in to comment.