bigrushdog

apktool script

Apr 9th, 2011
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.71 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. exec<$1
  4. res_dir="./res/"
  5. drawables=$res_dir'drawable-mdpi/'
  6.  
  7. echo "Reading public.xml..."
  8. value=0
  9. while read line
  10. do
  11. PUBLIC[$value]=$line$'\n'
  12. ((value ++))
  13. done < $1
  14.  
  15. echo "Parsing public.xml for declared filenames..."
  16. for ((i=0; i<${#PUBLIC[@]};i++));
  17. do
  18. temp[$i]=$(echo ${PUBLIC[$i]}| awk -F ' ' '{print $3}'| cut -c 7-| head -c -2)
  19. done
  20.  
  21. parsed_fnames=($(for((i=0;i<"${#temp[@]}";i++));do echo ${temp[$i]}; done |sort))
  22.  
  23.  
  24. echo "Scanning resources folders for actual resources present..."
  25. pngres=($(find $res_dir -type f -name \*.png -printf %f\\n| sort))
  26.  
  27. echo "Looking for \"APKTOOL_DUMMY\" files in resources..."
  28.  
  29. for ((i=0; i<${#PUBLIC[@]};i++));
  30. do
  31. str5=$(echo ${PUBLIC[$i]}| awk -F ' ' '{print $3}'| cut -c 7-| head -c -7)
  32. if [ "$str5" == "APKTOOL_DUMMY" ]; then
  33.     echo "${PUBLIC[$i]}"
  34. fi
  35. #echo $str5
  36. done
  37.  
  38. echo "Comparing declared resources against actual resources present..."
  39.  
  40. k=0
  41. for ((i=0; i<${#parsed_fnames[@]};i++));
  42. do
  43.     str1=${parsed_fnames[$i]}.png
  44.     str2=${pngres[$k]}
  45.     #echo "str1 = $str1 str2 = $str2"
  46.     if [ "$str1" != "$str2" ]; then
  47.         #echo "$str1 does not equal $str2" >> test1.txt
  48.         str3=${parsed_fnames[$i]}.9.png
  49.     fi
  50.     if [ "$str3" != "$str2" ]; then
  51.         #echo "$str3 does not equal $str2 Creating dummy resource for $str1" >> test1.txt
  52.         #touch "$drawables$str1"
  53.         dummy_list[$k]=$str1
  54.     else
  55.     ((k++))
  56.     #echo "$str3 equals $str2 No action required" >> test1.txt
  57.     fi
  58. #echo "str1 = $str1 not equal str2 = $str2" >> test1.txt
  59. done
  60. echo $k
  61. echo "${dummy_list[@]}"
  62. echo
  63. echo "Created ${#dummy_list[@]} dummy files..."
  64. echo "Public key's = ${#PUBLIC[@]}"
  65. echo "Parsed public for filenames = ${#parsed_fnames[@]}"
  66. echo "Total found PNG files = ${#pngres[@]}"
Advertisement
Add Comment
Please, Sign In to add comment