-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathre_serialize.sh
More file actions
executable file
·129 lines (100 loc) · 2.76 KB
/
re_serialize.sh
File metadata and controls
executable file
·129 lines (100 loc) · 2.76 KB
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
# http://www.imajeenyus.com/computer/20130301_android_tablet/android/unpack_repack_recovery_image.html
# http://www.omappedia.com/wiki/Android_eMMC_Booting
TOOLS_PATH="$HOME/bin"
OEM_BUILD_ZIP="my_build.zip"
SERIAL_DEFAULT="XXXXXXXX" # this will be replaced by a unique one
SERIAL_NEW=`$TOOLS_PATH/serial_generator.sh`
echo "SERIAL_NEW=$SERIAL_NEW"
DIR="OEM"
function unzip_base_build() {
echo
echo "--------------------------------------"
echo "unzipping base build"
echo "--------------------------------------"
if [[ ! -d $DIR ]]
then
mkdir $DIR
fi
cp *.zip $DIR;
cd $DIR
echo "BEFORE..."
ls -la
unzip $OEM_BUILD_ZIP
echo "AFTER..."
ls -la
}
function unpack_img() {
echo
echo "--------------------------------------"
echo "unpack: recovery img!"
echo "--------------------------------------"
echo "$TOOLS_PATH/recovery/unmkbootimg recovery*.img > output.txt"
cd *v
$TOOLS_PATH/recovery/unmkbootimg recovery*.img > output.txt
exit 0
mkdir ramdisk
cd ramdisk
gunzip -c ../initramfs.cpio.gz | cpio -i
cp default.prop default.prop.bak
echo "You are here:"
pwd
ls -la
}
function replace_default_serial_num() {
echo
echo "--------------------------------------"
echo "replace default serial #"
echo "--------------------------------------"
echo "default serial #: $SERIAL_DEFAULT"
echo "new serial #: $SERIAL_NEW"
find . -type f -exec sed -i "s/$SERIAL_DEFAULT/$SERIAL_NEW/" {} +
}
function re_pack_img() {
echo
echo "--------------------------------------"
echo "re-pack: recovery img!"
echo "--------------------------------------"
echo "creating ramdisk-new.gz..."
cd ..
echo "You are here:"
pwd
$TOOLS_PATH/recovery/tools/mkbootfs ramdisk | gzip > ramdisk-new.gz
ls -la
cd ramdisk
echo "You are here:"
pwd
echo "creating ../newramdisk.cpio.gz..."
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
ls -la
cd ..
echo "You are here:"
pwd
echo "BEFORE"
ls -la
echo "creating recovery.new.img..."
$TOOLS_PATH/recovery/tools/mkbootimg --kernel zImage --ramdisk newramdisk.cpio.gz --base 0x40000000 --cmdline 'console=ttyS0,115200 rw init=/init loglevel=8' -o recovery.new.img
read -p "press enter"
echo "AFTER"
ls -la
}
function cleanup() {
echo
echo "--------------------------------------"
echo "cleanup!"
echo "--------------------------------------"
rm recovery.2knand.img
mv recovery.new.img recovery.2knand.img
rm -rf ramdisk
rm output
cd ..
ls -la
read -p "out dir"
rm -rf *.zip __*
cd *v
ls -la
}
unzip_base_build
unpack_img
replace_default_serial_num
re_pack_img
cleanup