This function adds a runtime script to the /hooks directory on the initramfs image. Note that this function will also install hooks with executable permissions for use by a later change to early init. With this commit, there are now methods available which can be used in place of the MODULES, FILES, BINARIES, and SCRIPT variables, as we now offer error checking on the add_* functions. Usage of the variables is deprecated, and these will no longer be read in a future version of mkinitcpio. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/functions b/functions index 97b401c..ad24076 100644 --- a/functions +++ b/functions @@ -422,8 +422,23 @@ add_file() { command install -Dm$mode "$src" "$BUILDROOT$dest" } +add_runscript() { + # Adds a runtime script to the initcpio image. This function takes no + # parameters. The name is derived from the script which calls it and + # cannot be changed due to limitations in early userspace. + + local script hookname=${BASH_SOURCE[1]##*/} + + if ! script=$(find_in_dirs "$hookname" "${HOOKDIR[@]}"); then + error "runtime script for \`%s' not found" "$hookname" + return + fi + + add_file "$script" "/hooks/$hookname" 755 +} + add_binary() { - # add a binary file to the initcpio image. library dependencies will + # Add a binary file to the initcpio image. library dependencies will # be discovered and added. # $1: path to binary # $2: destination on initcpio (optional, defaults to same as source) @@ -490,7 +505,7 @@ parse_hook() { if [[ $SCRIPT ]]; then script=$(find_in_dirs "$SCRIPT" "${HOOKDIR[@]}") && - add_file "$script" "/hooks/$SCRIPT" + add_file "$script" "/hooks/$SCRIPT" 755 fi } -- 1.7.10.2