apktool 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2007 The Android Open Source Project
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # This script is a wrapper for smali.jar, so you can simply call "smali",
  17. # instead of java -jar smali.jar. It is heavily based on the "dx" script
  18. # from the Android SDK
  19. # Set up prog to be the path of this script, including following symlinks,
  20. # and set up progdir to be the fully-qualified pathname of its directory.
  21. prog="$0"
  22. while [ -h "${prog}" ]; do
  23. newProg=`/bin/ls -ld "${prog}"`
  24. newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
  25. if expr "x${newProg}" : 'x/' >/dev/null; then
  26. prog="${newProg}"
  27. else
  28. progdir=`dirname "${prog}"`
  29. prog="${progdir}/${newProg}"
  30. fi
  31. done
  32. oldwd=`pwd`
  33. progdir=`dirname "${prog}"`
  34. cd "${progdir}"
  35. progdir=`pwd`
  36. prog="${progdir}"/`basename "${prog}"`
  37. cd "${oldwd}"
  38. jarfile=apktool_2.4.1.jar
  39. libdir="$progdir"
  40. if [ ! -r "$libdir/$jarfile" ]
  41. then
  42. echo `basename "$prog"`": can't find $jarfile"
  43. exit 1
  44. fi
  45. javaOpts=""
  46. # If you want DX to have more memory when executing, uncomment the following
  47. # line and adjust the value accordingly. Use "java -X" for a list of options
  48. # you can pass here.
  49. #
  50. javaOpts="-Xmx512M -Dfile.encoding=utf-8"
  51. # Alternatively, this will extract any parameter "-Jxxx" from the command line
  52. # and pass them to Java (instead of to dx). This makes it possible for you to
  53. # add a command-line parameter such as "-JXmx256M" in your ant scripts, for
  54. # example.
  55. while expr "x$1" : 'x-J' >/dev/null; do
  56. opt=`expr "$1" : '-J\(.*\)'`
  57. javaOpts="${javaOpts} -${opt}"
  58. shift
  59. done
  60. if [ "$OSTYPE" = "cygwin" ] ; then
  61. jarpath=`cygpath -w "$libdir/$jarfile"`
  62. else
  63. jarpath="$libdir/$jarfile"
  64. fi
  65. # add current location to path for aapt
  66. PATH=$PATH:`pwd`;
  67. export PATH;
  68. exec java $javaOpts -jar "$jarpath" "$@"