From c2dba7385b9f0052e47a856d6c32f0a34465a554 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Tue, 18 Nov 2014 01:45:19 +0200 Subject: [PATCH] pandora-scripts: improve op_osupgrade --- recipes/pandora-system/pandora-scripts.bb | 6 ++- .../pandora-scripts/op_osupgrade.sh | 17 ++----- .../pandora-scripts/op_osupgrade_work.sh | 49 +++++++++++++++++++ 3 files changed, 57 insertions(+), 15 deletions(-) mode change 100644 => 100755 recipes/pandora-system/pandora-scripts/op_osupgrade.sh create mode 100755 recipes/pandora-system/pandora-scripts/op_osupgrade_work.sh diff --git a/recipes/pandora-system/pandora-scripts.bb b/recipes/pandora-system/pandora-scripts.bb index 9732249..eccd198 100644 --- a/recipes/pandora-system/pandora-scripts.bb +++ b/recipes/pandora-system/pandora-scripts.bb @@ -5,7 +5,7 @@ COMPATIBLE_MACHINE = "omap3-pandora" RDEPENDS = "bash sed gawk grep zenity" -PR = "r163" +PR = "r164" SRC_URI = " \ file://op_bright.sh \ @@ -16,6 +16,7 @@ SRC_URI = " \ file://op_usbhost.sh \ file://op_usbhost.pnd \ file://op_osupgrade.sh \ + file://op_osupgrade_work.sh \ file://op_osupgrade.pnd \ file://op_sysspeed.sh \ file://op_createsd.sh \ @@ -96,7 +97,8 @@ do_install() { install -d ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_common.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_getpndmg.sh ${D}${prefix}/pandora/scripts/ - install -m 0755 ${WORKDIR}/op_osupgrade.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_osupgrade.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_osupgrade_work.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_bright.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_cpuspeed.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_dspspeed.sh ${D}${prefix}/pandora/scripts/ diff --git a/recipes/pandora-system/pandora-scripts/op_osupgrade.sh b/recipes/pandora-system/pandora-scripts/op_osupgrade.sh old mode 100644 new mode 100755 index 9968fe9..973518a --- a/recipes/pandora-system/pandora-scripts/op_osupgrade.sh +++ b/recipes/pandora-system/pandora-scripts/op_osupgrade.sh @@ -1,4 +1,5 @@ #!/bin/sh +work_script_path="/usr/pandora/scripts/op_osupgrade_work.sh" kernel_path="/boot/uImage-3" zenity --question --title="Update Firmware OS" --text="This little tool helps you to keep your firmware OS up-to-date with the latest tweaks.\n\nPlease note that this is in TESTING state and\nmight break parts of your system with unstable packages!\n\nMake sure your Pandora is connected to the internet and click the Upgrade-Button.\n\n" --ok-label="Upgrade OS" --cancel-label="Quit" || exit 0 @@ -22,24 +23,14 @@ Aborting." exit 1 fi -rm -f /tmp/upgrade_ok +rm -f /tmp/upgrade_ok /tmp/upgrade_script_updated kernelmd5_old=`md5sum $kernel_path` # reminder: don't use '&&' '||' ... after tee, it breaks set -e, no idea why terminal -x bash -c \ - '( set -e; \ - cd /tmp/; \ - echo "Updating package lists..."; \ - opkg update 2>&1; \ - echo "Checking for updated packages..."; \ - opkg upgrade 2>&1; \ - touch /tmp/upgrade_ok; \ - sync; \ - echo "Finished, press Ctrl-C to exit" ) \ + "( $work_script_path || ( echo && echo "Retrying.." && $work_script_path ) ) 2>&1 \ | tee /tmp/upgrade.log; \ - test -e /tmp/upgrade_ok || sleep 3' - -sync + test -e /tmp/upgrade_ok || sleep 3" kernelmd5_new=`md5sum $kernel_path` diff --git a/recipes/pandora-system/pandora-scripts/op_osupgrade_work.sh b/recipes/pandora-system/pandora-scripts/op_osupgrade_work.sh new file mode 100755 index 0000000..2f4241e --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_osupgrade_work.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +set -e +export HOME=/home/root +cd /tmp/ + +script_path="/usr/pandora/scripts/op_osupgrade_work.sh" +script_pkg="pandora-scripts" +script_updated_f="/tmp/upgrade_script_updated" + +echo "Updating package lists..." +opkg update + +echo "Checking for updated packages..."; \ + +# check if this script was updated. If it was, update and restart it +if opkg list-upgradable | grep -q "$script_pkg"; then + mtime_pre=`stat -c '%Y' $script_path` + opkg install $script_pkg + mtime_post=`stat -c '%Y' $script_path` + if [ "$mtime_pre" != "$mtime_post" -a ! -e "$script_updated_f" ]; then + # just in case.. + touch "$script_updated_f" + echo "Update script was updated, restarting.." + exec $script_path + fi +fi + +# check if opkg was updated.. Maybe we can fix it's breakages someday.. +for o in `opkg list-upgradable | grep opkg | awk '{print $1}'`; do + opkg install $o + opkg_updated=1 +done + +if [ "$opkg_updated" = "1" ]; then + opkg update +fi + +# finally run the upgrade itself +opkg upgrade + +# done +touch /tmp/upgrade_ok +sync + +# do we still need this? +echo "Finished, press Ctrl-C to exit" + +exit 0 -- 2.39.5