From: Grazvydas Ignotas Date: Fri, 18 Jun 2010 18:46:41 +0000 (+0300) Subject: hotfix_updater: improve error logging X-Git-Tag: sz_beta3~23 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bf38aedb4cd317bc203d2914a8099ccca46c3d2;p=pandora-misc.git hotfix_updater: improve error logging also fixes some errors not being reported --- diff --git a/hotfix_updater/updater.sh b/hotfix_updater/updater.sh index b1bebbe..2400a3e 100755 --- a/hotfix_updater/updater.sh +++ b/hotfix_updater/updater.sh @@ -21,10 +21,22 @@ oldmmenu1=d15bf3ad29f12fa2325534b8fcd5c1f4 oldmmenu2=fa45e9bc91c48640a9ea592de5fbeb3c currmmenu=$(md5sum /usr/bin/mmenu | cut -d" " -f1) currmmenuconf=$(md5sum /etc/pandora/conf/mmenu.conf | cut -d" " -f1) -err="Your system has been updated without any errors." rm /tmp/updater.log +log() +{ + echo "$@" >> /tmp/updater.log + echo "$@" >&2 +} + +rm /tmp/updater_err.log + +err() +{ + echo "$@" >> /tmp/updater_err.log +} + if zenity --question --title="Update Package 2" --text="\ This PND updates your Pandora OS. You can safely delete it after it has finished.\n\ This pack includes all updates from Hotfix 1 as well.\n\n\ @@ -45,8 +57,8 @@ update_kernel() needfree=$(ls -lk uImage | grep uImage | cut -d" " -f5) currfree=$(df /boot | grep boot | awk '{print $4}') if [ $currfree -lt $needfree ]; then - err="There is not enough diskspace on /boot/ to update the kernel.\n\nKernel couldn't be updated." - echo "Kernel not updated - not enough diskspace on /boot/" >> /tmp/updater.log + err "There is not enough diskspace on /boot/ to update the kernel.\nKernel couldn't be updated." + log "Kernel not updated - not enough diskspace on /boot/" have_error=true else cp uImage /boot/uImage.new @@ -67,14 +79,14 @@ update_kernel() bad_checksum=true fi if $bad_checksum; then - 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." - echo "Kernel not updated - checksum error" >> /tmp/updater.log + 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." + log "Kernel not updated - checksum error" have_error=true fi fi if ! $have_error; then - echo "Kernel successfully updated" >> /tmp/updater.log + log "Kernel successfully updated" fi sync } @@ -91,7 +103,7 @@ if [ "$kernel_known" = "true" -o -z "$currkern" ]; then if [ "$currkern" != "$newkern" ]; then update_kernel else - echo "Kernel already up-to-date" >> /tmp/updater.log + log "Kernel already up-to-date" fi else if zenity --question --title="Custom kernel?" --text="\ @@ -100,7 +112,7 @@ Update it anyway?\n\ (if unsure, select Yes)" --ok-label="Yes" --cancel-label="No" ; then update_kernel else - echo "Kernel update skipped" >> /tmp/updater.log + log "Kernel update skipped" fi fi @@ -114,13 +126,13 @@ update_uboot() { if flash_eraseall /dev/mtd1 && nandwrite -p /dev/mtd1 u-boot.bin; then # XXX: perhaps we need to check if write went ok? - echo "u-boot.bin flashed." >> /tmp/updater.log + log "u-boot.bin flashed." else - echo "u-boot.bin flashing failed." >> /tmp/updater.log + log "u-boot.bin flashing failed." fi } -rm /tmp/u-boot.bin.nand 2> /deb/null +rm /tmp/u-boot.bin.nand 2> /dev/null nanddump -o -b -q -f /tmp/u-boot.bin.nand /dev/mtd1 uboot_nand_ver=`strings /tmp/u-boot.bin.nand | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'` uboot_ver=`strings u-boot.bin | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'` @@ -144,13 +156,13 @@ Update it anyway?\n\ (if unsure, select Yes)" --ok-label="Yes" --cancel-label="No" ; then update_uboot else - echo "u-boot update skipped\n(nand has $uboot_nand_ver)" >> /tmp/updater.log + log "u-boot update skipped\n(nand has $uboot_nand_ver)" fi else update_uboot fi else - echo "u-boot already up-to-date\n($uboot_nand_ver)" >> /tmp/updater.log + log "u-boot already up-to-date\n($uboot_nand_ver)" fi @@ -161,10 +173,10 @@ fi echo "20" echo "# Installing missing Python libraries" if [ "`opkg list-installed | grep python-shell`" ]; then - echo "Python libraries were already installed." >> /tmp/updater.log + log "Python libraries were already installed." else 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 - echo "Python libraries installed" >> /tmp/updater.log + log "Python libraries installed" sync fi @@ -191,19 +203,19 @@ if [ $oldmmenu1 = $currmmenu -o $oldmmenu2 = $currmmenu ]; then rm /etc/pandora/conf/mmenu.conf mv /etc/pandora/conf/mmenu.conf.old /etc/pandora/conf/mmenu.conf mv /usr/bin/mmenu.old /usr/bin/mmenu - 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." - echo "MiniMenu not updated - checksum error" >> /tmp/updater.log + 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." + log "MiniMenu not updated - checksum error" fi else rm /usr/bin/mmenu.new rm /etc/pandora/conf/mmenu.conf.new - 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." - echo "MiniMenu not updated - checksum error" >> /tmp/updater.log + 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." + log "MiniMenu not updated - checksum error" fi - echo "MiniMenu successfully updated" >> /tmp/updater.log + log "MiniMenu successfully updated" sync else - echo "MiniMenu already up-to-date" >> /tmp/updater.log + log "MiniMenu already up-to-date" fi @@ -212,20 +224,20 @@ if [ $oldmmenu1 = $currmmenu -o $oldmmenu2 = $currmmenu ]; then echo "40" echo "# Installing Boost Library" if [ "`opkg list-installed | grep boost-system`" ]; then - echo "Boost library was already installed" >> /tmp/updater.log + log "Boost library was already installed" else 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 - echo "Boost library installed" >> /tmp/updater.log + log "Boost library installed" sync fi echo "60" echo "# Installing Lua5.1" if [ "`opkg list-installed | grep lua5.1`" ]; then - echo "Lua5.1 was already installed" >> /tmp/updater.log + log "Lua5.1 was already installed" else opkg install 2/lua5.1_5.1.4-r5.5_armv7a.ipk - echo "Lua5.1 installed" >> /tmp/updater.log + log "Lua5.1 installed" sync fi @@ -269,23 +281,23 @@ echo "# Installing updated scripts" cp 2/thunar.pnd /usr/pandora/mmenu/ cp 2/xchat.pnd /usr/pandora/mmenu/ - echo "The scripts have been updated" >> /tmp/updater.log + log "The scripts have been updated" sync echo "80" echo "# Fixing Touchscreen-Permissions" chmod 666 /etc/pointercal - echo "Permissions updated" >> /tmp/updater.log + log "Permissions updated" #else - # echo "The scripts were up-to-date" >> /tmp/updater.log + # log "The scripts were up-to-date" #fi echo "90" echo "# Installing Evince" if [ "`opkg list-installed | grep evince`" ]; then - echo "Evince was already installed" >> /tmp/updater.log + log "Evince was already installed" else opkg install 2/libpoppler-glib4_0.12.3-r0.5_armv7a.ipk 2/libpoppler5_0.12.3-r0.5_armv7a.ipk 2/espgs_8.15.3-r1.5_armv7a.ipk 2/poppler-data_0.4.0-r1.5_all.ipk 2/poppler_0.12.3-r0.5_armv7a.ipk 2/libcupsimage_1.4.3-r2.5_armv7a.ipk 2/evince_2.30.0-r0.5_armv7a.ipk - echo "Evince installed" >> /tmp/updater.log + log "Evince installed" sync fi @@ -298,6 +310,11 @@ echo "# Update finished" --title="Installing Updates..." \ --text="Updating System..." \ --percentage=0 + +err=`cat /tmp/updater_err.log` +if [ -z "$err" ]; then + err="Your system has been updated without any errors." +fi update=$(cat /tmp/updater.log) zenity --info --title="Update finished" --text "$err\n\n${update}"