--- trunk/grubby/new-kernel-pkg 2013/10/21 13:22:57 2238 +++ trunk/grubby/new-kernel-pkg 2013/10/21 14:08:21 2263 @@ -116,6 +116,7 @@ then liloConfig="" bootPrefix=/boot + extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) ubootDir=${UBOOT_DIR:-"/boot"} ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} ubootKList=${UBOOT_KLIST:-"klist.txt"} @@ -170,7 +171,7 @@ install() { # XXX kernel should be able to be specified also (or work right on ia64) - if [ ! -f ${bootPrefix}/${kernelName}-${version} ] + if [ ! -f ${kernelImage} ] then [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" return @@ -195,9 +196,9 @@ if [[ -z ${initrdfile} ]] then [[ -n ${verbose} ]] && echo "No initrd, just adding system map" - /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version} + /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version} else - /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version} + /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version} /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null rm ${bootPrefix}/vmlinux.sm-${version} fi @@ -217,24 +218,25 @@ cfgLilo="" fi + if [[ -n ${banner} ]] + then + title="${banner} [ ${version} ]" + elif [[ $(read_os_release id) = magellan ]] + then + title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" + elif [ -f /etc/mageversion ] + then + title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" + else + title="Magellan Linux [ ${version} ]" + fi + if [[ -n ${cfgGrub} ]] then [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" - if [[ -n ${banner} ]] - then - title="${banner} [ ${version} ]" - elif [ -f /etc/mageversion ] - then - title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" - elif [[ $(read_os_release id) = magellan ]] - then - title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" - else - title="Magellan Linux [ ${version} ]" - fi ${grubby} --grub -c ${grubConfig} \ - --add-kernel=${bootPrefix}/${kernelName}-${version} \ + --add-kernel=${kernelImage} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" @@ -245,20 +247,8 @@ then [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" - if [[ -n ${banner} ]] - then - title="${banner} [ ${version} ]" - elif [ -f /etc/mageversion ] - then - title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" - elif [[ $(read_os_release id) = magellan ]] - then - title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" - else - title="Magellan Linux [ ${version} ]" - fi ${grubby} --grub2 -c ${grub2Config} \ - --add-kernel=${bootPrefix}/${kernelName}-${version} \ + --add-kernel=${kernelImage} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ ${mbkernel:+--add-multiboot="${mbkernel}"} \ ${mbargs:+--mbargs="${mbargs}"} \ @@ -270,20 +260,8 @@ then [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" - if [[ -n ${banner} ]] - then - title="${banner} [ ${version} ]" - elif [ -f /etc/mageversion ] - then - title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" - elif [[ $(read_os_release id) = magellan ]] - then - title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" - else - title="Magellan Linux [ ${version} ]" - fi ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ - --add-kernel=${bootPrefix}/${kernelName}-${version} \ + --add-kernel=${kernelImage} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ ${mbkernel:+--add-multiboot="${mbkernel}"} \ ${mbargs:+--mbargs="${mbargs}"} \ @@ -296,7 +274,7 @@ then [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" - ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \ + ${grubby} --add-kernel=${kernelImage} ${INITRD} \ --copy-default ${makedefault} --title ${version} \ ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ @@ -320,20 +298,8 @@ then [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" - if [[ -n ${banner} ]] - then - title="${banner} [ ${version} ]" - elif [ -f /etc/mageversion ] - then - title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" - elif [[ $(read_os_release id) = magellan ]] - then - title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" - else - title="Magellan Linux [ ${version} ]" - fi ${grubby} --extlinux -c ${extlinuxConfig} \ - --add-kernel=${bootPrefix}/${kernelName}-${version} \ + --add-kernel=${kernelImage} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" @@ -348,7 +314,7 @@ if [ -d /proc/iSeries ] then [[ -n ${verbose} ]] && echo "On an iSeries, remove img file" - rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null + rm -f ${kernelImage}.img 2>/dev/null return fi @@ -356,7 +322,7 @@ then [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" ${grubby} --grub -c ${grubConfig} \ - --remove-kernel=${bootPrefix}/${kernelName}-${version} + --remove-kernel=${kernelImage} else [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" fi @@ -364,7 +330,7 @@ then [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" ${grubby} --grub2 -c ${grub2Config} \ - --remove-kernel=${bootPrefix}/${kernelName}-${version} + --remove-kernel=${kernelImage} else [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" fi @@ -372,7 +338,7 @@ then [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ - --remove-kernel=${bootPrefix}/${kernelName}-${version} + --remove-kernel=${kernelImage} else [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" fi @@ -380,7 +346,7 @@ if [[ -n ${cfgLilo} ]] then [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" - ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag} + ${grubby} --remove-kernel=${kernelImage} --${liloFlag} if [[ -n ${runLilo} ]] then @@ -439,6 +405,7 @@ fi mv ${tmpKList} ${ubootDir}/${ubootKList} + [ -x /sbin/a-b-c ] && /sbin/a-b-c else [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" [ -f ${tmpKList} ] && rm -f ${tmpKList} @@ -454,7 +421,7 @@ then [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" ${grubby} --extlinux -c ${extlinuxConfig} \ - --remove-kernel=${bootPrefix}/${kernelName}-${version} + --remove-kernel=${kernelImage} else [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" fi @@ -462,7 +429,7 @@ update() { - if [ ! -f ${bootPrefix}/${kernelName}-${version} ] + if [ ! -f ${kernelImage} ] then [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" return @@ -484,10 +451,11 @@ then [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" ${grubby} --grub -c ${grubConfig} \ - --update-kernel=${bootPrefix}/${kernelName}-${version} \ + --update-kernel=${kernelImage} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ - ${removeargs:+--remove-args="${removeargs}"} + ${removeargs:+--remove-args="${removeargs}"} \ + ${mbkernel:+--add-multiboot="${mbkernel}"} else [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" fi @@ -496,7 +464,7 @@ then [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" ${grubby} --grub2 -c ${grub2Config} \ - --update-kernel=${bootPrefix}/${kernelName}-${version} \ + --update-kernel=${kernelImage} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ ${removeargs:+--remove-args="${removeargs}"} @@ -508,7 +476,7 @@ then [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ - --update-kernel=${bootPrefix}/${kernelName}-${version} \ + --update-kernel=${kernelImage} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ ${removeargs:+--remove-args="${removeargs}"} @@ -519,7 +487,7 @@ if [[ -n ${cfgLilo} ]] then [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" - ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ + ${grubby} --update-kernel=${kernelImage} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ ${removeargs:+--remove-args="${removeargs}"} \ @@ -546,7 +514,7 @@ [[ -n ${verbose} ]] && echo "creating uImage-${version}" mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ -e ${ubootAddress} -n ${version} \ - -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} + -d ${kernelImage} ${ubootDir}/uImage-${version} [[ -n ${verbose} ]] && echo "creating uInitrd-${version}" mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ @@ -565,6 +533,7 @@ [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit fi echo ${version} >> ${ubootDir}/${ubootKList} + [ -x /sbin/a-b-c ] && /sbin/a-b-c else [[ -n ${verbose} ]] && echo "cannot make ${version} the default" fi @@ -576,7 +545,7 @@ then [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" ${grubby} --extlinux -c ${extlinuxConfig} \ - --update-kernel=${bootPrefix}/${kernelName}-${version} \ + --update-kernel=${kernelImage} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ ${removeargs:+--remove-args="${removeargs}"} @@ -618,7 +587,11 @@ doRmmoddep() { [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" - [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.* + if [ -d /lib/modules/${version} ] + then + rm -f /lib/modules/${version}/modules.*.bin \ + /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep} + fi } @@ -642,9 +615,9 @@ ;; --initrdfile*) - if echo $1 | grep '=' >/dev/null + if [[ $1 == --initrdfile\=* ]] then - initrdfile=$(echo $1 | sed 's/^--initrdfile=//') + initrdfile=${1#--initrdfile=} else initrdfile=$2 shift @@ -652,9 +625,9 @@ ;; --kernel-args*) - if echo $1 | grep '=' >/dev/null + if [[ $1 == --kernel-args\=* ]] then - kernargs=$(echo $1 | sed 's/^--kernel-args=//') + kernargs=${1#--kernel-args=} else kernargs=$2 shift @@ -662,9 +635,9 @@ ;; --remove-args*) - if echo $1 | grep '=' >/dev/null + if [[ $1 == --remove-args\=* ]] then - removeargs=$(echo $1 | sed 's/^--remove-args=//') + removeargs=${1#--remove-args=} else removeargs=$2 shift @@ -672,9 +645,9 @@ ;; --banner*) - if echo $1 | grep '=' >/dev/null + if [[ $1 == --banner\=* ]] then - banner=$(echo $1 | sed 's/^--banner=//') + banner=${1#--banner=} else banner=$2 shift @@ -682,9 +655,9 @@ ;; --multiboot*) - if echo $1 |grep '=' >/dev/null + if [[ $1 == --multiboot\=* ]] then - mbkernel=$(echo $1 | sed 's/^--multiboot=//') + mbkernel=${1#--multiboot=} else # can't really support having an optional second arg here # sorry! @@ -693,9 +666,9 @@ ;; --mbargs*) - if echo $1 |grep '=' >/dev/null + if [[ $1 == --mbargs\=* ]] then - mbargs=$(echo $1 | sed 's/^--mbargs=//') + mbargs=${1#--mbargs=} else mbargs="$2" shift @@ -714,10 +687,10 @@ makedefault="--make-default" ;; - --package) - if echo $1 | grep '=' >/dev/null + --package*) + if [[ $1 == --package\=* ]] then - package=$(echo $1 | sed 's/^--package=//') + package=${1#--package=} else package=$2 shift @@ -732,6 +705,22 @@ addplymouthinitrd=--add-plymouth-initrd ;; + --kernel-image*) + if [[ $1 == --kernel-image\=* ]] + then + kernelImage=${1#--kernel-image=} + else + kernelImage="$2" + shift + fi + if ! [[ -f ${kernelImage} ]] + then + echo "Can't find kernel image '${kernelImage}'" >&2 + usage + exit 1 + fi + ;; + -v) verbose=-v ;; @@ -779,6 +768,8 @@ fi fi +[[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}" + # set the initrd file based on arch; ia64 is the only currently known oddball if [[ -z ${initrdfile} ]] then