3 # Look after changelog for script/patch version info.
5 # PDroid created by svyat. Official PDroid thread is
6 # http://forum.xda-developers.com/showthread.php?t=1357056
8 # The Auto-Patcher created by pastime1971 and mateorod
9 # Thread and support for the Auto-Patcher can be found at
10 # http://forum.xda-developers.com/showthread.php?p=27589651#post27589651
14 # 2012.05.12. (v0.2) allows user to specify a different version of patches
15 # 2012.05.13. (v0.3.0) force "patch -N", remove temp upon failure, generate log output
16 # 2012.05.13. (v0.3.1) revised the generation of updater-script (SGS2)
17 # 2012.05.15. added AOSP patches
18 # 2012.05.15. added crespo-aosp patches; device-specific patching if patch exists
19 # 2012.05.15. remove restore.zip upon failure
20 # 2012.05.15. (v0.4.1) added CM7 (GB) patches
21 # 2012.05.18. (v0.4.2) added checking for tool commands
22 # 2012.05.21. (v0.4.3) apply device-specific patches only when it is specified
23 # 2012.05.26. added task title to log
24 # 2012.05.31. (v0.4.4) CM9 patches updated, crespo-aosp added
25 # 2012.06.04. (v0.4.5) added checking tools and rom, added aroma installer support
26 # add patch outputs reroute
27 # 2012.06.15. CM9 patches updated
28 # 2012.06.16. (v0.4.6) AOKP patches updated, patch versions restructured
29 # 2012.06.17. (v0.5.0) patcher script reorganized, removed build.prop
30 # 2012.06.17. (v0.6.0) auto patcher script for pdroid and v6 patches
31 # 2012.06.19. (v0.6.1) add patches for CM7.2 Final
32 # 2012.06.20. (v0.6.2) updated CM 7.2 patches
33 # 2012.06.23. (v0.6.3) fix symlinks
34 # 2012.06.26. (v0.6.4) added 0618 patches for cm7 nightlies; removed 0619 cm7.2 final
35 # 2012.06.27. (v0.6.5) added new CM9 patches (20120626)
36 # 2012.06.27. (v0.6.6) added CM7 nightly patches (20120625) (finally!)
37 # 2012.07.02. (v0.7.0) Redid AOSP/AOKP; add Windows support (using Cygwin). Thanks kobik77!
38 # 2012.07.06. (v0.7.1) updated CM9 patches (20120706)
39 # 2012.07.08. (v0.7.2) updated AOKP (20120707) and CM9 (20120708) pdroid patches
40 # 2012.07.11. (v1.0.0) reworked script works on Linux, Mac OSX, and Windows (on Cygwin);
41 # added new ICS/JellyBean support for the new V6-Supercharger
42 # 2012.07.18. (v1.0.1) new CM7/CM9 Pdroid patches (20120718)
43 # 2012.07.23. (v1.0.2) updated CM9 patches (20120723)
44 # 2012.07.23. (v1.0.3) updated CM9 patches (20120724)
45 # 2012.08.06. (v1.5.0) updated smali/baksmali binaries to 1.33
46 # 2012.08.06. Added Pdroid/V6supercharger support for CM10 Jellybean!
47 # 2012.08.06. Improved PDroid stability and efficiency (Thanks CollegeDev)
48 # 2012.08.06. (v1.6.0) added aokp-jb patches for pdroid/v6supercharger, script update
49 # 2012.08.17. (v1.9.5) Added support for pdroid_addon, by CollegeDev.
50 # Added insecure boot.img mod
51 # Added support for aosp-jb (This needs testing, and may not be
52 # a wide patch due to large variation between AOSP roms.
53 # -Please report all experiences!
54 # Updated all v6supercharger patches w/new edits to ProcessList
55 # Major script overhaul in preparation for additional mods!
56 # 2012.08.20. (v1.9.6) Conditional support for Official cm10 and aokp-jb builds
57 # 2012.08.23. (v1.9.7) Final/confirmed pdroid support for Official CM10 and AOKP-JB
58 # 2012.09.04 (v1.9.8) Bundled cygwin-compatible tools (original was corrupt).
59 # For Cygwin, replaced h2b function with simple bash math
60 # conversion (req'd for compat w/ Cygwin tools).
61 # 2012.08.26. (v2.0.0) Added .apk patching
62 # Added 3G Dongle support for Nexus 7 (trevd)
63 # TabletUI support for Nexus 7 (maybe more)
64 # Google Voice support for Nexus 7
65 # mods are 3gdongle, tabletUI, voice, or nexus7suite (for all)
66 # Added provisional file copy menu to widen patching base
67 # 2012.09.11. (v2.0.1) Cygwin support fixes
68 # 2012.09.11. (v2.0.2) Bugfix for 3gdongle (all)
69 # 2012.09.16. (v2.1.0) Significant restructuring of core operations; added edit text file
70 # fix for "method-cap" errors in pdroid.
71 # 2012.09.20. (v2.1.1) Fix for Phone FC's; OSX support finalized; ContentResolver resolved
72 # 2012.09.28. (v2.1.2) Hotfix for failed pdroid patching. Logging improvements.
73 # 2012.10.07. (v2.1.5) Final pdroid support for CM7.2 Official Releases
74 # Added aosp-mod patches for pdroid patching of AOSP kangs
75 # Switched to Chainfire's (f)aapt for speed/space reasons
76 # 2012.10.13. (v2.1.6) New PDroid patches for aokp-jb and cm10 4.1.2
77 # Revert (f)aapt- temporary due to reported issues
78 # 2012.10.15. (v2.17) New (again) CM10 pdroid patches.
79 # Move files to be copied into $p/$R/$B
80 # -This required a bunch of file moving-report broken symlinks.
81 # Some error check on the old RIL delete functions (thanks bundrik)
82 # 2012.10.16. (v2.1.7.5) Fix FC on phone with CM10 pdroid patches
83 # 2012.10.19. (v2.1.9) Testing CM10 support for PDroid Extension by CollegeDev.
84 # 2012.10.22. (v2.2.0) aosp/aokp and cm10 support for pdroid extension by CollegeDev
85 # MAJOR reworking of patches and improved query. only 4 mod types:
86 # cm, aokp, aosp, and pa. See our OP for details.
87 # 2012.10.26. (v2.3.0) Final (LTS) version. Stable for now until upstream breaks any patches
88 # Thanks to KicknGuitar for the OSX testing!
89 # 2012.11.01. (v2.3.1) Fix for pdroid RIL deletion for older roms
90 # Better Build query logic and help messages
91 # 2012.11.02. (v2.3.5) Add Evervolv support for all mods- Thanks to new maintainer poncik!
92 # Fix method cap for pdroid/pd2.0 for AOKP and kangs
93 # 2012.11.06. (v2.4.0) Update pd2.0 patches to latest pd2.0 release- all except Evervolv
94 # add GsmService to smali.txt; improve rom probe
95 # 2012.11.08. (v2.4.2) Add Evervolv support for pd2.0; Device-specific scripts
96 # Will display error if using a mod on an inapplicable rom
97 # 2012.11.09. (v2.4.5) Error catch for random method issues, fix pd2.0 Evervolv and aosp-jb
98 # 2012.11.17. (v2.4.6) Fix pdroid for CM7. FINALLY!.
99 # 2012.11.17. (v2.4.7) Internal debugging improvements
100 # 2013.01.13. (v2.5.0) Added 'openpdroid' mod --Open-Source Pdroid framework
101 # BIG Improvements to help and error-catch. Try ./auto_patcher -h
102 # 2013.01.15. (v2.5.1) OpenPDroid support for Evervolv and ParanoidAndroid, hotfix for Mms
103 # 2013.01.15. (v2.5.2) Fix for cygwin temp files (kobik), provisional telephony files added
104 # 2013.01.16. (v2.5.3) SlimRom support. Rearrange structure for ApG.
105 # 2013.01.23. (v2.5.4) Fix small bugs related to rearrange
106 # 2013.01.25. (v2.5.7) 4.2 TabletUI support [cm,aokp,aosp,Evervolv]
107 # 2013.01.28. (v2.5.8) Fix for ICS PDroid; small fixes/expansions
108 # 2013.02.01. (v2.6.0) OpenPdroid 1.0.1 patches (cm, aokp, aosp, evervolv and slimrom. no pa.
109 # Fixed TabletUI for Cm10.1- aosp to come. Removed most old patches.
110 # 2013.02.01. (v2.6.25) PA OpenPDroid 1.0.1 patches; AOSP TabletUI. removed opd all 1.0.0
111 # 2013.02.09. (v2.7.0) Add new AOKP, CM9, CM10,CM10.1 and PA (3.0) patches for OPD
112 # 2013.02.09. (v2.7.5) Add new AOKP, AOSP, CM10.1 and PA (3.0) patches for OPD (Andr. 4.2.2)
113 # 2013.02.17. (v2.7.9) 4.2.2 opd 4 evervolv; v6supercharger,3gdongle and all but tabletUI.
114 # 2013.02.20. (v2.8.0) New CM10.1 opd patches. Each BID can have own provisionals now.
115 # 2013.02.23. (v2.8.2) SlimRom 4.2.2 support (from karamelos), APK recompile safety net.
116 # 2013.03.01. (v2.8.3) PAC (.aosp-pac) 4.2.2 support (from AussieLambChops), apktool 1.5.2
117 # 2013.03.03. (v2.8.4) Remove settings.apk from tabUI, replace Mms.apk. Refactors.
118 # 2013.03.06. (v2.8.5) Bugfixes, mainly.
119 # 2013.03.17. (v2.8.6) Added 4.2.2 tabletUI test run for CM from Caldair.
120 # 2013.03.18. (v2.8.6.5) Hotfix from caldair for tabletUI, new SlimRom patches
121 # 2013.03.18. (v2.8.7) TabletUI support for 10 inch screens (caldair)
122 # 2013.03.25. (v2.8.8) Fix for Cygwin paths with spaces (from kobik77)
123 # 2013.04.06. (v2.9.0) Added new tabletUI patches for CM and 4.2 conflicts.
124 # 2013.04.10. (v2.9.1) Updated aokp openpdroid patches (0405) please report.
125 # 2013.04.18. (V2.9.2) Added AOSP and SlimROm TabletUI patches (credit: Caldair)
126 # 2013.04.18. (V2.9.3) Added missing framework2.jar opd aosp 4.1
127 # 2013.05.08. (v2.9.4) Updates to TabletUI (from Caldair)
128 # 2013.05.18. (v2.9.5) New AOKP openpdroid patches (0514)
129 # 2013.05.20. (v2.9.6) New CM and PAC-man (aosp) openpdroid patches.
130 # 2013.05.27. (v2.9.7) $INCREMENTAL patches for bugs/updates and GPS fix for opd (credits to phillipberndt)
131 # 2013.05.30. (v2.9.8) Improve apk handling: test fix disappearing apks. New opd: evervolv,slim
132 # 2013.06.18. (v2.9.83) Introduce auto-update for OSX and Linux...turn off by setting it false in .config
133 # Update PACman patches for OPD and update telephony for PA to silence errors
134 # 2013.06.18. (v2.9.84) Some environment trickery to speed up search/sort. Add WEBSITE for mods.
135 # Check updating. New AOKP OPD patches
136 # 2013.06.19. (v2.9.85) Fixes to auto-update. Added changelog.txt
137 # 2013.06.20. (v2.9.865) Various bugfixes, add color, obfuscate $PROVISIONALS.
138 # 2013.06.21. (v2.9.87) Added ALTERNATE patches feature- hopefully fixes PA telephony issues.
139 # 2013.06.22. (v2.9.875) New tabletUI patches, revert flawed CONFLICTS feature
140 # 2013.06.22. (v2.9.88) New CM opd patches
141 # 2013.06.28. (v2.9.89) revert baksmali changes for now (still needs work), add new PACman OPD 6/26
142 # 2013.07.02. (v2.9.91) Switch to SlimRom team's aapt and apktool for OSX+Windows (Need OSX builder!)
143 # 2013.07.07. (v2.9.92) New opd patches for Slim/PA; some fixes to tabletUi by Caldair
144 # 2013.07.17. (v2.9.927) Fix missing Mms (finally), support for CM Final, many bugfixes (conflicts, mod ordering, etc.)
145 # 2013.07.20. (v2.9.93) New OPD CM patches, many bugfixes
146 # 2013.07.20. (v2.9.935) New PA, AOKP patches. gitattribute. FIx PING for cygwin. (h/t: gcydtmkq)
147 # 2013.08.05. (v2.9.941) Bundle patchv2.6.1 for cygwin.
148 # 2013.08.07. (v3.0.0) Support for Android-4.3 (Opendproid only- CM and AOSP).
149 # 2013.08.09. (v3.0.1) Build date and patch date matching for multiple mods- all mods will now use best available match.
152 # SHELL PROGRAMMING NOTES:
154 # [[ -n STRING ]] or [[ -z STRING ]]
157 # PATCHES_VERSION needs to be incremented every time ANY changes occur to patches.
158 PATCHES_VERSION
="20130810"
159 CURRENT_ANDROID
="4.3.0"
161 # pass variables to children
164 # Set any environmental variables
167 # unused for now...for experiments with "-s" flag and new patches made with it.
168 BAKSMALI_BINARY
=baksmali.jar
169 SMALI_BINARY
=smali.jar
171 declare -a PATCH_DATE_LIST
173 # Available ROMTYPES.
174 # ROMTYPES that are hidden can be forced on the command line. But they are best left
175 # blank to be automatically parsed by our romprobe or by just entering the parent...usually AOSP.
177 #Non-obvious ROMTYPE legend
178 # @.aosp-slim: SlimRom @.aosp-pac: PAC-man
179 # @.aosp-ever: Evervolv @pa: ParanoidAndroid (official jellybean branch only for now)
180 declare -a AVAILABLE_ROMTYPES
=('aokp' 'aosp' 'cm' 'pa' '.aosp-slim' '.aosp-pac' '.aosp-ever')
182 # Config file: For now hosting AUTO_UPDATE and PRODUCTION(currently unused). Not under version control.
183 if [ ! -f .config
]; then
184 cp -a ap_scripts
/config_template .config
188 # Colorize and add text parameters
189 red
=$
((tput setaf
1) 2>/dev
/null
) # red
190 grn
=$
((tput setaf
2) 2>/dev
/null
) # green
191 cyan
=$
((tput setaf
6) 2>/dev
/null
) # cyan
192 txtBold
=$
((tput bold
) 2>/dev
/null
) # Bold
193 txtReset
=$
((tput sgr0
) 2>/dev
/null
) # Reset
196 # pass color and then reset
197 echo -e $@
${txtReset}
201 echo -e ${txtBold}$@
${txtReset}
205 PID
="openpdroid,3gdongle" # default example
210 echo " usage: ./auto_patcher <ROM> <MODS> <ROMTYPE>"
211 echo " example: ./auto_patcher CM10.zip $PID cm"
213 echo "Use ./auto_patcher -h for the help menu"
222 echo "Multiple MODS can be combined by separating them with a comma and NO SPACES!!!"
224 echo " usage: ./auto_patcher <ROM> <MODS> <ROMTYPE>"
226 echo " example: ./auto_patcher CM10.zip openpdroid,3gdongle cm"
232 echo "* press 'q' available patches or CTRL-c to quit the help menu *"
238 echo "AVAILABLE PATCHES"
240 echo "*******************************************************************"
241 echo "Note: There are ONLY 4 ROMTYPES: [pa, cm, aokp, and aosp]."
243 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
245 echo "!!! Do not put Android Version number on command line !!!!"
246 echo "*****************************************************************"
247 echo "Specific auto_patcher script options"
248 echo " ./auto_patcher -h mods Lists mods"
249 echo " -h <MODNAME> Specific <MOD> info"
250 echo " -h advanced Advanced usage+lists all available patch dates"
257 # From rom_error (bad romtype) and date_error (patch date w/o specifying romtype)
259 echo "!!!There are only four supported ROMTYPES: 1) cm 2) aokp 3) aosp 4) pa"
261 echo "Find out which of the above ROMTYPES your rom is based on and try again!"
262 echo "**********************************************"
270 echo "The Auto-Patcher Advanced Usage"
271 echo "*********************************"
273 echo "For those of you determined to try everything..."
275 echo "You can also try adding a patch date as a final argument."
277 echo " ./auto_patcher <ROM> <MOD> <ROMTYPE> <DATE>"
279 echo "Please note: There are only four ROMTYPES: {pa, aokp, aosp and cm}"
280 echo " -The various appellations after that are for internal use only!"
282 echo "The Auto-Patcher has a pretty great rom probe, specifying the date is"
283 echo " deprecated...you don't need to, we promise."
288 [[ -n $ROOT ]] && \rm
-rf "$ROOT"/tmp
*
293 GARBAGE
=($
(find $@
-name "*.orig")) && rm -rf ${GARBAGE[@]} && echo "GARBAGE= ${GARBAGE[@]}" >> "$LOG"
294 GARBAGE
=($
(find $@
-name "*.rej")) && rm -rf ${GARBAGE[@]} && echo "GARBAGE= ${GARBAGE[@]}" >> "$LOG"
299 # General purpose error. Used for errors in main, as opposed to probe or set-up.
301 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
302 printtask
"!!! error: $@"
303 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
309 # Smali binary error. Problem often goes away on second run.
311 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
312 printtask
"!!! error: $@"
313 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
315 if [[ $
(grep 'method index is too large' "$LOG") != "" ]]; then
316 printtask
"!!! Problem with method cap !!!"
317 printtask
"... attempting fix ..."
318 . patches
/.common
/framework.jar.sh
2>&1 > ${JAR}.log
319 printtask
"... rebuild framework.jar ..."
320 java
-Xmx512M -jar smali.jar
-a $API tmp
/${FILE}.out
/smali
-o tmp
/${FILE}.out
/classes.dex
>> "$LOG" 2>> "$LOG"
321 [ -f tmp
/${FILE}.out
/classes.dex
] || print_error
"Could not resolve method cap issue- please submit log"
323 printtask
"!!! This error is generally due to an unknown bug in the smali binary!"
324 echo "In our experience, it goes away if you run the patcher a second time."
325 echo " Please run the Auto-Patcher with the same command once again."
327 echo "If after the third attempt the same thing happens,"
328 echo " please upload your logfile to our support thread!"
335 unknown_mod_error
() {
337 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
338 printtask
"!!! error: $@"
339 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
346 # Function that exposes attempts to apply a mod to an upsupported Android version
348 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
349 printtask
"!!! error: $@"
350 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
357 # Remind users to include a romtype if they are going to specify a patch date
359 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
360 printtask
"!!! error: $@"
361 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
363 echo "Please put a ROMTYPE before the patch date and run again!!"
368 # For when an unsupported romtype is manually entered on the command-line
370 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
371 printtask
"!!! error: $@"
372 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
377 # For conflicting packages
379 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
380 printtask
"!!! error: $@"
381 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
388 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
389 printtask
"!! error: $@ "
390 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
392 printtask
"!! The Auto-Patcher could not find its patches and/or tools!"
394 echo "* Did you run ./batch.sh first?"
396 echo "The patch_patches.tgz and patch_tools.tgz need to be in this directory,"
397 echo " one way or another..."
404 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
405 printtask
"!! error: $@ "
406 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
407 printtask
"Your set-up is missing a dependency."
408 echo "We require JDK, tar, patch and cpio."
411 echo "Each distro is different"
412 echo "but ensure you have them all installed and try again."
419 printtask
"Updater: disabled"
421 printtask
"You will not be able to get automatic updates because we could not find 'git'."
422 printtask
"Find out how to install git for your system and that feature should work automatically"
428 echo -e $@ |
tee -a "$LOG"
435 copy_prepatched_provisional
() {
436 print_to_log
"File for which patching failed:"
437 print_to_log
"---------------------------------------------"
439 print_to_log
"${FAIL##*/}"
441 print_to_log
"---------------------------------------------"
443 print_to_log
"We are adding a pre-patched copy of those files."
445 print_to_log
"Please only file a bug report if running the program gives you problems!!!"
446 print_to_log
"... replace $FAIL ..."
447 \rm
-rf tmp
/${FILE}.out/smali/${FAIL} tmp/${FILE}.out/smali/${FAIL}.orig tmp/${FILE}.out/smali/${FAIL}.rej
448 \
cp -av "$PROVISIONAL" tmp
/${FILE}.out
/smali
/${FAIL} >> "$LOG" 2>&1
449 SID
=(${SID[@]} $FAIL)
450 print_to_log
"... failed patch sucessfully resolved ..."
453 prep_alternate_patch
() {
454 # Use alt.patch, if exists. Increment in case there are multiple alternates.
455 mv -v $ALTERNATIVE_PATCH $PARB/${NAME}.
patch >> "$LOG"
456 ALT_PATCH_NUMBER
=$
((PATCH_NUMBER
+ 1))
458 # Get fresh files/variables + decompile again (use rm b/c privacy files wouldn't get overwritten)
459 # TODO: test patch -R instead of re-decompiling. Should work.
460 rm -rf tmp
/${FILE}.out
/smali
461 java
-jar baksmali.jar
-b -a $API -o tmp
/${FILE}.out
/smali
${FILE} >> "$LOG" 2>> "$LOG"
462 unset FAILS
&& unset SID
463 current_jar
=$
(($current_jar - 1))
467 no_network_access
() {
468 PING_CHECK
"www.github.com" >> "$LOG" 2>&1 && NETWORK
=true
# second try and check github
469 PING_CHECK
"www.google.com" >> "$LOG" 2>&1 # test for internet in general
470 if [[ "$NETWORK" == true
]]; then
473 printtask
"Check for update failed, probably because of no internet access."
474 echo "The autopatcher will continue with current local version: $VERSION"
481 auto_update_error
() {
483 printtask
"### Update failed ###"
485 printtask
"It appears you may have made some changes that prevent automatic updating."
487 printtask
"You could run 'git reset --hard' to return the autopatcher to its original form"
488 printtask
" or set AUTO_UPDATE to false in the .config file to stop getting this message."
494 printtask
"... backing up auto_patcher to auto_patcher.bak ..."
495 cp -av auto_patcher auto_patcher.bak
>> "$LOG" #backup for user in case of changes
499 warn_of_overwrite
() {
500 # Only seen once, by users without ".git" directories
501 # Only users who got program @ download page see this, all others (ApG included) use git
502 echo "This is a one time set-up process that will overwrite all local changes!"
503 echo "If this is not ok with you press ctrl-C and set AUTO_UPDATE to false in .config"
508 printtask
"### establishing the repo ###"
509 echo "... please be patient, this should only be needed once ..."
511 git clone https
://github.com
/mateor
/auto-patcher
>> "$LOG" || no_network_access
513 mv -v auto-patcher
/".git" .
>> "$LOG"
515 git checkout
-q master || auto_update_error
516 git
reset --hard 2>&1 >> "$LOG"
521 export_log_and_variables
() {
522 AUTO_PATCHER_OLD_VERSION
=$VERSION
523 AUTO_PATCHER_OLD_PATCHES_VERSION
=$PATCHES_VERSION
524 AUTO_PATCHER_WAS_UPDATED
=true
525 UPDATED_LOG
="$PATCHES_VERSION".updated.log
526 cp -a "$LOG" "$UPDATED_LOG"
531 CHANGELOG
="changelog.txt"
532 echo "" > "$CHANGELOG"
533 CURRENT_HEAD
=$
(git rev-parse HEAD
)
534 echo "Changelog from Autopatcher$AUTO_PATCHER_OLD_VERSION to Autopatcher$VERSION" >> "$CHANGELOG"
535 echo "---------------------------------------------------------------------------" >> "$CHANGELOG"
536 echo "" >> "$CHANGELOG"
537 echo " Get more info about any individual commit by entering 'git show \$NUMBER'" >> "$CHANGELOG"
538 echo "" >> "$CHANGELOG"
539 git log
--pretty=oneline
$ORIGINAL_HEAD...
$CURRENT_HEAD >> changelog.txt
540 printtask
"... "$CHANGELOG" has been updated ..."
545 # Function for devices that use SDcard installs. Also to be tested for CM7
546 # since CM7 seems to use an updater-script that wipes EMMC. Testing
548 \rm
$UPDATER_LOC/$UPDS 2>&1
549 \
cp patches
/.common
/$UPDATER_LOC/$UPDS $UPDATER_LOC >> "$LOG" 2>&1
550 echo "run_program(\"/sbin/busybox\", \"umount\", \"/system\");" >> UPDATE.txt
551 cat UPDATE.txt
>> $UPDATER_LOC/$UPDS
553 echo "New updater-script being used:" >> "$LOG"
554 echo "-----------------------------" >> "$LOG"
555 cat $UPDATER_LOC/$UPDS >> "$LOG"
561 echo $
(cygpath
-ua "$1") |
sed 's:/$::g'
564 #[[ $(echo $1 | awk '/^\//') == $1 ]] && echo "$1" || echo "$PWD/$1"
565 [[ ${1:0:1} == "/" ]] && echo "$1" ||
echo "$PWD/$1"
568 echo $
(readlink
-f "$1")
571 if [[ ${1:0:1} == "/" ]]; then
573 elif [[ ${1:0:2} == "./" ]]; then
584 echo "The Auto-Patcher $VERSION"
585 echo "*******************************"
587 echo "The available mods are"
588 echo "****************************************************"
589 echo "* pdroid openpdroid voice v6supercharger *"
590 echo "* voice insecure secure external_internal *"
591 echo "* tabletUI 3gdongle pd2.0 *"
592 echo "****************************************************"
594 echo "To find out more about any mod, simply enter:"
595 echo " ./auto_patcher -h <MODNAME>"
604 CEILING
=$CURRENT_ANDROID
614 echo "**************************************"
615 echo "The Auto-Patcher ate a kitten once..."
616 echo "**************************************"
618 DEV
="mateor and Caldair"
619 WEBSITE
="https://github.com/mateor/auto-patcher"
624 (advanced_help
&& find -H * -name 201*) |
more -d
630 DESC
="Use on wifi-only tablets to have the software register as 'voice-enabled'. Allows VOIP like Google Voice to function."
631 DESC
="bongostl's setup method can be seen at the link."
632 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=1823701"
638 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."
640 DEPENDENCY
="The V6 Supercharger Script. Get it at the link"
641 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=991276"
643 PID
="v6supercharger" # allows shorthand 'v6' to find patches.
648 DESC
="Security Software that manages access to personal data w/o causing FC's. No longer under development."
649 DESC1
="Try the open-source expansion of this program, OpenPdroid."
650 DESC2
="(It's the 'openpdroid' mod within the Auto-Patcher)."
652 DEPENDENCY
="The Pdroid app. You can get it at the link"
653 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=1923576"
659 DESC
="An expansion of the PDroid application/framework."
661 DEPENDENCY
="The free PDroid2.0 app available at the link"
662 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=1923576"
667 DESC
="A fork of the open-source PDroid and Pdroid2.0 framework."
668 DEV
="CollegeDev/FFU5y/wbedard/mateorod/Community"
669 DEPENDENCY
="PDroidManager(opensource) or PDroid2.0(CollegeDev)"
670 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=1994860"
674 echo "No mod named 'opendroid'. You probably mean 'openpdroid'. Try again."
681 DESC
="Swap internal and external storage."
685 DESC
="Make any boot.img insecure and allow remount as well as adb push/pull of system files. True root."
689 DESC
="Make any boot.img secure."
694 DESC
="Allows 3gdongles to work on wifi tablets w/o 3rd party applications."
696 DEPENDENCY
="None, but read the troubleshooting guide at the link"
697 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=1798631"
702 if [[ $ANDR == "4.3" ]]; then
703 ROM_CONFLICTS
=(aosp .aosp-slim .aosp-ever aokp pa
)
704 elif [[ $ANDR == "4.2" ]]; then
705 ROM_CONFLICTS
=(.aosp-ever aokp pa
)
707 ROM_CONFLICTS
=(pa .aosp-slim
)
709 DESC
="Changes the user interface of Phones and Phablets to the popular Tablet UI."
710 DEV
="barmullio/Caldair"
711 WEBSITE
="http://forum.xda-developers.com/showthread.php?t=2154075"
717 DESC
="??? Unknown modtype ??? Check your spelling or the mod list!"
718 DESC1
=" Try: \"./auto_patcher -h mods\""
721 # strip decimals from android version (i.e. 2.3.7 becomes 237) so we can do math
723 COMPATF
=${FLOOR//[.]/}
724 COMPATC
=${CEILING//[.]/}
725 if [[ ${#NVID} -lt 3 ]]; then
731 if [ -f patches
/$P/$A/$R/$B/$FILE ]; then
734 # Move the certs and manifests from the ROM's apk into the prepatched copy
735 jar
-xvf ..
/"$FILE" META-INF AndroidManifest.xml
>> "$LOG"
736 jar
-ufv ..
/patches
/$P/$A/$R/$B/$FILE META-INF
/CERT
* AndroidManifest.xml
>> "$LOG" 2>> "$LOG"
738 \
cp -av patches
/$P/$A/$R/$B/$FILE $FILE >> "$LOG" 2>&1
739 echo "... Patching $APK failed, but we have successfuly copied over a prepatched file ..."
742 print_error
"failed patching $APK!!!"
746 no_mod_selected_error
() {
748 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
749 printtask
"!!! error: $@"
750 printtask
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
752 printtask
"You need to enter a MOD before you try and specify the ROMTYPE."
753 printtask
"Check the help menu for the list of available MODS"
758 check_against_rom_types
() {
759 # this checks to see if the user has entered a ROMTYPE in the MOD spot and outputs advice if so.
760 NUMBER_OF_AVAILABLE_ROMTYPES
=${#AVAILABLE_ROMTYPES[@]}
761 for ((i
=0; i
< $NUMBER_OF_AVAILABLE_ROMTYPES; i
++)); do
762 if [[ ${AVAILABLE_ROMTYPES[i]} == "$P" ]]; then
763 no_mod_selected_error
"\"$P\" is a ROMTYPE not a MOD"
769 for G
in ${PID[@]}; do
771 if ($UNKNOWN_MOD); then
772 check_against_rom_types
773 unknown_mod_error
"\"$G\" is not a valid mod. Check your spelling or the mod list!!!"
774 elif [[ "$NVID" -lt "$COMPATF" ]]; then
775 mismatch_error
"Your Android $VID rom is too old! The minimum for $G is \n !!! Android $FLOOR!"
776 elif [[ "$NVID" -gt "$COMPATC" ]]; then
777 mismatch_error
"Sorry, $G has not been made available for Android $VID yet!"
782 rom_compat_check
() {
783 N
=${#ROM_CONFLICTS[@]}
784 for ((i
=0; i
< $N; i
++)); do
785 if [[ $RID == ${ROM_CONFLICTS[$i]} ]]; then
791 rom_compat_error
() {
792 print_error
"$RID is incompatible with $PID!!!"
798 echo $
(cygpath
-da "$1")
806 #contains () { for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done; return 1; }
808 parse
() { echo "${1%%_*}"; }
811 if [ -f system
/build.prop
]; then
812 result
=($
(grep $1 system
/build.prop |
tr -d '\r' |
tr '=' ' '))
821 jar
-xvf "$ROMX" system
/framework
/framework2.jar
>> "$LOG"
822 if [ -s system
/framework
/framework2.jar
]; then
831 MID
=$
(getbuildprop ro.build.romversion
)
832 if [[ $MID == "Evervolv"* ]]; then
835 MID
=$
(getbuildprop ro.build.display.id
)
836 if [[ "$MID" == "ev"* ]]; then
846 MID
=$
(getbuildprop ro.build.romversion
)
847 if [[ "$MID" == "pac"* ]] ||
[[ "$MID" == "PAC"* ]]; then
850 MID
=$
(getbuildprop ro.build.display.id
)
851 if [[ "$MID" == "pac"* ]] ||
[[ "$MID" == "PAC"* ]]; then
860 SLMID
=$
(getbuildprop ro.modversion
)
861 SLMMID
=$
(getbuildprop updateme.name
)
862 if [[ "$SLMMID" == "Slim"* ]] ||
[[ $SLMMID == "slim"* ]]; then
864 elif [[ "$SLMID" == "Slim"* ]] ||
[[ $SLMID == "slim"* ]]; then
867 if [[ "$ANDR" == "4.1" ]]; then
876 CMID
=$
(getbuildprop ro.modversion
)
877 PAID
=$
(getbuildprop ro.pa.version
)
878 MID
=$
(getbuildprop ro.build.display.id
)
879 [[ "$MID" == "" ]] && MID
=$
(parse $
(getbuildprop ro.build.display.id
))
880 DID
=$
(getbuildprop ro.product.device
)
881 [[ "$DID" == "" ]] && DID
=$
(getbuildprop ro.build.product
)
882 if [[ -n $PAID ]]; then
914 VID
=$
(getbuildprop ro.build.version.release
)
915 if [ ${#VID} -lt 4 ]; then # in case of non-standard versioning in build.prop (defy!)
918 ANDR
="${VID%.*}" # Cut to 1 significant digit to cover specific range or release.
920 if [ "$ANDR" == "2.3" ]; then
924 elif [ "$ANDR" == "4.0" ]; then
927 MID
=$
(getbuildprop ro.rommanager.developerid
)
928 [[ "$MID" == "" ]] && MID
=$
(parse $
(getbuildprop ro.modversion
))
929 DID
=$
(getbuildprop ro.product.device
)
930 [[ "$DID" == "" ]] && DID
=$
(getbuildprop ro.build.product
)
933 pa|cm9|cm|cyanogenmod
*)
943 echo "!!! $MID is not supported yet, trying aosp !!!"
947 elif [ "$ANDR" == "4.1" ]; then
950 CMID
=$
(getbuildprop ro.cm.version
)
951 if [[ -n $CMID ]]; then
954 MID
=$
(getbuildprop ro.build.display.id
)
955 [[ "$MID" == "" ]] && MID
=$
(parse $
(getbuildprop ro.build.display.id
))
956 DID
=$
(getbuildprop ro.product.device
)
957 [[ "$DID" == "" ]] && DID
=$
(getbuildprop ro.build.product
)
959 cm10|cm
*|cyanogenmod
*)
972 RID
=$
(aosp_mod_check
);
976 elif [ "$ANDR" == "4.2" ] ||
[ "$ANDR" == "4.3" ]; then
978 [ "$ANDR" == "4.2" ] && API
=17
979 if [ "$ANDR" == "4.3" ]; then
981 BAKSMALI_BINARY
="baksmali.jar"
982 SMALI_BINARY
="smali.jar"
984 CMID
=$
(getbuildprop ro.cm.version
)
985 MID
=$
(getbuildprop ro.build.display.id
)
986 [[ "$MID" == "" ]] && MID
=$
(parse $
(getbuildprop ro.build.display.id
))
987 DID
=$
(getbuildprop ro.product.device
)
988 [[ "$DID" == "" ]] && DID
=$
(getbuildprop ro.build.product
)
993 # hack to account for Final builds with old code and current build dates. Huge hack, but if there
994 # is one thing I don't believe in, it's "educating the user-base". Not happening. So hack it is.
995 if [[ "$CMID" == "10.1.2"* ]] ||
[[ "$CMID" == "10.1.3"* ]]; then
996 echo " ### CMID: $CMID: Selecting CM Final Build patches" >> "$LOG"
997 BID_OVERRIDE
=20130516
1004 if [[ "$MID" == "pac"* ]] ||
[[ "$MID" == "PAC"* ]]; then
1014 RID
="$(ever_check)";
1018 print_error
"unknown ROM version $VID: generally means cannot find/read build.prop"
1020 # romtype_set allows hiding ".aosp-*" types from users while leaving them as options on CLI
1022 echo "... result of ROM check: version= $VID rom= $ROMTYPE ..."
1026 # Advanced build date query
1027 # This should set the patch date automatically.
1030 UTC
=$
(getbuildprop ro.build.
date.utc
)
1032 # Difference in how OS X and Linux/Cygwin handles 'date' utility
1035 BDID
=$
(date -r $UTC +%Y
%m
%d
)
1036 echo "#### Darwin Build Query used ####" >> "$LOG"
1039 BDID
=$
(date -d "1970-01-01 UTC $UTC seconds" +"%Y%m%d")
1040 echo "#### Standard Build Query ####" >> "$LOG"
1044 # If patch date is specified on CLI, use that patch date
1045 if [ $# -gt 3 ]; then
1051 # CM7 roms do not have UTC time stamp- so no build query.
1053 echo "*** CM7 roms default to latest patches. If using an older rom ***"
1054 echo "*** specify patch date on command line. Use -h to see available patches ***"
1058 for P
in ${PID[@]}; do
1059 [ -d patches
/$P/$ANDR ] && A
=$ANDR || A
=all
1060 [ -d patches
/$P/$A/"$RID" ] && R
=$RID || R
=generic
1061 [ -d patches
/$P/$A/$R/$BID ] && B
=$BID || B
=latest
1062 PAR
=patches
/$P/$A/$R
1063 PARB
=patches
/$P/$A/$R/$B
1064 DATES
=$
(ls patches
/$P/$A/"$R" |
grep '201*')
1065 # Intialize variable - an upperbound to determine lowest in first loop.
1067 # find earliest available patch date
1069 if [[ $i -lt $BID ]]; then
1073 # Check if earliest patches are from before build date. Else use earliest
1075 # If rom is newer than earliest patch set, find best match
1076 if [[ $
(($BID-$BDID)) -lt 0 ]]; then
1078 # use any patch that matches $UTC
1079 if [[ $
(($BDID-$g)) -eq 0 ]]; then
1082 # Set highest $BID w/o going over $UTC
1083 elif [[ $
(($BDID-$g)) -gt 0 ]] && [[ $g -gt $BID ]]; then
1088 # Error catch if query fails.
1089 [[ $BID == "20201231" ]] && BID
=latest
&& echo "Build Query Failed!! Default to latest!" >> "$LOG"
1090 if [[ -n "$BID_OVERRIDE" ]]; then
1093 printtask
"... $P patch date has been set to: $BID ..."
1094 MODS_LIST
[$PATCH_COUNTER]=$P
1095 PATCH_DATE_LIST
[$PATCH_COUNTER]=$BID
1096 PATCH_COUNTER
=$
(($PATCH_COUNTER + 1))
1104 RIL
=$
(getbuildprop ro.telephony.ril_class
)
1105 [[ -n $RIL ]] && printtask
"... result of ROM check: RIL= $RIL"
1109 echo "# VER= $VERSION" >> "$LOG"
1110 echo "# OS= $OSTYPE ${BIT}bit" >> "$LOG"
1111 echo "# VID= $VID" >> "$LOG"
1112 echo "# PID= ${PID[@]}" >> "$LOG"
1113 echo "# MID= $MID" >> "$LOG"
1114 echo "# RID= $RID" >> "$LOG"
1115 echo "# ANDR= $ANDR" >> "$LOG"
1116 echo "# BDID= $BDID" >> "$LOG"
1117 echo "# DID= $DID" >> "$LOG"
1118 echo "# BID= $BID" >> "$LOG"
1120 if [ -d ..
/".git" ]; then
1122 echo -n "Current HEAD: " >> "$LOG"
1123 git log
--pretty=oneline HEAD^..HEAD
>> "$LOG"
1129 if [[ $1 == -h ]]; then
1130 if [ $# -gt 1 ]; then
1134 echo "The Auto-Patcher $VERSION by Mateorod and Pastime1971"
1135 echo "*************************************************"
1137 echo "Mod Name: $PID"
1140 if [[ $DESC1 ]]; then # test to see is there is a second DESC line
1143 if [[ $DESC2 ]]; then
1147 echo "Developer: $DEV"
1148 echo "Dependancies: $DEPENDENCY"
1149 if [[ $WEBSITE ]]; then
1150 echo "Website: $WEBSITE"
1153 echo "Works on ROMs from Android $FLOOR -> $CEILING"
1160 [[ $# -lt 1 ||
-z $1 ]] && PID
="mods" && mods_info
1161 [[ $1 == "-h" ]] && usage_help |
less && display_help
1164 echo "The Auto-Patcher $VERSION"
1165 # by pastime1971 and mateorod
1166 if [[ -n "$AUTO_PATCHER_WAS_UPDATED" ]]; then
1167 echo " (auto-updated from $AUTO_PATCHER_OLD_VERSION)"
1172 ROOT
="$(abspath "$
(dirname "$(abspath "$
(type -p "$0")")")")"
1173 TOOL
="$ROOT/patch_tools.tgz"
1174 PTCH
="$ROOT/patch_patches.tgz"
1176 # set temporary directory
1177 DATE
=$
(date +%Y
%m
%d
%H
%M
%S
)
1178 TEMP
="$ROOT/tmp$DATE"
1179 TMP
="$ROOT/tmp$DATE"
1180 TMPDIR
="$ROOT/tmp$DATE"
1183 ROMX
=$
(extpath
"$1")
1187 if [[ $OSTYPE == "cygwin" ]]; then
1192 #PATCH_BINARY="./patch"
1193 AUTO_UPDATE
=false
# CYGWIN AUTO_UPDATE TESTERS COMMENT THIS LINE HERE!
1199 (ping "$PINGCOUNT" "$@")
1202 (ping $@
$PINGCOUNT)
1208 LOG
=$
(abspath .
/log
$DATE.txt
)
1209 #echo $ROOT $TOOL $ROM $TEMP "$LOG"
1210 echo "ROOT= $ROOT" >> "$LOG"
1211 echo "TOOL= $TOOL" >> "$LOG"
1212 echo "ROM= $ROM" >> "$LOG"
1213 echo "ROMX= $ROMX" >> "$LOG"
1216 # Auto-Update # excluding ApG/cygwin for now until I talk with kobik.
1217 # To turn off auto updating, set AUTO_UPDATE in .config to false
1221 if [ $
(which git
) ]; then
1224 miss_git_error
"Missing \"git\" utility"
1228 if [[ "$AUTO_UPDATE" == true
]] && [[ "$GIT" == true
]]; then
1229 PING_CHECK
"www.github.com" > /dev
/null
2>&1 && NETWORK
=true || no_network_access
1230 if [[ "$NETWORK" == true
]]; then
1231 printtask
"### checking for updates ###"
1233 # establish the repo if not already present- one time operation.
1234 if [ ! -d ".git" ]; then
1235 printtask
"... initial setup to allow automatic updating ..."
1236 backup_script
&& warn_of_overwrite
1237 establish_repo
&& export_log_and_variables
1238 printtask
"### rerunning script with latest version ###"
1243 # Here is the regular update process
1244 git fetch origin
2>&1 >> "$LOG" || no_network_access
1245 if !("$NETWORK"); then
1246 printtask
"Updater: not able to run auto_update."
1248 COMMITS_BEHIND
=$
(git rev-list HEAD..origin
/master
--count)
1249 case "$COMMITS_BEHIND" in
1251 printtask
"Updater: Auto-Patcher is already up to date"
1254 ORIGINAL_HEAD
=$
(git rev-parse HEAD
)
1255 printtask
"... Updater: update found ..."
1257 printtask
"... Updating Auto-Patcher ..."
1258 git merge
--no-edit origin
/master
2>&1 >> "$LOG" || auto_update_error
1259 export_log_and_variables
1260 printtask
"### updated, now rerunning script with latest version ###"
1270 if ( [[ -n "$AUTO_PATCHER_WAS_UPDATED" ]] ||
[ -f *".updated.log" ] ); then
1271 ORIGINAL_PATCHES_VERSION
=$
( ls *.updated.log |
sed -e 's/\.updated.log//' )
1272 if ( [[ $PATCHES_VERSION -gt $AUTO_PATCHER_OLD_PATCHES_VERSION ]] ||
[[ $PATCHES_VERSION -gt $ORIGINAL_PATCHES_VERSION ]] ); then
1273 echo "... integrating new patches ..."
1274 sh
batch.sh
>> /dev
/null
2>> "$LOG"
1278 # If program was updated, merge the logs
1279 if ( [[ -n "$AUTO_PATCHER_WAS_UPDATED" ]] ||
[ -f *".updated.log" ] ); then
1280 cat *".updated.log" >> "$LOG"
1281 rm -f *".updated.log"
1284 #remove old zips, if built under identical parameters.
1285 \rm
-f $RESTORE.
zip $UPDATE.
zip
1287 CHK
=$
(getconf LONG_BIT
)
1288 if [[ $CHK = "64" ]]; then
1290 else [[ $BIT = "32" ]];
1294 printtask
"### verify tools ###"
1296 if [[ $CYGWIN == false
]];then
1297 which patch >> "$LOG" || misstools_error
"Missing \"patch\" utility."
1299 which tar >> "$LOG" || misstools_error
"Missing \"tar\" utility"
1300 which jar
>> "$LOG" || misstools_error
"Missing \"Java Development Kit\" (JDK)"
1301 which java
>> "$LOG" || misstools_error
"Missing \"Java Development Kit\" (JDK)"
1302 which cpio >> "$LOG" || misstools_error
"Missing \"cpio\" utility"
1303 [ -f "$TOOL" ] || misspatch_error
"patch_tool.tgz is missing"
1304 [ -f "$PTCH" ] || misspatch_error
"patch_patches.tgz is missing"
1305 printtask
"### verify ROM ###"
1306 [ -f "$ROM" ] || print_error
"Cannot find $1!! Make sure you have the location and name right"
1307 echo "### running $0 $@" >> "$LOG"
1312 echo "PATH= $PATH" >> "$LOG"
1314 printtask
"### unzip patch tools ###"
1315 tar xzf
"$TOOL" > /dev
/null || print_error
"failed extracting tools !!!"
1317 # Get OS specific tools
1320 \
mv cygwin
/aapt.exe .
1321 \
mv cygwin
/patch.
* .
1322 \
mv cygwin
/*.exe boot
/
1323 \rm
-rf cygwin
# why? If you want to we can keep/add it to mac/linux, though.
1335 # Ensure aapt permissions - possibly to one day be expanded to all tools in a function.
1338 printtask
"### unzip patch patches ###"
1339 tar xzf
"$PTCH" > /dev
/null || print_error
"failed extracting patches !!!"
1341 # we need build.prop for both RIL probing and ROM probing
1342 jar
-xvf "$ROMX" system
/build.prop
2>> "$LOG" || print_error
"failed extracting build.prop from $ROMX !!!"
1346 printtask
"### probe rom type ###"
1350 if [ $# -gt 1 ]; then
1352 if [[ "$PIT" = "-h" ]]; then
1357 if [ $# -gt 2 ]; then
1381 RID
=$
(aosp_mod_check
);
1389 date_error
"You must specify ROMTYPE if designating a patch date!!"
1392 rom_error
"$RID is not a valid ROMTYPE!!"
1396 echo "... Using $ROMTYPE patches ..."
1398 echo "... Using results of ROM check ..."
1402 if [ $# -gt 1 ]; then
1403 PIL
=${2//,/ } # If more than one mod, make string separated by spaces
1406 echo "No mods selected. Defaulting to openpdroid, since that's what you probably want..."
1409 # Ensure only 1 Pdroid mod at a time; PDroid first, so provisionals do not overwrite other mods...
1411 PID
=(${PIL// / }) # turn string of requested mods into array
1412 COPYPID
=("${PID[@]}") # working copy to iterate over
1413 MODS_NUMBER
=${#COPYPID[@]} # number of elements (mods)
1415 if [[ $MODS_NUMBER > 1 ]]; then # because if only one mod, not needed
1417 for p
in ${COPYPID[@]}; do
1418 # this first loop detects presence of any pdroid mod and sets it to be first applied (SPID[0])
1419 if [ "$p" = "pdroid" ] ||
[ "$p" = "pd2.0" ] ||
[ "$p" = "openpdroid" ]; then
1420 SPID
[0]=$p #set pdroid first
1421 unset COPYPID
["$INDEX"]
1424 INDEX
=$
((INDEX
+ 1)) # if (!pdroid), set as 1, 2...
1427 for p
in ${COPYPID[@]}; do
1428 # ensures they aren't applyingy more than one pdroid mod and slots in any remaining mods.
1429 if [ "$p" = "pdroid" ] ||
[ $p = "pd2.0" ] ||
[ $p = "openpdroid" ]; then
1430 conflict_error
"Those mods conflict! Only one pdroid mod at a time!"
1438 SPID
=("${COPYPID[@]}")
1440 # reset the mod list, with the pdroid-type mod applied first (for provisional use's sake)
1443 # Check if selected mods are available for rom's Android version.
1446 # Make sure mod and rom don't conflict (e.g. pa and tabletUI)
1447 for T
in ${PID[@]}; do
1448 PID
=$T #Set PID so mods_info function returns different values for each mod
1450 if [[ ${ROM_CONFLICTS[@]} != "None" ]]; then
1454 # reset to original ordered list
1458 if [ $# -gt 3 ]; then # if a date is specified on command line...
1459 # Set date to match argument and ensure that patches with that date exist
1461 [ -d patches
/$PID/$ANDR/$RID/$BID ] || print_error
"No $PID patches for $RID on $BID!! Try the help menu!!"
1462 # Run build_query- this overrides the above but gets useful info
1464 # Reset patch date to argument (basically undo the effects of the build_query call)
1466 printtask
"... $PID patch date set manually to: $BID ..."
1467 PATCH_DATE_LIST
[0]=$BID
1469 build_query
# if no date specified, use one from build_query
1475 if [[ ( "$PID" == "-h" ||
"$RID" == "-h" ||
"$BID" == "-h" ) ]]; then
1476 #Although this placement may be perfect for romfilter. although it throws the scheme...
1481 for P
in ${PID[@]}; do
1482 [ -d patches
/$P ] || print_error
"$P is not available"
1483 [ -d patches
/$P/$ANDR ] && A
=$ANDR || A
=all
1484 [ -d patches
/$P/$A/$RID ] && R
=$RID || R
=generic
1485 [ -d patches
/$P/$A/$R/$BID ] && B
=$BID || B
=latest
1488 [ -f patches
/$P/files.txt
] && FILES
=$
(cat patches
/$P/files.txt
)
1489 [ -f patches
/$P/$A/files.txt
] && FILES
=$
(cat patches
/$P/$A/files.txt
)
1490 [ -f patches
/$P/$A/$R/files.txt
] && FILES
=$
(cat patches
/$P/$A/$R/files.txt
)
1491 [ -f patches
/$P/$A/$R/$B/files.txt
] && FILES
=$
(cat patches
/$P/$A/$R/$B/files.txt
)
1492 for FILE
in ${FILES[@]}; do
1495 [[ ${CID[@]} =~ ${FILE:1} ]] && print_error "${FILE:1} is already being copied" || CID=(${CID[@]} ${FILE:1})
1498 [[ ${EID[@]} =~ ${FILE:1} ]] || EID=(${EID[@]} ${FILE:1})
1501 [[ ${JID[@]} =~
$FILE ]] || JID
=(${JID[@]} $FILE)
1502 echo "set_perm(0, 0, 0644, \"/$FILE\");" >> UPDATE.txt
1504 # added for the use-case of apktool failure
1505 @system
/*apk
) # apks to decompile with smali binaries instead of apktool
1506 [[ ${JID[@]} =~ ${FILE:1} ]] || JID=(${JID[@]} ${FILE:1})
1507 FORMATTED_FILE
=${FILE:1}
1508 echo "set_perm(0, 0, 0644, \"/$FORMATTED_FILE\");" >> UPDATE.txt
1511 [[ ${AID[@]} =~
$FILE ]] || AID
=(${AID[@]} $FILE)
1512 echo "set_perm(0, 0, 0644, \"/$FILE\");" >> UPDATE.txt
1513 # $APKID will have elements removed sometimes--$AID is the master list for the update.zip
1514 declare -a APKID
=( "${AID[@]}" )
1517 [[ ${IID[@]} =~
$FILE ]] || IID
=(${IID[@]} $FILE)
1520 [[ ${TID[@]} =~
$FILE ]] || TID
=(${TID[@]} $FILE)
1525 echo "### DELETE FILES= ${EID[@]}" >> "$LOG"
1526 echo "### COPY FILES= ${CID[@]}" >> "$LOG"
1527 echo "### JAR FILES= ${JID[@]}" >> "$LOG"
1528 echo "### APK FILES= ${AID[@]}" >> "$LOG"
1529 echo "### IMG FILES= ${IID[@]}" >> "$LOG"
1530 echo "### TXT FILES= ${TID[@]}" >> "$LOG"
1532 # extract system files
1533 printtask
"### unzip rom ###"
1534 jar
-xvf "$ROMX" ${JID[@]} ${AID[@]} ${IID[@]} ${TID[@]} 2>> "$LOG" || print_error "failed extracting ${JID[@]} ${AID[@]} ${IID[@]} from
$ROMX !!!"
1537 # Update/Restore.zip scripts and prep
1538 printtask "### create updater script ###"
1539 UPDATER_LOC
=META-INF
/com
/google
/android
1541 UPDATE
="update-$ROMTYPE-$DID-$BDID-${PIL// /-}"
1542 RESTORE
="restore-$ROMTYPE-$DID-$BDID"
1544 jar
-xvf "$ROMX" $UPDATER_LOC/$UPDS $UPDATER_LOC/update-binary
1545 jar
-xvf "$ROMX" $UPDATER_LOC/update-binary-installer
1> /dev
/null
2> /dev
/null
1547 # Determine Installer- Aroma or ClockworkMod
1548 if [ -f $UPDATER_LOC/update-binary-installer
]; then
1549 printtask
"... using Aroma installer ..."
1550 \
mv $UPDATER_LOC/update-binary-installer
$UPDATER_LOC/update-binary
1552 printtask
"... using Clockworkmod installer ..."
1555 # Create updater scripts
1556 cat patches
/.common
/updater-message.txt
>> $UPDS
1557 cat $UPDATER_LOC/$UPDS |
grep ^mount |
grep "/system" |
head -n 1 >> $UPDS
1558 [ -s $UPDS ] ||
echo "run_program(\"/sbin/busybox\", \"mount\", \"/system\");" >> $UPDS
1559 # restore the original
1560 for FILE
in ${EID[@]}; do
1561 jar
-xvf "$ROMX" $FILE 2> /dev
/null || printtask
"!!! warning $FILE cannot be restored !!!"
1563 # replace with the original or delete it
1564 for FILE
in ${CID[@]}; do
1565 jar
-xvf "$ROMX" $FILE 2> /dev
/null ||
echo "delete(\"/$FILE\");" >> $UPDS
1567 echo "package_extract_dir(\"system\", \"/system\");" >> $UPDS
1568 # permission management for files that need specific perms
1569 cat $UPDATER_LOC/$UPDS |
grep set_perm |
grep "/system" >> $UPDS
1570 for P
in ${PID[@]}; do
1571 if [ -s patches
/$P/$A/set_perm.txt
]; then
1572 echo "...setting permissions..."
1573 cat patches
/$P/$A/set_perm.txt
>> $UPDS
1576 cat $UPDATER_LOC/$UPDS |
grep ^unmount |
grep "/system" |
head -n 1 >> $UPDS
1577 [[ ${IID[@]} =~ boot.img
]] && cat $UPDATER_LOC/$UPDS |
grep "boot.img" >> $UPDS
1578 echo "ui_print(\" .\");" >> $UPDS
1579 echo "ui_print(\" .\");" >> $UPDS
1580 echo "ui_print(\" done!\");" >> $UPDS
1581 cat $UPDS > $UPDATER_LOC/$UPDS
1582 echo "# generated $UPDS" >> "$LOG"
1585 printtask
"### create restore.zip ###"
1586 jar
-cvf tmp.
zip ${JID[@]} ${AID[@]} ${IID[@]} META-INF
> /dev
/null
2>> "$LOG"
1587 java
-jar signapk.jar updatecert.pem updatekey.pk8 tmp.
zip signed.
zip 2>> "$LOG"
1588 \
mv signed.
zip $RESTORE.
zip
1592 # Begin patching process
1594 # decompile system files
1595 printtask
"### decompile system files ###"
1596 for FILE
in ${JID[@]}; do
1598 printtask
"... decompile $JAR ..."
1599 java
-jar baksmali.jar
-b -a $API -o tmp
/${FILE}.out
/smali
${FILE} >> "$LOG" 2>> "$LOG"
1600 if [ $FILE == "system/framework/framework.jar" ]; then
1601 printtask
"... extract preloaded-classes ..."
1602 jar
-xvf ${FILE} preloaded-classes
>> "$LOG" 2>> "$LOG"
1603 \
mv preloaded-classes tmp
/${FILE}.out
/
1607 # install framework-files for APK...
1608 if [ ${#AID[@]} -gt 0 ]; then
1609 jar
-xvf "$ROMX" system
/framework
/framework-res.apk
>> "$LOG"
1610 printtask
"... installing framework files ..."
1611 java
-jar apktool.jar
if system
/framework
/framework-res.apk
1613 for FILE
in ${AID[@]}; do
1615 if [ -f $FILE ]; then
1616 printtask
"... decompile $APK ..."
1617 java
-jar apktool.jar d
-f $FILE tmp
/$FILE.out
2>> "$LOG"
1622 # Unpack image files {boot.img only so far...}
1623 for FILE
in ${IID[@]}; do
1624 printtask
"### unpacking $FILE ###"
1627 if [ -f boot.img
]; then
1629 .
/unpackbootimg
$EXE -i ..
/boot.img
>> "$LOG" 2>> "$LOG"
1632 gzip -dc ..
/boot.img-ramdisk.gz |
cpio -i >> "$LOG" 2>> "$LOG"
1635 print_error
"A mod needs to patch boot.img! This rom does not contains boot.img."
1639 print_error
"cannot process $FILE"
1644 # apply system modification
1646 for ((i
=0; i
< ${#PID[@]}; i
++)); do
1648 BID
=${PATCH_DATE_LIST[$i]}
1649 [ -d patches
/$P/$ANDR ] && A
=$ANDR || A
=all
1650 [ -d patches
/$P/$A/$RID ] && R
=$RID || R
=generic
1651 [ -d patches
/$P/$A/$R/$BID ] && B
=$BID || B
=latest
1652 PAR
=patches
/$P/$A/$R
1653 PARB
=patches
/$P/$A/$R/$B
1655 unset FILES COPY DELS JARS APKS IMGS TXTS
1656 [ -f patches
/$P/files.txt
] && FILES
=$
(cat patches
/$P/files.txt
)
1657 [ -f patches
/$P/$A/files.txt
] && FILES
=$
(cat patches
/$P/$A/files.txt
)
1658 [ -f patches
/$P/$A/$R/files.txt
] && FILES
=$
(cat patches
/$P/$A/$R/files.txt
)
1659 [ -f patches
/$P/$A/$R/$B/files.txt
] && FILES
=$
(cat patches
/$P/$A/$R/$B/files.txt
)
1660 for FILE
in ${FILES[@]}; do
1663 COPY
=(${COPY[@]} ${FILE:1})
1666 DELS
=(${DELS[@]} ${FILE:1})
1669 JARS
=(${JARS[@]} $FILE)
1672 JARS
=(${JARS[@]} ${FILE:1})
1675 APKS
=(${APKS[@]} $FILE)
1678 IMGS
=(${IMGS[@]} $FILE)
1681 TXTS
=(${TXTS[@]} $FILE)
1686 [[ -n ${COPY[@]} ]] && echo "### copy patch $P/$A/$ROMTYPE/$B ###"
1687 echo "### copy patch $P/$A/$R/$B ###" >> "$LOG"
1688 for FILE
in ${COPY[@]}; do
1689 printtask
"... copying $FILE ..."
1692 if [ -e patches
/$P/$A/$R/$B/$FILE ]; then
1693 printtask
"... overwriting $FILE from $P ..."
1694 \
cp -av patches
/$P/$A/$R/$B/$FILE .
/$DEST >> "$LOG" 2>&1
1695 elif [ -e patches
/$P/common
/$FILE ]; then
1696 printtask
"... overwriting $FILE from $P ..."
1697 echo " ### SOMETHING WENT WRONG!! Could not find file-- using common. ###" >> "$LOG"
1698 \
cp -av patches
/$P/common
/$FILE .
/$DEST >> "$LOG" 2>&1
1700 print_error
"$FILE is missing in the patch. Please upload your logfile to the support thread!"
1704 # unconditional smali copying- For particularly troublesome files
1705 [ -f patches
/$P/smali.txt
] && SMALI
=$
(cat patches
/$P/smali.txt
)
1706 [ -f patches
/$P/$A/smali.txt
] && SMALI
=$
(cat patches
/$P/$A/smali.txt
)
1707 [ -f patches
/$P/$A/$R/smali.txt
] && SMALI
=$
(cat patches
/$P/$A/$R/smali.txt
)
1708 [ -f patches
/$P/$A/$R/$B/smali.txt
] && SMALI
=$
(cat patches
/$P/$A/$R/$B/smali.txt
)
1710 for SMALI
in ${SMALI[@]}; do
1711 if [ -f patches
/$P/$A/$R/$B/$SMALI ]; then
1712 printtask
"... overwriting $MOVE ..."
1713 \
cp -a patches
/$P/$ANDR/$R/$B/$SMALI tmp
/$SMALI >> "$LOG" 2>&1
1714 # This lower area should be deprecated now...wait and see. Each BID has own link to provisionals now.
1715 elif [ -f patches
/$P/$A/.provisionals
/$SMALI ]; then
1716 printtask
"... overwriting $MOVE ..."
1717 \
cp -a patches
/$P/$ANDR/.provisionals
/$SMALI tmp
/$SMALI >> "$LOG"
1721 [[ -n ${DELS[@]} ]] && echo "### delete patch $P/$A/$ROMTYPE/$B ###"
1722 echo "### delete patch $P/$A/$R/$B ###" >> "$LOG"
1723 for FILE
in ${DELS[@]}; do
1724 printtask
"... deleting $FILE ..."
1727 [[ -n ${JARS[@]} ]] && echo "### jar patch $P/$A/$ROMTYPE/$B ###"
1728 echo "### jar patch $P/$A/$R/$B ###" >> "$LOG"
1730 # Iterate through jars and patch. If fails, try prepatched provisionals or look for alternative patch.
1731 for (( current_jar
=0; current_jar
< ${#JARS[@]}; current_jar
++)); do
1732 FILE
=${JARS[$current_jar]}
1734 if [[ $FILE == *".jar" ]]; then # allows for *.apks to be decompiled by baksmali
1737 # check for abscense of any apks decompiled by baksmali (~* in files.txt). Missing jars will still error
1738 if [ ! -d "tmp/${FILE}.out" ] ; then
1739 echo "No $JAR in your ROM. Not able to patch this file."
1740 echo "## No $JAR in ROM ###" >> "$LOG"
1741 declare -a JID
=( ${JID[@]/$FILE/} )
1744 NAME
=$JAR # TODO: Maybe rename this, since it now encompases apks at times
1746 printtask
"... apply $NAME.patch ..."
1747 $PATCH_BINARY -Nls -p1 -d tmp
/${FILE}.out < $PARB/${NAME}.patch 2>&1 > ${JAR}.log
1748 for INCREMENTAL
in $
(ls $PARB/${NAME}-*.
patch 2>/dev
/null
); do
1749 printtask
"... apply $(basename $INCREMENTAL) ..."
1750 $PATCH_BINARY -Nls -p1 -d tmp
/${FILE}.out
< $INCREMENTAL 2>&1 >> ${JAR}.log
1752 cat ${JAR}.log
>> "$LOG"
1755 # patch preloaded-classes only if a patch exists
1756 if [ -f $PARB/preloaded.
patch ]; then
1757 printtask
"... apply preloaded.patch ..."
1758 $PATCH_BINARY -Nls -p1 -d tmp
/${FILE}.out
< $PARB/preloaded.
patch 2>&1 > preloaded.log
1759 cat preloaded.log
>> "$LOG"
1760 [[ $
(grep FAILED preloaded.log
) != "" ]] && print_error
"failed preloaded.patch"
1764 echo -n "" # do nothing else
1767 # substitute failed smali with provisional (a prepatched smali file)
1769 FAILS
=($
(grep FAILED
${JAR}.log |
sed -e 's/.*smali\///' |
sed -e 's/\.rej//'))
1771 if [[ -n ${FAILS[@]} ]]; then
1772 print_to_log
"!!! PATCHING FAILED FOR ${FAILS[@]} !!!"
1773 echo "### replace ${FAILS[@]} ###" > ${JAR}.log
1774 for FAIL
in ${FAILS[@]}; do
1775 PROVISIONAL
="patches/$P/$ANDR/.provisionals/${FILE}.out/smali/${FAIL}"
1776 ALTERNATIVE_PATCH
=$
(ls $PARB/${NAME}$ALT_PATCH_NUMBER*.
patch 2>/dev
/null
)
1777 if [ ! -f "$PROVISIONAL" ]; then
1778 if [ -f "$ALTERNATIVE_PATCH" ]; then
1779 printtask
"## trying alternative ${NAME} patch ###"
1780 prep_alternate_patch
1782 print_error
"failed $FAIL in $JAR cannot be remedied"
1785 echo "!!! patch error for $FAIL !!!" >> "$LOG"
1786 [[ ${SID[@]} =~
$FAIL ]] && print_error
"$FAIL was already replaced before"
1787 copy_prepatched_provisional
1791 [[ $
(grep FAILED
${JAR}.log
) != "" ]] && print_error
"failed $NAME.patch"
1792 garbage tmp
/${FILE}.out
1794 # run special $JAR.sh scripts if any JAR needs special attention
1795 if [ -f patches
/$P/$A/$R/$B/${JAR}.sh
]; then
1796 printtask
"... apply $JAR.sh ..."
1797 . patches
/$P/$A/$R/$B/${JAR}.sh
2>&1 > ${JAR}.log
1798 cat ${JAR}.log |
tee -a "$LOG"
1802 [[ -n ${APKS[@]} ]] && echo "### apk patch $P/$A/$ROMTYPE/$B ###"
1803 echo "### apk patch $P/$A/$R/$B ###" >> "$LOG"
1804 for FILE
in ${APKS[@]}; do
1806 if [ -d "tmp/${FILE}.out" ] ; then
1807 printtask
"... apply $APK.patch ..."
1808 $PATCH_BINARY -Nls -p2 -d tmp
/${FILE}.out < $PARB/${APK}.patch 2>&1 > ${APK}.log
1809 cat ${APK}.log
>> "$LOG"
1811 if [[ $
(grep FAILED
${APK}.log
) != "" ]]; then
1813 declare -a APKID
=( ${APKID[@]/$FILE/} )
1815 garbage tmp
/${FILE}.out
1817 echo "No $APK in your ROM. Not able to patch this file."
1818 echo "## No $APK in ROM ###" >> "$LOG"
1821 [[ -n ${IMGS[@]} ]] && echo "### img patch $P/$A/$ROMTYPE/$B ###"
1822 echo "### img patch $P/$A/$R/$B ###" >> "$LOG"
1823 for FILE
in ${IMGS[@]}; do
1825 printtask
"... applying $IMG.patch ..."
1826 $PATCH_BINARY -Nls -p1 -d boot
/ramdisk
< $PARB/${IMG}.
patch >> "$LOG" || print_error
"failed patching $FILE"
1829 # Text Editing Functions --this can really do just about anything. Needs a working restore!
1830 [[ -n ${TXTS[@]} ]] && echo "### text patch $P/$A/$ROMTYPE/$B ###"
1831 echo "### text patch $P/$A/$R/$B ###" >> "$LOG"
1832 for FILE
in ${TXTS[@]}; do
1834 if [[ -f $PARB/${TXT}.
patch ]]; then
1835 printtask
"... apply $TXT.patch ..."
1836 $PATCH_BINARY -Nls -p2 -d system
/ < $PARB/${TXT}.
patch 2>&1 > ${TXT}.log
1837 #cat ${TXT}.log | tee -a "$LOG"
1838 [[ $
(grep FAILED
${TXT}.log
) != "" ]] && print_error
"failed $TXT.patch"
1840 if [[ -f $PAR/${TXT}.
awk ]]; then
1841 printtask
"... apply $TXT.awk ..."
1842 awk -f $PAR/${TXT}.
awk $FILE > text || print_error
"failed $TXT.awk"
1845 if [[ -f $PAR/${TXT}.
sed ]]; then
1846 printtask
"... apply $TXT.sed ..."
1847 sed -f $PAR/${TXT}.
sed $FILE > text || print_error
"failed $TXT.sed"
1850 if [[ -f $PAR/${TXT}.sh
]]; then
1851 printtask
"... apply $TXT.sh ..."
1852 .
$PAR/${TXT}.sh
2>&1 >> ${TXT}.log || print_error
"failed $TXT.sh"
1858 # Device specific scripts- Placement is up-for-review
1859 if [ -f patches
/.devices
/$DID/$DID.sh
]; then
1860 . patches
/.devices
/$DID/$DID.sh
1863 # Replace updater-script for CM7- it formats system -Testing
1864 if [ "$ANDR" == "gingerbread" ]; then
1868 # Rebuilding system files
1870 [[ -n ${JID[@]} ]] && printtask
"### rebuild jar ###"
1871 for FILE
in ${JID[@]}; do
1873 printtask
"... rebuild $JAR ..."
1874 java
-Xmx512M -jar smali.jar
-a $API tmp
/${FILE}.out
/smali
-o tmp
/${FILE}.out
/classes.dex
>> "$LOG" 2>> "$LOG"
1875 [ -f tmp
/${FILE}.out
/classes.dex
] || smali_error
"failed compiling $JAR !!!"
1876 jar
-ufv ${FILE} -C tmp
/${FILE}.out
/ classes.dex
>> "$LOG" 2>> "$LOG"
1877 if [ $FILE == "system/framework/framework.jar" ]; then
1878 jar
-ufv ${FILE} -C tmp
/${FILE}.out
/ preloaded-classes
>> "$LOG" 2>> "$LOG"
1882 [[ -n ${APKID[@]} ]] && printtask
"### rebuild apk ###"
1883 for FILE
in ${APKID[@]}; do
1885 if [ -d tmp
/${FILE}.out
]; then
1886 apk_was_copied
=false
1887 printtask
"... rebuild $APK ..."
1888 java
-jar apktool.jar b tmp
/${FILE}.out
>> "$LOG" 2>> "$LOG" || apk_copy
1889 if !("$apk_was_copied"); then
1890 jar
-uvf $FILE -C tmp
/${FILE}.out
/build
/apk
/ .
> /dev
/null
2>> "$LOG"
1895 [[ -n ${IID[@]} ]] && printtask
"### rebuild img ###"
1896 for FILE
in ${IID[@]}; do
1897 printtask
"### rebuild $FILE ###"
1900 # Rebuilding boot.img
1902 printtask
"... rebuilding ramdisk ..."
1903 .
/mkbootfs
$EXE .
/ramdisk |
gzip > ramdisk-new.gz
1904 printtask
"... composing boot.img ..."
1905 BASE
=$
(cat boot.img-base
)
1906 # hex to decimal in cygwin prefixing "0x" w/ C arithmetic
1907 PGSIZE
=$
((${PGFORM}$
(cat boot.img-pagesize
)))
1908 CMDLINE
=$
(cat boot.img-cmdline
)
1909 echo "cmdline = no_console_suspend=1 console=null $CMDLINE" >> "$LOG"
1910 echo "pagesize = $PGSIZE" >> "$LOG"
1911 echo "base = $BASE" >> "$LOG"
1912 printtask
"... rebuilding boot.img ..."
1913 .
/mkbootimg
$EXE --kernel boot.img-zImage
--ramdisk ramdisk-new.gz
--cmdline "no_console_suspend=1 console=null $CMDLINE" --base "$BASE" --pagesize "$PGSIZE" -o ..
/boot.img || print_error
"failed building boot.img"
1917 print_error
"cannot process $FILE"
1922 printtask
"### create $UPDATE.zip ###"
1923 jar
-cfv tmp.
zip ${IID[@]} ${JID[@]} ${AID[@]} ${CID[@]} ${TID[@]} META-INF
>> "$LOG" 2>> "$LOG"
1924 java
-jar signapk.jar updatecert.pem updatekey.pk8 tmp.
zip $UPDATE.
zip 2>> "$LOG"
1926 \
mv $RESTORE.
zip $UPDATE.
zip ..
1927 printtask
"### finished ###"
1929 printtask
"$(colorize_bold ${red}Congratulations), the patching was $(colorize_bold ${red}successful)."
1930 printtask
"Any errors you may have seen were succesfully handled!"
1932 printtask
"!!! Only file a bug report if the software is $(colorize_bold ${grn}not) behaving as expected !!!"
1934 echo "to install patched files, flash:"
1935 printtask
"---$(colorize_bold ${grn}$UPDATE.zip)"
1937 printtask
"to restore original system, flash:"
1938 printtask
"---$(colorize_bold ${grn}$RESTORE.zip)"
1941 # add announcement- optional.
1942 for P
in ${PID[@]}; do
1943 [ -d patches
/$P/$ANDR ] && A
=$ANDR || A
=all
1944 [ -d patches
/$P/$A/$RID ] && R
=$RID || R
=generic
1945 [ -d patches
/$P/$A/$R/$BID ] && B
=$BID || B
=latest
1946 if [ -f patches
/$P/$A/$R/$B/README.txt
]; then
1947 cat patches
/$P/$A/$R/$B/README.txt
1948 elif [ -f patches
/$P/$A/$R/README.txt
]; then
1949 cat patches
/$P/$A/$R/README.txt
1950 elif [ -f patches
/$P/$A/README.txt
]; then
1951 cat patches
/$P/$A/README.txt