summaryrefslogtreecommitdiff
path: root/utils/nwztools/scripts/exec_file.sh
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-09-27 00:09:06 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-10-19 17:09:04 +0200
commit21fb5aff39ec63ae7c69b02d26e694f07016816f (patch)
treea7d7be7fc625f60505c867be651c1516b84748c1 /utils/nwztools/scripts/exec_file.sh
parent2a2800b528010320ca504a39106806ec21f02203 (diff)
downloadrockbox-21fb5aff39ec63ae7c69b02d26e694f07016816f.tar.gz
rockbox-21fb5aff39ec63ae7c69b02d26e694f07016816f.zip
nwztools: rework upg scripts
The exec_file allows to embed a script/executable and run it on target. It takes of unpacking, remounting contents rw and redirect output to exec.txt at the root of the drive. More generally, rework how the makefile works. Change-Id: Iec719227be96e80701ad8f5398d2d34389f4da9e
Diffstat (limited to 'utils/nwztools/scripts/exec_file.sh')
-rw-r--r--utils/nwztools/scripts/exec_file.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/utils/nwztools/scripts/exec_file.sh b/utils/nwztools/scripts/exec_file.sh
new file mode 100644
index 0000000000..059014de2c
--- /dev/null
+++ b/utils/nwztools/scripts/exec_file.sh
@@ -0,0 +1,62 @@
1#!/bin/sh
2
3# The updater script on the NWZ has a major bug/feature:
4# it does NOT clear the update flag if the update scrit fails
5# thus causing a update/reboot loop and a bricked device
6# always clear to make sure we don't end up being screwed
7nvpflag fup 0xFFFFFFFF
8
9#
10# This script extracts the second file from the UPG to /tmp and runs it
11#
12
13
14# go to /tmp
15cd /tmp
16
17# get content partition path
18CONTENTS="/contents"
19CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
20
21lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART"
22
23# 2) We need to remount the contents partition in read-write mode be able to
24# write something on it
25lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw"
26if ! mount -o remount,rw $CONTENTS_PART $CONTENTS
27then
28 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: remount failed"
29 sleep 3
30 exit 0
31fi
32
33# get update filename
34_UPDATE_FN_=`nvpstr ufn`
35
36# extract second file
37fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 exec
38if [ "$?" != 0 ]; then
39 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: no file to execute"
40 sleep 3
41 exit 0
42fi
43
44# make it executable
45chmod 755 exec
46if [ "$?" != 0 ]; then
47 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "ERROR: cannot make it executable"
48 sleep 3
49 exit 0
50fi
51
52# run it and redirect all outputs to exec.txt
53lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Running file..."
54/tmp/exec 2>&1 >$CONTENTS/exec.txt
55
56# 4) Success screen
57lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds."
58sleep 3
59sync
60
61# finish
62exit 0