-
Notifications
You must be signed in to change notification settings - Fork 42
/
auto_patcher
executable file
·2218 lines (2020 loc) · 83.9 KB
/
auto_patcher
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
# The MIT License (MIT)
#
# Copyright (c) 2012, 2013-4 Mateor
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Look after changelog for script/patch version info.
# PDroid created by svyat. Official PDroid thread is
# http://forum.xda-developers.com/showthread.php?t=1357056
# The Auto-Patcher was created by pastime1971 and mateorod
# Thread and support for the Auto-Patcher can be found at
# http://forum.xda-developers.com/showthread.php?p=27589651#post27589651
# ChangeLog
# 2012.05.00. (v0.1)
# 2012.05.12. (v0.2) allows user to specify a different version of patches
# 2012.05.13. (v0.3.0) force "patch -N", remove temp upon failure, generate log output
# 2012.05.13. (v0.3.1) revised the generation of updater-script (SGS2)
# 2012.05.15. added AOSP patches
# 2012.05.15. added crespo-aosp patches; device-specific patching if patch exists
# 2012.05.15. remove restore.zip upon failure
# 2012.05.15. (v0.4.1) added CM7 (GB) patches
# 2012.05.18. (v0.4.2) added checking for tool commands
# 2012.05.21. (v0.4.3) apply device-specific patches only when it is specified
# 2012.05.26. added task title to log
# 2012.05.31. (v0.4.4) CM9 patches updated, crespo-aosp added
# 2012.06.04. (v0.4.5) added checking tools and rom, added aroma installer support
# add patch outputs reroute
# 2012.06.15. CM9 patches updated
# 2012.06.16. (v0.4.6) AOKP patches updated, patch versions restructured
# 2012.06.17. (v0.5.0) patcher script reorganized, removed build.prop
# 2012.06.17. (v0.6.0) auto patcher script for pdroid and v6 patches
# 2012.06.19. (v0.6.1) add patches for CM7.2 Final
# 2012.06.20. (v0.6.2) updated CM 7.2 patches
# 2012.06.23. (v0.6.3) fix symlinks
# 2012.06.26. (v0.6.4) added 0618 patches for cm7 nightlies; removed 0619 cm7.2 final
# 2012.06.27. (v0.6.5) added new CM9 patches (20120626)
# 2012.06.27. (v0.6.6) added CM7 nightly patches (20120625) (finally!)
# 2012.07.02. (v0.7.0) Redid AOSP/AOKP; add Windows support (using Cygwin). Thanks kobik77!
# 2012.07.06. (v0.7.1) updated CM9 patches (20120706)
# 2012.07.08. (v0.7.2) updated AOKP (20120707) and CM9 (20120708) pdroid patches
# 2012.07.11. (v1.0.0) reworked script works on Linux, Mac OSX, and Windows (on Cygwin);
# added new ICS/JellyBean support for the new V6-Supercharger
# 2012.07.18. (v1.0.1) new CM7/CM9 Pdroid patches (20120718)
# 2012.07.23. (v1.0.2) updated CM9 patches (20120723)
# 2012.07.23. (v1.0.3) updated CM9 patches (20120724)
# 2012.08.06. (v1.5.0) updated smali/baksmali binaries to 1.33
# 2012.08.06. Added Pdroid/V6supercharger support for CM10 Jellybean!
# 2012.08.06. Improved PDroid stability and efficiency (Thanks CollegeDev)
# 2012.08.06. (v1.6.0) added aokp-jb patches for pdroid/v6supercharger, script update
# 2012.08.17. (v1.9.5) Added support for pdroid_addon, by CollegeDev.
# Added insecure boot.img mod
# Added support for aosp-jb (This needs testing, and may not be
# a wide patch due to large variation between AOSP roms.
# -Please report all experiences!
# Updated all v6supercharger patches w/new edits to ProcessList
# Major script overhaul in preparation for additional mods!
# 2012.08.20. (v1.9.6) Conditional support for Official cm10 and aokp-jb builds
# 2012.08.23. (v1.9.7) Final/confirmed pdroid support for Official CM10 and AOKP-JB
# 2012.09.04 (v1.9.8) Bundled cygwin-compatible tools (original was corrupt).
# For Cygwin, replaced h2b function with simple bash math
# conversion (req'd for compat w/ Cygwin tools).
# 2012.08.26. (v2.0.0) Added .apk patching
# Added 3G Dongle support for Nexus 7 (trevd)
# TabletUI support for Nexus 7 (maybe more)
# Google Voice support for Nexus 7
# mods are 3gdongle, tabletUI, voice, or nexus7suite (for all)
# Added provisional file copy menu to widen patching base
# 2012.09.11. (v2.0.1) Cygwin support fixes
# 2012.09.11. (v2.0.2) Bugfix for 3gdongle (all)
# 2012.09.16. (v2.1.0) Significant restructuring of core operations; added edit text file
# fix for "method-cap" errors in pdroid.
# 2012.09.20. (v2.1.1) Fix for Phone FC's; OSX support finalized; ContentResolver resolved
# 2012.09.28. (v2.1.2) Hotfix for failed pdroid patching. Logging improvements.
# 2012.10.07. (v2.1.5) Final pdroid support for CM7.2 Official Releases
# Added aosp-mod patches for pdroid patching of AOSP kangs
# Switched to Chainfire's (f)aapt for speed/space reasons
# 2012.10.13. (v2.1.6) New PDroid patches for aokp-jb and cm10 4.1.2
# Revert (f)aapt- temporary due to reported issues
# 2012.10.15. (v2.17) New (again) CM10 pdroid patches.
# Move files to be copied into $p/$R/$B
# -This required a bunch of file moving-report broken symlinks.
# Some error check on the old RIL delete functions (thanks bundrik)
# 2012.10.16. (v2.1.7.5) Fix FC on phone with CM10 pdroid patches
# 2012.10.19. (v2.1.9) Testing CM10 support for PDroid Extension by CollegeDev.
# 2012.10.22. (v2.2.0) aosp/aokp and cm10 support for pdroid extension by CollegeDev
# MAJOR reworking of patches and improved query. only 4 mod types:
# cm, aokp, aosp, and pa. See our OP for details.
# 2012.10.26. (v2.3.0) Final (LTS) version. Stable for now until upstream breaks any patches
# Thanks to KicknGuitar for the OSX testing!
# 2012.11.01. (v2.3.1) Fix for pdroid RIL deletion for older roms
# Better Build query logic and help messages
# 2012.11.02. (v2.3.5) Add Evervolv support for all mods- Thanks to new maintainer poncik!
# Fix method cap for pdroid/pd2.0 for AOKP and kangs
# 2012.11.06. (v2.4.0) Update pd2.0 patches to latest pd2.0 release- all except Evervolv
# add GsmService to smali.txt; improve rom probe
# 2012.11.08. (v2.4.2) Add Evervolv support for pd2.0; Device-specific scripts
# Will display error if using a mod on an inapplicable rom
# 2012.11.09. (v2.4.5) Error catch for random method issues, fix pd2.0 Evervolv and aosp-jb
# 2012.11.17. (v2.4.6) Fix pdroid for CM7. FINALLY!.
# 2012.11.17. (v2.4.7) Internal debugging improvements
# 2013.01.13. (v2.5.0) Added 'openpdroid' mod --Open-Source Pdroid framework
# BIG Improvements to help and error-catch. Try ./auto_patcher -h
# 2013.01.15. (v2.5.1) OpenPDroid support for Evervolv and ParanoidAndroid, hotfix for Mms
# 2013.01.15. (v2.5.2) Fix for cygwin temp files (kobik), provisional telephony files added
# 2013.01.16. (v2.5.3) SlimRom support. Rearrange structure for ApG.
# 2013.01.23. (v2.5.4) Fix small bugs related to rearrange
# 2013.01.25. (v2.5.7) 4.2 TabletUI support [cm,aokp,aosp,Evervolv]
# 2013.01.28. (v2.5.8) Fix for ICS PDroid; small fixes/expansions
# 2013.02.01. (v2.6.0) OpenPdroid 1.0.1 patches (cm, aokp, aosp, evervolv and slimrom. no pa.
# Fixed TabletUI for Cm10.1- aosp to come. Removed most old patches.
# 2013.02.01. (v2.6.25) PA OpenPDroid 1.0.1 patches; AOSP TabletUI. removed opd all 1.0.0
# 2013.02.09. (v2.7.0) Add new AOKP, CM9, CM10,CM10.1 and PA (3.0) patches for OPD
# 2013.02.09. (v2.7.5) Add new AOKP, AOSP, CM10.1 and PA (3.0) patches for OPD (Andr. 4.2.2)
# 2013.02.17. (v2.7.9) 4.2.2 opd 4 evervolv; v6supercharger,3gdongle and all but tabletUI.
# 2013.02.20. (v2.8.0) New CM10.1 opd patches. Each BID can have own provisionals now.
# 2013.02.23. (v2.8.2) SlimRom 4.2.2 support (from karamelos), APK recompile safety net.
# 2013.03.01. (v2.8.3) PAC (.aosp-pac) 4.2.2 support (from AussieLambChops), apktool 1.5.2
# 2013.03.03. (v2.8.4) Remove settings.apk from tabUI, replace Mms.apk. Refactors.
# 2013.03.06. (v2.8.5) Bugfixes, mainly.
# 2013.03.17. (v2.8.6) Added 4.2.2 tabletUI test run for CM from Caldair.
# 2013.03.18. (v2.8.6.5) Hotfix from caldair for tabletUI, new SlimRom patches
# 2013.03.18. (v2.8.7) TabletUI support for 10 inch screens (caldair)
# 2013.03.25. (v2.8.8) Fix for Cygwin paths with spaces (from kobik77)
# 2013.04.06. (v2.9.0) Added new tabletUI patches for CM and 4.2 conflicts.
# 2013.04.10. (v2.9.1) Updated aokp openpdroid patches (0405) please report.
# 2013.04.18. (V2.9.2) Added AOSP and SlimROm TabletUI patches (credit: Caldair)
# 2013.04.18. (V2.9.3) Added missing framework2.jar opd aosp 4.1
# 2013.05.08. (v2.9.4) Updates to TabletUI (from Caldair)
# 2013.05.18. (v2.9.5) New AOKP openpdroid patches (0514)
# 2013.05.20. (v2.9.6) New CM and PAC-man (aosp) openpdroid patches.
# 2013.05.27. (v2.9.7) $INCREMENTAL patches for bugs/updates and GPS fix for opd (credits to phillipberndt)
# 2013.05.30. (v2.9.8) Improve apk handling: test fix disappearing apks. New opd: evervolv,slim
# 2013.06.18. (v2.9.83) Introduce auto-update for OSX and Linux...turn off by setting it false in .config
# Update PACman patches for OPD and update telephony for PA to silence errors
# 2013.06.18. (v2.9.84) Some environment trickery to speed up search/sort. Add WEBSITE for mods.
# Check updating. New AOKP OPD patches
# 2013.06.19. (v2.9.85) Fixes to auto-update. Added changelog.txt
# 2013.06.20. (v2.9.865) Various bugfixes, add color, obfuscate $PROVISIONALS.
# 2013.06.21. (v2.9.87) Added ALTERNATE patches feature- hopefully fixes PA telephony issues.
# 2013.06.22. (v2.9.875) New tabletUI patches, revert flawed CONFLICTS feature
# 2013.06.22. (v2.9.88) New CM opd patches
# 2013.06.28. (v2.9.89) revert baksmali changes for now (still needs work), add new PACman OPD 6/26
# 2013.07.02. (v2.9.91) Switch to SlimRom team's aapt and apktool for OSX+Windows (Need OSX builder!)
# 2013.07.07. (v2.9.92) New opd patches for Slim/PA; some fixes to tabletUi by Caldair
# 2013.07.17. (v2.9.927) Fix missing Mms (finally), support for CM Final, many bugfixes (conflicts, mod ordering, etc.)
# 2013.07.20. (v2.9.93) New OPD CM patches, many bugfixes
# 2013.07.20. (v2.9.935) New PA, AOKP patches. gitattribute. FIx PING for cygwin. (h/t: gcydtmkq)
# 2013.08.05. (v2.9.941) Bundle patchv2.6.1 for cygwin.
# 2013.08.07. (v3.0.0) Support for Android-4.3 (Opendproid only- CM and AOSP).
# 2013.08.09. (v3.0.1) Build date and patch date matching for multiple mods- all mods will now use best available match.
# 2013.08.12. (v3.0.2) OpD support for Evervolv, PACman and PA and CM10 returns
# 2013.08.26. (v3.1.0) The big switch to SMALI.patch instead of JAR.patch. It begins...
# 2013.08.30. (v3.1.1) Some debugging and add Carbon support
# 2013.09.04. (v3.1.4) Update context_editor- still struggling with some Cygwin line endings.
# 2013.09.05. (v3.1.5) Push the 3.1 branch to master...if your rom fails please upload rom and sources!
# 2013.09.09. (v3.1.7) Fix INCREMENTAL patches, fix git log error breaking otherwise fine build (from phillipberndt)
# 2013.10.01. (v3.1.8) Update cm reservoir
# 2013.10.09. (v3.1.9) Update cm, carbon reservoir and mods for 4.3.1
# 2013.10.12. (v3.2.0) Add odex check, weaken PROBE_RESULTS safety check- update cm patches
# 2013.10.22. (v3.2.2) Update CM patches and begin rollout of patches w/ gps-fix included (only works for some devices!)
# 2013.10.22. (v3.2.3) Update some patches and add MIT header to all applicable files.
# 2013.11.05. (v3.2.5) Bugfixes. Update reservoirs- test mobile data error
# 2013.11.05. (v3.5.0) Kitkat support for aosp OpD
# 2013.11.05. (v3.5.2) Kitkat support for cm
# 2013.11.12. (v3.5.5) Use baksmali-2.0 for KitKat. Replace all 4.4 patches for that. Clean up.
# 2013.11.12. (v3.5.5) Fix 4.3 decompiling. Allow for priv-app/Mms
# 2013.11.14. (v3.6.0) Remove olld ${JAR}.patch files= cut size in half
# 2013.11.14. (v3.6.2) Update some reservoirs
# 2013.12.06. (v3.6.3) Update some patches
# 2013.12.08. (v3.6.5) Support for 4.4.1
# 2013.12.12. (v3.6.6) Support for 4.4.2, and better/strict handling of priv-app/Mms.apk
# 2013.12.20. (v3.6.71) Find and replace lingering preloaded.patch
# 2013.12.20. (v3.6.8) Fix problems created by 3.6.71 and remove a bunch of old patches
# 2013.12.20. (v3.7.0) Fix autopatcher to work with Android 2.3 again.
# 2013.12.20. (v3.7.2) Update slimrom, Cm for OpD
# 2013.12.27. (v3.7.5) Add error catch for interactive patch failures; fix up CONTEXT_EDITOR function some.
# 2014.01.04. (v3.7.6) Add some reservoirs, clean up.
# 2014.01.07. (v3.7.7) Add 4.4 AOKP, refine the build query some
# 2014.01.10. (v3.7.8) update reservoir
# 2014.01.13. (v3.7.9) update reservoir
# 2014.01.15. (v3.8.0) fix breakages from 3.7.9 (sorry! My fault.)
# 2014.01.22. (v3.8.1) update cm and aosp-vanir for OpD
# 2014.01.25. (v3.8.2) Update provisionals for vanir and cm -please report any bad experiences, likely others need updating.
# 2014.02.04. (v3.8.3) Update provisionals for temasek and omni- tests to see if Camera FCs are from us
# SHELL PROGRAMMING NOTES:
# [ -s FILE ]
# [[ -n STRING ]] or [[ -z STRING ]]
VERSION="v3.8.3"
# PATCHES_VERSION needs to be incremented every time ANY changes occur to patches.
PATCHES_VERSION="20140204"
CURRENT_ANDROID="4.4.2"
# pass variables to children
set -a
# Set any environmental variables
LANG=C
CYGWIN=false
# we use baksmali-2.0 for Android 4.4 and greater- see proberom function.
BAKSMALI_BINARY=baksmali.jar
SMALI_BINARY=smali.jar
declare -a MODS_LIST
declare -a PATCH_DATE_LIST
# Available ROMTYPES.
# ROMTYPES that are hidden can be forced on the command line. But they are best left
# blank to be automatically parsed by our romprobe or by just entering the parent...usually AOSP.
#Non-obvious ROMTYPE legend
# @.aosp-slim: SlimRom @.aosp-pac: PAC-man
# @.aosp-ever: Evervolv @pa: ParanoidAndroid (official jellybean branch only for now)
# @.aosp-root: RootBox @aosp-oni: OmniRom
# @.aosp-vanir: VanirAOSP
declare -a AVAILABLE_ROMTYPES=('aokp' 'aosp' 'cm' 'pa' '.aosp-slim' '.aosp-pac' '.aosp-ever' '.aosp-vanir' '.aosp-root' '.aosp-omni')
# Config file: For now hosting AUTO_UPDATE and PRODUCTION(currently unused). Not under version control.
if [ ! -f .config ]; then
cp -a ap_scripts/config_template .config
fi
source .config
# Colorize and add text parameters
red=$((tput setaf 1) 2>/dev/null) # red
grn=$((tput setaf 2) 2>/dev/null) # green
cyan=$((tput setaf 6) 2>/dev/null) # cyan
txtBold=$((tput bold) 2>/dev/null) # Bold
txtReset=$((tput sgr0) 2>/dev/null) # Reset
colorize () {
# pass color and then reset
echo -e $@${txtReset}
}
colorize_bold () {
echo -e ${txtBold}$@${txtReset}
}
printusage_help () {
PID="openpdroid,3gdongle" # default example
brief_help
}
brief_help () {
echo " usage: ./auto_patcher <ROM> <MODS>"
echo " example: ./auto_patcher CM10.zip $PID"
echo ""
echo "Use ./auto_patcher -h for the help menu"
echo ""
printtask "After long and hard thought I have discontinued support for OpenPDroid."
printtask "I was not going to port to Android 4.5 but a recent breakage pushed the deadline forward."
echo ""
printtask "You can read more at the OpenPDroid XDA thread."
printtask "http://forum.xda-developers.com/showpost.php?p=50160845&postcount=509"
echo ""
cleanup
exit
}
usage_help () {
PID=mods
mods_display
echo "Multiple MODS can be combined by separating them with a comma and NO SPACES!!!"
echo ""
echo " usage: ./auto_patcher <ROM> <MODS>"
echo ""
echo " example: ./auto_patcher CM10.zip openpdroid,3gdongle"
echo ""
echo " You no longer need to enter a ROMTYPE...EVER! It will hurt, not help."
echo ""
usage_more_help
}
usage_more_help () {
echo "* press 'q' to see available patches and then CTRL-c to quit the help menu *"
}
display_help () {
cd patches
echo ""
echo "AVAILABLE PATCHES"
echo ""
echo "*******************************************************************"
echo "Note: There are ONLY 4 ROMTYPES: [pa, cm, aokp, and aosp]"
echo ""
echo " Specifying ROMTYPE is DEPRECATED as of Autopatcherv3.1.0"
echo ""
find -H * \( -name aokp -o -name cm -o -name aosp -o -name pa -o -name all -o -name generic \) -prune | column -c 85 | more -d -7
echo ""
echo "*****************************************************************"
echo "Specific auto_patcher help options"
echo " ./auto_patcher -h mods Lists mods"
echo " -h <MODNAME> Specific <MOD> info"
echo ""
cleanup
exit
}
romtype_help () {
# From rom_error (bad romtype) and date_error (patch date w/o specifying romtype)
echo ""
echo "!!!There are only four supported ROMTYPES: 1) cm 2) aokp 3) aosp 4) pa"
echo ""
echo "Specifying a romtype is no longer needed for any mod and is DEPRECATED."
echo -e " Try w/o it first, okay?"
cleanup
brief_help
}
cleanup () {
[[ -n $ROOT ]] && \rm -rf "$ROOT"/tmp*
}
garbage () {
unset GARBAGE
GARBAGE=($(find $@ -name "*.orig")) && rm -rf ${GARBAGE[@]} && echo "GARBAGE= ${GARBAGE[@]}" >> "$LOG"
GARBAGE=($(find $@ -name "*.rej")) && rm -rf ${GARBAGE[@]} && echo "GARBAGE= ${GARBAGE[@]}" >> "$LOG"
}
print_error () {
# General purpose error. Used for errors in main, as opposed to probe or set-up.
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
brief_help
}
smali_error () {
# Smali binary error. Problem often goes away on second run.
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
if [[ $(grep 'method index is too large' "$LOG") != "" ]]; then
printtask "!!! Problem with method cap !!!"
printtask "... attempting fix ..."
. patches/.common/framework.jar.sh 2>&1 > ${JAR}.log
printtask "... rebuild framework.jar ..."
java -Xmx512M -jar $SMALI_BINARY -a $API tmp/${FILE}.out/smali -o tmp/${FILE}.out/classes.dex >> "$LOG" 2>> "$LOG"
[ -f tmp/${FILE}.out/classes.dex ] || \
print_error "Could not resolve method cap issue- please submit log"
else
printtask "!!! This error is generally due to an unknown bug in the smali binary!"
echo "In our experience, it goes away if you run the patcher a second time."
echo " Please run the Auto-Patcher with the same command once again."
echo ""
echo "If after the third attempt the same thing happens,"
echo " please upload your logfile to our support thread!"
echo ""
cleanup
exit
fi
}
unknown_mod_error () {
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
cleanup
printusage_help
}
mismatch_error () {
# Function that exposes attempts to apply a mod to an upsupported Android version
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
cleanup
brief_help
}
date_error () {
# Remind users to include a romtype if they are going to specify a patch date
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo " !! Manually specifying a date is DEPRECATED and no longer necessary. But if you insist..."
echo " Please put a ROMTYPE before the patch date and run again!!"
romtype_help
}
rom_error () {
# For when an unsupported romtype is manually entered on the command-line
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
romtype_help
}
conflict_error () {
# For conflicting packages
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
cleanup
PID=mods
mods_info
}
misspatch_error () {
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!! error: $@ "
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
printtask "!! The Auto-Patcher could not find its patches and/or tools!"
echo ""
echo "* Did you run ./batch.sh first?"
echo ""
echo "The patch_patches.tgz and patch_tools.tgz need to be in this directory,"
echo " one way or another..."
echo ""
cleanup
brief_help
}
misstools_error () {
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!! error: $@ "
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "Your set-up is missing a dependency."
echo "We require JDK, tar, patch and cpio."
echo ""
echo ""
echo "Each distro is different"
echo "but ensure you have them all installed and try again."
echo ""
cleanup
brief_help
}
miss_git_error () {
printtask "Updater: disabled"
echo ""
printtask "You will not be able to get automatic updates because we could not find 'git'."
printtask "Find out how to install git for your system and that feature should work automatically"
echo ""
}
printtask () {
echo "" >> "$LOG"
echo -e $@ | tee -a "$LOG"
}
print_to_log () {
echo "$@" >> "$LOG"
}
check_odex () {
jar -xvf "$ROMX" system/framework/framework.odex >> "$LOG"
if [ -s system/framework/framework.odex ]; then
odex_error "You are attempting to patch a stock odexed rom!"
fi
}
odex_error () {
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!! error: $@ "
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
printtask "At this point we only support deodexed, open-source roms, like CyanogenMod or AOKP."
echo ""
brief_help
}
no_network_access () {
NETWORK=false # assume that we don't have network
git fetch origin >> "$LOG" 2>&1 && NETWORK=true && return # we should focus on git fetch only
PING_CHECK "www.google.com" >> "$LOG" 2>&1 # test for internet in general, if git fetch fails
printtask "Check for update failed, probably because of no internet access."
echo "The autopatcher will continue with current local version: $VERSION"
echo ""
sleep 2
}
auto_update_error () {
echo ""
printtask "### Update failed ###"
printtask ""
printtask "It appears you may have made some changes that prevent automatic updating."
echo ""
printtask "You could run 'git reset --hard' to return the autopatcher to its original form"
printtask " or set AUTO_UPDATE to false in the .config file to stop getting this message."
echo ""
printusage_help
}
backup_script () {
printtask "... backing up auto_patcher to auto_patcher.bak ..."
cp -av auto_patcher auto_patcher.bak >> "$LOG" #backup for user in case of changes
echo ""
}
warn_of_overwrite () {
# Only seen once, by users without ".git" directories
# Only users who got program @ download page see this, all others (ApG included) use git
echo "This is a one time set-up process that will overwrite all local changes!"
echo "If this is not ok with you press ctrl-C and set AUTO_UPDATE to false in .config"
echo ""
}
establish_repo() {
printtask "### establishing the repo ###"
echo "... please be patient, this should only be needed once ..."
echo ""
git clone https://github.com/mateor/auto-patcher >> "$LOG" || no_network_access
if ($NETWORK); then
mv -v auto-patcher/".git" . >> "$LOG"
rm -rf auto-patcher
git checkout -q master || auto_update_error
git reset --hard 2>&1 >> "$LOG"
echo ""
fi
}
export_log_and_variables () {
AUTO_PATCHER_OLD_VERSION=$VERSION
AUTO_PATCHER_OLD_PATCHES_VERSION=$PATCHES_VERSION
AUTO_PATCHER_WAS_UPDATED=true
UPDATED_LOG="$PATCHES_VERSION".updated.log
cp -a "$LOG" "$UPDATED_LOG"
rm -f "$LOG"
}
print_changelog () {
CHANGELOG="changelog.txt"
echo "" > "$CHANGELOG"
CURRENT_HEAD=$(git rev-parse HEAD)
echo "Changelog from Autopatcher$AUTO_PATCHER_OLD_VERSION to Autopatcher$VERSION" >> "$CHANGELOG"
echo "---------------------------------------------------------------------------" >> "$CHANGELOG"
echo "" >> "$CHANGELOG"
echo " Get more info about any individual commit by entering 'git show \$NUMBER'" >> "$CHANGELOG"
echo "" >> "$CHANGELOG"
git log --pretty=oneline $ORIGINAL_HEAD...$CURRENT_HEAD >> changelog.txt
printtask "... "$CHANGELOG" has been updated ..."
}
replace_updater () {
# Function for devices that use SDcard installs. Also to be tested for CM7
# since CM7 seems to use an updater-script that wipes EMMC. Testing
\rm $UPDATER_LOC/$UPDS 2>&1
\cp patches/.common/$UPDATER_LOC/$UPDS $UPDATER_LOC >> "$LOG" 2>&1
echo "run_program(\"/sbin/busybox\", \"umount\", \"/system\");" >> UPDATE.txt
cat UPDATE.txt >> $UPDATER_LOC/$UPDS
echo ""
echo "New updater-script being used:" >> "$LOG"
echo "-----------------------------" >> "$LOG"
cat $UPDATER_LOC/$UPDS >> "$LOG"
}
abspath () {
case $(uname -s) in
CYGWIN*)
echo $(cygpath -ua "$1") | sed 's:/$::g'
;;
Darwin)
#[[ $(echo $1 | awk '/^\//') == $1 ]] && echo "$1" || echo "$PWD/$1"
[[ ${1:0:1} == "/" ]] && echo "$1" || echo "$PWD/$1"
;;
Linux)
echo $(readlink -f "$1")
;;
*)
if [[ ${1:0:1} == "/" ]]; then
echo "$1"
elif [[ ${1:0:2} == "./" ]]; then
echo "$PWD/${1:2}"
else
echo "$PWD/$1"
fi
;;
esac
}
mods_display () {
echo ""
echo "The Auto-Patcher $VERSION"
echo "*******************************"
echo ""
echo "The available mods are"
echo "****************************************************"
echo "* pdroid openpdroid voice v6supercharger *"
echo "* voice insecure secure external_internal *"
echo "* tabletUI 3gdongle pd2.0 *"
echo "****************************************************"
echo ""
echo "To find out more about any mod, simply enter:"
echo " ./auto_patcher -h <MODNAME>"
echo ""
cleanup
}
mods_info () {
# Defaults
DEPENDENCY="None"
DEV="Unknown"
CEILING=$CURRENT_ANDROID
ROM_CONFLICTS=(None)
UNKNOWN_MOD=false
DEVICE_LIMIT="None"
case "$PID" in
mods)
mods_display
exit
;;
auto*)
echo ""
echo "**************************************"
echo "The Auto-Patcher ate a kitten once..."
echo "**************************************"
echo ""
DEV="mateor and Caldair"
WEBSITE="https://github.com/mateor/auto-patcher"
printusage_help
;;
voice)
FLOOR=4.0.0
DESC="Use on wifi-only tablets to have the software register as 'voice-enabled'. Allows VOIP like Google Voice to function."
DESC="bongostl's setup method can be seen at the link."
WEBSITE="http://forum.xda-developers.com/showthread.php?t=1823701"
DEV="bongostl"
;;
v6 | v6supercharger)
FLOOR=4.0.0
CEILING=4.3.1
DESC="A memory-management tool. It requires smali edits for Android roms 4.0+. The Auto-Patcher applies all 50+ edits recommended by the dev."
DEV="Zeppelinrox"
DEPENDENCY="The V6 Supercharger Script. Get it at the link"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=991276"
PID="v6supercharger" # allows shorthand 'v6' to find patches. # this does not work :-|
;;
pdroid)
FLOOR=2.3.7
CEILING=4.1.2
DESC="Security Software that manages access to personal data w/o causing FC's. No longer under development."
DESC1="Try the open-source expansion of this program, OpenPdroid."
DESC2="(It's the 'openpdroid' mod within the Auto-Patcher)."
DEV="Svyat"
DEPENDENCY="The Pdroid app. You can get it at the link"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=1923576"
;;
pd2.0)
FLOOR=4.1.2
CEILING=4.1.2
DESC="An expansion of the PDroid application/framework."
DEV="CollegeDev"
DEPENDENCY="The free PDroid2.0 app available at the link"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=1923576"
;;
openpdroid)
FLOOR=4.1.2
CEILING=4.4.2
EXPIRATION=20140120
DESC="A fork of the open-source PDroid and Pdroid2.0 framework."
DEV="CollegeDev/FFU5y/wbedard/mateor/Community"
DEPENDENCY="PDroidManager(opensource)"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=1994860"
if [[ $ANDR == "4.1" ]]; then
ROM_CONFLICTS=( pa cm )
fi
;;
opendroid)
echo ""
echo "No mod named 'opendroid'. You probably mean 'openpdroid'. Try again."
PID="mods"
mods_info
;;
external_internal)
FLOOR=2.3.3
CEILING=4.1.2
DESC="Swap internal and external storage."
;;
insecure)
FLOOR=2.3.3
DESC="Make any boot.img insecure and allow remount as well as adb push/pull of system files. True root."
;;
secure)
FLOOR=2.3.3
DESC="Make any boot.img secure."
;;
3gdongle)
FLOOR=4.1.0
CEILING=4.3.1
DESC="Allows 3gdongles to work on wifi tablets w/o 3rd party applications."
DEV="trevd"
DEPENDENCY="None, but read the troubleshooting guide at the link"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=1798631"
DEVICE_LIMIT=( grouper )
if [[ $ANDR == "4.3" ]]; then
# at least. Looks like CM merged this mod. Probably other roms have as well.
ROM_CONFLICTS=( cm )
fi
;;
tabletUI)
FLOOR=4.1.0
CEILING=4.3.1
EXPIRATION=20131205
if [[ $ANDR == "4.3" ]]; then
ROM_CONFLICTS=(.aosp-slim .aosp-ever aokp pa)
elif [[ $ANDR == "4.2" ]]; then
ROM_CONFLICTS=(.aosp-ever aokp pa)
else
ROM_CONFLICTS=(pa .aosp-slim)
fi
DESC="Changes the user interface of Phones and Phablets to the popular Tablet UI."
DEV="barmullio/Caldair"
WEBSITE="http://forum.xda-developers.com/showthread.php?t=2154075"
;;
*)
UNKNOWN_MOD=true
FLOOR=?????
CEILING=?????
DESC="??? Unknown modtype ??? Check your spelling or the mod list!"
DESC1=" Try: \"./auto_patcher -h mods\""
esac
# strip decimals from android version (i.e. 2.3.7 becomes 237) so we can do math
NVID=${VID//[.]/}
NVID=${NVID:0:3}
COMPATF=${FLOOR//[.]/}
COMPATC=${CEILING//[.]/}
if [[ ${#NVID} -lt 3 ]]; then
NVID="$NVID"0
fi
}
apk_copy () {
if [ -f patches/$P/$A/$R/$B/$FILE ]; then
mkdir apk_staging
cd apk_staging
# Move the certs and manifests from the ROM's apk into the prepatched copy
jar -xvf ../"$FILE" META-INF AndroidManifest.xml >> "$LOG"
jar -ufv ../patches/$P/$A/$R/$B/$FILE META-INF/CERT* AndroidManifest.xml >> "$LOG" 2>> "$LOG"
cd ..
\cp -av patches/$P/$A/$R/$B/$FILE $FILE >> "$LOG" 2>&1
echo "... Patching $APK failed, but we have successfuly copied over a prepatched file ..."
apk_was_copied=true
else
print_error "failed patching $APK!!!"
fi
}
no_mod_selected_error () {
echo ""
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
printtask "!!! error: $@"
printtask "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
printtask "You need to enter a MOD before you try and specify the ROMTYPE."
printtask "Check the help menu for the list of available MODS"
echo ""
printusage_help
}
check_against_rom_types () {
# this checks to see if the user has entered a ROMTYPE in the MOD spot and outputs advice if so.
NUMBER_OF_AVAILABLE_ROMTYPES=${#AVAILABLE_ROMTYPES[@]}
for ((i=0; i < $NUMBER_OF_AVAILABLE_ROMTYPES; i++)); do
if [[ ${AVAILABLE_ROMTYPES[i]} == "$P" ]]; then
no_mod_selected_error "\"$P\" is a ROMTYPE not a MOD"
fi
done
}
compat_check () {
for G in ${PID[@]}; do
mods_info
if ($UNKNOWN_MOD); then
check_against_rom_types
unknown_mod_error "\"$G\" is not a valid mod. Check your spelling or the mod list!!!"
elif [[ "$NVID" -lt "$COMPATF" ]]; then
mismatch_error "Your Android $VID rom is too old! The minimum for $G is \n !!! Android $FLOOR!"
elif [[ "$NVID" -gt "$COMPATC" ]]; then
mismatch_error "Sorry, $G has not been made available for Android $VID yet!"
fi
done
}
rom_compat_check () {
N=${#ROM_CONFLICTS[@]}
for ((i=0; i < $N; i++)); do
if [[ $RID == ${ROM_CONFLICTS[$i]} ]]; then
rom_compat_error
fi
done
}
rom_compat_error () {
echo ""
if ( [[ "$PID" == openpdroid ]] && [[ "$ANDR" == 4.1 ]] ); then
echo " OpenPdroid support for CyanogenMod was broken around 2/05/13"
echo " Use a ROM from before then or patch for 'pdroid' instead"
fi
# lets also add the common names for $RID (like rom_name)
print_error "$PID is incompatible with $ROMNAME for Android $ANDR !!!"
}
device_compat_check () {
O=${#DEVICE_LIMIT[@]}
for ((i=0; i < $O; i++)); do
if [[ $DID == ${DEVICE_LIMIT[$i]} ]]; then
DEVICE_MATCHED=true
fi
done
if [[ ! "$DEVICE_MATCHED" == true ]]; then
device_compat_error
fi
}
device_compat_error () {
print_error "$PID is not available for $DID!!! Supported devices: ${DEVICE_LIMIT[@]}"
}
extpath () {
case $(uname -s) in
CYGWIN*)
echo $(cygpath -da "$1")
;;
*)
echo $(abspath "$1")
;;
esac
}
#contains () { for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done; return 1; }
parse () { echo "${1%%_*}"; }
getbuildprop () {
if [ -f system/build.prop ]; then
result=($(grep $1 system/build.prop | tr -d '\r' | tr '=' ' '))
echo "${result[1]}"
else
echo ""
fi
}
aosp_mod_check() {
jar -xvf "$ROMX" system/framework/framework2.jar >> "$LOG"
if [ -s system/framework/framework2.jar ]; then
ever_check
else
AOSP=aosp
fi
echo $AOSP
}
ever_check() {
MID=$(getbuildprop ro.build.romversion)
if [[ $MID == "Evervolv"* ]]; then
AOSP=".aosp-ever"
else
MID=$(getbuildprop ro.build.display.id)
if [[ "$MID" == "ev"* ]]; then
AOSP=".aosp-ever"
else
pac_check
fi
fi
echo $AOSP
}
pac_check() {
MID=$(getbuildprop ro.build.romversion)
if [[ "$MID" == "pac"* ]] || [[ "$MID" == "PAC"* ]]; then
AOSP=".aosp-pac"
else
MID=$(getbuildprop ro.build.display.id)
if [[ "$MID" == "pac"* ]] || [[ "$MID" == "PAC"* ]]; then
AOSP=".aosp-pac"
else
slim_check
fi
fi
}
slim_check() {
SLMID=$(getbuildprop ro.modversion)
SLMMID=$(getbuildprop updateme.name)
if [[ "$SLMMID" == "Slim"* ]] || [[ $SLMMID == "slim"* ]]; then
AOSP=".aosp-slim"
elif [[ "$SLMID" == "Slim"* ]] || [[ $SLMID == "slim"* ]]; then
AOSP=".aosp-slim"
else
if [[ "$ANDR" == "4.1" ]]; then
AOSP=.aosp-mod
else
rootbox_check
fi
fi
}
rootbox_check() {
ROOTBOXAID=$(getbuildprop ro.rootbox.version)
if [[ -n $ROOTBOXAID ]]; then
AOSP=.aokp-root
else
vanir_check
fi
}
vanir_check() {
VANIRAID=$(getbuildprop ro.goo.rom)
if [[ "$VANIRAID" == "vanir"* ]] || [[ "$VANIRAID" == "Vanir"* ]]; then
AOSP=.aosp-vanir
else
omni_check
fi
}
omni_check() {
OMNIAID=$(getbuildprop ro.modversion)
if [[ "$OMNIAID" == "Omni"* ]] || [[ "$OMNIAID" == "omni"* ]]; then
AOSP=".aosp-omni"
else
AOSP="aosp"
fi
}
pa_check() {
CMID=$(getbuildprop ro.modversion)
PAID=$(getbuildprop ro.pa.version)
MID=$(getbuildprop ro.build.display.id)
[[ "$MID" == "" ]] && MID=$(parse $(getbuildprop ro.build.display.id))
DID=$(getbuildprop ro.product.device)
[[ "$DID" == "" ]] && DID=$(getbuildprop ro.build.product)
if [[ -n $PAID ]]; then
RID=pa
else
case $CMID in
[Pp][Aa]*)
RID=pa;
;;
*)
RID=cm;
;;
esac
fi
}
romtype_set () {
case $RID in
cm)
ROMTYPE="cm"
ROMNAME="CyanogenMod"
;;
aokp*)
ROMTYPE="aokp"
ROMNAME="AOKP"
;;
pa)
ROMTYPE="pa"
ROMNAME="ParanoidAndroid"
;;
.aosp-slim)
ROMTYPE="aosp"
ROMNAME="SlimRom"
;;