--- /dev/null
+#!/bin/bash
+#
+# Script to gather the ipks that were changed in a new firmware compared to an
+# older firmware. Update the variables at the top to match your files and then
+# just run the script. It should generate 4 output txt files as well as fetch
+# the ipks that are to be installed.
+
+
+WORKING_DIR=`pwd`
+
+# where shall the packages end?
+PACKAGES_FOLDER=$WORKING_DIR/hotfix/packages
+
+# old and new list of packages seperated by newlines
+OLD_PACKAGES=$WORKING_DIR/installed-packages_fw1.txt
+NEW_PACKAGES=$WORKING_DIR/installed-packages_hf5r.txt
+
+# names of the output files
+TO_BE_REMOVED=$WORKING_DIR/to_be_removed.txt
+TO_BE_ADDED=$WORKING_DIR/to_be_added.txt
+REALLY_REMOVED=$WORKING_DIR/really_removed.txt
+REALLY_ADDED=$WORKING_DIR/really_added.txt
+
+
+
+# some temp files
+TMP1=$WORKING_DIR/tmp1.txt
+TMP2=$WORKING_DIR/tmp2.txt
+
+
+#
+# gather list of new and removed packages based on the input files
+#
+
+if [ ! -f $OLD_PACKAGES ]
+then
+ echo "could not find the new package list at $OLD_PACKAGES; aborting"
+ exit 1;
+fi
+if [ ! -f $NEW_PACKAGES ]
+then
+ echo "could not find the new package list at $NEW_PACKAGES; aborting"
+ exit 1;
+fi
+
+# list of removed packages since "OLD_PACKAGES" (means also packages that were replaced in a new version!)
+diff $OLD_PACKAGES $NEW_PACKAGES | grep "<" | cut -f 2 -d " " | sort > $TO_BE_REMOVED
+
+# list of added packages in "NEW_PACKAGES" compared to "OLD_PACKAGES" (also updated versions!)
+diff $OLD_PACKAGES $NEW_PACKAGES | grep ">" | cut -f 2 -d " " | sort > $TO_BE_ADDED
+
+cat $TO_BE_REMOVED | cut -f 1 -d "_" | sort > $TMP1
+cat $TO_BE_ADDED | cut -f 1 -d "_" | sort > $TMP2
+
+diff $TMP1 $TMP2 | grep "<" | cut -f 2 -d " " | sort > $REALLY_REMOVED
+diff $TMP1 $TMP2 | grep ">" | cut -f 2 -d " " | sort > $REALLY_ADDED
+
+#cleanup temp files from "gathering package list"
+rm -f $TMP1 $TMP2
+
+
+#
+# find out filenames for "new" packages and download the files
+#
+
+# remove existing old stamp files
+rm -f $WORKING_DIR/Packages.stamps.all $WORKING_DIR/Packages.stamps.armv7a $WORKING_DIR/Packages.stamps.omap3-pandora
+
+# get recent stamp files from the feed
+wget --output-document=$WORKING_DIR/Packages.stamps.all http://www.openpandora.org/feeds/unstable/all/Packages.stamps
+wget --output-document=$WORKING_DIR/Packages.stamps.armv7a http://www.openpandora.org/feeds/unstable/armv7a/Packages.stamps
+wget --output-document=$WORKING_DIR/Packages.stamps.omap3-pandora http://www.openpandora.org/feeds/unstable/omap3-pandora/Packages.stamps
+
+# convert package entries in stamp files into the correct "full" urls
+cat $WORKING_DIR/Packages.stamps.all | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/all/;g' > $TMP1
+cat $WORKING_DIR/Packages.stamps.armv7a | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/armv7a/;g' >> $TMP1
+cat $WORKING_DIR/Packages.stamps.omap3-pandora | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/omap3-pandora/;g' >> $TMP1
+
+# cleanup temp files
+rm -f $WORKING_DIR/Packages.stamps.all $WORKING_DIR/Packages.stamps.armv7a $WORKING_DIR/Packages.stamps.omap3-pandora
+
+# get the list of the relevant (aka 'new) package URLs
+for i in `cat $TO_BE_ADDED`;
+do
+ grep "$i" $TMP1 >> $TMP2;
+done
+
+# seperate into 'kernel' and 'other' (every packagename that starts with 'kernel' is only relevant for the kernel space
+cat $TMP2 | grep "\/kernel" > $TMP2.kernel
+cat $TMP2 | grep -v "\/kernel" > $TMP2.other
+
+
+#create folders for the new packages
+if [ ! -d $PACKAGES_FOLDER/kernel ]
+then
+ mkdir -p $PACKAGES_FOLDER/kernel
+fi
+if [ ! -d $PACKAGES_FOLDER/other ]
+then
+ mkdir -p $PACKAGES_FOLDER/other
+fi
+
+# download kernel ipks
+cd $PACKAGES_FOLDER/kernel
+wget --no-clobber -i $TMP2.kernel
+
+# download other ipks
+cd $PACKAGES_FOLDER/other
+wget --no-clobber -i $TMP2.other
+
+# cleanup all the remaining temp files
+rm -f $TMP1 $TMP2 $TMP2.kernel $TMP2.other
+
+
+#
+# explain the results in some nice words
+#
+
+echo -e
+echo -e
+echo -e
+echo "Explaination of created folders and files"
+echo -e
+echo "Created text files:"
+echo " $TO_BE_REMOVED: files that are no longer included (at least not as this exact package version)"
+echo " $TO_BE_ADDED: files that are to be installed (complete package name incl version number"
+echo " $REALLY_REMOVED: package names of those packages that are no longer installed (and should be removed using opkg!)"
+echo " $REALLY_ADDED: package names of packages that were added since the old version"
+echo -e
+echo "Saved all ("`ls $PACKAGES_FOLDER/kernel/*ipk | wc -l`") kernel related ipks to:"
+echo " $PACKAGES_FOLDER/kernel"
+echo "Saved all ("`ls $PACKAGES_FOLDER/other/*ipk | wc -l`") 'other' ipks to:"
+echo " $PACKAGES_FOLDER/other"
+echo -e
+echo "You can now copy the folder $PACKAGES_FOLDER into the place where you create the pnd file."
--- /dev/null
+#!/bin/bash
+
+#
+# Variables that should be manually adjusted for new versions
+#
+
+# kernels we are sure we want to update
+oldkern="\
+3112d1782a90c2c87ae17a152a35deae \
+b00a5d617f11366689488395b19411de \
+aed218fe59ff93618bddd2b52b020014 \
+53ca541a471f726eb1103f19d4306e61 \
+b66eb9ddee6ae95b682e20a1ac429413 \
+c53a33cae520f3c4dc5f558d35602225 \
+467643e4b4f7b17dd7366ddb5395857b \
+262ca590cb2153328d90800e0d88247d \
+6020b4ff1d1fa3900c765caaa6a1bb48 \
+4500538eca6650ff254195e6be86de02 \
+2d7c0ce238d6f1714ed7eb0312eb10f2 \
+"
+newkern=2abf194bcbe2fca56ef48286d7c7145c
+currkern=$(md5sum /boot/uImage | cut -d" " -f1)
+
+# u-boot versions we want to update
+oldubootvers="\
+U-Boot_2010.03_(May_19_2010_-_18:30:30) \
+U-Boot_2010.03-dirty_(Jun_27_2010_-_18:24:31) \
+U-Boot_2010.03_(Jun_18_2010_-_20:43:36) \
+"
+
+# Please list the name of the current kernel image used by okpg here. It is
+# basically the output of this command:
+# sudo opkg list-installed | grep kernel-image
+# If this exact name is matched, the upgrade of the kernel package as well
+# as the kernel modules will be skipped, saving about 50% of the runtime of
+# this installer!
+OPKG_KERNEL_NAME="kernel-image-2.6.27.46-omap1 - 2.6.27-pandora+r24+git4bc490f3aa30d331d624faf2816851211a05f0b7.2-r24.5"
+
+# Forcefully removing packages: this list is basically the collection of
+# package names that are meant to be removed. This collection is a side
+# product of the "get-updated-packages.sh" script. Please make also sure to
+# add noteworthy packages in the variable "MAIN_UPDATER_TEXT" below.
+$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"
+
+# Some texts used for display in zenity
+MAIN_UPDATER_TITLE="Update Package 5"
+MAIN_UPDATER_TEXT="\
+This PND updates your Pandora OS. You can safely delete it after it has finished.\n\
+This pack includes all updates from previous Hotfix Packs as well.\n\n\
+This Update will REMOVE the following applications:\n\
+AbiWord, Gnumeric, Pidgin, ClawsMail as well as the community wallpapers.\n\n\
+Do you want to start the upgrade now? "
+CUSTOM_KERNEL_INSTALLED_TEXT="\
+You seem to have custom or newer kernel in flash.\n\n\
+Update it anyway?\n\
+(if unsure, select Yes)"
+CUSTOM_UBOOT_INSTALLED_TEXT="\
+You seem to have custom or newer u-boot in flash.\n\n\
+Update it anyway?\n\
+(if unsure, select Yes)"
+
+
+#
+# Functions used during the script
+#
+
+err()
+{
+ echo "$@" >> /tmp/updater_err.log
+}
+
+
+log()
+{
+ echo "$@" >> /tmp/updater.log
+ echo "$@" >&2
+}
+
+
+#function for installing all packages in folder
+# parameters:
+# $1 path for packages
+# $2 start percentage for zenity (int!)
+# $3 end percentage for zenity (int!)
+# $4 step width for zenity ($4 percent point per gui update / opkg run)
+# $5 message displayed in zenity during the update
+install_all_ipk_in_folder()
+{
+ PACKAGE_PATH=$1
+ START_PERCENTAGE=$2
+ END_PERCENTAGE=$3
+ STEP_PERCENTAGE=$4
+ ZENITY_UPDATE_MESSAGE=$5
+
+ # counting for kernel files:
+ NUMBER_PACKAGES=`ls $PACKAGE_PATH/*ipk | wc -l`
+
+ let DIFF_PERCENTAGE=$END_PERCENTAGE-$START_PERCENTAGE
+ let STEP_NUMBER=$NUMBER_PACKAGES*$STEP_PERCENTAGE/$DIFF_PERCENTAGE
+
+ # set the start values so that at the first run the zenity bar is already updated.
+ VAR=$STEP_NUMBER
+ PERCENTAGE=$START_PERCENTAGE
+
+ PACKAGE_LIST=""
+ # iterate over all packages in the given path
+ for my_package in $PACKAGE_PATH/*ipk
+ do
+ # packages have to be installed in "batches" of several packages or
+ # opkg takes 30s per package! because of this gather a list of packages
+ # and install them whenever a treshold is reached!
+
+ # only run the zenity update as well as opkg when "enough" packages are reached
+ if [ $VAR -eq $STEP_NUMBER ]
+ then
+ # opkg will err out if the package list is empty which happens in the first iteration
+ if [ -n "$PACKAGE_LIST" ]
+ then
+ # actually install the current block of packages
+ opkg install --nodeps --force-depends $PACKAGE_LIST >> ./opkg.log
+ # after installing, reset PACKAGE_LIST to empty
+ PACKAGE_LIST=""
+ fi
+
+ echo "$PERCENTAGE"
+ echo "$ZENITY_UPDATE_MESSAGE"
+ let PERCENTAGE=$PERCENTAGE+$STEP_PERCENTAGE
+ VAR=0
+ fi
+ let VAR=VAR+1
+
+ # populate package list by appending the current package
+ PACKAGE_LIST="$PACKAGE_LIST $my_package"
+ done
+
+ # there might still be some packages left to work on, do so now:
+ opkg install --nodeps --force-depends $PACKAGE_LIST >> ./opkg.log
+}
+
+
+update_kernel()
+{
+ have_error=false
+ rm /boot/vmli*
+ rm /boot/uImage.old
+ rm /boot/uImage-*
+ 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.\nKernel couldn't be updated."
+ log "Kernel not updated - not enough diskspace on /boot/"
+ have_error=true
+ else
+ cp uImage /boot/uImage.new
+ sync
+ bad_checksum=false
+ currkern=$(md5sum /boot/uImage.new | cut -d" " -f1)
+ if [ "$currkern" = "$newkern" ];
+ then
+ mv /boot/uImage /boot/uImage.old
+ mv /boot/uImage.new /boot/uImage
+ currkern=$(md5sum /boot/uImage | cut -d" " -f1)
+ if [ "$currkern" != "$newkern" ];
+ then
+ rm /boot/uImage
+ mv /boot/uImage.old /boot/uImage
+ bad_checksum=true
+ fi
+ else
+ rm /boot/uImage.new
+ bad_checksum=true
+ fi
+ if $bad_checksum;
+ then
+ 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
+ log "Kernel successfully updated"
+ echo "The kernel has been updated. You need to restart your system." > /tmp/updreboot
+ fi
+ sync
+}
+
+
+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?
+ log "u-boot.bin flashed."
+ else
+ log "u-boot.bin flashing failed."
+ fi
+}
+
+
+
+#
+# The "real" script itself where the work is done...
+#
+
+
+# cleanup of old log files
+rm /tmp/updater.log
+rm ./opkg.log
+rm /tmp/updreboot
+rm /tmp/updater_err.log
+
+
+if zenity --question --title="$MAIN_UPDATER_TITLE" --text="$MAIN_UPDATER_TEXT" --ok-label="Start now" --cancel-label="Don't do it";
+then
+ # inside the huge ( )-Block the normal update is done
+ (
+
+ # Save list of services
+
+ mkdir /tmp/rcsave
+ cp -r /etc/rc* /tmp/rcsave
+ opkg remove --force-depends pandora-lcd-state >> ./opkg.log
+ rm /var/lib/opkg/*
+
+ #
+ # Remove old files
+ #
+ echo "5"
+ echo "# Removing old packages"
+ # Forcefully removing packages: this list is basically the collection of
+ # package names that are meant to be removed. This collection is a side
+ # product of the "get-updated-packages.sh" script. Please make also sure to
+ # add noteworthy packages in the variable "MAIN_UPDATER_TEXT" above.
+ opkg remove --nodeps --force-depends $PACKAGES_FOR_REMOVAL
+
+
+ #
+ # Kernel Update
+ #
+
+ modup=$(opkg list-installed | grep kernel-image)
+ if [ "$modup" != "$OPKG_KERNEL_NAME" ];
+ then
+ # call the function for installing ipks
+ # $1 path for packages
+ # $2 start percentage for zenity (int!)
+ # $3 end percentage for zenity (int!)
+ # $4 step width for zenity ($4 percent point per gui update / opkg run)
+ # $5 message displayed in zenity during the update
+ install_all_ipk_in_folder packages/kernel 7 65 6 "# Updating Kernel Modules... this will take a while..."
+ fi
+
+ echo "65"
+ echo "# Updating kernel if needed"
+
+ kernel_known=false
+ for oknl in $oldkern $newkern;
+ do
+ if [ "$oknl" = "$currkern" ];
+ then
+ kernel_known=true
+ break
+ fi
+ done
+
+ if [ "$kernel_known" = "true" -o -z "$currkern" ];
+ then
+ if [ "$currkern" != "$newkern" ];
+ then
+ update_kernel
+ else
+ log "Kernel already up-to-date"
+ fi
+ else
+ if zenity --question --title="Custom kernel?" --text="$CUSTOM_KERNEL_INSTALLED_TEXT" --ok-label="Yes" --cancel-label="No";
+ then
+ update_kernel
+ else
+ log "Kernel update skipped"
+ fi
+ fi
+
+
+ #
+ # u-boot Update
+ #
+
+
+ echo "70"
+ echo "# U-Boot if needed"
+
+ if [ -f u-boot.bin ];
+ then
+ 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'`
+ uboot_size=`stat -c %s u-boot.bin`
+
+ dd if=/tmp/u-boot.bin.nand of=/tmp/u-boot.bin.nand.cmp bs=$uboot_size count=1
+ if ! cmp u-boot.bin /tmp/u-boot.bin.nand.cmp
+ then
+ uboot_need_to_ask=true
+ for oldver in $oldubootvers;
+ do
+ if [ "$oldver" = "$uboot_nand_ver" ];
+ then
+ uboot_need_to_ask=false
+ break
+ fi
+ done
+
+ if $uboot_need_to_ask;
+ then
+ if zenity --question --title="Custom u-boot?" --text="$CUSTOM_UBOOT_INSTALLED_TEXT" --ok-label="Yes" --cancel-label="No";
+ then
+ update_uboot
+ else
+ log "u-boot update skipped\n(nand has $uboot_nand_ver)"
+ fi
+ else
+ update_uboot
+ fi
+ else
+ log "u-boot already up-to-date\n($uboot_nand_ver)"
+ fi
+ fi
+
+
+ echo "75"
+ echo "# Preparing OS update."
+
+
+ #
+ # Update IPKs.
+ #
+
+ # call the function for installing ipks
+ # $1 path for packages
+ # $2 start percentage for zenity (int!)
+ # $3 end percentage for zenity (int!)
+ # $4 step width for zenity ($4 percent point per gui update / opkg run)
+ # $5 message displayed in zenity during the update
+ install_all_ipk_in_folder packages/other 80 95 6 "# Updating OS... this will take a while."
+
+ # we seem to always want to forcefully overwrite the skel files!
+ if [ -f packages/other/pandora-skel_*ipk ]
+ then
+ for my_package in packages/other/pandora-skel_*ipk
+ do
+ opkg install --force-overwrite $my_package >> ./opkg.log
+ done
+ fi
+
+ log "Packages updated"
+
+ echo "95"
+ echo "# Finalizing update"
+
+ rm -r /etc/rc*
+ cp -r /tmp/rcsave/* /etc/
+ rm -R /tmp/rcsave
+
+
+ if [ -f /etc/rc5.d/S20apmd ];
+ then
+ update-rc.d -f xinetd remove
+ update-rc.d -f avahi-daemon remove
+ update-rc.d -f apmd remove
+ update-rc.d -f banner remove
+ update-rc.d -f portmap remove
+ update-rc.d -f blueprobe remove
+ update-rc.d -f pandora-lcd-state remove
+ update-rc.d -f pandora-state start 39 S . stop 31 0 1 6 .
+ fi
+
+ chmod 666 /etc/pointercal
+ user=$(cat /tmp/currentuser)
+ cp /etc/skel/.vimrc /home/$user/.vimrc --no-clobber
+ chown $user:$user /home/$user/.vimrc
+
+ sync
+ log "Final scripts finished"
+
+ echo "100"
+ echo "# Update finished"
+
+ ) |
+ # Zenity Progress goes here
+ zenity --progress \
+ --title="Installing Updates..." \
+ --text="Updating System..." \
+ --percentage=0
+
+ # check for erros and display the final "I am about to be done" message
+ err=`cat /tmp/updater_err.log`
+ if [ -z "$err" ]; then
+ err="Your system has been updated and will now reboot."
+ fi
+ update=$(cat /tmp/updater.log)
+ zenity --info --title="Update finished" --text "$err\n\n${update}"
+
+
+ #if [ -f /tmp/updreboot ];
+ #then
+ # reboot=`cat /tmp/updreboot`
+ # zenity --info --title="You need to reboot" --text "${reboot}"
+ # rm /tmp/updreboot
+ #fi
+ reboot
+fi