Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to automatically pick up the latest apktool.jar version #3683

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions scripts/linux/apktool
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is a wrapper for smali.jar, so you can simply call "smali",
# instead of java -jar smali.jar. It is heavily based on the "dx" script
# This script is a wrapper for apktool.jar, so you can simply call "apktool",
# instead of java -jar apktool.jar. It is heavily based on the "dx" script
# from the Android SDK

# Set up prog to be the path of this script, including following symlinks,
Expand All @@ -41,10 +41,15 @@ cd "${oldwd}"

jarfile=apktool.jar
libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ]
then
echo `basename "$prog"`": can't find $jarfile"
exit 1
if [ ! -r "$libdir/$jarfile" ]; then
# Find the highest version of apktool_*.jar in the directory.
highest_jarfile=$(ls "$libdir"/apktool_*.jar 2>/dev/null | sort -V | tail -n 1)
if [ -n "$highest_jarfile" ]; then
jarfile=$(basename "$highest_jarfile")
else
echo `basename "$prog"`": can't find $jarfile"
exit 1
fi
fi

javaOpts=""
Expand Down
18 changes: 12 additions & 6 deletions scripts/osx/apktool
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is a wrapper for smali.jar, so you can simply call "smali",
# instead of java -jar smali.jar. It is heavily based on the "dx" script
# This script is a wrapper for apktool.jar, so you can simply call "apktool",
# instead of java -jar apktool.jar. It is heavily based on the "dx" script
# from the Android SDK

# Set up prog to be the path of this script, including following symlinks,
Expand Down Expand Up @@ -43,8 +43,14 @@ jarfile=apktool.jar
libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ]
then
echo `basename "$prog"`": can't find $jarfile"
exit 1
# Find the highest version of apktool_*.jar in the directory.
highest_jarfile=$(ls "$libdir"/apktool_*.jar 2>/dev/null | sort -V | tail -n 1)
if [ -n "$highest_jarfile" ]; then
jarfile=$(basename "$highest_jarfile")
else
echo `basename "$prog"`": can't find $jarfile"
exit 1
fi
fi

javaOpts=""
Expand All @@ -66,9 +72,9 @@ while expr "x$1" : 'x-J' >/dev/null; do
done

if [ "$OSTYPE" = "cygwin" ] ; then
jarpath=`cygpath -w "$libdir/$jarfile"`
jarpath=`cygpath -w "$libdir/$jarfile"`
else
jarpath="$libdir/$jarfile"
jarpath="$libdir/$jarfile"
fi

# add current location to path for aapt
Expand Down