Hotfix 2: Continued to work on it :)
[openpandora.oe.git] / recipes / hotfix / updater1.sh
1 #### THIS SCRIPT IS NOT FINISHED YET! ####
2
3 #!/bin/bash
4 newkern=b00a5d617f11366689488395b19411de
5 oldkern=3112d1782a90c2c87ae17a152a35deae
6 currkern=$(md5sum /boot/uImage | cut -d" " -f1)
7 needfree=$(ls -lk uImage | grep uImage | cut -d" " -f5)
8 oldinterfaces=23f72750f2f7335b9c2ed3f55aaa5061
9 oldrcwl1251=7a6361e842f0f589418218436affbe07
10 newmmenu=af66a5118a9bfef8eca5de13ee64c6a1
11 oldmmenu1=
12 oldmmenu2=fa45e9bc91c48640a9ea592de5fbeb3c
13 oldmmenuconf1=
14 oldmmenuconf2=c90d33c362121ddd0e24e9eac0b82da9
15 newmmenuconf=d3b237cf95ff6c6e81b23483e87391e1
16 currmmenu=$(md5sum /usr/bin/mmenu | cut -d" " -f1)
17 currmmenuconf=$(md5sum /etc/pandora/conf/mmenu.conf | cut -d" " -f1)
18 err="Your system has been updated without any errors."
19
20 rm /tmp/updater.log
21 rm /tmp/updatedetail.log
22
23 if zenity --question --title="Update Package 2" --text="This PND updates your Pandora OS. You can safely delete it after it has finished.\nThis pack includes all updates from Hotfix 1 as well.\n\nDo you want to start the upgrade now? " --ok-label="Start now" --cancel-label="Don't do it" ; then
24
25 (
26 echo "10"
27 echo "# Updating kernel if needed"
28
29 # HotFix 1
30 # Kernel Update
31
32   if [ $oldkern = $currkern ]; then   
33      rm /boot/uImage.old >> /tmp/updatedetail.log
34      currfree=$(df /boot | grep boot | awk '{print $4}')
35      if [ $currfree -lt $needfree ]; then
36         err="There is not enough diskspace on /boot/ to update the kernel.\n\nKernel couldn't be updated."
37         echo "Kernel not updated - not enough diskspace on /boot/" >> /tmp/updater.log
38       else
39         cp 1/uImage /boot/uImage.new >> /tmp/updatedetail.log
40         sync
41         currkern=$(md5sum /boot/uImage.new | cut -d" " -f1)
42           if [ $currkern = $newkern ]; then
43             mv /boot/uImage /boot/uImage.old >> /tmp/updatedetail.log
44             mv /boot/uImage.new /boot/uImage >> /tmp/updatedetail.log
45             currkern=$(md5sum /boot/uImage | cut -d" " -f1)
46             if [ $currkern != $newkern ]; then
47                rm /boot/uImage >> /tmp/updatedetail.log
48                mv /boot/uImage.old /boot/uImage >> /tmp/updatedetail.log
49                err="There was a checksum error while copying the kernel.\n\nKernel couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
50                echo "Kernel not updated - checksum error" >> /tmp/updater.log
51             fi
52           else
53             rm /boot/uImage.new >> /tmp/updatedetail.log
54             err="There was a checksum error while copying the kernel.\n\nKernel couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
55             echo "Kernel not updated - checksum error" >> /tmp/updater.log
56           fi
57      fi
58   fi
59   echo "Kernel successfully updated" >> /tmp/updater.log
60   sync
61
62 # Libraries for HotFix 1
63   
64 echo "20"
65 echo "# Installing missing Python libraries"
66 if [ "`opkg list-installed | grep python-shell`" ]; then
67    echo "Python libraries were already installed." >> /tmp/updater.log
68 else 
69   opkg install 1/gnome-vfs-plugin-ftp_2.24.1-r2.5_armv7a.ipk 1/gnome-vfs-plugin-http_2.24.1-r2.5_armv7a.ipk 1/python-pycairo_1.4.0-ml3.5_armv7a.ipk 1/python-pygtk_2.16.0-r1.5_armv7a.ipk 1/python-shell_2.6.4-ml9.1.5_armv7a.ipk >> /tmp/updatedetail.log
70   echo "Python libraries installed" >> /tmp/updater.log
71   sync
72 fi
73
74 # HotFix 2
75 # MiniMenu Update
76
77 echo "30"
78 echo "# Installing updated MiniMenu"
79  if [ $oldmmenu1 = $currmmenu -o $oldmmenu2 = $currmenu]; then   
80      rm /usr/bin/mmenu.old >> /tmp/updatedetail.log
81      cp 2/mmenu /usr/bin/mmenu.new >> /tmp/updatedetail.log
82      cp 2/mmenu.conf /etc/pandora/conf/mmenu.conf.new >> /tmp/updatedetail.log
83         sync
84         currmmenu=$(md5sum /usr/bin/mmenu.new | cut -d" " -f1)
85           if [ $currmmenu = $newmmenu ]; then
86             mv /usr/bin/mmenu /usr/bin/mmenu.old >> /tmp/updatedetail.log
87             mv /etc/pandora/conf/mmenu.conf /etc/pandora/conf/mmenu.conf.old >> /tmp/updatedetail.log
88             mv /usr/bin/mmenu.new /usr/bin/mmenu >> /tmp/updatedetail.log
89             mv /etc/pandora/conf/mmenu.conf.new /etc/pandora/conf/mmenu.conf >> /tmp/updatedetail.log
90             currmmenu=$(md5sum /boot/uImage | cut -d" " -f1)
91             if [ $currmmenu != $newmmenu ]; then
92                rm /usr/bin/mmenu >> /tmp/updatedetail.log
93                rm /etc/pandora/conf/mmenu.conf >> /tmp/updatedetail.log
94                mv /etc/pandora/conf/mmenu.conf.old /etc/pandora/conf/mmenu.conf >> /tmp/updatedetail.log
95                mv /usr/bin/mmenu.old /usr/bin/mmenu >> /tmp/updatedetail.log
96                err="There was a checksum error while copying MiniMenu.\n\nMiniMenu couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
97                echo "MiniMenu not updated - checksum error" >> /tmp/updater.log
98             fi
99           else
100             rm /usr/bin/mmenu.new >> /tmp/updatedetail.log
101             rm /etc/pandora/conf/mmenu.conf.new >> /tmp/updatedetail.log
102             err="There was a checksum error while copying MiniMenu.\n\nMiniMenu couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
103             echo "MiniMenu not updated - checksum error" >> /tmp/updater.log
104           fi
105      fi
106   fi
107   echo "MiniMenu successfully updated" >> /tmp/updater.log
108   sync
109
110 # Libraries for HotFix 2
111
112 echo "40"
113 echo "# Installing Boost Library"
114 if [ "`opkg list-installed | grep boost-system`" ]; then
115   echo "Boost library was already installed" >> /tmp/updater.log
116 else  
117   opkg install 2/boost_1.41.0-r8.1.5_armv7a.ipk 2/boost-filesystem_1.41.0-r8.1.5_armv7a.ipk 2/boost-graph_1.41.0-r8.1.5_armv7a.ipk 2/boost-iostreams_1.41.0-r8.1.5_armv7a.ipk 2/boost-program-options_1.41.0-r8.1.5_armv7a.ipk 2/boost-python_1.41.0-r8.1.5_armv7a.ipk 2/boost-regex_1.41.0-r8.1.5_armv7a.ipk 2/boost-serialization_1.41.0-r8.1.5_armv7a.ipk 2/boost-signals_1.41.0-r8.1.5_armv7a.ipk 2/boost-system_1.41.0-r8.1.5_armv7a.ipk 2/boost-test_1.41.0-r8.1.5_armv7a.ipk >> /tmp/updatedetail.log
118   echo "Boost library installed" >> /tmp/updater.log
119   sync
120 fi
121
122 # Bugfixes in Scripts
123
124 echo "50"
125 echo "# Installing updated scripts"
126 if [ ! -f /usr/bin/stopmmenu ]; then
127   cp 2/op_bluetooth.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
128   cp 2/op_calibrate.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
129   cp 2/op_datetime.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
130   cp 2/op_lcdsettings.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
131   cp 2/op_nubmode.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
132   cp 2/op_startupmanager.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
133   cp 2/op_switchgui.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
134   cp 2/op_usermanager.sh /usr/pandora/scripts/ >> /tmp/updatedetail.log
135   cp 2/gui.conf /etc/pandora/conf/ >> /tmp/updatedetail.log
136   cp 2/op_bluetooth.desktop /usr/share/applications/ >> /tmp/updatedetail.log   
137   cp 2/rc.wl1251 /etc/init.d/wl1251-init >> /tmp/updatedetail.log
138   cp 2/interfaces /etc/network/ >> /tmp/updatedetail.log
139   cp 2/stopmmenu /usr/bin/stopmmenu >> /tmp/updatedetail.log
140   echo "The scripts have been updated" >> /tmp/updater.log
141   sync
142 else
143   echo "The scripts were up-to-date" >> /tmp/updater.log
144 fi
145
146
147 # Zenity Progress goes here
148 fi
149
150
151
152
153
154
155