omap3-pandora-kernel2: update
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_osupgrade_work.sh
1 #!/bin/sh
2
3 set -e
4 export HOME=/home/root
5 cd /tmp/
6
7 script_path="/usr/pandora/scripts/op_osupgrade_work.sh"
8 script_pkg="pandora-scripts"
9 script_updated_f="/tmp/upgrade_script_updated"
10
11 echo "Updating package lists..."
12 opkg update
13
14 echo "Checking for updated packages..."; \
15
16 # check if this script was updated. If it was, update and restart it
17 if opkg list-upgradable | grep -q "$script_pkg"; then
18   mtime_pre=`stat -c '%Y' $script_path`
19   opkg install $script_pkg
20   mtime_post=`stat -c '%Y' $script_path`
21   if [ "$mtime_pre" != "$mtime_post" -a ! -e "$script_updated_f" ]; then
22     # just in case..
23     touch "$script_updated_f"
24     echo "Update script was updated, restarting.."
25     exec $script_path
26   fi
27 fi
28
29 # check if opkg was updated.. Maybe we can fix it's breakages someday..
30 for o in `opkg list-upgradable | grep opkg | awk '{print $1}'`; do
31   opkg install $o
32   opkg_updated=1
33 done
34
35 if [ "$opkg_updated" = "1" ]; then
36   opkg update
37 fi
38
39 # finally run the upgrade itself
40 opkg upgrade
41
42 # update .xinitrc
43 xinitrc="/home/$SUDO_USER/.xinitrc"
44 if test -e "$xinitrc" && ! cmp -s /etc/skel/.xinitrc "$xinitrc"; then
45   # ... only from a known old version
46   known="5642b24d5d4570c6779807904506c162 b2cf2d45ef7f3bee9836105008c009a7"
47   md5=`md5sum "$xinitrc" | awk '{print $1}'`
48   for k in $known; do
49     if [ "$md5" = "$k" ]; then
50       cp -av /etc/skel/.xinitrc "$xinitrc"
51       break
52     fi
53   done
54 fi
55
56 # done
57 touch /tmp/upgrade_ok
58 sync
59
60 # do we still need this?
61 echo "Finished, press Ctrl-C to exit"
62
63 exit 0