diff options
-rwxr-xr-x | install.sh | 1 | ||||
-rw-r--r-- | mkinitcpio | 28 | ||||
-rw-r--r-- | mkinitcpio.d/example.preset | 13 |
3 files changed, 41 insertions, 1 deletions
@@ -8,6 +8,7 @@ sed -e 's|CONFIG="mkinitcpio.conf"|CONFIG="/etc/mkinitcpio.conf"|g' \ -e 's|FUNCTIONS="functions"|FUNCTIONS="/lib/initcpio/functions"|g' \ -e 's|HOOKDIR="hooks"|HOOKDIR="/lib/initcpio/hooks"|g' \ -e 's|INSTDIR="install"|INSTDIR="/lib/initcpio/install"|g' \ + -e 's|PRESETDIR="mkinitcpio.d"|PRESETDIR="/etc/mkinitcpio.d"|g' \ < mkinitcpio > ${1}/sbin/mkinitcpio chmod 755 ${1}/sbin/mkinitcpio @@ -25,6 +25,8 @@ MODULE_FILE="" SAVELIST="" GENIMG="" APPEND="" +PRESET="" +PRESETDIR="mkinitcpio.d" QUIET="y" SHOW_AUTOMODS="n" @@ -39,6 +41,7 @@ usage () echo " -b BASEDIR Use BASEDIR. default: /" echo " -g IMAGE Generate a cpio image as IMAGE. default: no" echo " -a NAME Append to an existing filelist. default: no" + echo " -p PRESET Build specified preset." echo " -v Verbose output. Default: no" echo " -M Display modules found via autodetection." echo " -L List all available hooks." @@ -47,7 +50,7 @@ usage () exit 1 } -while getopts ':c:k:s:b:g:a:vH:LMh' arg; do +while getopts ':c:k:s:b:g:a:p:vH:LMh' arg; do if [ "${OPTARG:0:1}" = "-" ]; then echo "error: optional argument to '-$arg' begins with a '-'" echo " you probably don't want this....aborting." @@ -60,6 +63,7 @@ while getopts ':c:k:s:b:g:a:vH:LMh' arg; do b) BASEDIR="$OPTARG" ;; g) GENIMG="$OPTARG" ;; a) APPEND="y"; SAVELIST="y"; FILELIST="$OPTARG" ;; + p) PRESET="$OPTARG" ;; v) QUIET="n" ;; H) source "${INSTDIR}/${OPTARG}"; echo "Help for hook '${OPTARG}':" @@ -78,6 +82,28 @@ while getopts ':c:k:s:b:g:a:vH:LMh' arg; do done shift $(($OPTIND - 1)) +# use preset $PRESET +if [ -n "${PRESET}" -a -f "${PRESETDIR}/${PRESET}.preset" ]; then + # Use -b and -v options specified earlier + PRESET_MKOPTS="" + [ -n "${BASEDIR}" ] && PRESET_MKOPTS="${PRESET_MKOPTS} -b ${BASEDIR}" + [ "${QUIET}" = "n" ] && PRESET_MKOPTS="${PRESET_MKOPTS} -v" + # Build all images + source ${PRESETDIR}/${PRESET}.preset + for ((i=0; i<${PRESET_N}; ++i)); do + [ -z "${PRESET_NAME[${i}]}" -o -z "${PRESET_KVER[${i}]}" -o -z "${PRESET_CONFIG[${i}]}" -o -z "${PRESET_IMAGE[${i}]}" ] && continue + echo "==> Building image \"${PRESET_NAME[${i}]}\"" + PRESET_CMD="${0} -c ${PRESET_CONFIG[${i}]} -k ${PRESET_KVER[${i}]} -g ${PRESET_IMAGE[${i}]} ${PRESET_MKOPTS}" + echo "==> Running command: ${PRESET_CMD}" + if ${PRESET_CMD}; then + echo "==> SUCCESS" + else + echo "==> FAIL" + fi + done + exit 0 +fi + # append a trailing / if needed if [ "${BASEDIR:${#BASEDIR}}" == "/" ]; then BASEDIR="${BASEDIR:0:${#BASEDIR}-1}" diff --git a/mkinitcpio.d/example.preset b/mkinitcpio.d/example.preset new file mode 100644 index 0000000..3dabdae --- /dev/null +++ b/mkinitcpio.d/example.preset @@ -0,0 +1,13 @@ +# Example mkinitcpio preset file + +PRESET_N=2 + +PRESET_NAME[0]="default" +PRESET_KVER[0]="2.6.18-ARCH" +PRESET_CONFIG[0]="/etc/mkinitcpio.conf" +PRESET_IMAGE[0]="/tmp/kernel26.img" + +PRESET_NAME[1]="fallback" +PRESET_KVER[1]="2.6.18-ARCH" +PRESET_CONFIG[1]="/boot/mkinitcpio-kernel26.conf" +PRESET_IMAGE[1]="/tmp/kernel26-fallback.img" |