droidzone

data/app odex-er

Mar 5th, 2011
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/system/bin/sh
  2. #
  3. # Posted by Droidzone
  4. # data/app odex-er
  5. # experimental - nandroid backup before you run this script!
  6. #
  7. # version 0.1, 29th January 2010
  8. # updated by Martin Johnson, M.J.Johnson @ massey.ac.nz June 2010 for Vogue
  9. #
  10.  
  11. rm /tmp.odex
  12. cd /data/app
  13.  
  14. # Check for and delete leftover .odex files after uninstalled apps
  15. for filename in *.odex
  16. do
  17. name=`basename $filename .odex`
  18. if [ ! -f $name.apk -a -f $filename ]
  19. then
  20. rm $filename
  21. echo "Removed $filename"
  22. fi
  23. done;
  24.  
  25. # Loop through all installed apps
  26. for filename in *.apk
  27. do
  28. name=`basename $filename .apk`
  29. if [ ! -f $name.odex -o $filename -nt $name.odex ]
  30. then
  31. # step 1 - odex the apk
  32. rm -f /tmp.odex
  33. /system/bin/dexopt-wrapper $filename /tmp.odex
  34.  
  35. # step 2 - did we succesfully odex?
  36. if [ $? -eq 0 ]
  37. then
  38. # step 3 - remove the classes.dex from the apk
  39. /system/bin/zip -d $filename classes.dex
  40.  
  41. # continue only if classes.dex was present
  42. if [ $? -eq 0 ]
  43. then
  44. # step 4 - zipalign, just in case
  45. /system/bin/zipalign -f -v 4 $filename /$filename.new
  46. mv -f /$filename.new $filename
  47. mv -f /tmp.odex $name.odex
  48. touch $name.odex
  49. echo "Odexed $filename"
  50. else
  51. echo "Error $filename did not contain classes.dex"
  52. fi
  53. else
  54. echo "Error creating odex from $filename"
  55. fi
  56. else
  57. echo "Nothing to do: $filename"
  58. fi
  59. done;
RAW Paste Data