From 8fe5878427767b06abc9378137f2c826fe610d8d Mon Sep 17 00:00:00 2001 From: Thomas Bächler Date: Tue, 24 Oct 2006 08:59:18 +0000 Subject: - Preset changes to better config file format - Global kver for all images in a preset - Allow comments (#) in kernel commandline git-svn-id: http://projects.archlinux.org/svn/initramfs/mkinitcpio@182 880c04e9-e011-0410-abf7-b926e227c9cd --- init | 1 + mkinitcpio | 34 ++++++++++++++++++++++++++++------ mkinitcpio.d/example.preset | 27 ++++++++++++++++++--------- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/init b/init index a1a7793..20d902e 100644 --- a/init +++ b/init @@ -18,6 +18,7 @@ echo "/bin/modprobe" > /proc/sys/kernel/modprobe for cmd in $CMDLINE; do case "$cmd" in + \#*) break ;; # ignore everything after a # in the commandline [0123456Ss]) export runlevel="$cmd" ;; single) export runlevel="S" ;; #some people use 'single' # replace can cause problems for the following entries diff --git a/mkinitcpio b/mkinitcpio index 90eef75..70f848c 100644 --- a/mkinitcpio +++ b/mkinitcpio @@ -86,15 +86,37 @@ shift $(($OPTIND - 1)) if [ -n "${PRESET}" ]; then if [ -f "${PRESETDIR}/${PRESET}.preset" ]; then # Use -b and -v options specified earlier - PRESET_MKOPTS="" + PRESET_MKOPTS="${0}" [ -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}" + for p in ${PRESETS[@]}; do + echo "==> Building image \"${p}\"" + PRESET_CMD="${PRESET_MKOPTS}" + eval "PRESET_KVER=\"\${${p}_kver}\"" + eval "PRESET_CONFIG=\"\${${p}_config}\"" + eval "PRESET_IMAGE=\"\${${p}_image}\"" + if [ -n "${PRESET_KVER}" ]; then + PRESET_CMD="${PRESET_CMD} -k ${PRESET_KVER}" + elif [ -n "${ALL_kver}" ]; then + PRESET_CMD="${PRESET_CMD} -k ${ALL_kver}" + else + echo "==> No kernel version specified. Skipping image \"${p}\"." + continue + fi + if [ -n "${PRESET_CONFIG}" ]; then + PRESET_CMD="${PRESET_CMD} -c ${PRESET_CONFIG}" + else + echo "==> No configuration file specified. Skipping image \"${p}\"." + continue + fi + if [ -n "${PRESET_IMAGE}" ]; then + PRESET_CMD="${PRESET_CMD} -g ${PRESET_IMAGE}" + else + echo "==> No image file specified. Skipping image \"${p}\"." + continue + fi echo "==> Running command: ${PRESET_CMD}" if ${PRESET_CMD}; then echo "==> SUCCESS" @@ -190,7 +212,7 @@ for hook in $HOOKS; do done if [ "${HAS_MODULES}" == "y" ]; then - echo ":: Generating module dependancies" + echo ":: Generating module dependencies" for mod in $(grep "file /lib/modules/${KERNELVERSION}" ${FILELIST} | cut -d' ' -f2); do dir=$(dirname "${mod}") mkdir -p "/tmp/${dir}" diff --git a/mkinitcpio.d/example.preset b/mkinitcpio.d/example.preset index 3dabdae..b283815 100644 --- a/mkinitcpio.d/example.preset +++ b/mkinitcpio.d/example.preset @@ -1,13 +1,22 @@ # Example mkinitcpio preset file -PRESET_N=2 +# preset names +PRESETS=('default' 'fallback') -PRESET_NAME[0]="default" -PRESET_KVER[0]="2.6.18-ARCH" -PRESET_CONFIG[0]="/etc/mkinitcpio.conf" -PRESET_IMAGE[0]="/tmp/kernel26.img" +# ALL_kver is used if presetname_kver is not set +# note for distribution kernels: this should be in a separate file +# and read like this: +# source /etc/mkinitcpio.d/exmaple.kver +ALL_kver='2.6.18-ARCH' -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" +# presetname_kver specifies the kernel version (omit if ALL_kver should be used) +# presetname_config specifies the configuration file +# presetname_image specifies the image to be generated + +#default_kver="2.6.18-ARCH" +default_config="/etc/mkinitcpio.conf" +default_image="/tmp/kernel26.img" + +#fallback_kver="2.6.18-ARCH" +fallback_config="/etc/mkinitcpio.d/mkinitcpio-kernel26-fallback.conf" +fallback_image="/tmp/kernel26-fallback.img" -- cgit v1.2.3-24-g4f1b