From 10180bbdef48f1b58eb595d66fe4aa396aa5ed30 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Fri, 30 Dec 2011 16:15:34 -0600 Subject: [PATCH] netinstall: final custom script, make sure to backup and install custom bootloaders at end of install, also make sure that the script knows about new u-boot.img files Signed-off-by: Robert Nelson --- mk_mmc.sh | 10 +++++-- scripts/debian-finish.sh | 30 ++++++++++---------- scripts/ubuntu-finish.sh | 60 +++++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/mk_mmc.sh b/mk_mmc.sh index c8335ad..09dddeb 100755 --- a/mk_mmc.sh +++ b/mk_mmc.sh @@ -1118,9 +1118,11 @@ function populate_boot { if mount -t vfat ${MMC}${PARTITION_PREFIX}1 ${TEMPDIR}/disk; then + mkdir -p ${TEMPDIR}/disk/cus if [ "${SPL_BOOT}" ] ; then if [ -f ${TEMPDIR}/dl/${MLO} ]; then cp -v ${TEMPDIR}/dl/${MLO} ${TEMPDIR}/disk/MLO + cp -v ${TEMPDIR}/dl/${MLO} ${TEMPDIR}/disk/cus/MLO fi fi @@ -1128,8 +1130,10 @@ function populate_boot { if [ -f ${TEMPDIR}/dl/${UBOOT} ]; then if echo ${UBOOT} | grep img > /dev/null 2>&1;then cp -v ${TEMPDIR}/dl/${UBOOT} ${TEMPDIR}/disk/u-boot.img + cp -v ${TEMPDIR}/dl/${UBOOT} ${TEMPDIR}/disk/cus/u-boot.img else cp -v ${TEMPDIR}/dl/${UBOOT} ${TEMPDIR}/disk/u-boot.bin + cp -v ${TEMPDIR}/dl/${UBOOT} ${TEMPDIR}/disk/cus/u-boot.bin fi fi fi @@ -1162,11 +1166,11 @@ if [ "${USE_UENV}" ] ; then cat ${TEMPDIR}/bootscripts/netinstall.cmd echo "-----------------------------" echo "Normal Boot Script:" - cp -v ${TEMPDIR}/bootscripts/normal.cmd ${TEMPDIR}/disk/normal.txt + cp -v ${TEMPDIR}/bootscripts/normal.cmd ${TEMPDIR}/disk/cus/normal.txt echo "-----------------------------" cat ${TEMPDIR}/bootscripts/normal.cmd echo "-----------------------------" - touch ${TEMPDIR}/disk/use_uenv + touch ${TEMPDIR}/disk/cus/use_uenv else echo "Copying boot.scr based boot scripts to Boot Partition" echo "-----------------------------" @@ -1178,7 +1182,7 @@ else cat ${TEMPDIR}/bootscripts/netinstall.cmd echo "-----------------------------" echo "Normal Boot Script:" - cp -v ${TEMPDIR}/bootscripts/normal.cmd ${TEMPDIR}/disk/boot.cmd + cp -v ${TEMPDIR}/bootscripts/normal.cmd ${TEMPDIR}/disk/cus/boot.cmd cat ${TEMPDIR}/bootscripts/normal.cmd echo "-----------------------------" fi diff --git a/scripts/debian-finish.sh b/scripts/debian-finish.sh index 22bc198..bed0a0f 100644 --- a/scripts/debian-finish.sh +++ b/scripts/debian-finish.sh @@ -8,25 +8,22 @@ FINAL_FSTYPE=$(mount | grep /dev/ | grep -v devpts | awk '{print $5}') rm -f /boot/uboot/uInitrd.net || true rm -f /boot/uboot/uImage.net || true -#Next: are we using uEnv.txt or boot.scr boot files? -if [ -f "/boot/uboot/use_uenv" ]; then - rm -f /boot/uboot/boot.scr || true - - if [ -f "/boot/uboot/normal.txt" ]; then - sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/normal.txt - sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/normal.txt +#Cleanup: Initial Bootloader +rm -f /boot/uboot/uEnv.txt || true +rm -f /boot/uboot/boot.scr || true - rm -f /boot/uboot/uEnv.txt || true - mv /boot/uboot/normal.txt /boot/uboot/uEnv.txt +#Next: are we using uEnv.txt or boot.scr boot files? +if [ -f "/boot/uboot/cus/use_uenv" ]; then + if [ -f "/boot/uboot/cus/normal.txt" ]; then + sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/cus/normal.txt + sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/cus/normal.txt + mv /boot/uboot/cus/normal.txt /boot/uboot/uEnv.txt fi else - if [ -f "/boot/uboot/boot.scr" ]; then - sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/boot.cmd - sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/boot.cmd - - rm -f /boot/uboot/boot.scr || true - mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot" -d /boot/uboot/boot.cmd /boot/uboot/boot.scr - fi + sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/cus/boot.cmd + sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/cus/boot.cmd + mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot" -d /boot/uboot/cus/boot.cmd /boot/uboot/boot.scr + cp /boot/uboot/cus/boot.cmd /boot/uboot/boot.cmd fi #Install Correct Kernel Image: @@ -35,3 +32,4 @@ update-initramfs -c -k `uname -r` mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d /boot/initrd.img-`uname -r` /boot/uboot/uInitrd mkimage -A arm -O linux -T kernel -C none -a ZRELADD -e ZRELADD -n `uname -r` -d /boot/vmlinuz-`uname -r` /boot/uboot/uImage rm -f /boot/uboot/linux-image-*_1.0*_arm*.deb || true + diff --git a/scripts/ubuntu-finish.sh b/scripts/ubuntu-finish.sh index 458f1e3..bd29118 100644 --- a/scripts/ubuntu-finish.sh +++ b/scripts/ubuntu-finish.sh @@ -14,43 +14,46 @@ rm -f /boot/uboot/uInitrd.bak || true rm -f /boot/uboot/uImage || true rm -f /boot/uboot/uImage.bak || true -#Did: Ubuntu touch and backup scr boot file? -if [ -f "/boot/uboot/boot.scr.bak" ]; then - rm -f /boot/uboot/boot.scr || true - mv /boot/uboot/boot.scr.bak /boot/uboot/boot.scr +#Cleanup: Initial Bootloader +rm -f /boot/uboot/boot.scr || true +rm -f /boot/uboot/boot.scr.bak || true +rm -f /boot/uboot/uEnv.txt || true +rm -f /boot/uboot/uEnv.txt.bak || true + +#Restore backup MLO (SPL) Bootloader? +rm -f /boot/uboot/MLO || true +rm -f /boot/uboot/MLO.bak || true + +if [ -f /boot/uboot/cus/MLO ] ; then + mv /boot/uboot/cus/MLO /boot/uboot/MLO fi -#Did: Ubuntu touch and backup MLO Bootloader? -if [ -f "/boot/uboot/MLO.bak" ]; then - rm -f /boot/uboot/MLO || true - mv /boot/uboot/MLO.bak /boot/uboot/MLO +#Restore, backup u-boot Bootloader? +rm -f /boot/uboot/u-boot.bin || true +rm -f /boot/uboot/u-boot.bin.bak || true +rm -f /boot/uboot/u-boot.img || true +rm -f /boot/uboot/u-boot.img.bak || true + +if [ -f /boot/uboot/cus/u-boot.img ] ; then + mv /boot/uboot/cus/u-boot.img /boot/uboot/u-boot.img fi -#Did: Ubuntu touch and backup u-boot.bin Bootloader? -if [ -f "/boot/uboot/u-boot.bin.bak" ]; then - rm -f /boot/uboot/u-boot.bin || true - mv /boot/uboot/u-boot.bin.bak /boot/uboot/u-boot.bin +if [ -f /boot/uboot/cus/u-boot.bin ] ; then + mv /boot/uboot/cus/u-boot.bin /boot/uboot/u-boot.bin fi #Next: are we using uEnv.txt or boot.scr boot files? -if [ -f "/boot/uboot/use_uenv" ]; then - rm -f /boot/uboot/boot.scr || true - - if [ -f "/boot/uboot/normal.txt" ]; then - sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/normal.txt - sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/normal.txt - - rm -f /boot/uboot/uEnv.txt || true - mv /boot/uboot/normal.txt /boot/uboot/uEnv.txt +if [ -f "/boot/uboot/cus/use_uenv" ]; then + if [ -f "/boot/uboot/cus/normal.txt" ]; then + sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/cus/normal.txt + sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/cus/normal.txt + mv /boot/uboot/cus/normal.txt /boot/uboot/uEnv.txt fi else - if [ -f "/boot/uboot/boot.scr" ]; then - sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/boot.cmd - sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/boot.cmd - - rm -f /boot/uboot/boot.scr || true - mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot" -d /boot/uboot/boot.cmd /boot/uboot/boot.scr - fi + sed -i -e 's:FINAL_PART:'$FINAL_PART':g' /boot/uboot/cus/boot.cmd + sed -i -e 's:FINAL_FSTYPE:'$FINAL_FSTYPE':g' /boot/uboot/cus/boot.cmd + mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot" -d /boot/uboot/cus/boot.cmd /boot/uboot/boot.scr + cp /boot/uboot/cus/boot.cmd /boot/uboot/boot.cmd fi #Cleanup: some of Ubuntu's packages: @@ -66,3 +69,4 @@ update-initramfs -c -k `uname -r` mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d /boot/initrd.img-`uname -r` /boot/uboot/uInitrd mkimage -A arm -O linux -T kernel -C none -a ZRELADD -e ZRELADD -n `uname -r` -d /boot/vmlinuz-`uname -r` /boot/uboot/uImage rm -f /boot/uboot/linux-image-*_1.0*_arm*.deb || true +