-
Notifications
You must be signed in to change notification settings - Fork 6
/
mrom_build_all.sh
executable file
·303 lines (269 loc) · 7.28 KB
/
mrom_build_all.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
DEST_DIR="/home/tassadar/nexus/multirom"
TARGETS="omni_grouper-userdebug omni_flo-userdebug omni_mako-userdebug omni_hammerhead-userdebug omni_shamu-userdebug"
API_KEY="--"
APP_ID="--"
COMPILE_THREADS="$(expr $(nproc) + 2)"
# Include passwords and API things
if [ -e ~/mrom_cfg.sh ]; then
. ~/mrom_cfg.sh
fi
nobuild=false
noclean=false
nodhst=false
nobasket=false
noxda=false
forcexda=false
build_spec=""
forceupload=false
recoveryonly=false
multiromonly=false
noupload=false
forcesync=false
nosync=false
recovery_patch=""
for a in $@; do
case $a in
-h|--help)
echo "$0 [nobuild] [noclean] [nodhst] [nobasket] [device=mako|grouper|flo|hammerhead|shamu] [forceall] [forcenone] [forceupload] [noupload] [forcesync] [nosync] [forcexda] [noxda] [recovery] [multirom] [recovery_patch=00-59]"
exit 0
;;
nobuild)
nobuild=true
;;
noclean)
noclean=true
;;
nobasket)
nobasket=true
;;
nodhst)
nodhst=true
;;
noxda)
noxda=true
;;
forcexda)
forcexda=true;
;;
device=*)
build_spec="$build_spec omni_${a#device=}-userdebug"
;;
forceupload)
forceupload=true
;;
noupload)
noupload=true
;;
forcesync)
forcesync=true
;;
nosync)
nosync=true
;;
recovery)
recoveryonly=true
;;
multirom)
multiromonly=true
;;
recovery_patch=*)
recovery_patch="${a#recovery_patch=}"
;;
forceall)
forcesync=true
forceupload=true
forcexda=true
;;
forcenone)
noupload=true
noxda=true
nosync=true
;;
esac
done
acquire_pass() {
if $3; then
return 0
fi
if [ -n "$2" ]; then
echo $2 | base64 -d
else
res=""
while [ -z "$res" ]; do
echo
echo -n "Enter your $1 password: "
read -s res
done
echo $res
fi
}
get_unique_devices_array() {
res=""
print $1
for dev in $1; do
if [[ "$res" != *$dev* ]]; then
res="${res} $dev"
fi
done
echo $res
}
dhst_pass_int="$(acquire_pass "dev-host" $DHST_PASS $nodhst)"
basket_pass_int="$(acquire_pass "buildbasket.com" $BASKET_PASS $nobasket)"
xda_pass_int="$(acquire_pass "XDA" $XDA_PASS $noxda)"
. build/envsetup.sh
upload=""
upload_devs=""
for t in $TARGETS; do
if [ -n "$build_spec" ]; then
requested=false
for spec in $build_spec; do
if [ "$t" == "$spec" ]; then
requested=true
break
fi
done
if ! $requested; then
continue
fi
fi
lunch $t
TARGET_DEVICE=$(basename $OUT)
if ! $nobuild; then
if ! $noclean; then
rm -r "$OUT"
fi
if $recoveryonly; then
make -j${COMPILE_THREADS} recoveryimage || exit 1
elif $multiromonly; then
make -j${COMPILE_THREADS} multirom_zip || exit 1
else
make -j${COMPILE_THREADS} recoveryimage multirom_zip || exit 1
fi
fi
if ! $multiromonly; then
do_auto_patch_increment="false"
patch="$recovery_patch"
if [ -z "$patch" ]; then
do_auto_patch_increment="true"
patch="00"
fi
files="$(RECOVERY_SUBVER="$patch" AUTO_PATCH_INCREMENT="$do_auto_patch_increment" PRINT_FILES="true" IMG_PATH="$OUT/recovery.img" mrom_recovery_release.sh)"
if [ "$?" != "0" ]; then
echo "mrom_recovery_release.sh failed!"
exit 1
fi
upload="${upload} ${files}"
# add device for each recovery file
for f in $files; do
upload_devs="${upload_devs} ${TARGET_DEVICE}"
done
fi
echo ""
if ! $recoveryonly; then
for f in $(ls "$OUT"/multirom-*v*-*.zip*); do
dest="$DEST_DIR/$TARGET_DEVICE/$(basename "$f" | sed s/-UNOFFICIAL//g)"
if [[ "$dest" == *.zip ]]; then
upload="${upload} $dest"
upload_devs="${upload_devs} ${TARGET_DEVICE}"
fi
echo Copying $(basename $f) to $dest
cp -a "$f" "$dest" || exit 1
done
fi
done
# convert to array
upload=($upload)
upload_devs=($upload_devs)
if $nodhst && $nobasket; then
noupload=true
fi
if $noupload; then
echo "Upload disabled by cmdline args"
else
echo "Do you want to upload these files to d-h.st and buildbasket.com?"
for (( i=0; i<${#upload[@]}; i++ )); do
echo " ${upload[$i]}"
done
if ! $forceupload; then
echo -n "Upload? [y/N]: "
read upload_files
else
echo "Upload forced, proceeding"
fi
if [ "$upload_files" = "y" ] || [ "$upload_files" = "Y" ] || $forceupload; then
echo
if ! $nodhst; then
echo "Uploading to d-h.st"
token=$(dhst_cli.py -l "$DHST_LOGIN" -p "$dhst_pass_int" login)
if [ "$?" != "0" ]; then
echo "Failed to log-in to d-h.st"
exit 1
fi
for (( i=0; i<${#upload[@]}; i++ )); do
u=${upload[$i]}
dev=${upload_devs[$i]}
dhst_cli.py -t "$token" -d multirom/$dev upload "$u"
if [ "$?" != "0" ]; then
echo "Failed to upload $u to d-h.st!"
exit 1
fi
done
fi
if ! $nobasket; then
echo
echo "Uploading to bascketbuild.com..."
for (( i=0; i<${#upload[@]}; i++ )); do
u=${upload[$i]}
u_file="$(basename "$u")"
u_dir="${u%$u_file}"
dev=${upload_devs[$i]}
echo "Uploading $u"
ftp -n <<EOF
open basketbuild.com
user $BASKET_LOGIN $basket_pass_int
cd multirom/${dev}
lcd $u_dir
put $u_file
EOF
if [ "$?" != "0" ]; then
echo "Failed to upload $u to basketbuild.com!"
exit 1
fi
done
fi
else
echo
echo "Not uploading anything"
fi
fi
if $nosync; then
echo "Sync disabled by cmdline args"
else
if ! $forcesync; then
echo -n "Sync files to manager? [y/N]: "
read upload_files
else
echo "Upload forced, proceeding"
fi
if [ "$upload_files" = "y" ] || [ "$upload_files" = "Y" ] || $forcesync; then
mrom_sync.py
fi
fi
if $noxda; then
echo "XDA thread update disabled by cmdline args"
else
if ! $forcexda; then
echo -n "Update XDA threads? [y/N]: "
read update_xda
else
echo "XDA Update force, proceeding"
update_xda=true
fi
if [ "$update_xda" = "y" ] || [ "$update_xda" = "Y" ]; then
devices="$(get_unique_devices_array "${upload_devs[*]}")"
for dev in $devices; do
mrom_update_xda.py -u $XDA_LOGIN -p $xda_pass_int --basket-login="$BASKET_LOGIN" --basket-pass="$basket_pass_int" -d $dev
done
fi
fi