-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsuperr
executable file
·6701 lines (6686 loc) · 199 KB
/
superr
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
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Do not edit this file unless you know what you are doing
banner() {
echo "$clears"
echo ""
echo "------------------------------------------------------"
echo "$bold$stand SuperR's Kitchen $normal"
echo "$italic$stand Author/原作者: SuperR $normal"
echo " Chinese/汉化: cofface (cofface@cofface.com) "
echo "------------------------------------------------------"
echo ""
}
assert_devices() {
isassertdevices
if [[ -d $prfiles/boot ]]; then
assertdir="$prfiles/boot"
else
assertdir="$prfiles"
fi
cd $usdir
if [[ $(grep -o "#ASSERT" updater-script) = "" ]]; then
sed -i '1i#ASSERT' updater-script
fi
if [[ $(grep -o "#ASSERT" updater-script) = "" ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_asserts_no_assert"
echo ""
read -p "$t_enter_rom_tools"
rom_tools
return 1
fi
while [[ ! ${assertch} =~ ^[1-4]$ ]] && [[ ! $assertch = "m" && ! $assertch = "q" ]]; do
banner
echo "$bluet$t_startup_project $greent$romname$normal"
echo "$bluet$t_startup_version $greent$androidversion$normal"
echo ""
echo "$yellowb$redt$t_menu_asserts$normal"
echo ""
echo "1) $t_menu_add_assert ($bluet$t_title_current$greent$assertdevices$normal)"
echo "2) $t_menu_asserts_custom ($bluet$t_title_current$greent$assertcustom1$normal)"
echo "3) $t_menu_asserts_reset"
echo "${yellowt}4) $t_menu_rom_tools"
echo "m = $t_title_main"
echo "${magentat}q = $t_menu_quit$normal"
echo ""
read -n 1 -p "$t_select" assertch
done
# START ROM Tools menu
if [[ $assertch = "4" ]]; then
rom_tools
return 1
# START Main menu
elif [[ $assertch = "m" ]]; then
cd $base
exec ./superr
return 1
# START Quit
elif [[ $assertch = "q" ]]; then
echo ""
echo ""
exit
fi
grep " getprop(\|(getprop(" updater-script > $assertdir/assert_original
grep -v " getprop(\|(getprop(" updater-script > updater-script2
mv updater-script2 updater-script
# START Add/Remove Device asserts
if [[ $assertch = "1" ]]; then
rm -rf $assertdir/assertdevice
rm -rf $assertdir/assert
banner
echo "$t_asserts_current $greent$assertdevices$normal"
echo ""
echo -e "$t_asserts_enter"
echo ""
echo "${yellowt}surnia,surnia_cdma,xt1526$normal"
echo ""
read -e -i "$devicename" -p "" assertdevice2
banner
echo "$bluet$t_asserts_prep$normal"
assertdevice=$(echo "$assertdevice2" | sed 's/\ //g')
echo "$assertdevice" | tr , '\n' > $assertdir/assertdevice
cd $assertdir
cat $tools/updater/custom/assert >> assert
firstdevice=$(head -1 assertdevice)
sed -i "s/#DEVICENAME/$firstdevice/g" assert
cat assertdevice | while read line; do
if [[ $(grep -o "\"$line\"" assert) = "" ]]; then
cat $tools/updater/custom/device >> assert
sed -i "s/#DEVICENAME/$line/g" assert
sed -i "s/#DEVICECHK/$devicechk/g" assert
fi
done
cat $tools/updater/custom/abort2 >> assert
sed -i "s/#DEVICECHK/$devicechk/g" assert
sed -i "s/#ASSERTDEVICE/$assertdevice/g" assert
# START Add Custom assert
elif [[ $assertch = "2" ]]; then
banner
echo -e "$t_asserts_type"
echo ""
echo "${yellowt}ro.baseband=1.09.20.1112$normal"
echo ""
read -e -p "" assertcustom
banner
echo "$bluet$t_asserts_prep_cust$normal"
propname=$(echo "$assertcustom" | cut -d"=" -f1)
propvalue=$(echo "$assertcustom" | cut -d"=" -f2)
cd $assertdir
cat $tools/updater/custom/assertcustom >> assertcustom
sed -i "s/#PROPNAME/$propname/g; s/#PROPVALUE/$propvalue/g" assertcustom
# START Reset asserts to default
elif [[ $assertch = "3" ]]; then
cd $assertdir
rm -rf assert assertcustom assertdevice
cat $tools/updater/custom/assert >> assert
cat $tools/updater/custom/abort >> assert
sed -i "s/#DEVICENAME/$devicename/g" assert
sed -i "s/#DEVICECHK/$devicechk/g" assert
sed -i '/#ASSERT/ r assert' $usdir/updater-script
assertch=""
assert_devices
return 1
fi
if [[ -f assertcustom ]]; then
grep "ro.product.device" assert > assert-2
mv assert-2 assert
cat assertcustom >> assert
fi
sed -i '/#ASSERT/ r assert' $usdir/updater-script
assertch=""
if [[ $assertdir != "$prfiles/boot" ]]; then
assert_devices
fi
return 1
}
boot_dmverity() {
banner
echo "${bluet}Removing dm-verity ...$normal"
vtmp=",verify=${byname}\/metadata verify=${byname} ,verify verify"
for i in $vtmp; do
if [[ $(${usesudo}grep "$i" $fstab) != "" ]]; then
${usesudo}sed -i "s/$i//g" $fstab
fi
done
}
boot_forcee() {
if [[ $forceestatus = "Yes" ]]; then
banner
read -n 1 -p "$t_boot_forcee_rem_ask" reply
if [[ ! $reply = "y" ]]; then
boot_tools
return 1
fi
banner
echo "$bluet$t_boot_rem_forcee$normal"
fetmp="forceencrypt forcefdeorfbe fileencryption"
for i in $fetmp; do
if [[ ! $(${usesudo}grep "/data" $fstab | grep "$i") = "" ]]; then
${usesudo}sed -i "/\/data/s/$i/encryptable/g" $fstab
touch $prfiles/$i
fi
done
banner
echo "$greent$t_boot_forsee_rem$normal"
echo ""
read -p "$t_enter_boot_menu"
else
banner
read -n 1 -p "$t_boot_forcee_add_ask" reply
if [[ ! $reply = "y" ]]; then
boot_tools
return 1
fi
banner
echo "$bluet$t_boot_add_forcee$normal"
if [[ -f $prfiles/forcefdeorfbe ]]; then
${usesudo}sed -i '/\/data/s/encryptable/forcefdeorfbe/g' $fstab
elif [[ -f $prfiles/forceencrypt ]]; then
${usesudo}sed -i '/\/data/s/encryptable/forceencrypt/g' $fstab
fi
rm -rf $prfiles/forcefdeorfbe $prfiles/forceencrypt
banner
echo "$greentt_boot_forcee_add$normal"
echo ""
read -p "$t_enter_boot_menu"
fi
boot_tools
return 1
}
boot_initd() {
if [[ $chosenimg = "recovery" ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_warn$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
if [[ -f $romdir/system/init.rc ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo -e "$redt$t_boot_initd_pixel$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
if [[ $initdstatus = "No" ]]; then
${usesudo}cp -r $tools/boot/initd/bootimg $romdir/
${usesudo}sed -i '1iimport /init.d_support.sh' $ramdir/init.rc
mkdir -p $sysdir/etc/init.d
touch $sysdir/etc/init.d/placeholder
if [[ -d $prfiles/init.d ]]; then
rm -rf $sysdir/etc/init.d
mv $prfiles/init.d $sysdir/etc/
fi
banner
echo "$greent$t_boot_initd_add$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
else
banner
echo "$greent$t_boot_already_initd$normal"
echo ""
read -n 1 -p "$t_boot_initd_rem_q"
echo ""
echo ""
if [[ $REPLY = "y" ]]; then
if [[ -d $sysdir/etc/init.d ]]; then
mv $sysdir/etc/init.d $prfiles/
fi
if [[ -f $sysdir/bin/sysinit && ! $(grep "init.d" $sysdir/bin/sysinit) = "" ]]; then
rm -rf $sysdir/bin/sysinit
fi
cd $ramdir
rm -rf $sysdir/etc/init.d
${usesudo}rm -rf $ramdir/sbin/sysinit.sh
${usesudo}rm -rf $ramdir/init.d_support.sh
${usesudo}grep -v "init.d_support" init.rc > init.rc2
${usesudo}mv init.rc2 init.rc
${usesudo}sed -i "s/[[:blank:]]*$//" init.rc
${usesudo}gawk 'BEGIN{x=1} /init.d/{x=!x;next} x{print}' init.rc > init.rc2
${usesudo}sed -i '${/^$/d;}' init.rc2
${usesudo}mv init.rc2 init.rc
isinitd
if [[ $initdstatus = "Yes" ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_initd_cant$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
banner
echo "$greent$t_boot_initd_rem$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
else
boot_tools
return 1
fi
fi
}
boot_insecure() {
if [[ $chosenimg = "recovery" ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_warn$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
if [[ $insecurestatus = "No" ]]; then
if [[ ! $(${usesudo}grep "ro.secure=1" $dfprop) = "" ]]; then
${usesudo}sed -i 's/ro\.secure=1/ro\.secure=0/' $dfprop
else
${usesudo}gawk 'a=/^#/{b=1}b&&!a{print "ro\.secure=0";b=0}1' $dfprop > ${dfprop}2
${usesudo}mv ${dfprop}2 $dfprop
fi
if [[ ! $(${usesudo}grep "ro.adb.secure=1" $dfprop) = "" ]]; then
${usesudo}sed -i 's/ro\.adb\.secure=1/ro\.adb\.secure=0/' $dfprop
else
${usesudo}gawk 'a=/ro\.secure=0/{b=1}b&&!a{print "ro\.adb\.secure=0";b=0}1' $dfprop > ${dfprop}2
${usesudo}mv ${dfprop}2 $dfprop
fi
banner
echo "$greent$t_boot_insecure$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
else
banner
echo "$greent$t_boot_already_insecure$normal"
echo ""
read -n 1 -p "$t_boot_secure_ask"
echo ""
echo ""
if [[ $REPLY = "y" ]]; then
${usesudo}sed -i 's/ro\.secure=0/ro\.secure=1/' $dfprop
${usesudo}sed -i 's/ro\.adb\.secure=0/ro\.adb\.secure=1/' $dfprop
banner
echo "$greentt_boot_secure$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
else
boot_tools
return 1
fi
fi
}
boot_repack() {
if [[ $bootext = "" ]]; then
banner
echo "$bluet$t_boot_repack $chosenimg2 ...$normal"
echo ""
fi
if [[ ! -d $prfiles/${chosenimg}_orig ]]; then
mkdir -p $prfiles/${chosenimg}_orig
cp $romdir/$chosenimg2 $prfiles/${chosenimg}_orig/
fi
${usesudo}mv $romdir/${chosenimg}img/ramdisk $AIK/
${usesudo}mv $romdir/${chosenimg}img/split_img $AIK/
cd $AIK
${usesudo}./repackimg.$script 2>&1 >> $logs/boot.log
if [[ $? = "1" ]]; then
${usesudo}mv $AIK/ramdisk $romdir/${chosenimg}img/
${usesudo}mv $AIK/split_img $romdir/${chosenimg}img/
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_repack_problem $chosenimg$normal"
echo ""
read -p "$t_enter_continue"
if [[ $bootext = "" ]]; then
boot_tools
fi
else
${usesudo2}chown -hR $myuser:$myuser image-new.img
cp image-new.img $romdir/${chosenimg}.img
${usesudo}./cleanup.sh 2>&1 >> $logs/boot.log
rm -rf $romdir/${chosenimg}img
fi
if [[ $islg = "lge" ]]; then
$tools/open_bump.py $chosenimg.img
mv ${chosenimg}_bumped.img $chosenimg.img
if [[ $bootext = "" ]]; then
echo "$greent$t_boot_bump_rename $chosenimg.img$normal"
echo ""
fi
fi
if [[ $bootext = "" ]]; then
banner
echo "$greent$chosenimg.img$t_boot_packed_d$normal"
echo ""
read -p "$t_enter_continue"
boot_tools
fi
cd $romdir
bootext=""
return 1
}
choose_img() {
chosenimg2=""
findimg=$(ls $romdir | grep "^boot\.img$\|^recovery\.img$\|^kernel\.elf$")
countimg=$(echo "$findimg" | wc -l)
if [[ $countimg = "1" ]]; then
chosenimg2="$findimg"
elif [[ $countimg -gt "1" ]]; then
while [[ $chosenimg2 = "" ]]; do
banner
echo "$bluet$t_startup_project $greent$romname$normal"
echo "$bluet$t_startup_version $greent$androidversion$normal"
echo ""
echo "$yellowb$redt$t_title_cho_boot$normal"
echo ""
choosepr imgcho in ${findimg[@]}
if [[ $REPLY = "q" ]]; then
exit
elif [[ $REPLY = "m" ]]; then
cd $base
exec ./superr
return 1
else
chosenimg2="$imgcho"
fi
done
fi
if [[ $chosenimg2 = "boot.img" || $chosenimg2 = "kernel.elf" ]]; then
chosenimg="boot"
elif [[ $chosenimg2 = "recovery.img" ]]; then
chosenimg="recovery"
fi
}
boot_tools() {
banner
echo "$bluet$t_boot_status$normal"
timestamp=$(date +%m-%d-%Y-%H:%M:%S)
dmveritystatus=""
forceestatus=""
dmveritystatus1=""
forceestatus1=""
insecurestatus=""
initdstatus=""
insecurestatus1=""
initdstatus1=""
islg=""
if [[ -f $sysdir/build.prop ]]; then
api=$(grep "ro.build.version.sdk" $sysdir/build.prop | cut -d"=" -f2)
androidversion=$(grep "ro.build.version.release" $sysdir/build.prop | cut -d"=" -f2)
elif [[ -f $romdir/build.prop ]]; then
api=$(grep "ro.build.version.sdk" $romdir/build.prop | cut -d"=" -f2)
androidversion=$(grep "ro.build.version.release" $romdir/build.prop | cut -d"=" -f2)
else
api="${redt}N/A"
androidversion="${redt}N/A"
fi
if [[ -f $tools/open_bump.py ]]; then
if [[ -f $sysdir/build.prop ]]; then
islg=$(grep "ro.product.brand" $sysdir/build.prop | cut -d"=" -f2)
elif [[ -f $romdir/build.prop ]]; then
islg=$(grep "ro.product.brand" $romdir/build.prop | cut -d"=" -f2)
fi
if [[ $islg = "lge" ]]; then
bumped=""
bumpedr=""
cd $romdir
if [[ -f $romdir/recovery.img ]]; then
bumpedr=$($tools/open_bump.py recovery.img | grep "already bumped")
rm -rf recovery_bumped.img
else
bumped=$($tools/open_bump.py boot.img | grep "already bumped")
rm -rf boot_bumped.img
fi
if [[ ! $bumped = "" ]]; then
bumpstatus=$(echo "${greent}Yes")
else
bumpstatus=$(echo "${redt}No")
fi
if [[ ! $bumpedr = "" ]]; then
bumpstatusr=$(echo "${greent}Yes")
else
bumpstatusr=$(echo "${redt}No")
fi
fi
fi
if [[ ! -f $romdir/system/init.rc ]]; then
if [[ ! -d $romdir/bootimg && ! -d $romdir/recoveryimg ]]; then
prchoice="ext"
choose_img
else
if [[ -d $romdir/bootimg ]]; then
chosenimg="boot"
chosenimg2="boot.img"
elif [[ -d $romdir/recoveryimg ]]; then
chosenimg="recovery"
chosenimg2="recovery.img"
fi
fi
ramdir="$romdir/${chosenimg}img/ramdisk"
dfprop="$ramdir/default.prop"
else
chosenimg="boot"
ramdir="$romdir/system"
if [[ -f $romdir/system/default.prop ]]; then
dfprop="$romdir/system/default.prop"
elif [[ -f $romdir/vendor/default.prop ]]; then
dfprop="$romdir/vendor/default.prop"
fi
fi
isdmverity
isforcee
isinitd
isinsecure
if [[ -d $romdir/${chosenimg}img || -f $romdir/system/init.rc ]]; then
choice=""
while [[ ! ${choice} =~ ^[1-5]$ ]] && [[ ! $choice = "m" && ! $choice = "q" ]]; do
banner
echo "$bluet$t_startup_project $greent$romname$normal"
echo "$bluet$t_startup_version $greent$androidversion$normal"
echo ""
echo "$yellowb$redt$t_title_boot$normal"
echo ""
if [[ ! -f $romdir/system/init.rc ]]; then
echo "1) $t_menu_pack_boot $chosenimg2"
fi
if [[ $chosenimg = "boot" ]]; then
echo "2) $t_menu_initd ($bluet$t_title_current$initdstatus1$normal)"
echo "3) $t_menu_insecure ($bluet$t_title_current$insecurestatus1$normal)"
echo "4) $t_menu_dmverity ($bluet$t_title_current$dmveritystatus1$normal)"
echo "5) $t_menu_forcee ($bluet$t_title_current$forceestatus1$normal)"
fi
echo "${yellowt}m = $t_title_main"
echo "${magentat}q = $t_menu_quit$normal"
echo ""
read -n 1 -p "$t_select" choice
if [[ -f $romdir/system/init.rc ]]; then
if [[ $choice = "1" ]]; then
choice=""
fi
fi
if [[ $chosenimg != "boot" ]]; then
if [[ ${choice} =~ ^[2-5]$ ]]; then
choice=""
fi
fi
done
# START Pack img, delete ramdisk
if [[ $choice = "1" ]]; then
boot_repack
return 1
# START Add/Remove init.d support
elif [[ $choice = "2" ]]; then
boot_initd
return 1
# START Insecure/Secure the boot.img
elif [[ $choice = "3" ]]; then
boot_insecure
return 1
# START Remove dm-verity
elif [[ $choice = "4" ]]; then
findfstab
if [[ $(${usesudo}grep "verify" $fstab) = "" ]]; then
banner
echo "${redb}${yellowt}${bold}$t_notice$normal"
echo "$redt$t_boot_already_dmverity$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
boot_dmverity
banner
echo "$greent$t_boot_dmverity_rem$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
# START Remove forceencrypt
elif [[ $choice = "5" ]]; then
if [[ -f $romdir/system/init.rc ]]; then
cd $romdir/system
else
cd $romdir/bootimg/ramdisk
fi
findfstab
boot_forcee
# START Main menu
elif [[ $choice = "m" ]]; then
cd $base
exec ./superr
return 1
# START Quit
elif [[ $choice = "q" ]]; then
echo ""
echo ""
exit
fi
fi
if [[ ! $chosenimg = "" ]]; then
choice=""
while [[ ! ${choice} =~ ^[1-3]$ ]] && [[ ! $choice = "m" && ! $choice = "q" ]]; do
banner
echo "$bluet$t_startup_project $greent$romname$normal"
echo "$bluet$t_startup_version $greent$androidversion$normal"
echo ""
echo "$yellowb$redt$t_title_boot$normal"
echo ""
echo "$redt$t_title_unpack$normal"
echo ""
if [[ $islg = "lge" && ! $bumpstatusr = "" ]]; then
echo "1) $t_menu_unpack $chosenimg2 ($bluet$t_title_bumped$bumpstatusr$normal)"
else
echo "1) $t_menu_unpack $chosenimg2"
fi
echo "2) $t_menu_boot_flashable $chosenimg"
if [[ $countimg -gt "1" ]]; then
echo "3) $t_menu_switch_boot"
fi
echo "${yellowt}m = $t_title_main"
echo "${magentat}q = $t_menu_quit$normal"
echo ""
read -n 1 -p "$t_select" choice
done
else
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_no_img $romname$normal"
echo ""
read -p "$t_enter_main_menu"
cd $base/
exec ./superr
return 1
fi
# START Unpack img
if [[ $choice = "1" ]]; then
boot_unpack
boot_tools
return 1
# START Build flashable
elif [[ $choice = "2" ]]; then
if [[ $chosenimg = "boot" && ! -f $romdir/boot.img ]]; then
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_no_img $romname$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
fi
if [[ ! -d $base/superr_$romname/00_project_files/logs ]]; then
mkdir -p $base/superr_$romname/00_project_files/logs
fi
get_devicename
if [[ $devicename = "" ]]; then
banner
echo "$redb$yellowt$t_error$normal"
echo "$redt$t_boot_prop_warn$normal"
echo ""
read -p "$t_enter_boot_menu"
boot_tools
return 1
else
mkdir -p $base/tools/devices/$devicename
deviceloc=""
deviceloc=$base/tools/devices/$devicename
fi
mkdir $prfiles/boot
cd $prfiles/boot
get_sig
get_byname
banner
echo "$bluet$t_boot_prep_build$normal"
if [[ -d $romdir/META-INF ]]; then
mv $romdir/META-INF $romdir/META-INF1
fi
cp -R $tools/updater/META-INF $romdir/
cp -R $tools/updater/config $romdir/
rm -rf $usdir/updater-script
if [[ $chosenimg = "recovery" ]]; then
signature2=$(echo "$signature-recovery")
signature3=$(echo "$signature1 Recovery")
cp $tools/updater/custom/updater-script-recovery $usdir/updater-script
elif [[ $chosenimg = "boot" ]]; then
signature2=$(echo "$signature-kernel")
signature3=$(echo "$signature1 Kernel")
if [[ -d $sysdir/etc/init.d ]]; then
cp $tools/updater/custom/updater-script-kernel-init $usdir/updater-script
else
cp $tools/updater/custom/updater-script-kernel $usdir/updater-script
fi
fi
part_setup
if [[ ! -f $prfiles/assert ]]; then
cd $prfiles/boot
cat $tools/updater/custom/assert >> assert
cat $tools/updater/custom/abort >> assert
sed -i "s/#DEVICENAME/$devicename/g" assert
sed -i "s/#DEVICECHK/$devicechk/g" assert
assertch="1"
assert_devices
else
cd $prfiles
sed -i '/#ASSERT/ r assert' $usdir/updater-script
fi
grep -v "#ASSERT" $usdir/updater-script > $usdir/updater-script2
mv $usdir/updater-script2 $usdir/updater-script
sed -i "s/#SIGNATURE/$signature3/g" $usdir/updater-script
sed -i "s/#DEVICENAME/$devicename/g" $usdir/updater-script
sed -i "s/#DEVICECHK/$devicechk/g" $usdir/updater-script
banner
if [[ $chosenimg = "recovery" ]]; then
echo "$bluet$signature2.zip $t_general_build $romname ...$normal"
cd $romdir
if [[ -f $signature2.zip ]]; then
mv $signature2.zip ${signature2}_$timestamp.zip
fi
$p7z a -tzip -mx5 $signature2.zip config recovery.img META-INF 2>/dev/null >> $logs/zip.log
elif [[ $chosenimg = "boot" && -f $romdir/boot.img ]]; then
echo "$bluet$signature2.zip $t_general_build $romname ...$normal"
cd $romdir
if [[ -f $signature2.zip ]]; then
mv $signature2.zip ${signature2}_$timestamp.zip
fi
if [[ -d $sysdir/etc/init.d ]]; then
$p7z a -tzip -mx5 $signature2.zip config boot.img system/etc/init.d META-INF 2>/dev/null >> $logs/zip.log
else
$p7z a -tzip -mx5 $signature2.zip config boot.img META-INF 2>/dev/null >> $logs/zip.log
fi
else
rm -rf $romdir/META-INF
if [[ -d $romdir/META-INF1 ]]; then
mv $romdir/META-INF1 $romdir/META-INF
fi
banner
echo "$redb$yellowt$bold$t_missing$normal"
echo "$redt$t_boot_no_img$normal"
echo ""
read -p "$t_enter_build_zip_menu"
boot_tools
return 1
fi
rm -rf $romdir/META-INF
if [[ -d $romdir/META-INF1 ]]; then
mv $romdir/META-INF1 $romdir/META-INF
fi
rm -rf $prfiles/boot
banner
echo "$greent$signature2.zip $t_general_create $romname$normal"
echo ""
signzip
read -p "$t_enter_boot_menu"
boot_tools
return 1
# START Boot/Recovery Menu
elif [[ $choice = "3" ]]; then
boot_tools
return 1
# START Main menu
elif [[ $choice = "m" ]]; then
cd $base
exec ./superr
return 1
# START Quit
elif [[ $choice = "q" ]]; then
echo ""
echo ""
exit
fi
}
boot_unpack() {
if [[ $bootext = "" ]]; then
banner
echo "$bluet$t_boot_unpack $chosenimg2 ...$normal"
echo ""
fi
if [[ -f $romdir/$chosenimg2 ]]; then
mkdir -p $romdir/${chosenimg}img
cd $AIK
${usesudo}./unpackimg.$script $romdir/$chosenimg2 2>&1 >> $logs/boot.log
if [[ $? = "1" ]]; then
rm -rf $romdir/${chosenimg}img ramdisk split_img
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_unpack_problem ${chosenimg}.img$normal"
echo ""
read -p "$t_enter_continue"
if [[ $bootext = "" ]]; then
boot_tools
fi
bootext=""
cd $romdir
return 1
fi
${usesudo}mv ramdisk $romdir/${chosenimg}img/
${usesudo}mv split_img $romdir/${chosenimg}img/
else
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_boot_need_img$normal"
echo ""
read -p "$t_enter_continue"
if [[ $bootext = "" ]]; then
boot_tools
fi
bootext=""
cd $romdir
return 1
fi
bootext=""
cd $romdir
}
build_custom_zip() {
docustzip() {
if [[ -f $signature2.zip ]]; then
mv $signature2.zip ${signature2}_$timestamp.zip
fi
$p7z a -tzip -mx5 $signature2.zip config system META-INF 2>/dev/null >> $logs/zip.log
rm -rf $romdir/META-INF
if [[ -d $romdir/META-INF1 ]]; then
mv $romdir/META-INF1 $romdir/META-INF
fi
}
timestamp=$(date +%m-%d-%Y-%H:%M:%S)
ready=""
isframe=""
isapp=""
islib=""
isprivapp=""
ismedia=""
isready () {
if [[ -d $sysdir/framework ]]; then
isframe="1"
fi
if [[ -d $sysdir/app ]]; then
isapp="1"
fi
if [[ -d $sysdir/lib ]]; then
islib="1"
fi
if [[ -d $sysdir/priv-app ]]; then
isprivapp="1"
fi
if [[ -d $sysdir/media ]]; then
ismedia="1"
fi
if [[ $isframe = "1" || $isapp = "1" || $islib = "1" || $isprivapp = "1" || $ismedia = "1" ]]; then
ready="1"
fi
}
isready
if [[ $ready = "1" ]]; then
banner
choice=""
while [[ ! ${choice} =~ ^[1-7]$ ]] && [[ ! $choice = "m" && ! $choice = "q" ]]; do
banner
echo "$bluet$t_startup_project $greent$romname$normal"
echo "$bluet$t_startup_version $greent$androidversion$normal"
echo ""
echo "$yellowb$redt$t_title_cho_cust_zip$normal"
echo ""
echo "1) $t_menu_fap"
echo "2) $t_menu_fapl"
echo "3) $t_menu_f"
echo "4) $t_menu_ap"
echo "5) $t_menu_l"
echo "6) $t_menu_m"
echo "${yellowt}7) $t_menu_build_menu"
echo "m = $t_title_main"
echo "${magentat}q = $t_menu_quit$normal"
echo ""
read -n 1 -p "$t_select" choice
done
# START Build zip menu
if [[ $choice = "7" ]]; then
build_zip
return 1
fi
# START Main menu
if [[ $choice = "m" ]]; then
cd $base
exec ./superr
return 1
fi
# START Exit
if [[ $choice = "q" ]]; then
echo ""
echo ""
exit
fi
byname=$(cat $deviceloc/superr_byname)
cd $prfiles
get_sig
banner
echo -e "$t_cust_deldir_q"
read -n 1 -p '' reply
if [[ $reply != "y" ]]; then
deldir="no"
fi
banner
echo "$bluet$t_cust_meta_prep$normal"
if [[ -d $romdir/META-INF ]]; then
mv $romdir/META-INF $romdir/META-INF1
fi
cp -R $tools/updater/META-INF $romdir/META-INF
cp -R $tools/updater/config $romdir/
rm -rf $usdir/updater-script
cp $tools/updater/custom/updater-script-system $usdir/updater-script
chosenimg="boot"
part_setup
if [[ ! -f assert ]]; then
cat $tools/updater/custom/assert >> assert
cat $tools/updater/custom/abort >> assert
sed -i "s/#DEVICENAME/$devicename/g" assert
sed -i "s/#DEVICECHK/$devicechk/g" assert
assertch="1"
assert_devices
else
sed -i '/#ASSERT/ r assert' $usdir/updater-script
fi
if [[ $deldir = "no" ]]; then
grep -v "delete_recursive\|Deleting" $usdir/updater-script > $usdir/updater-script2
mv $usdir/updater-script2 $usdir/updater-script
fi
grep -v "#ASSERT" $usdir/updater-script > $usdir/updater-script2
mv $usdir/updater-script2 $usdir/updater-script
sed -i "s/#SIGNATURE/$signature1/g" $usdir/updater-script
sed -i "s/#DEVICENAME/$devicename/g" $usdir/updater-script
sed -i "s/#DEVICECHK/$devicechk/g" $usdir/updater-script
if [[ $choice = "1" || $choice = "2" || $choice = "4" ]]; then
cd $romdir
find $sysdir $romdir/vendor 2>/dev/null | sed 's/^/\//' | sed "s/$romdir//g"| sort > $prfiles/all_files.txt
cd $prfiles
rm -rf symlinks
cp symlinks.orig symlinks
grep "/system/app\|/system/priv-app" all_files.txt | cut -d"/" -f1-4 | grep -v "^/system/app$\|^/system/priv-app$" | sort -u >> appsym
line=""
grep "/system/app" symlinks | cut -d"\"" -f4 | cut -d"/" -f1-4 | while read line; do
if [[ ! "$line" = $(grep "^$line$" appsym) ]]; then
grep -v "$line" symlinks > symlinks2
mv symlinks2 symlinks
fi
done
line=""
grep "/system/priv-app" symlinks | cut -d"\"" -f4 | cut -d"/" -f1-4 | while read line; do
if [[ ! "$line" = $(grep "^$line$" appsym) ]]; then
grep -v "$line" symlinks > symlinks2
mv symlinks2 symlinks
fi
done
sort -u symlinks > symlinks2
mv symlinks2 symlinks
rm -rf appsym
grep "/system/app/\|/system/priv-app/" symlinks | sort >> symlinks_lib
sed -i '1iui_print(\"\");' symlinks_lib
sed -i '1iui_print(\"Creating symlinks...\");' symlinks_lib
sed -i '/#SYM/ r symlinks_lib' $usdir/updater-script
rm -rf symlinks_lib
cd $usdir
grep -v "#SYM" updater-script > updater-script2
mv updater-script2 updater-script
if [[ -d $sysdir/app || -d $sysdir/priv-app ]]; then
if [[ "$odexstatus" = "Deodexed" ]]; then
banner
read -n 1 -p "$t_zipalign_q" reply
echo ""
echo ""
if [[ $reply = "y" ]]; then
dozipalign
cd $usdir
fi
fi
else
banner
echo "$redb$yellowt$bold$t_error$normal"
echo "$redt$t_cust_no_app_priv $romname$normal"
echo ""
read -p "$t_enter_build_menu"
build_zip
return 1
fi
else
cd $usdir
grep -v "#SYM" updater-script > updater-script2
mv updater-script2 updater-script
fi
banner
# START framework, app, priv-app
if [[ $choice = "1" ]]; then
if [[ ! $isframe = "" && ! $isapp = "" && ! $isprivapp = "" ]]; then
signature2=$(echo "$signature-afp")
echo "$bluet$signature2.zip $t_general_build $romname ...$normal"
cd $usdir
grep -v "\"/system/lib\"\|\"/system/lib64\"\|\"/system/media\"" updater-script > updater-script2
mv updater-script2 updater-script
cd $romdir
mv system system1
mkdir system
mv system1/app system/
mv system1/framework system/
mv system1/priv-app system/
docustzip
mv system/app system1/
mv system/framework system1/
mv system/priv-app system1/
rm -rf system
mv system1 system
else
rm -rf $romdir/META-INF
if [[ -d $romdir/META-INF1 ]]; then
mv $romdir/META-INF1 $romdir/META-INF
fi
banner
echo "$redb$yellowt$bold$t_missing$normal"
echo "$redt$t_cust_not_exist$normal"
echo ""
read -p "$t_enter_build_menu"
build_zip
return 1
fi
# START framework, app, priv-app, lib
elif [[ $choice = "2" ]]; then
if [[ ! $isframe = "" && ! $isapp = "" && ! $isprivapp = "" && ! $islib = "" ]]; then
signature2=$(echo "$signature-aflp")
echo "$bluet$signature2.zip $t_general_build $romname ...$normal"
cd $usdir
if [[ -d $sysdir/lib64 ]]; then
grep -v "\"/system/media\"" updater-script > updater-script2
else