[arch-projects] [PATCH 13/13] add -A option for adding hooks during build

Dave Reisner d at falconindy.com
Fri Jul 22 20:21:20 EDT 2011


Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
I can see this being useful for one-off images made outside the context of a
preset, but this might also just be some oddball feature that never gets used.

 mkinitcpio       |    8 +++++---
 mkinitcpio.5.txt |    5 +++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/mkinitcpio b/mkinitcpio
index c5c174b..e46306c 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -24,7 +24,7 @@ COMPRESSION=gzip
 declare TMPDIR= BASEDIR= MODULE_FILE= GENIMG= PRESET= COMPRESSION_OPTIONS= BUILDROOT=
 declare NC= BOLD= BLUE= GREEN= RED= YELLOW=
 declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1
-declare -a SKIPHOOKS ADDED_MODULES MODPATHS
+declare -a ADDHOOKS SKIPHOOKS ADDED_MODULES MODPATHS
 
 # Add /{,usr}/sbin to path
 # works around undetected problems like in #8448
@@ -40,6 +40,7 @@ mkinitcpio %VERSION%
 usage: ${0##*/} [options]
 
   Options:
+   -A ADDHOOKS      Add ADDHOOKS (comma-separated) when building the image.
    -b BASEDIR       Use BASEDIR. default: /
    -c CONFIG        Use CONFIG file. default: /etc/mkinitcpio.conf
    -g IMAGE         Generate a cpio image as IMAGE. default: no
@@ -97,8 +98,9 @@ get_kernver() {
 trap 'cleanup 130' INT
 trap 'cleanup 143' TERM
 
-while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do
+while getopts ':A:c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do
     case "${arg}" in
+        A) IFS=, read -r -a ADDHOOKS <<< "$OPTARG" ;;
         c) CONFIG="${OPTARG}" ;;
         k) optkver=$OPTARG ;;
         s) SAVELIST=1; ;;
@@ -283,7 +285,7 @@ trap '[[ $FUNCNAME = parse_hook ]] && (( ++builderrors ))' ERR
 #parse 'global' hook, as defined in ${CONFIG}
 parse_hook
 
-for hook in ${HOOKS}; do
+for hook in ${HOOKS} "${ADDHOOKS[@]}"; do
     in_array "$hook" "${SKIPHOOKS[@]}" && continue
     unset MODULES BINARIES FILES SCRIPT
     build () { error "$hook: no build function..."; }
diff --git a/mkinitcpio.5.txt b/mkinitcpio.5.txt
index f963dac..d233957 100644
--- a/mkinitcpio.5.txt
+++ b/mkinitcpio.5.txt
@@ -24,6 +24,11 @@ other features.
 
 Options
 -------
+*-A* 'hooks'::
+	Add 'hooks' when generating the image. Several hooks should be
+	comma-separated. These will be added, in order, after any other hooks
+	are processed from the config file.
+
 *-b* 'basedir'::
 	Use 'basedir' as a starting point for gathering information about the
 	currently running system. Default: /.
-- 
1.7.6



More information about the arch-projects mailing list