summaryrefslogtreecommitdiffstats
path: root/rbutil/mknwzboot/install_script.sh
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-09-17 22:16:50 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-09-17 22:16:50 +0200
commit7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9 (patch)
tree5988df37e1cc3b83ecd7f1aa170bc60665ce72d9 /rbutil/mknwzboot/install_script.sh
parentac59669d460397b628f08dfcc7b6df6eec272091 (diff)
downloadrockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.tar.gz
rockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.tar.bz2
rockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.zip
mknwzboot: add support for uninstallation
There is not need for a bootloader file to create an uninstall firmware so one needs to provide a model. Also cleanup the install script a bit by factoring message into a function, also print them to the log so that the user can report what was printed on the screen easily. The uninstall script is quite trivial, it remounts the rootfs and restores the backed up OF to its right place. Change-Id: I1f5c0efeb965fdc7fe17f45c2753c0f52c34f7f1
Diffstat (limited to 'rbutil/mknwzboot/install_script.sh')
-rw-r--r--rbutil/mknwzboot/install_script.sh51
1 files changed, 33 insertions, 18 deletions
diff --git a/rbutil/mknwzboot/install_script.sh b/rbutil/mknwzboot/install_script.sh
index 18296d257e..76bd12c4d5 100644
--- a/rbutil/mknwzboot/install_script.sh
+++ b/rbutil/mknwzboot/install_script.sh
@@ -1,5 +1,11 @@
#!/bin/sh
+# NOTE: busybox is using ash, a very posix and very pedantic shell, make sure
+# you test your scripts with
+# busybox sh -n <script>
+# and if you really, really don't want to download busybox to try it, then go
+# ahead and brick your device
+
# The updater script on the NWZ has a major bug/feature:
# it does NOT clear the update flag if the update scrit fails
# thus causing a update/reboot loop and a bricked device
@@ -13,14 +19,24 @@ cd /tmp
CONTENTS="/contents"
CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
-lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART"
+# print a message to the screen and also on the standard output
+# lcdprint x,y msg
+lcdprint ()
+{
+ echo $2
+ lcdmsg -f /usr/local/bin/font_08x12.bmp -l $1 "$2"
+}
+
+# clear screen
+lcdmsg -c ""
+lcdprint 0,3 "Contents partition:\n$CONTENTS_PART"
# We need to remount the contents partition in read-write mode be able to
# write something on it
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw"
+lcdprint 0,6 "Remount $CONTENTS rw"
mount -o remount,rw $CONTENTS_PART $CONTENTS
if [ "$?" != 0 ]; then
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: remount failed"
+ lcdprint 0,15 "ERROR: remount failed"
sleep 3
exit 0
fi
@@ -35,10 +51,10 @@ ROOTFS_TMP_DIR=/tmp/rootfs
SPIDERAPP_PATH=$ROOTFS_TMP_DIR/usr/local/bin/SpiderApp
# mount root partition
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Mount root filesystem"
+lcdprint 0,7 "Mount root filesystem"
mkdir $ROOTFS_TMP_DIR
if [ "$?" != 0 ]; then
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mkdir failed"
+ lcdprint 0,15 "ERROR: mkdir failed"
sleep 3
exit 0
fi
@@ -58,13 +74,13 @@ if [ "$?" != 0 ]; then
mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
fi
if [ "$?" != 0 ]; then
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mount failed"
+ lcdprint 0,15 "ERROR: mount failed"
sleep 3
exit 0
fi
# rename the previous main application unless there is already a copy
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,8 "Backup OF"
+lcdprint 0,8 "Backup OF"
if [ ! -e $SPIDERAPP_PATH.of ]; then
mv $SPIDERAPP_PATH $SPIDERAPP_PATH.of
fi
@@ -75,12 +91,12 @@ fi
#
# we need a small trick here: we want to pipe directly the output of the decryption
# tool to tar, to avoid using space in /tmp/ or on the user partition
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Install rockbox"
+lcdprint 0,9 "Install rockbox"
FIFO_FILE=/tmp/rb.fifo
mkfifo $FIFO_FILE
if [ "$?" != 0 ]; then
umount "$ROOTFS_TMP_DIR"
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create fifo"
+ lcdprint 0,15 "ERROR: cannot create fifo"
sleep 3
exit 0
fi
@@ -89,7 +105,7 @@ fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 $FIFO_FILE &
tar -C $ROOTFS_TMP_DIR -xvf $FIFO_FILE
if [ "$?" != 0 ]; then
umount "$ROOTFS_TMP_DIR"
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: extraction failed"
+ lcdprint 0,15 "ERROR: extraction failed"
sleep 3
exit 0
fi
@@ -97,46 +113,45 @@ fi
wait
if [ "$?" != 0 ]; then
umount "$ROOTFS_TMP_DIR"
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: no file to extract"
+ lcdprint 0,15 "ERROR: no file to extract"
sleep 3
exit 0
fi
# create a symlink from /.rockbox to /contents/.rockbox (see dualboot code
# for why)
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Create rockbox symlink"
+lcdprint 0,10 "Create rockbox symlink"
rm -f "$ROOTFS_TMP_DIR/.rockbox"
ln -s "$CONTENTS/.rockbox" "$ROOTFS_TMP_DIR/.rockbox"
if [ "$?" != 0 ]; then
umount "$ROOTFS_TMP_DIR"
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create rockbox symlink"
+ lcdprint 0,15 "ERROR: cannot create rockbox symlink"
sleep 3
exit 0
fi
# unmount root partition
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,11 "Unmount root filesystem"
+lcdprint 0,11 "Unmount root filesystem"
sync
if [ "$?" != 0 ]; then
umount "$ROOTFS_TMP_DIR"
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: sync failed"
+ lcdprint 0,15 "ERROR: sync failed"
sleep 3
exit 0
fi
umount $ROOTFS_TMP_DIR
if [ "$?" != 0 ]; then
- lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: umount failed"
+ lcdprint 0,15 "ERROR: umount failed"
sleep 3
exit 0
fi
# Success screen
-lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds."
+lcdprint 0,15 "Rebooting in 3 seconds."
sleep 3
sync
echo "Installation successful"
# finish
exit 0
-