summaryrefslogtreecommitdiff
path: root/recipes/images/files/library/tegra/update.sh
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2015-07-15 11:45:11 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2015-07-15 15:00:02 +0200
commit1b9de1cb6c67ec3e75a83896e57e9b3b59883a0e (patch)
treeb61ca9471cb483882fe611597f02495feee4395f /recipes/images/files/library/tegra/update.sh
parent655e23e732fdfc21c82e58749b042d57c5d34d20 (diff)
update.sh create_configblock.sh: improve test for awk and exit on failure
On recent Ubuntu distributions gawk no longer supports awk -V which makes the test fail. Simulate our awk use case and test the result instead. Additionally set 'set -e' to exit immediately on errors. Fix places where a command returns not zero in 'normal' situations. E.g. A full disk leads otherwise to funny effects. Allow relative OUT_DIR.
Diffstat (limited to 'recipes/images/files/library/tegra/update.sh')
-rwxr-xr-xrecipes/images/files/library/tegra/update.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/recipes/images/files/library/tegra/update.sh b/recipes/images/files/library/tegra/update.sh
index 8b7ed94..862ceb5 100755
--- a/recipes/images/files/library/tegra/update.sh
+++ b/recipes/images/files/library/tegra/update.sh
@@ -2,6 +2,9 @@
# Prepare files needed for flashing an Apalis/Colibri T20/T30 module and
# copy them to a convenient location for using from a running U-Boot
+# exit on error
+set -e
+
# sometimes we need the binary echo, not the shell builtin
ECHO=`which echo`
#some distros have fs tools only in root's path
@@ -223,6 +226,10 @@ if [ ! -d "$OUT_DIR" ] ; then
exit 1
fi
+#sanity check for awk programs
+AWKTEST=`echo 100000000 | awk -v min=100 -v f=10000 '{rootfs_size=$1+f*512;rootfs_size=int(rootfs_size/1024/985); print (rootfs_size+min) }'` || true
+[ "${AWKTEST}x" = "204x" ] || { echo >&2 "Program awk not available. Aborting."; exit 1; }
+
#sanity check for correct untared rootfs
DEV_OWNER=`ls -ld rootfs/dev | awk '{print $3}'`
if [ "${DEV_OWNER}x" != "rootx" ]
@@ -244,10 +251,9 @@ sudo ${PARTED} -v >/dev/null 2>&1 || { echo >&2 "Program parted not available.
[ "${MKFSVFAT}x" != "x" ] || { echo >&2 "Program mkfs.vfat not available. Aborting."; exit 1; }
MKFSEXT3=`sudo which mkfs.ext3`
[ "${MKFSEXT3}x" != "x" ] || { echo >&2 "Program mkfs.ext3 not available. Aborting."; exit 1; }
-awk -V >/dev/null 2>&1 || { echo >&2 "Program awk not available. Aborting."; exit 1; }
dd --help >/dev/null 2>&1 || { echo >&2 "Program dd not available. Aborting."; exit 1; }
-tegra-uboot-flasher/cbootimage -h >/dev/null 2>&1
-[ "$?" -lt 2 ] || { echo >&2 "Program cbootimage not available. 32bit compatibility libs? Aborting."; exit 1; }
+CBOOT_CNT=`tegra-uboot-flasher/cbootimage -h | grep -c outputimage`
+[ "$CBOOT_CNT" -gt 0 ] || { echo >&2 "Program cbootimage not available. 32bit compatibility libs? Aborting."; exit 1; }
if [ "${MODTYPE}" = "colibri-t20" ] ; then
#sanity check, can we execute mkfs.ubifs, e.g. see the help text?
@@ -266,8 +272,8 @@ fi
sudo chown $USER: ${BINARIES}
#make a file with the used versions for U-Boot, kernel and rootfs
-sudo touch ${BINARIES}/versions.txt
-sudo chmod ugo+w ${BINARIES}/versions.txt
+rm -f ${BINARIES}/versions.txt
+touch ${BINARIES}/versions.txt
echo "Component Versions" > ${BINARIES}/versions.txt
basename "`readlink -e ${BINARIES}/${U_BOOT_BINARY}`" >> ${BINARIES}/versions.txt
if [ "${MODTYPE}" = "colibri-t20" ] ; then
@@ -386,6 +392,7 @@ else
fi
#copy to $OUT_DIR
+OUT_DIR=`readlink -f $OUT_DIR`
cd ${BINARIES}
sudo cp ${CBOOT_IMAGE} ${KERNEL_IMAGETYPE} ${EMMC_PARTS} ${IMAGEFILE}* flash*.img versions.txt "$OUT_DIR"
cd ..