-
Notifications
You must be signed in to change notification settings - Fork 7
/
build_sdm450.sh
executable file
·611 lines (537 loc) · 17.4 KB
/
build_sdm450.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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
#!/bin/bash
# SDM450 kernel build script v0.5
export PLATFORM_VERSION=8
BUILD_COMMAND=$1
if [ "$BUILD_COMMAND" == "a6plte_eur_open" ]; then
BUILD_PRODUCT=a6plte_eur_open
PRODUCT_NAME=a6plte_eur
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "a6plte_sea_open" ]; then
BUILD_PRODUCT=a6plte_sea_open
PRODUCT_NAME=a6plte_sea
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "a6plte_ltn_open" ]; then
BUILD_PRODUCT=a6plte_ltn_open
PRODUCT_NAME=a6plte_ltn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "a6plte_chn_open" ]; then
BUILD_PRODUCT=a6plte_chn_open
PRODUCT_NAME=a6plte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "a6plte_kor_ktt" ]; then
BUILD_PRODUCT=a6plte_kor_ktt
PRODUCT_NAME=a6plte_kor
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_cis_ser" ]; then
BUILD_PRODUCT=j8plte_cis_ser
PRODUCT_NAME=j8plte_cis
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
elif [ "$BUILD_COMMAND" == "a6plte_cis_ser" ]; then
BUILD_PRODUCT=a6plte_cis_ser
PRODUCT_NAME=a6plte_cis
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
elif [ "$BUILD_COMMAND" == "j8plte_eur_open" ]; then
BUILD_PRODUCT=j8plte_eur_open
PRODUCT_NAME=j8plte_eur
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_sea_open" ]; then
BUILD_PRODUCT=j8plte_sea_open
PRODUCT_NAME=j8plte_sea
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_chn_open" ]; then
BUILD_PRODUCT=j8plte_chn_open
PRODUCT_NAME=j8plte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_chn_hk" ]; then
BUILD_PRODUCT=j8plte_chn_hk
PRODUCT_NAME=j8plte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_chn_cmcc" ]; then
BUILD_PRODUCT=j8plte_chn_cmcc
PRODUCT_NAME=j8plte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j8plte_kor_ktt" ]; then
BUILD_PRODUCT=j8plte_kor_ktt
PRODUCT_NAME=j8plte_kor
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_eur_open" ]; then
BUILD_PRODUCT=gta2xllte_eur_open
PRODUCT_NAME=gta2xllte_eur
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_sea_open" ]; then
BUILD_PRODUCT=gta2xllte_sea_open
PRODUCT_NAME=gta2xllte_sea
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_usa_spr" ]; then
BUILD_PRODUCT=gta2xllte_usa_spr
PRODUCT_NAME=gta2xllte_usa
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_usa_vzw" ]; then
BUILD_PRODUCT=gta2xllte_usa_vzw
PRODUCT_NAME=gta2xllte_usa
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_mea_open" ]; then
BUILD_PRODUCT=gta2xllte_mea_open
PRODUCT_NAME=gta2xllte_mea
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_mea_tur" ]; then
BUILD_PRODUCT=gta2xllte_mea_tur
PRODUCT_NAME=gta2xllte_mea
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_chn_open" ]; then
BUILD_PRODUCT=gta2xllte_chn_open
PRODUCT_NAME=gta2xllte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_chn_hk" ]; then
BUILD_PRODUCT=gta2xllte_chn_hk
PRODUCT_NAME=gta2xllte_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_cis_ser" ]; then
BUILD_PRODUCT=gta2xllte_cis_ser
PRODUCT_NAME=gta2xllte_cis
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xllte_can_single" ]; then
BUILD_PRODUCT=gta2xllte_can_single
PRODUCT_NAME=gta2xllte_can
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xlwifi_eur_open" ]; then
BUILD_PRODUCT=gta2xlwifi_eur_open
PRODUCT_NAME=gta2xlwifi_eur
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xlwifi_cis_ser" ]; then
BUILD_PRODUCT=gta2xlwifi_cis_ser
PRODUCT_NAME=gta2xlwifi_cis
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "gta2xlwifi_chn_open" ]; then
BUILD_PRODUCT=gta2xlwifi_chn_open
PRODUCT_NAME=gta2xlwifi_chn
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "j6plte_cis_ser" ]; then
BUILD_PRODUCT=j6plte_cis_ser
PRODUCT_NAME=j6plte_cis
SIGN_MODEL=
USE_FINGERPRINT_TZ="false"
KASLR_DEFCONFIG=
elif [ "$BUILD_COMMAND" == "c7lte_chn" ]; then
BUILD_PRODUCT=c7lte_chn
PRODUCT_NAME=c7ltechn
SIGN_MODEL=SM-C7000_CHN_CHC_ROOT0
USE_FINGERPRINT_TZ="true"
KASLR_DEFCONFIG=kaslr_defconfig
fi
BUILD_WHERE=$(pwd)
BUILD_KERNEL_DIR=$BUILD_WHERE
BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/../..
BUILD_KERNEL_OUT_DIR=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME/obj/KERNEL_OBJ
PRODUCT_OUT=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME
SECURE_SCRIPT=$BUILD_ROOT_DIR/buildscript/tools/signclient.jar
BUILD_CROSS_COMPILE=$BUILD_ROOT_DIR/android/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
KERNEL_DEFCONFIG=sdm450_sec_defconfig
DEBUG_DEFCONFIG=sdm450_sec_eng_defconfig
SELINUX_DEFCONFIG=selinux_defconfig
SELINUX_LOG_DEFCONFIG=selinux_log_defconfig
DMVERITY_DEFCONFIG=dmverity_defconfig
if [ "${SEC_BUILD_CONF_TIMA_ENABLED}" == "true" ] ; then
TIMA_DEFCONFIG=tima_defconfig
fi
if [ "${SEC_BUILD_CONF_USE_DMVERITY}" == "true" ] ; then
DMVERITY_DEFCONFIG=dmverity_defconfig
fi
if [ "${SEC_BUILD_CONF_KERNEL_KASLR}" == "true" ] ; then
KASLR_DEFCONFIG=kaslr_defconfig
fi
# default value for various sensors
sec_conf_use_fingerprint_tz=true
sec_conf_use_fingerprint_nontz=false
sec_conf_use_iris_tz=false
USE_FINGERPRINT_TZ="false"
MODEL=${BUILD_COMMAND%%_*}
PRODUCT_NAME=`cat ../../model/build_conf/$MODEL/build_conf.$BUILD_COMMAND \
| sed -n "/^prebuilt-binary/p" \
| sed "s/prebuilt-binary[ \t]=[ \t]//g" \
| sed "s/android\/vendor\/samsung\/configs\///g" \
| sed "s/\/.*//g"`
echo PRODUCT_NAME=$PRODUCT_NAME
SIGN_PROJECT=`cat ../../model/build_conf/$MODEL/build_conf.$BUILD_COMMAND \
| sed -n "/^project/p" \
| sed "s/project[ \t]*=[ \t]*//g" \
| sed "2,/*/d"`
SIGN_SUFFIX=`cat ../../model/build_conf/$MODEL/build_conf.$BUILD_COMMAND \
| sed -n "/^suffix/p" \
| sed "s/suffix[ \t]*=[ \t]*//g" \
| sed "2,/*/d"`
SIGN_MODEL=$SIGN_PROJECT$SIGN_SUFFIX
echo MODEL=$MODEL
echo PRODUCT_NAME=$PRODUCT_NAME
echo SIGN_PROJECT=$SIGN_PROJECT
echo SIGN_SUFFIX=$SIGN_SUFFIX
echo SIGN_MODEL=$SIGN_MODEL
echo TIMA_DEFCONFIG=$TIMA_DEFCONFIG
echo DMVERITY_DEFCONFIG=$DMVERITY_DEFCONFIG
echo KASLR_DEFCONFIG=$KASLR_DEFCONFIG
while getopts "w:t:" flag; do
case $flag in
w)
BUILD_OPTION_HW_REVISION=$OPTARG
echo "-w : "$BUILD_OPTION_HW_REVISION""
;;
t)
TARGET_BUILD_VARIANT=$OPTARG
echo "-t : "$TARGET_BUILD_VARIANT""
;;
*)
echo "wrong 2nd param : "$OPTARG""
exit -1
;;
esac
done
shift $((OPTIND-1))
SECURE_OPTION=
SEANDROID_OPTION=
if [ "$2" == "-B" ]; then
SECURE_OPTION=$2
elif [ "$2" == "-E" ]; then
SEANDROID_OPTION=$2
else
NO_JOB=
fi
if [ "$3" == "-B" ]; then
SECURE_OPTION=$3
elif [ "$3" == "-E" ]; then
SEANDROID_OPTION=$3
else
NO_JOB=
fi
MODEL=${BUILD_PRODUCT%%_*}
TEMP=${BUILD_PRODUCT#*_}
REGION=${TEMP%%_*}
CARRIER=${TEMP##*_}
VARIANT=${CARRIER}
PROJECT_NAME=${VARIANT}
if [ "${REGION}" == "${CARRIER}" ]; then
VARIANT_DEFCONFIG=sdm450_sec_${MODEL}_${CARRIER}_defconfig
else
VARIANT_DEFCONFIG=sdm450_sec_${MODEL}_${REGION}_${CARRIER}_defconfig
fi
CERTIFICATION=NONCERT
BUILD_CONF_PATH=$BUILD_ROOT_DIR/buildscript/build_conf/${MODEL}
BUILD_CONF=${BUILD_CONF_PATH}/common_build_conf.${MODEL}
case $1 in
clean)
echo "Not support... remove kernel out directory by yourself"
exit 1
;;
*)
BOARD_KERNEL_BASE=0x00000000
BOARD_KERNEL_PAGESIZE=4096
BOARD_KERNEL_TAGS_OFFSET=0x01E00000
BOARD_RAMDISK_OFFSET=0x02000000
BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 androidboot.bootdevice=7824900.sdhci earlycon=msm_hsl_uart,0x78af000"
mkdir -p $BUILD_KERNEL_OUT_DIR
;;
esac
KERNEL_ZIMG=$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/Image.gz-dtb
DTC=$BUILD_KERNEL_OUT_DIR/scripts/dtc/dtc
FUNC_CLEAN_DTB()
{
if ! [ -d $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts ] ; then
echo "no directory : "$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts""
else
echo "rm files in : "$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/*.dtb""
rm $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/*.dtb
fi
}
INSTALLED_DTIMAGE_TARGET=${PRODUCT_OUT}/dt.img
DTBTOOL=$BUILD_KERNEL_DIR/tools/dtbTool
FUNC_BUILD_DTIMAGE_TARGET()
{
echo ""
echo "================================="
echo "START : FUNC_BUILD_DTIMAGE_TARGET"
echo "================================="
echo ""
echo "DT image target : $INSTALLED_DTIMAGE_TARGET"
if ! [ -e $DTBTOOL ] ; then
if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then
mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin
fi
cp $BUILD_KERNEL_DIR/tools/dtbTool $DTBTOOL
fi
cp $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/samsung/sdm450/*.dtb $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/.
echo "$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \
-p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/"
$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \
-p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/
chmod a+r $INSTALLED_DTIMAGE_TARGET
echo ""
echo "================================="
echo "END : FUNC_BUILD_DTIMAGE_TARGET"
echo "================================="
echo ""
}
FUNC_BUILD_KERNEL()
{
echo ""
echo "=============================================="
echo "START : FUNC_BUILD_KERNEL"
echo "=============================================="
echo ""
echo "build MODEL="$MODEL""
echo "build CARRIER="$CARRIER""
echo "build CERTIFICATION="$CERTIFICATION""
echo "build project="$PROJECT_NAME""
echo "build common config="$KERNEL_DEFCONFIG ""
echo "build variant config="$VARIANT_DEFCONFIG ""
echo "build secure option="$SECURE_OPTION ""
echo "build SEANDROID option="$SEANDROID_OPTION ""
echo "build selinux defconfig="$SELINUX_DEFCONFIG ""
echo "build selinux log defconfig="$SELINUX_LOG_DEFCONFIG ""
echo "build tima defconfig="$TIMA_DEFCONFIG ""
echo "build dmverity defconfig="$DMVERITY_DEFCONFIG""
echo "build kaslr defconfig="$KASLR_DEFCONFIG""
if [ "$BUILD_COMMAND" == "" ]; then
SECFUNC_PRINT_HELP;
exit -1;
fi
FUNC_CLEAN_DTB
if [[ "${SEC_BUILD_OPTION_EXTRA_BUILD_CONFIG}" != *"kasan"* ]] && \
[[ "${SEC_BUILD_OPTION_EXTRA_BUILD_CONFIG}" != *"ubsan"* ]];
then
KCFLAGS=-mno-android
fi
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE KCFLAGS=$KCFLAGS \
VARIANT_DEFCONFIG=$VARIANT_DEFCONFIG \
DEBUG_DEFCONFIG=$DEBUG_DEFCONFIG $KERNEL_DEFCONFIG \
SELINUX_DEFCONFIG=$SELINUX_DEFCONFIG \
SELINUX_LOG_DEFCONFIG=$SELINUX_LOG_DEFCONFIG \
DMVERITY_DEFCONFIG=$DMVERITY_DEFCONFIG \
KASLR_DEFCONFIG=$KASLR_DEFCONFIG || exit -1
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE KCFLAGS=$KCFLAGS || exit -1
rsync -cv $KERNEL_ZIMG $PRODUCT_OUT/kernel
FUNC_BUILD_DTIMAGE_TARGET
echo ""
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
FUNC_MKBOOTIMG()
{
echo ""
echo "==================================="
echo "START : FUNC_MKBOOTIMG"
echo "==================================="
echo ""
MKBOOTIMGTOOL=$BUILD_ROOT_DIR/android/kernel/tools/mkbootimg
if ! [ -e $MKBOOTIMGTOOL ] ; then
if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then
mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin
fi
cp $BUILD_ROOT_DIR/anroid/kernel/tools/mkbootimg $MKBOOTIMGTOOL
fi
echo "Making boot.img ..."
echo " $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \
--ramdisk $PRODUCT_OUT/ramdisk.img \
--output $PRODUCT_OUT/boot.img \
--cmdline "$BOARD_KERNEL_CMDLINE" \
--base $BOARD_KERNEL_BASE \
--pagesize $BOARD_KERNEL_PAGESIZE \
--ramdisk_offset $BOARD_RAMDISK_OFFSET \
--tags_offset $BOARD_KERNEL_TAGS_OFFSET \
--dt $INSTALLED_DTIMAGE_TARGET"
$MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \
--ramdisk $PRODUCT_OUT/ramdisk.img \
--output $PRODUCT_OUT/boot.img \
--cmdline "$BOARD_KERNEL_CMDLINE" \
--base $BOARD_KERNEL_BASE \
--pagesize $BOARD_KERNEL_PAGESIZE \
--ramdisk_offset $BOARD_RAMDISK_OFFSET \
--tags_offset $BOARD_KERNEL_TAGS_OFFSET \
--dt $INSTALLED_DTIMAGE_TARGET
if [ "$SEANDROID_OPTION" == "-E" ] ; then
FUNC_SEANDROID
fi
if [ "$SECURE_OPTION" == "-B" ]; then
FUNC_SECURE_SIGNING
fi
cd $PRODUCT_OUT
if [ -e $PRODUCT_OUT/boot.img ] ; then
tar cvf boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar boot.img
fi
if [ -e $PRODUCT_OUT/recovery.img ] ; then
tar cvf recovery_${MODEL}_${CARRIER}_${CERTIFICATION}.tar recovery.img
fi
cd $BUILD_ROOT_DIR
if ! [ -d output ] ; then
mkdir -p output
fi
echo ""
echo "================================================="
echo "-->Note, copy to $BUILD_TOP_DIR/../output/ directory"
echo "================================================="
if [ -e $PRODUCT_OUT/boot.img ] ; then
cp $PRODUCT_OUT/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar $BUILD_ROOT_DIR/output/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar || exit -1
fi
if [ -e $PRODUCT_OUT/recovery.img ] ; then
cp $PRODUCT_OUT/recovery_${MODEL}_${CARRIER}_${CERTIFICATION}.tar $BUILD_ROOT_DIR/output/recovery_${MODEL}_${CARRIER}_${CERTIFICATION}.tar || exit -1
fi
echo ""
echo "==================================="
echo "END : FUNC_MKBOOTIMG"
echo "==================================="
echo ""
}
FUNC_SEANDROID()
{
if [ -e $PRODUCT_OUT/boot.img ] ; then
echo -n "SEANDROIDENFORCE" >> $PRODUCT_OUT/boot.img
fi
if [ -e $PRODUCT_OUT/recovery.img ] ; then
echo -n "SEANDROIDENFORCE" >> $PRODUCT_OUT/recovery.img
fi
}
FUNC_SECURE_SIGNING()
{
if [ -e $PRODUCT_OUT/boot.img ] ; then
echo "java -jar $SECURE_SCRIPT -model $SIGN_MODEL -runtype ss_openssl_sha -input $PRODUCT_OUT/boot.img -output $PRODUCT_OUT/signed_boot.img"
openssl dgst -sha256 -binary $PRODUCT_OUT/boot.img > sig_32
java -jar $SECURE_SCRIPT -runtype ss_openssl_sha -model $SIGN_MODEL -input sig_32 -output sig_256
cat $PRODUCT_OUT/boot.img sig_256 > $PRODUCT_OUT/signed_boot.img
mv -f $PRODUCT_OUT/boot.img $PRODUCT_OUT/unsigned_boot.img
mv -f $PRODUCT_OUT/signed_boot.img $PRODUCT_OUT/boot.img
fi
if [ -e $PRODUCT_OUT/recovery.img ] ; then
echo "java -jar $SECURE_SCRIPT -model $SIGN_MODEL -runtype ss_openssl_sha -input $PRODUCT_OUT/recovery.img -output $PRODUCT_OUT/signed_recovery.img"
openssl dgst -sha256 -binary $PRODUCT_OUT/boot.img > sig_32
java -jar $SECURE_SCRIPT -runtype ss_openssl_sha -model $SIGN_MODEL -input sig_32 -output sig_256
cat $PRODUCT_OUT/recovery.img sig_256 > $PRODUCT_OUT/signed_recovery.img
mv -f $PRODUCT_OUT/recovery.img $PRODUCT_OUT/unsigned_recovery.img
mv -f $PRODUCT_OUT/signed_recovery.img $PRODUCT_OUT/recovery.img
fi
CERTIFICATION=CERT
}
SECFUNC_PRINT_HELP()
{
echo -e '\E[33m'
echo "Help"
echo "$0 \$1 \$2 \$3"
echo " \$1 : "
echo " a6plte_eur_open"
echo " a6plte_sea_open"
echo " a6plte_ltn_open"
echo " a6plte_chn_open"
echo " a6plte_kor_ktt"
echo " j8plte_cis_ser"
echo " j8plte_eur_open"
echo " j8plte_sea_open"
echo " j8plte_chn_open"
echo " j8plte_chn_cmcc"
echo " gta2xllte_eur_open"
echo " gta2xllte_sea_open"
echo " gta2xllte_usa_spr"
echo " gta2xllte_usa_vzw"
echo " gta2xllte_can_single"
echo " gta2xllte_chn_open"
echo " gta2xllte_chn_hk"
echo " gta2xllte_cis_ser"
echo " gta2xlwifi_chn_open"
echo " gta2xlwifi_cis_ser"
echo " \$2 : "
echo " -B or Nothing (-B : Secure Binary)"
echo " \$3 : "
echo " -E or Nothing (-E : SEANDROID Binary)"
echo -e '\E[0m'
}
function set_export_var() {
local __var_name=${1}
local __value=${2}
local __export_var=${3}
[ "${__value}x" == "x" ] && \
__value=false
echo "set sxport var for ${__export_var}"
if [[ "${BUILD_CONF}x" != "x" && -f ${BUILD_CONF} ]]; then
local __get_var=$(grep ${__var_name} ${BUILD_CONF} | tr -d ' ')
if [[ "${__get_var}x" != "x" && "${__get_var:0:1}" != "#" ]]; then
__value=$(echo "${__get_var}" | cut -d '#' -f1 | cut -d '=' -f2 | tr -d ' ')
fi
fi
export ${__export_var}=${__value}
echo "${__export_var}=${__value}"
}
SET_SEC_VARIABLE()
{
set_export_var fingerprint-tz \
${sec_conf_use_fingerprint_tz} \
SEC_BUILD_CONF_USE_FINGERPRINT_TZ
set_export_var fingerprint-nontz \
${sec_conf_use_fingerprint_nontz} \
SEC_BUILD_CONF_USE_FINGERPRINT_NONTZ
set_export_var iris-tz \
${sec_conf_use_iris_tz} \
SEC_BUILD_CONF_USE_IRIS_TZ
}
# MAIN FUNCTION
rm -rf ./build.log
(
START_TIME=`date +%s`
SET_SEC_VARIABLE
FUNC_BUILD_KERNEL
#FUNC_RAMDISK_EXTRACT_N_COPY
FUNC_MKBOOTIMG
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
) 2>&1 | tee -a ./build.log