From 062e00d462438e1bc076bf37418c50f39ed23dcd Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Mon, 28 Jul 2014 17:00:32 -0500 Subject: [PATCH] zz-uenv_txt: should take care of all possiblites now.. Signed-off-by: Robert Nelson --- lib/debian-finish.sh | 1 + lib/shared/zz-uenv_txt | 59 +++++++++++++++++++++++++++++++++++++----- lib/ubuntu-finish.sh | 1 + 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/lib/debian-finish.sh b/lib/debian-finish.sh index 8cc5553..7f3953f 100644 --- a/lib/debian-finish.sh +++ b/lib/debian-finish.sh @@ -179,6 +179,7 @@ else cp /boot/initrd.img-`uname -r` /boot/uboot/boot/initrd.img-current if [ -f /boot/uboot/uImage ] ; then cp /boot/uboot/uImage /boot/uboot/boot/uImage + echo "zreladdr=${zreladdr}" >> ${wfile} fi if [ -f /boot/uboot/uInitrd ] ; then cp /boot/uboot/uInitrd /boot/uboot/boot/uInitrd diff --git a/lib/shared/zz-uenv_txt b/lib/shared/zz-uenv_txt index 6f665d8..f2d9be2 100644 --- a/lib/shared/zz-uenv_txt +++ b/lib/shared/zz-uenv_txt @@ -2,14 +2,13 @@ version="$1" -if [ -f /boot/uEnv.txt ] ; then - - # passing the kernel version is required - if [ -z "${version}" ]; then - echo >&2 "W: zz-uenv_txt: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number" - exit 2 - fi +# passing the kernel version is required +if [ -z "${version}" ]; then + echo >&2 "W: zz-uenv_txt: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number" + exit 2 +fi +if [ -f /boot/uEnv.txt ] ; then unset older_kernel older_kernel=$(grep uname_r /boot/uEnv.txt | grep -v '#' | awk -F"=" '{print $2}' || true) @@ -23,3 +22,49 @@ if [ -f /boot/uEnv.txt ] ; then fi fi +udir="/boot/uboot/boot" +if [ -f ${udir}/uEnv.txt ] ; then + unset older_kernel + older_kernel=$(grep uname_r ${udir}/uEnv.txt | grep -v '#' | awk -F"=" '{print $2}' || true) + unset zreladdr + zreladdr=$(grep zreladdr ${udir}/uEnv.txt | grep -v '#' | awk -F"=" '{print $2}' || true) + + if [ ! "x${older_kernel}" = "xcurrent" ] ; then + if [ -f ${udir}/vmlinuz-current ] ; then + rm -f ${udir}/vmlinuz-current || true + cp /boot/vmlinuz-${version} ${udir}/vmlinuz-current + if [ "${zreladdr}" ] ; then + if [ -f ${udir}/uImage ] ; then + rm -rf ${udir}/uImage || true + mkimage -A arm -O linux -T kernel -C none -a ${zreladdr} -e ${zreladdr} -n ${version} -d ${udir}/vmlinuz-current ${udir}/uImage + fi + fi + fi + if [ -f ${udir}/initrd.img-current ] ; then + rm -f ${udir}/ || true + cp /boot/initrd.img-${version} ${udir}/initrd.img-current + if [ -f ${udir}/uInitrd ] ; then + rm -rf ${udir}/uInitrd || true + mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d ${udir}/initrd.img-current ${udir}/uInitrd + fi + fi + if [ -d ${udir}/dtbs/current/ ] ; then + rm -rf ${udir}/dtbs/current/ || true + mkdir -p ${udir}/dtbs/current/ + + if [ -d /boot/dtbs/${version}/ ] ; then + cp /boot/dtbs/${version}/*.dtb ${udir}/dtbs/current/ + else + if [ -d /usr/lib/linux-image-${version}/ ] ; then + cp /usr/lib/linux-image-${version}/*.dtb ${udir}/dtbs/current/ + else + if [ -d /lib/firmware/${version}/device-tree/ ] ; then + cp /lib/firmware/${version}/device-tree/*.dtb ${udir}/dtbs/current/ + fi + fi + fi + if + echo "zz-uenv_txt: Updating boot drive for: [${version}]" + fi +fi + diff --git a/lib/ubuntu-finish.sh b/lib/ubuntu-finish.sh index 396bc58..f89a538 100644 --- a/lib/ubuntu-finish.sh +++ b/lib/ubuntu-finish.sh @@ -149,6 +149,7 @@ else cp /boot/initrd.img-`uname -r` /boot/uboot/boot/initrd.img-current if [ -f /boot/uboot/uImage ] ; then cp /boot/uboot/uImage /boot/uboot/boot/uImage + echo "zreladdr=${zreladdr}" >> ${wfile} fi if [ -f /boot/uboot/uInitrd ] ; then cp /boot/uboot/uInitrd /boot/uboot/boot/uInitrd