2020-07-16 19:42:05 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://developer.android.com/studio/command-line/apksigner
|
2016-10-07 01:38:12 +02:00
|
|
|
TERMUX_PKG_DESCRIPTION="APK signing tool"
|
2020-09-16 21:35:50 +02:00
|
|
|
TERMUX_PKG_LICENSE="Apache-2.0, GPL-2.0"
|
2020-07-16 19:42:05 +02:00
|
|
|
TERMUX_PKG_VERSION=${TERMUX_ANDROID_BUILD_TOOLS_VERSION}
|
2020-12-07 21:30:53 +01:00
|
|
|
TERMUX_PKG_REVISION=1
|
2019-08-12 17:28:41 +02:00
|
|
|
TERMUX_PKG_BUILD_IN_SRC=true
|
2016-10-07 01:38:12 +02:00
|
|
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
2020-07-21 10:19:54 +02:00
|
|
|
TERMUX_PKG_SKIP_SRC_EXTRACT=true
|
2016-10-07 01:38:12 +02:00
|
|
|
|
2020-07-21 10:02:33 +02:00
|
|
|
termux_step_get_source() {
|
2020-07-16 19:42:05 +02:00
|
|
|
termux_download \
|
|
|
|
"https://android.googlesource.com/platform/tools/apksig/+/refs/tags/platform-tools-$TERMUX_PKG_VERSION/src/main/java/com/android/apksig/internal/asn1/Asn1BerParser.java?format=TEXT" \
|
2020-10-23 00:23:35 +02:00
|
|
|
$TERMUX_PKG_CACHEDIR/Asn1BerParser_b64.java \
|
2020-07-16 19:42:05 +02:00
|
|
|
f0506dedb7291dce1066b7aec3fc42c70b1862b39d9cdb176ba75d24b870765e
|
2020-10-23 00:23:35 +02:00
|
|
|
mkdir -p "$TERMUX_PKG_SRCDIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_post_get_source() {
|
|
|
|
cd "$TERMUX_PKG_SRCDIR"
|
|
|
|
mkdir -p com/android/apksig/internal/asn1
|
|
|
|
base64 -d $TERMUX_PKG_CACHEDIR/Asn1BerParser_b64.java > com/android/apksig/internal/asn1/Asn1BerParser.java
|
2020-07-16 19:42:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_pre_configure() {
|
|
|
|
# Requires Android SDK, not available on device
|
|
|
|
if $TERMUX_ON_DEVICE_BUILD; then
|
|
|
|
termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make() {
|
2020-07-16 19:42:05 +02:00
|
|
|
mkdir -p $TERMUX_PREFIX/share/dex
|
|
|
|
cp $ANDROID_HOME/build-tools/${TERMUX_PKG_VERSION}/lib/apksigner.jar "$TERMUX_PKG_SRCDIR"
|
|
|
|
SOURCEFILE="$TERMUX_PKG_SRCDIR/apksigner.jar"
|
2016-10-07 18:59:01 +02:00
|
|
|
|
2020-07-16 19:42:05 +02:00
|
|
|
cd "$TERMUX_PKG_SRCDIR"
|
2020-09-16 21:35:50 +02:00
|
|
|
|
|
|
|
# java.util.Base64 is available only on Android 8 and higher.
|
|
|
|
# Provide a class copied from OpenJDK, so apksigner will work
|
|
|
|
# on Android 7.
|
|
|
|
mkdir -p java/util
|
|
|
|
cp $TERMUX_PKG_BUILDER_DIR/Base64.java java/util/
|
|
|
|
javac java/util/Base64.java
|
2020-07-16 19:42:05 +02:00
|
|
|
javac -cp "$SOURCEFILE" com/android/apksig/internal/asn1/Asn1BerParser.java
|
2020-09-16 22:49:46 +02:00
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64.class'
|
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64$1.class'
|
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64$DecInputStream.class'
|
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64$Decoder.class'
|
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64$Encoder.class'
|
|
|
|
zip -u "$SOURCEFILE" 'java/util/Base64$EncOutputStream.class'
|
2020-07-16 19:42:05 +02:00
|
|
|
zip -u "$SOURCEFILE" com/android/apksig/internal/asn1/Asn1BerParser.class
|
2018-07-26 12:21:43 +02:00
|
|
|
|
|
|
|
$TERMUX_D8 \
|
|
|
|
--classpath $ANDROID_HOME/platforms/android-$TERMUX_PKG_API_LEVEL/android.jar \
|
|
|
|
--release \
|
|
|
|
--min-api $TERMUX_PKG_API_LEVEL \
|
|
|
|
--output $TERMUX_PKG_TMPDIR \
|
2020-07-16 19:42:05 +02:00
|
|
|
$SOURCEFILE
|
|
|
|
}
|
2018-07-26 12:21:43 +02:00
|
|
|
|
2020-07-16 19:42:05 +02:00
|
|
|
termux_step_make_install() {
|
2018-07-26 12:21:43 +02:00
|
|
|
cd $TERMUX_PKG_TMPDIR
|
2020-07-16 19:42:05 +02:00
|
|
|
unzip $SOURCEFILE */*.txt
|
|
|
|
jar cf apksigner.jar classes.dex com/
|
2018-07-26 12:21:43 +02:00
|
|
|
mv apksigner.jar $TERMUX_PREFIX/share/dex/apksigner.jar
|
|
|
|
|
2016-10-07 01:38:12 +02:00
|
|
|
echo '#!/bin/sh' > $TERMUX_PREFIX/bin/apksigner
|
2020-07-26 02:25:09 +02:00
|
|
|
echo "dalvikvm -Xcompiler-option --compiler-filter=speed -cp $TERMUX_PREFIX/share/dex/apksigner.jar com.android.apksigner.ApkSignerTool \$@" >> $TERMUX_PREFIX/bin/apksigner
|
2016-10-07 01:38:12 +02:00
|
|
|
chmod +x $TERMUX_PREFIX/bin/apksigner
|
|
|
|
}
|
2020-07-26 13:19:30 +02:00
|
|
|
|
|
|
|
termux_step_create_debscripts() {
|
|
|
|
cat <<- EOF > ./postinst
|
2020-07-26 19:32:34 +02:00
|
|
|
#!${TERMUX_PREFIX}/bin/bash
|
|
|
|
rm -f $TERMUX_PREFIX/share/dex/oat/*/apksigner.{art,oat,odex,vdex} >/dev/null 2>&1
|
2020-07-26 13:19:30 +02:00
|
|
|
exit 0
|
|
|
|
EOF
|
|
|
|
}
|