summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functions30
-rwxr-xr-xmkinitcpio1
2 files changed, 25 insertions, 6 deletions
diff --git a/functions b/functions
index 2dcfe11..80286e0 100644
--- a/functions
+++ b/functions
@@ -181,6 +181,29 @@ in_array() {
return 1 # Not Found
}
+funcgrep() {
+ awk -v funcmatch="$1" '
+ /^[[:space:]]*[[:alnum:]_]+[[:space:]]*\([[:space:]]*\)/ {
+ match($1, funcmatch)
+ print substr($1, RSTART, RLENGTH)
+ }' "$2"
+}
+
+list_hookpoints() {
+ local funcs
+
+ [[ -e ${1/install/hooks} ]] || return 0
+
+ mapfile -t funcs < <(funcgrep '^run_[[:alnum:]_]+' "${1/install/hooks}")
+
+ echo
+ msg "This hook has runtime scripts:"
+ in_array run_earlyhook "${funcs[@]}" && msg2 "early hook"
+ in_array run_hook "${funcs[@]}" && msg2 "pre-mount hook"
+ in_array run_latehook "${funcs[@]}" && msg2 "post-mount hook"
+ in_array run_cleanuphook "${funcs[@]}" && msg2 "cleanup hook"
+}
+
auto_modules() {
# Perform auto detection of modules via sysfs.
@@ -441,12 +464,7 @@ add_runscript() {
add_file "$script" "/hooks/$hookname" 755
- mapfile -t funcs < \
- <(awk '
- /^[[:space:]]*[[:alnum:]_]+[[:space:]]*\([[:space:]]*\)/ {
- match($1, /[[:alnum:]_]+/)
- print substr($1, RSTART, RLENGTH)
- }' "$script")
+ mapfile -t funcs < <(funcgrep '^run_[[:alnum:]_]+' "$script")
for fn in "${funcs[@]}"; do
case $fn in
diff --git a/mkinitcpio b/mkinitcpio
index 8762991..7497b7c 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -188,6 +188,7 @@ while :; do
fi
msg "Help for hook '$1':"
help
+ list_hookpoints "$script"
exit 0 ;;
-L|--listhooks)
msg "Available hooks"