diff options
Diffstat (limited to 'utils/ypr0tools/patch-firmware.sh')
-rwxr-xr-x | utils/ypr0tools/patch-firmware.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/utils/ypr0tools/patch-firmware.sh b/utils/ypr0tools/patch-firmware.sh new file mode 100755 index 0000000000..879b3f879d --- /dev/null +++ b/utils/ypr0tools/patch-firmware.sh | |||
@@ -0,0 +1,67 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | |||
4 | ###################################################################### | ||
5 | # __________ __ ___. | ||
6 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
7 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
8 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
9 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
10 | # \/ \/ \/ \/ \/ | ||
11 | # | ||
12 | # * Script to patch an unpacked Samsung YP-R0 firmware file */ | ||
13 | # Copyright (C) 2011 Thomas Martitz | ||
14 | ###################################################################### | ||
15 | # bail out early | ||
16 | set -e | ||
17 | |||
18 | if [ $# -lt 1 ] || [ $# -gt 2 ]; then | ||
19 | echo "Usage: $0 <files path> [path to unpacked rom]" | ||
20 | echo "\t<files path> is expected to have a rootfs layout and to contain" | ||
21 | echo "\tonly the files to overwrite (plain cp -r is used)" | ||
22 | exit 1 | ||
23 | fi | ||
24 | |||
25 | FILES=${1%/} | ||
26 | FILES=${FILES:-"/"} | ||
27 | DIR=${2:-"."} | ||
28 | DIR=${DIR%/} | ||
29 | ROOTFS=$DIR/rootfs | ||
30 | CRAMFS=$DIR/cramfs-fsl.rom | ||
31 | |||
32 | # sanity checks | ||
33 | |||
34 | # this needs to be run as root! | ||
35 | if [ $(whoami) != "root" ] | ||
36 | then | ||
37 | echo "This needs to be run as root" | ||
38 | exit 1 | ||
39 | fi | ||
40 | |||
41 | if [ ! -e $1 ] || [ ! -e $2 ]; then | ||
42 | echo "$1 or $2 does not exist" | ||
43 | exit 1 | ||
44 | fi | ||
45 | |||
46 | if [ -z $ROOTFS ] || [ -z $FILES ]; then | ||
47 | echo "Invalid input directories" | ||
48 | exit 1 | ||
49 | fi | ||
50 | |||
51 | if [ ! -e $CRAMFS ]; then | ||
52 | echo "Cramfs image not found (did you extract the firmware?)" | ||
53 | exit 1 | ||
54 | fi | ||
55 | |||
56 | echo "Extracting cramfs image" | ||
57 | |||
58 | [ ! -e $ROOTFS ] || rmdir -p $ROOTFS | ||
59 | cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS | ||
60 | |||
61 | echo "Patching rootfs" | ||
62 | echo "cp -r $FILES/* $ROOTFS/" | ||
63 | cp -r $FILES/.rockbox $ROOTFS/ | ||
64 | cp -r $FILES/* $ROOTFS/ | ||
65 | |||
66 | echo "Packing new cramfs image" | ||
67 | cramfs-1.1/mkcramfs $ROOTFS $CRAMFS | ||