--- trunk/grubby/new-kernel-pkg 2012/03/03 16:05:42 1778 +++ trunk/grubby/new-kernel-pkg 2013/10/21 13:28:04 2239 @@ -91,6 +91,7 @@ elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] then liloConfig=/etc/yaboot.conf + grub2Config=/boot/grub/grub.cfg bootPrefix=/boot lilo=/sbin/ybin liloFlag=yaboot @@ -111,26 +112,20 @@ lilo=/sbin/zipl runLilo="yes" isx86="" -elif [[ ${ARCH} = armv7l ]] || [[ ${ARCH} = armv7hl ]] || [[ ${ARCH} = armv5tel ]] +elif [[ ${ARCH} =~ armv[5|7].*l ]] then - machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') liloConfig="" bootPrefix=/boot - ubootDir=${UBOOT_DIR:-"/boot/uboot"} + ubootDir=${UBOOT_DIR:-"/boot"} ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} ubootKList=${UBOOT_KLIST:-"klist.txt"} ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} + ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} mounted="" liloFlag="" isx86="" - if [[ ${machine} == "OMAP3 Beagle Board" ]] || [[ ${machine} == "OMAP4 Panda board" ]] - then - ubootAddress=0x80008000 - else - ubootAddress=0x00008000 - fi else # this leaves i?86 and x86_64 liloConfig=/etc/lilo.conf @@ -210,7 +205,11 @@ fi # get the root filesystem to use - rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) + rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab 2>/dev/null) + if [[ -z $rootdevice ]] + then + rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline) + fi if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] then @@ -218,22 +217,23 @@ 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} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ @@ -246,18 +246,6 @@ 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} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ @@ -271,19 +259,7 @@ 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} \ + ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ --add-kernel=${bootPrefix}/${kernelName}-${version} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ ${mbkernel:+--add-multiboot="${mbkernel}"} \ @@ -321,18 +297,6 @@ 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} \ ${INITRD} --copy-default ${makedefault} --title "${title}" \ @@ -372,7 +336,7 @@ if [[ -n ${cfgGrub2Efi} ]] then [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" - ${grubby} --grub2 -c ${grub2EfiConfig} \ + ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ --remove-kernel=${bootPrefix}/${kernelName}-${version} else [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" @@ -405,7 +369,7 @@ then tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) curversion=$(tail -n1 ${ubootDir}/${ubootKList}) - sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} + sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} newversion=$(tail -n1 ${tmpKList}) if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] then @@ -508,7 +472,7 @@ if [[ -n ${cfgGrub2Efi} ]] then [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" - ${grubby} --grub2 -c ${grub2EfiConfig} \ + ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ --update-kernel=${bootPrefix}/${kernelName}-${version} \ ${INITRD} \ ${kernargs:+--args="${kernargs}"} \ @@ -801,17 +765,45 @@ # add dracut i18n, keyboard and plymouth kernel args if requested if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] then - [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap - [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont - - if [[ -n ${KEYMAP} ]] + if [ -r /etc/vconsole.conf ] then - kernargs="${kernargs} KEYTABLE=${KEYMAP}" + . /etc/vconsole.conf + + for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE + do + val=$(eval echo \$$i) + [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}" + done + else + if [ -r /etc/conf.d/consolefont ] + then + . /etc/conf.d/consolefont + + if [[ -n ${CONSOLEFONT} ]] + then + kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" + fi + fi + + if [ -r /etc/conf.d/keymap ] + then + . /etc/conf.d/keymap + + if [[ -n ${KEYMAP} ]] + then + kernargs="${kernargs} KEYTABLE=${KEYMAP}" + fi + fi fi - if [[ -n ${CONSOLEFONT} ]] + if [ -r /etc/locale.conf ] then - kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" + . /etc/locale.conf + + if [[ -n ${LANG} ]] + then + kernargs="${kernargs} LANG=${LANG}" + fi fi fi @@ -869,6 +861,21 @@ fi fi +# if we're using U-Boot, check if the default load address should change +if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]] +then + [[ ${version} =~ .([^.]*)$ ]] + platform=${BASH_REMATCH[1]} + # A few platforms use an alternate kernel load address + if [[ ${platform} = omap ]] + then + ubootAddress=0x80008000 + elif [[ ${platform} = imx ]] + then + ubootAddress=0x90008000 + fi +fi + # if we have a lilo config on an x86 box, see if the default boot loader # is lilo to determine if it should be run if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]