forked from broodplank/android_build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·502 lines (460 loc) · 15.8 KB
/
build.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#!/bin/bash
# ---------------------------------------------------------
# >>> Init Vars
HOMEDIR=${PWD}
# JOBS=`cat /proc/cpuinfo | grep processor | wc -l`;
# If you uncomment the "JOBS" var make sure you comment the
# "JOBS" var down below in the build config
# ---------------------------------------------------------
# ---------------------------------------------------------
# >>> broodROM Jellybean Automated Build Script
# >>> Copyright 2013 broodplank.net
# >>> REV8 (Release 4)
# ---------------------------------------------------------
# ---------------------------------------------------------
# >>> Check for updates before starting?
#
CHECKUPDATES=0 # 0 to disable, 1 for repo sync
# ---------------------------------------------------------
# ---------------------------------------------------------
#
# >>> BUILD CONFIG
#
# ---------------------------------------------------------
#
# >>> Main Configuration (intended for option 6, All-In-One)
#
JOBS=5 # CPU Cores + 1 (also hyperthreading)
INCLUDERECOVERY=0 # Includes recovery.img in zip (0/1)
INCLUDEGAPPS=1 # Include Lite version of GAPPS
# Only for personal use! Distribution is strictly prohibited!
USEOTAPACKAGE=0 # Use 'make otapackage' instead of fetching META-INF from vendor
# Set it to '1' when your device is not yet officially supported
# >>> Odin Configuration
# All files besides system.img, boot.img, reovery.img and cache.img
# should be placed in build/broodrom/odin to be included if 1 (below)
#
BUILDODIN=0 # If 1, an odin package will be created
# If 0, all options below will be ignored
ODINADDMODEM=0 # Add amss.mbn (modem) to odin package
ODINADDBOOT=0 # Add adsp.mbn, dbl.mbn, osbl.mbn (bootloader)
ODINADDPARAM=0 # Add EMMCBOOT.MBN and partition.bin
#
# ---------------------------------------------------------
. build/envsetup.sh
clear
echo "----------------------------------------"
echo "- BROODROM JELLYBEAN -"
echo "----------------------------------------"
echo " "
echo " >>> Please choose target device"
lunch
clear
echo ${TARGET_PRODUCT} | sed -e 's/full_//g' > ./currentdevice
export DEVICE=`cat ./currentdevice`;
rm -f ./currentdevice
TARGETDIR=${HOMEDIR}/out/target/product/${DEVICE}
RELEASENAME="broodROM-JB-Release-4-${DEVICE}.zip"
ShowMenu () {
clear
echo "----------------------------------------"
echo "- BROODROM JELLYBEAN -"
echo "----------------------------------------"
echo "- www.broodplank.net -"
echo "----------------------------------------"
echo " "
echo ">>> Selected target device: ${DEVICE}"
echo ">>> Number of simultaneous jobs: ${JOBS}"
echo " "
echo "Please make your choice:"
echo " "
echo " [1] Update broodROM JB (Sync repositories)"
echo " [2] Compile broodROM JB"
echo " [3] Compile broodRecovery"
echo " [4] Build CWM ZIP"
echo " [5] Build Odin Image"
echo " "
echo " [6] All of the above actions"
echo " "
echo " If option 6 is chosen, please open the build.sh script"
echo " in the source root and adjust the variables to your needs"
echo " "
echo " [x] Exit"
echo " "
}
while [ 1 ]
do
ShowMenu
read CHOICE
case "$CHOICE" in
"1")
clear
echo "----------------------------------------"
echo "- Syncing repositories... -"
echo "----------------------------------------"
repo sync
clear
;;
"2")
clear
echo " "
echo "----------------------------------------"
echo "- Preparing environment for compiling -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Loading initial environment setup"
echo " "
. build/envsetup.sh
echo " "
echo "Ordering full_${DEVICE}-userdebug for lunch"
echo "Ignore the dependencies not found warning"
echo " "
lunch full_${DEVICE}-userdebug
echo " "
echo "----------------------------------------"
echo "- Compiling broodROM Jellybean -"
echo "- Number of simultaneous jobs: ${JOBS} -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Building!"
echo " "
make -j${JOBS} ${MAKEPARAM}
;;
"3")
clear
echo " "
echo "----------------------------------------"
echo "- Preparing environment for compiling -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Loading initial environment setup"
echo " "
. build/envsetup.sh
echo " "
echo "Ordering full_${DEVICE}-userdebug for lunch"
echo "Ignore the dependencies not found warning"
echo " "
lunch full_${DEVICE}-userdebug
echo " "
echo "----------------------------------------"
echo "- Compiling broodRecovery -"
echo "- Number of simultaneous jobs: ${JOBS} -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Building!"
echo " "
make otatools -j${JOBS}
make recoveryimage -j${JOBS}
;;
"4")
if [[ "$USEOTAPACKAGE" == "1" ]]; then
make otapackage -j ${JOBS}
echo "---------------------------------------------"
echo "- CWM Zip creation process completed -"
echo "- Zip can be found out/target/device folder -"
echo "---------------------------------------------"
else
echo " "
echo "----------------------------------------"
echo "- Manipulating output... -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Replacing contents of xbin"
rm -Rf ${TARGETDIR}/system/xbin
cp -Rf ${HOMEDIR}/build/broodrom/xbin ${TARGETDIR}/system/xbin
echo "Replacing kernel"
cp -f ${TARGETDIR}/system/etc/broodrom/boot_ocuv.img ${TARGETDIR}/boot.img
if [[ "$INCLUDERECOVERY" == "1" ]]; then
echo "Placing META-INF folder"
rm -Rf ${TARGETDIR}/META-INF
cp -Rf ${HOMEDIR}/build/broodrom/recovery/META-INF1 ${TARGETDIR}/META-INF
else
echo "Placing META-INF folder"
rm -Rf ${TARGETDIR}/META-INF
cp -Rf ${HOMEDIR}/build/broodrom/recovery/META-INF ${TARGETDIR}/META-INF
fi;
if [[ "$INCLUDEGAPPS" == "1" ]]; then
echo "Including GAPPS into system, ONLY FOR PERSONAL USE!"
cp -Rf ${HOMEDIR}/build/broodrom/gapps/* ${TARGETDIR}/system/
fi;
echo " "
echo "----------------------------------------"
echo "- Packing final OTA zip file -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Preparing zip contents:"
cd ${TARGETDIR}
rm -Rf autobuild
mkdir autobuild
echo "Copy boot.img"
cp boot.img autobuild/boot.img
if [[ "$INCLUDERECOVERY" == "1" ]]; then
echo "Copy recovery.img"
cp -f recovery.img autobuild/recovery.img
fi;
echo "Copy system folder"
cp -R system autobuild/system
echo "Copy META-INF folder"
cp -R META-INF autobuild/META-INF
cd autobuild
echo "Zipping all"
zip -r ${RELEASENAME} .
mv -f ${RELEASENAME} ${HOMEDIR}/build/broodrom/${RELEASENAME}
echo " "
echo "----------------------------------------"
echo "- Signing final OTA zip file -"
echo "----------------------------------------"
echo " "
busybox sleep 1
cd ${HOMEDIR}/build/broodrom
echo "Signing, please wait..."
java -jar signapk.jar testkey.x509.pem testkey.pk8 ${RELEASENAME} signed-${RELEASENAME}
mv -f signed-${RELEASENAME} ${HOMEDIR}/signed-${RELEASENAME}
rm -f ${RELEASENAME}
echo "Signing done!"
echo " "
echo " "
echo "---------------------------------------------"
echo "- CWM Zip creation process completed -"
echo "- Signed Zip can be found in root folder -"
echo "---------------------------------------------"
fi;
;;
"5")
clear
rm -Rf ${HOMEDIR}/broodROM-Release-4.tar.md5
rm -Rf ${TARGETDIR}/autobuildodin
echo " "
echo "----------------------------------------"
echo "- Building Odin Package -"
echo "----------------------------------------"
echo "- - "
echo "- Build Odin Package: -"
echo "- Include Modem: ${ODINADDMODEM} -"
echo "- Include Bootloader: ${ODINADDBOOT} -"
echo "- Include Param: ${ODINADDPARAM} -"
echo "----------------------------------------"
echo " "
busybox sleep 5
echo "Preparing files for packaging"
echo " "
rm -Rf ${TARGETDIR}/autobuildodin
mkdir ${TARGETDIR}/autobuildodin
cp ${TARGETDIR}/system.img ${TARGETDIR}/autobuildodin/system.img
cp ${TARGETDIR}/system/etc/broodrom/boot_ocuv.img ${TARGETDIR}/autobuildodin/boot.img
cp ${TARGETDIR}/recovery.img ${TARGETDIR}/autobuildodin/recovery.img
echo "Creating empty cache file"
dd if=/dev/zero of=${TARGETDIR}/autobuildodin/cache.img bs=1K count=102400
if [[ "$ODINADDMODEM" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/amss.mbn ${TARGETDIR}/autobuildodin/amss.mbn
$ODINMODEM = "amss.mbn"
fi;
if [[ "$ODINADDBOOT" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/adsp.mbn ${TARGETDIR}/autobuildodin/adsp.mbn
cp ${HOMEDIR}/build/broodrom/odin/osbl.mbn ${TARGETDIR}/autobuildodin/osbl.mbn
cp ${HOMEDIR}/build/broodrom/odin/dbl.mbn ${TARGETDIR}/autobuildodin/dbl.mbn
$ODINBOOT = "adsp.mbn osbl.mbn dbl.mbn"
fi;
if [[ "$ODINADDPRAM" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/EMMCBOOT.MBN ${TARGETDIR}/autobuildodin/EMMCBOOT.MBN
cp ${HOMEDIR}/build/broodrom/odin/partition.bin ${TARGETDIR}/autobuildodin/partition.bin
$ODINPARAM = "EMMCBOOT.MBN partition.bin"
fi;
echo " "
echo "Packing odin files"
echo " "
cd ${TARGETDIR}/autobuildodin
tar -c boot.img recovery.img system.img cache.img ${ODINMODEM} ${ODINBOOT} ${ODINPARAM} > broodROM-Release-4.tar
echo " "
echo "Adding MD5 Sums"
echo " "
md5sum -t broodROM-Release-4.tar >> broodROM-Release-4.tar
mv broodROM-Release-4.tar ${HOMEDIR}/broodROM-Release-4.tar.md5
echo " "
echo "Done!"
echo " "
busybox sleep 1
;;
"6")
if [[ "$CHECKUPDATES" == "1" ]]; then
echo "----------------------------------------"
echo "- Syncing repositories... -"
echo "----------------------------------------"
repo sync
clear
fi;
echo " "
echo "----------------------------------------"
echo "- Preparing environment for compiling -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Loading initial environment setup"
echo " "
. build/envsetup.sh
echo " "
echo "Ordering full_${DEVICE}-userdebug for lunch"
echo "Ignore the dependencies not found warning"
echo " "
lunch full_${DEVICE}-userdebug
echo " "
echo "----------------------------------------"
echo "- Compiling broodROM Jellybean -"
echo "- Number of simultaneous jobs: ${JOBS} -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Building!"
echo " "
make -j${JOBS} ${MAKEPARAM}
if [[ "$USEOTAPACKAGE" == "1" ]]; then
make otapackage -j ${JOBS}
echo "---------------------------------------------"
echo "- CWM Zip creation process completed -"
echo "- Zip can be found out/target/device folder -"
echo "---------------------------------------------"
else
echo " "
echo "----------------------------------------"
echo "- Manipulating output... -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Replacing contents of xbin"
rm -Rf ${TARGETDIR}/system/xbin
cp -Rf ${HOMEDIR}/build/broodrom/xbin ${TARGETDIR}/system/xbin
echo "Replacing kernel"
cp -f ${TARGETDIR}/system/etc/broodrom/boot_ocuv.img ${TARGETDIR}/boot.img
if [[ "$INCLUDERECOVERY" == "1" ]]; then
echo "Placing META-INF folder"
rm -Rf ${TARGETDIR}/META-INF
cp -Rf ${HOMEDIR}/build/broodrom/recovery/META-INF1 ${TARGETDIR}/META-INF
else
echo "Placing META-INF folder"
rm -Rf ${TARGETDIR}/META-INF
cp -Rf ${HOMEDIR}/build/broodrom/recovery/META-INF ${TARGETDIR}/META-INF
fi;
if [[ "$INCLUDEGAPPS" == "1" ]]; then
echo "Including GAPPS into system, ONLY FOR PERSONAL USE!"
cp -Rf ${HOMEDIR}/build/broodrom/gapps/* ${TARGETDIR}/system/
fi;
echo " "
echo "----------------------------------------"
echo "- Packing final OTA zip file -"
echo "----------------------------------------"
echo " "
busybox sleep 1
echo "Preparing zip contents:"
cd ${TARGETDIR}
rm -Rf autobuild
mkdir autobuild
echo "Copy boot.img"
cp boot.img autobuild/boot.img
if [[ "$INCLUDERECOVERY" == "1" ]]; then
echo "Copy recovery.img"
cp -f recovery.img autobuild/recovery.img
fi;
echo "Copy system folder"
cp -R system autobuild/system
echo "Copy META-INF folder"
cp -R META-INF autobuild/META-INF
cd autobuild
echo "Zipping all"
zip -r ${RELEASENAME} .
mv -f ${RELEASENAME} ${HOMEDIR}/build/broodrom/${RELEASENAME}
echo " "
echo "----------------------------------------"
echo "- Signing final OTA zip file -"
echo "----------------------------------------"
echo " "
busybox sleep 1
cd ${HOMEDIR}/build/broodrom
echo "Signing, please wait..."
java -jar signapk.jar testkey.x509.pem testkey.pk8 ${RELEASENAME} signed-${RELEASENAME}
mv -f signed-${RELEASENAME} ${HOMEDIR}/signed-${RELEASENAME}
rm -f ${RELEASENAME}
echo "Signing done!"
echo " "
echo " "
echo "---------------------------------------------"
echo "- CWM Zip creation process completed -"
echo "- Signed Zip can be found in root folder -"
echo "---------------------------------------------"
fi;
busybox sleep 3
if [[ "$BUILDODIN" == "1" ]]; then
rm -Rf ${HOMEDIR}/broodROM-Release-4.tar.md5
rm -Rf ${TARGETDIR}/autobuildodin
echo " "
echo "----------------------------------------"
echo "- Performing Additional Tasks -"
echo "----------------------------------------"
echo "- - "
echo "- Build Odin Package: -"
echo "- Include Modem: ${ODINADDMODEM} -"
echo "- Include Bootloader: ${ODINADDBOOT} -"
echo "- Include Param: ${ODINADDPARAM} -"
echo "----------------------------------------"
echo " "
busybox sleep 5
echo "Preparing files for packaging"
echo " "
rm -Rf ${TARGETDIR}/autobuildodin
mkdir ${TARGETDIR}/autobuildodin
cp ${TARGETDIR}/system.img ${TARGETDIR}/autobuildodin/system.img
cp ${TARGETDIR}/system/etc/broodrom/boot_ocuv.img ${TARGETDIR}/autobuildodin/boot.img
cp ${TARGETDIR}/recovery.img ${TARGETDIR}/autobuildodin/recovery.img
echo "Creating empty cache file"
dd if=/dev/zero of=${TARGETDIR}/autobuildodin/cache.img bs=1K count=102400
if [[ "$ODINADDMODEM" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/amss.mbn ${TARGETDIR}/autobuildodin/amss.mbn
$ODINMODEM = "amss.mbn"
fi;
if [[ "$ODINADDBOOT" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/adsp.mbn ${TARGETDIR}/autobuildodin/adsp.mbn
cp ${HOMEDIR}/build/broodrom/odin/osbl.mbn ${TARGETDIR}/autobuildodin/osbl.mbn
cp ${HOMEDIR}/build/broodrom/odin/dbl.mbn ${TARGETDIR}/autobuildodin/dbl.mbn
$ODINBOOT = "adsp.mbn osbl.mbn dbl.mbn"
fi;
if [[ "$ODINADDPRAM" == "1" ]]; then
cp ${HOMEDIR}/build/broodrom/odin/EMMCBOOT.MBN ${TARGETDIR}/autobuildodin/EMMCBOOT.MBN
cp ${HOMEDIR}/build/broodrom/odin/partition.bin ${TARGETDIR}/autobuildodin/partition.bin
$ODINPARAM = "EMMCBOOT.MBN partition.bin"
fi;
echo " "
echo "Packing odin files"
echo " "
cd ${TARGETDIR}/autobuildodin
tar -c boot.img recovery.img system.img cache.img ${ODINMODEM} ${ODINBOOT} ${ODINPARAM} > broodROM-Release-4.tar
echo " "
echo "Adding MD5 Sums"
echo " "
md5sum -t broodROM-Release-4.tar >> broodROM-Release-4.tar
mv broodROM-Release-4.tar ${HOMEDIR}/broodROM-Release-4.tar.md5
echo "Cleaning remains..."
echo " "
rm -f ${HOMEDIR}/cache.img
rm -Rf ${TARGETDIR}/autobuild
rm -Rf ${TARGETDIR}/autobuildodin
rm -Rf ${TARGETDIR}/META-INF
echo " "
echo " ---------------------------------------------"
echo " - Odin package creation done! -"
echo " - Odin One package can be found in root -"
echo " ---------------------------------------------"
echo " "
echo " EXIT"
fi;
;;
"x")
exit
;;
esac
done
exit