-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild
executable file
·46 lines (34 loc) · 1.43 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
[ -z "$1" ] && echo "usage: ./build <directory>" && echo "e.g. ./build disass" && exit 1
# read .env
if [ -f .env ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
[ -z "$JAVA_PATH" ] && JAVA_PATH=java
[ -z "$APKTOOL_PATH" ] && APKTOOL_PATH=/opt/apktool/apktool.jar
[ -z "$UBER_APK_SIGNER_PATH" ] && UBER_APK_SIGNER_PATH=/opt/uber-apk-signer/uber-apk-signer-1.2.1.jar
echo "JAVA_PATH: $JAVA_PATH"
echo "APKTOOL_PATH: $APKTOOL_PATH"
echo "UBER_APK_SIGNER_PATH: $UBER_APK_SIGNER_PATH"
# Set version
VERSION=$(jq -r ".version" bttv.manifest.json)
VERSIONCODE=$(jq -r ".versionCode" bttv.manifest.json)
sed -i "s/android:versionCode=\".*\"/android:versionCode=\"${VERSIONCODE}\"/" $1/AndroidManifest.xml
sed -i "s/android:versionName=\".*\"/android:versionName=\"${VERSION}\"/" $1/AndroidManifest.xml
sed -i "s/android:text=\"BTTV .*\"/android:text=\"BTTV ${VERSION}\"/" $1/res/layout/settings_logout_footer.xml
cd $1
APK_PATH=./dist/twitch.apk
# Build using APKTool
$JAVA_PATH -Xmx6g -jar $APKTOOL_PATH b . --use-aapt2 &&
# Sign with keystore if available, else use debug KS
if [ -z "$KS" ]; then
$JAVA_PATH -jar $UBER_APK_SIGNER_PATH -a $APK_PATH
rm $APK_PATH &&
mv ./dist/twitch-aligned-debugSigned.apk $APK_PATH
else
$JAVA_PATH -jar $UBER_APK_SIGNER_PATH -a $APK_PATH --ks $KS --ksAlias bttv-android --ksPass $KSPASS --ksKeyPass $KSPASS
rm $APK_PATH &&
mv ./dist/twitch-aligned-signed.apk $APK_PATH
fi
echo "Done: $APK_PATH"