chris41g

Zipalign

Oct 6th, 2011
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.55 KB | None | 0 0
  1. #!/system/bin/sh
  2. ## This program is free software; you can redistribute it and/or modify it
  3. # under the terms of the GNU Library General Public License as published
  4. # by the Free Software Foundation; either version 2, or (at your option)
  5. # any later version.
  6. ## This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9. # GNU General Public License for more details.
  10. ## License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
  11. ##
  12. ## Automatic ZipAlign by Wes Garner
  13. # ZipAlign files in /data not previously ZipAligned (using md5sum)
  14. # Thanks to oknowton for the changes
  15. # Changelog:
  16. # 1.1 (12/1/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
  17. # 1.0 (11/30/09) Original
  18. ZA='logwrapper zipalign'
  19. log -p i -t init:zipalign "INIT.zipalign BEGIN:automatic ZipAlign"
  20. for apk in /data/app/*.apk ; do
  21.     $ZA -c 4 $apk
  22.     ZIPCHECK=$?
  23.     if [ $ZIPCHECK -eq 1 ]; then
  24.         log -p i -t init:zipalign "INIT.zipalign INFO:ZipAligning $(basename $apk)"
  25.         $ZA -f 4 $apk /cache/$(basename $apk);
  26.             if [ -e /cache/$(basename $apk) ]; then
  27.                 logwrapper cp -f -p /cache/$(basename $apk) $apk
  28.                 rm /cache/$(basename $apk);
  29.             else
  30.                 log -p e -t init:zipalign "INIT.zipalign ERROR:ZipAligning $(basename $apk) failed"
  31.             fi;
  32.     else
  33.         log -p d -t init:zipalign "INIT.zipalign DEBUG:ZipAlign already completed on $apk"
  34.     fi;
  35. done;
  36. log -p i -t init:zipalign "INIT.zipalign END:automatic ZipAlign finished"
  37.  
Advertisement
Add Comment
Please, Sign In to add comment