op_osupgrade: add some sanity checks
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_osupgrade.sh
1 #!/bin/sh
2 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
3
4 # check free space
5 root_free=`df | grep '/$' | sed -e '2~1d' | awk '{print $4}'`
6 if [ "$root_free" -lt 20000 ]; then
7   zenity --error --text "There is not enough free space left in root partition
8 (at least 20MB is required).
9 This usually means your NAND is almost full.
10
11 Delete some files and try again. Alternatively you can do a full reflash."
12   exit 1
13 fi
14
15 # check for default angstrom feeds
16 if cat /etc/opkg/*.conf | awk -F# '{printf $1}' | grep -q www.angstrom-distribution.org; then
17   zenity --error --text "There seem to be Angstrom feeds in your opkg configs, \
18 upgraging from them is known to make the system unbootable.
19 Aborting."
20   exit 1
21 fi
22
23 terminal -x bash -c \
24   'echo "Updating package lists..." && \
25    opkg update 2>&1 | tee /tmp/upgrade.log && test ${PIPESTATUS[0]} -eq 0 && \
26    echo "Checking for updated packages..." && \
27    opkg upgrade 2>&1 | tee -a /tmp/upgrade.log && test ${PIPESTATUS[0]} -eq 0 && \
28    touch /tmp/upgrade_ok || sleep 3'
29
30 if test -e /tmp/upgrade_ok; then
31   zenity --info --title="Upgrade complete" \
32     --text "All operations have been finished.\n\nYou can find a logfile at /tmp/upgrade.log"
33 else
34   zenity --error --title="Errors detected" \
35     --text "Errors detected during update.\n\nYou can find a logfile at /tmp/upgrade.log"
36 fi
37 rm -f /tmp/upgrade_ok