4 # Variables that should be manually adjusted for new versions
7 # kernels we are sure we want to update
9 3112d1782a90c2c87ae17a152a35deae \
10 b00a5d617f11366689488395b19411de \
11 aed218fe59ff93618bddd2b52b020014 \
12 53ca541a471f726eb1103f19d4306e61 \
13 b66eb9ddee6ae95b682e20a1ac429413 \
14 c53a33cae520f3c4dc5f558d35602225 \
15 467643e4b4f7b17dd7366ddb5395857b \
16 262ca590cb2153328d90800e0d88247d \
17 6020b4ff1d1fa3900c765caaa6a1bb48 \
18 4500538eca6650ff254195e6be86de02 \
19 2d7c0ce238d6f1714ed7eb0312eb10f2 \
21 newkern=2abf194bcbe2fca56ef48286d7c7145c
22 currkern=$(md5sum /boot/uImage | cut -d" " -f1)
24 # u-boot versions we want to update
26 U-Boot_2010.03_(May_19_2010_-_18:30:30) \
27 U-Boot_2010.03-dirty_(Jun_27_2010_-_18:24:31) \
28 U-Boot_2010.03_(Jun_18_2010_-_20:43:36) \
31 # Please list the name of the current kernel image used by okpg here. It is
32 # basically the output of this command:
33 # sudo opkg list-installed | grep kernel-image
34 # If this exact name is matched, the upgrade of the kernel package as well
35 # as the kernel modules will be skipped, saving about 50% of the runtime of
37 OPKG_KERNEL_NAME="kernel-image-2.6.27.46-omap1 - 2.6.27-pandora+r24+git4bc490f3aa30d331d624faf2816851211a05f0b7.2-r24.5"
39 # Forcefully removing packages: this list is basically the collection of
40 # package names that are meant to be removed. This collection is a side
41 # product of the "get-updated-packages.sh" script. Please make also sure to
42 # add noteworthy packages in the variable "MAIN_UPDATER_TEXT" below.
43 $PACKAGES_FOR_REMOVAL="abiword claws-mail gnumeric libgles-omap3-rawdemos libgnt0 libgoffice-0.8-8 libgoffice-0.8-plugin-plot-barcol libgoffice-0.8-plugin-plot-distrib libgoffice-0.8-plugin-plot-pie libgoffice-0.8-plugin-plot-radar libgoffice-0.8-plugin-plot-surface libgoffice-0.8-plugin-plot-xy libgoffice-0.8-plugin-reg-linear libgoffice-0.8-plugin-reg-logfit libgoffice-0.8-plugin-smoothing libgsf-gnome-1-114 libgstfarsight-0.10-0 libnice libpurple libpurple-plugin-ssl libpurple-plugin-ssl-gnutls libpurple-protocol-aim libpurple-protocol-icq libpurple-protocol-irc libpurple-protocol-msn libpurple-protocol-xmpp libpurple-protocol-yahoo pandora-wallpaper-community pidgin pidgin-data"
45 # Some texts used for display in zenity
46 MAIN_UPDATER_TITLE="Update Package 5"
48 This PND updates your Pandora OS. You can safely delete it after it has finished.\n\
49 This pack includes all updates from previous Hotfix Packs as well.\n\n\
50 This Update will REMOVE the following applications:\n\
51 AbiWord, Gnumeric, Pidgin, ClawsMail as well as the community wallpapers.\n\n\
52 Do you want to start the upgrade now? "
53 CUSTOM_KERNEL_INSTALLED_TEXT="\
54 You seem to have custom or newer kernel in flash.\n\n\
56 (if unsure, select Yes)"
57 CUSTOM_UBOOT_INSTALLED_TEXT="\
58 You seem to have custom or newer u-boot in flash.\n\n\
60 (if unsure, select Yes)"
64 # Functions used during the script
69 echo "$@" >> /tmp/updater_err.log
75 echo "$@" >> /tmp/updater.log
80 #function for installing all packages in folder
82 # $1 path for packages
83 # $2 start percentage for zenity (int!)
84 # $3 end percentage for zenity (int!)
85 # $4 step width for zenity ($4 percent point per gui update / opkg run)
86 # $5 message displayed in zenity during the update
87 install_all_ipk_in_folder()
93 ZENITY_UPDATE_MESSAGE=$5
95 # counting for kernel files:
96 NUMBER_PACKAGES=`ls $PACKAGE_PATH/*ipk | wc -l`
98 let DIFF_PERCENTAGE=$END_PERCENTAGE-$START_PERCENTAGE
99 let STEP_NUMBER=$NUMBER_PACKAGES*$STEP_PERCENTAGE/$DIFF_PERCENTAGE
101 # set the start values so that at the first run the zenity bar is already updated.
103 PERCENTAGE=$START_PERCENTAGE
106 # iterate over all packages in the given path
107 for my_package in $PACKAGE_PATH/*ipk
109 # packages have to be installed in "batches" of several packages or
110 # opkg takes 30s per package! because of this gather a list of packages
111 # and install them whenever a treshold is reached!
113 # only run the zenity update as well as opkg when "enough" packages are reached
114 if [ $VAR -eq $STEP_NUMBER ]
116 # opkg will err out if the package list is empty which happens in the first iteration
117 if [ -n "$PACKAGE_LIST" ]
119 # actually install the current block of packages
120 opkg install --nodeps --force-depends --force-overwrite $PACKAGE_LIST >> ./opkg.log
121 # after installing, reset PACKAGE_LIST to empty
126 echo "$ZENITY_UPDATE_MESSAGE"
127 let PERCENTAGE=$PERCENTAGE+$STEP_PERCENTAGE
132 # populate package list by appending the current package
133 PACKAGE_LIST="$PACKAGE_LIST $my_package"
136 # there might still be some packages left to work on, do so now:
137 opkg install --nodeps --force-depends --force-overwrite $PACKAGE_LIST >> ./opkg.log
147 needfree=$(ls -lk uImage | grep uImage | cut -d" " -f5)
148 currfree=$(df /boot | grep boot | awk '{print $4}')
149 if [ $currfree -lt $needfree ];
151 err "There is not enough diskspace on /boot/ to update the kernel.\nKernel couldn't be updated."
152 log "Kernel not updated - not enough diskspace on /boot/"
155 cp uImage /boot/uImage.new
158 currkern=$(md5sum /boot/uImage.new | cut -d" " -f1)
159 if [ "$currkern" = "$newkern" ];
161 mv /boot/uImage /boot/uImage.old
162 mv /boot/uImage.new /boot/uImage
163 currkern=$(md5sum /boot/uImage | cut -d" " -f1)
164 if [ "$currkern" != "$newkern" ];
167 mv /boot/uImage.old /boot/uImage
176 err "There was a checksum error while copying the kernel.\nKernel couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
177 log "Kernel not updated - checksum error"
184 log "Kernel successfully updated"
185 echo "The kernel has been updated. You need to restart your system." > /tmp/updreboot
193 if flash_eraseall /dev/mtd1 && nandwrite -p /dev/mtd1 u-boot.bin;
195 # XXX: perhaps we need to check if write went ok?
196 log "u-boot.bin flashed."
198 log "u-boot.bin flashing failed."
205 # The "real" script itself where the work is done...
209 # cleanup of old log files
213 rm /tmp/updater_err.log
216 if zenity --question --title="$MAIN_UPDATER_TITLE" --text="$MAIN_UPDATER_TEXT" --ok-label="Start now" --cancel-label="Don't do it";
218 # inside the huge ( )-Block the normal update is done
221 # Save list of services
224 cp -r /etc/rc* /tmp/rcsave
225 opkg remove --force-depends pandora-lcd-state >> ./opkg.log
232 echo "# Removing old packages"
233 # Forcefully removing packages: this list is basically the collection of
234 # package names that are meant to be removed. This collection is a side
235 # product of the "get-updated-packages.sh" script. Please make also sure to
236 # add noteworthy packages in the variable "MAIN_UPDATER_TEXT" above.
237 opkg remove --nodeps --force-depends $PACKAGES_FOR_REMOVAL
244 modup=$(opkg list-installed | grep kernel-image)
245 if [ "$modup" != "$OPKG_KERNEL_NAME" ];
247 # call the function for installing ipks
248 # $1 path for packages
249 # $2 start percentage for zenity (int!)
250 # $3 end percentage for zenity (int!)
251 # $4 step width for zenity ($4 percent point per gui update / opkg run)
252 # $5 message displayed in zenity during the update
253 install_all_ipk_in_folder packages/kernel 7 50 6 "# Updating Kernel Modules... this will take a while..."
257 echo "# Updating kernel if needed"
260 for oknl in $oldkern $newkern;
262 if [ "$oknl" = "$currkern" ];
269 if [ "$kernel_known" = "true" -o -z "$currkern" ];
271 if [ "$currkern" != "$newkern" ];
275 log "Kernel already up-to-date"
278 if zenity --question --title="Custom kernel?" --text="$CUSTOM_KERNEL_INSTALLED_TEXT" --ok-label="Yes" --cancel-label="No";
282 log "Kernel update skipped"
293 echo "# U-Boot if needed"
295 if [ -f u-boot.bin ];
297 rm /tmp/u-boot.bin.nand 2> /dev/null
298 nanddump -o -b -q -f /tmp/u-boot.bin.nand /dev/mtd1
299 uboot_nand_ver=`strings /tmp/u-boot.bin.nand | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
300 uboot_ver=`strings u-boot.bin | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
301 uboot_size=`stat -c %s u-boot.bin`
303 dd if=/tmp/u-boot.bin.nand of=/tmp/u-boot.bin.nand.cmp bs=$uboot_size count=1
304 if ! cmp u-boot.bin /tmp/u-boot.bin.nand.cmp
306 uboot_need_to_ask=true
307 for oldver in $oldubootvers;
309 if [ "$oldver" = "$uboot_nand_ver" ];
311 uboot_need_to_ask=false
316 if $uboot_need_to_ask;
318 if zenity --question --title="Custom u-boot?" --text="$CUSTOM_UBOOT_INSTALLED_TEXT" --ok-label="Yes" --cancel-label="No";
322 log "u-boot update skipped\n(nand has $uboot_nand_ver)"
328 log "u-boot already up-to-date\n($uboot_nand_ver)"
334 echo "# Preparing OS update."
341 # call the function for installing ipks
342 # $1 path for packages
343 # $2 start percentage for zenity (int!)
344 # $3 end percentage for zenity (int!)
345 # $4 step width for zenity ($4 percent point per gui update / opkg run)
346 # $5 message displayed in zenity during the update
347 install_all_ipk_in_folder packages/other 60 80 6 "# Updating OS... this will take a while."
349 # Install those packages that come from openpandora.org seperately at the end to make sure that the correct config files are replaced.
351 # call the function for installing ipks
352 # $1 path for packages
353 # $2 start percentage for zenity (int!)
354 # $3 end percentage for zenity (int!)
355 # $4 step width for zenity ($4 percent point per gui update / opkg run)
356 # $5 message displayed in zenity during the update
357 install_all_ipk_in_folder packages/pandora 80 95 6 "# Updating OS... this will take a while."
359 log "Packages updated"
362 echo "# Finalizing update"
365 cp -r /tmp/rcsave/* /etc/
369 if [ -f /etc/rc5.d/S20apmd ];
371 update-rc.d -f xinetd remove
372 update-rc.d -f avahi-daemon remove
373 update-rc.d -f apmd remove
374 update-rc.d -f banner remove
375 update-rc.d -f portmap remove
376 update-rc.d -f blueprobe remove
377 update-rc.d -f pandora-lcd-state remove
378 update-rc.d -f pandora-state start 39 S . stop 31 0 1 6 .
381 chmod 666 /etc/pointercal
382 user=$(cat /tmp/currentuser)
383 cp /etc/skel/.vimrc /home/$user/.vimrc --no-clobber
384 chown $user:$user /home/$user/.vimrc
387 log "Final scripts finished"
390 echo "# Update finished"
393 # Zenity Progress goes here
395 --title="Installing Updates..." \
396 --text="Updating System..." \
399 # check for erros and display the final "I am about to be done" message
400 err=`cat /tmp/updater_err.log`
401 if [ -z "$err" ]; then
402 err="Your system has been updated and will now reboot."
404 update=$(cat /tmp/updater.log)
405 zenity --info --title="Update finished" --text "$err\n\n${update}"
408 #if [ -f /tmp/updreboot ];
410 # reboot=`cat /tmp/updreboot`
411 # zenity --info --title="You need to reboot" --text "${reboot}"