-
Notifications
You must be signed in to change notification settings - Fork 235
/
make.sh
executable file
·155 lines (136 loc) · 3.45 KB
/
make.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
#!/bin/bash
# Copyright (C) 2021 Xiaoxindada <[email protected]>
# 2021 Jiuyu <[email protected]>
LOCALDIR=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
cd $LOCALDIR
source ./bin.sh
source ./language_helper.sh
Usage() {
cat <<EOT
Usage:
$0 <Build Type> <OS Type> <Firmware Path> [Other args]
Build Type: [--AB|--ab] or [-A|-a|--a-only]
OS Type: Rom OS type to build
Firmware Path: Rom Firmware Path
Other args:
[--fix-bug]: Fix bugs in Rom
EOT
}
case $1 in
"--AB"|"--ab")
build_type="--ab"
;;
"-A"|"-a"|"--a-only")
build_type="-a"
echo $NOTSUPPAONLY
exit 1
;;
"-h"|"--help")
Usage
exit 1
;;
*)
Usage
exit 1
;;
esac
if [ $# -lt 3 ];then
Usage
exit 1
fi
os_type="$2"
firmware="$3"
build_type="$build_type"
other_args=""
shift 3
if [ ! -e $firmware ];then
if [ ! -e $LOCALDIR/tmp/$firmware ];then
echo $NOTFOUNDFW
exit 1
fi
fi
function firmware_extract() {
partition_list="system vendor system_ext odm product reserve boot vendor_boot"
if [ -e $firmware ];then
7z x -y "$firmware" -o"./tmp/"
fi
if [ -e $LOCALDIR/tmp/$firmware ];then
7z x -y "$LOCALDIR/tmp/$firmware" -o"$LOCALDIR/tmp/"
fi
for i in $(ls $LOCALDIR/tmp);do
[ ! -d $LOCALDIR/tmp/$i ] && continue
cd $LOCALDIR/tmp/$i
if [ $(ls | wc -l) != "0" ];then
mv -f ./* ../
fi
cd $LOCALDIR
done
cd $LOCALDIR/tmp
for partition in $partition_list ;do
# Detect payload.bin
if [ -e ./payload.bin ];then
mv ./payload.bin ../payload/
cd ../payload
echo $UNZIPINGPLB
python ./payload.py ./payload.bin ./out
for i in $partition_list ;do
if [ -e ./out/$i.img ];then
echo "$i.img $MOVINGIMG"
mv ./out/$i.img $IMAGESDIR/
fi
done
rm -rf ./payload.bin
rm -rf ./out/*
cd $LOCALDIR/tmp
fi
# Detect dat.br
if [ -e ./${partition}.new.dat.br ];then
echo "$UNPACKING_STR ${partition}.new.dat.br"
$bin/brotli -d ${partition}.new.dat.br
python $bin/sdat2img.py ${partition}.transfer.list ${partition}.new.dat ./${partition}.img
mv ./${partition}.img $IMAGESDIR/
rm -rf ./${partition}.new.dat
fi
# Detect split new.dat
if [ -e ./${partition}.new.dat.1 ];then
echo "$SPLIT_DETECTED ${partition}.new.dat, $MERGING_STR"
cat ./${partition}.new.dat.{1..999} 2>/dev/null >> ./${partition}.new.dat
rm -rf ./${partition}.new.dat.{1..999}
python $bin/sdat2img.py ${partition}.transfer.list ${partition}.new.dat ./${partition}.img
mv ./${partition}.img $IMAGESDIR/
rm -rf ./${partition}.new.dat
fi
# Detect general new.dat
if [ -e ./${partition}.new.dat ];then
echo "$UNPACKING_STR ${partition}.new.dat"
python $bin/sdat2img.py ${partition}.transfer.list ${partition}.new.dat ./${partition}.img
mv ./${partition}.img $IMAGESDIR/
fi
# Detect image
if [ -e ./${partition}.img ];then
mv ./${partition}.img $IMAGESDIR/
fi
done
cd $IMAGESDIR
}
echo $INITINGENV
chmod -R 777 ./
./workspace_cleanup.sh > /dev/null 2>&1
rm -rf $WORKSPACE
mkdir -p $IMAGESDIR
mkdir -p $TARGETDIR
echo $ENVINITFINISH
if (echo $@ | grep -qo -- "--fix-bug") ;then
other_args+=" --fix-bug"
fi
firmware_extract
cd $LOCALDIR
if [ -e $IMAGESDIR/system.img ];then
echo "./SGSI.sh $build_type $os_type $other_args"
./SGSI.sh $build_type $os_type $other_args
./workspace_cleanup.sh
exit 0
else
echo $NOTFOUNDSYSTEMIMG
exit 1
fi