From da24b3230234a6d73a7ea1d52422245522201d26 Mon Sep 17 00:00:00 2001 From: Thomas Bächler Date: Mon, 16 Oct 2006 22:42:18 +0000 Subject: added initial preset support git-svn-id: http://projects.archlinux.org/svn/initramfs/mkinitcpio@178 880c04e9-e011-0410-abf7-b926e227c9cd --- install.sh | 1 + mkinitcpio | 28 +++++++++++++++++++++++++++- mkinitcpio.d/example.preset | 13 +++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 mkinitcpio.d/example.preset diff --git a/install.sh b/install.sh index a704f29..465af40 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/mkinitcpio b/mkinitcpio index 330faf2..5084c2b 100644 --- a/mkinitcpio +++ b/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" -- cgit v1.2.3-24-g4f1b