This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
forked from jt1134/android_device_samsung_charge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
updater.sh
executable file
·173 lines (135 loc) · 5.09 KB
/
updater.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/tmp/busybox sh
#
# Updater Script for Droid Charge
# (c) 2011 by Teamhacksung
#
set -x
export PATH=/:/sbin:/system/xbin:/system/bin:/tmp:$PATH
SD_DEV=/dev/block/mmcblk1p1
# check if we're running on a bml or mtd device
if /tmp/busybox test -e /dev/block/bml7 ; then
# we're running on a bml device
# make sure sdcard is mounted
if ! /tmp/busybox grep -q /mnt/sdcard /proc/mounts ; then
/tmp/busybox mkdir -p /mnt/sdcard
/tmp/busybox umount -l $SD_DEV
if ! /tmp/busybox mount -t vfat $SD_DEV /mnt/sdcard ; then
/tmp/busybox echo "Cannot mount sdcard."
exit 1
fi
fi
# remove old log
rm -rf /mnt/sdcard/cyanogenmod_bml.log
# everything is logged into /sdcard/cyanogenmod.log
exec >> /mnt/sdcard/cyanogenmod_bml.log 2>&1
# the phone seems to run fine without /efs (there's just DivX DRM
# and a text file containing the bluetooth MAC address), but we
# might as well back it up anyway. The actual EFS partition is
# BML13, which we need to keep as-is.
# make sure efs is mounted
if ! /tmp/busybox grep -q /efs /proc/mounts ; then
/tmp/busybox mkdir -p /efs
/tmp/busybox umount -l /dev/block/stl3
if ! /tmp/busybox mount -t rfs /dev/block/stl3 /efs ; then
/tmp/busybox echo "Cannot mount efs."
exit 2
fi
fi
# create a backup of efs
if /tmp/busybox test -e /mnt/sdcard/backup/efs ; then
/tmp/busybox mv /mnt/sdcard/backup/efs /mnt/sdcard/backup/efs-$$
fi
/tmp/busybox rm -rf /mnt/sdcard/backup/efs
/tmp/busybox mkdir -p /mnt/sdcard/backup/efs
/tmp/busybox cp -R /efs/ /mnt/sdcard/backup
# dump actual efs/nvdata partition
/tmp/busybox dd if=/dev/block/bml13 of=/mnt/sdcard/backup/efs/nv_data.bin bs=256K
# dump modem
/tmp/busybox dd if=/dev/block/bml12 of=/mnt/sdcard/backup/efs/modem.bin bs=256K
# write the package path to sdcard cyanogenmod.cfg
#if /tmp/busybox test -n "$UPDATE_PACKAGE" ; then
# PACKAGE_LOCATION=${UPDATE_PACKAGE#/mnt}
# /tmp/busybox echo "$PACKAGE_LOCATION" > /mnt/sdcard/cyanogenmod.cfg
#fi
# Scorch any ROM Manager settings to require the user to reflash recovery
/tmp/busybox rm -f /mnt/sdcard/clockworkmod/.settings
# write new kernel to boot partition
flash_image boot /tmp/boot.img
if [ "$?" != "0" ] ; then
exit 3
fi
# write new kernel to recovery partition
flash_image recovery /tmp/boot.img
if [ "$?" != "0" ] ; then
exit 3
fi
/tmp/busybox sync
/sbin/reboot now
exit 0
elif /tmp/busybox test -e /dev/block/mtdblock0 ; then
# we're running on a mtd device
# make sure sdcard is mounted
/tmp/busybox mkdir -p /sdcard
if ! /tmp/busybox grep -q /sdcard /proc/mounts ; then
/tmp/busybox umount -l $SD_DEV
if ! /tmp/busybox mount -t vfat $SD_DEV /sdcard ; then
/tmp/busybox echo "Cannot mount sdcard."
exit 4
fi
fi
# remove old log
rm -rf /sdcard/cyanogenmod_mtd.log
# everything is logged into /sdcard/cyanogenmod.log
exec >> /sdcard/cyanogenmod_mtd.log 2>&1
# if a cyanogenmod.cfg exists, then this is a first time install
# let's format the volumes and restore efs
#if ! /tmp/busybox test -e /sdcard/cyanogenmod.cfg ; then
# exit 0
#fi
# remove the cyanogenmod.cfg to prevent this from looping
/tmp/busybox rm -f /sdcard/cyanogenmod.cfg
# unmount, format and mount system
/tmp/busybox umount -l /system
erase_image system
/tmp/busybox mount -t yaffs2 /dev/block/mtdblock2 /system
# unmount and format cache
/tmp/busybox umount /cache
/tmp/make_ext4fs -b 4096 -g 32768 -i 8192 -I 256 -a /cache /dev/block/mmcblk0p3
# unmount and format data
/tmp/busybox umount /data
/tmp/make_ext4fs -b 4096 -g 32768 -i 8192 -I 256 -a /data /dev/block/mmcblk0p1
# unmount and format datadata
/tmp/busybox umount -l /datadata
erase_image datadata
# restore efs backup
if /tmp/busybox test -e /sdcard/backup/efs/nv_data.bin ; then
/tmp/busybox umount -l /efs
erase_image efs
/tmp/busybox mkdir -p /efs
if ! /tmp/busybox grep -q /efs /proc/mounts ; then
if ! /tmp/busybox mount -t yaffs2 /dev/block/mtdblock3 /efs ; then
/tmp/busybox echo "Cannot mount efs."
exit 6
fi
fi
/tmp/busybox cp -R /sdcard/backup/efs /
# make sure we have modem/nvdata
if ! /tmp/busybox test -e /efs/nv_data.bin ; then
/tmp/bml_over_mtd dump nvdata 2002 reservoir 2004 /efs/nv_data.bin
fi
if ! /tmp/busybox test -e /efs/modem.bin ; then
/tmp/bml_over_mtd dump radio 1954 reservoir 2004 /efs/modem.bin
fi
/tmp/busybox umount -l /efs
else
/tmp/busybox echo "Cannot restore efs."
exit 7
fi
# remount data
if ! /tmp/busybox mount -t ext4 /dev/block/mmcblk0p1 /data ; then
/tmp/busybox echo "Cannot mount data."
exit 4
fi
# images will be flashed later in script
exit 0
fi