summaryrefslogtreecommitdiffstats
path: root/rbutil/mknwzboot/install_script.sh
diff options
context:
space:
mode:
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
-