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

This commit is contained in:
codebymikey 2024-09-06 11:30:56 +01:00 committed by GitHub
parent c5dbcd6532
commit 5974d7477e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 12 deletions

View File

@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# This script is a wrapper for smali.jar, so you can simply call "smali", # This script is a wrapper for apktool.jar, so you can simply call "apktool",
# instead of java -jar smali.jar. It is heavily based on the "dx" script # instead of java -jar apktool.jar. It is heavily based on the "dx" script
# from the Android SDK # from the Android SDK
# Set up prog to be the path of this script, including following symlinks, # Set up prog to be the path of this script, including following symlinks,
@ -41,10 +41,15 @@ cd "${oldwd}"
jarfile=apktool.jar jarfile=apktool.jar
libdir="$progdir" libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ] if [ ! -r "$libdir/$jarfile" ]; then
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" echo `basename "$prog"`": can't find $jarfile"
exit 1 exit 1
fi
fi fi
javaOpts="" javaOpts=""

View File

@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# This script is a wrapper for smali.jar, so you can simply call "smali", # This script is a wrapper for apktool.jar, so you can simply call "apktool",
# instead of java -jar smali.jar. It is heavily based on the "dx" script # instead of java -jar apktool.jar. It is heavily based on the "dx" script
# from the Android SDK # from the Android SDK
# Set up prog to be the path of this script, including following symlinks, # Set up prog to be the path of this script, including following symlinks,
@ -43,8 +43,14 @@ jarfile=apktool.jar
libdir="$progdir" libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ] if [ ! -r "$libdir/$jarfile" ]
then 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" echo `basename "$prog"`": can't find $jarfile"
exit 1 exit 1
fi
fi fi
javaOpts="" javaOpts=""