forked from eduvpn/android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ar_build_app_tar.sh
executable file
·74 lines (59 loc) · 2.78 KB
/
ar_build_app_tar.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
###############################################################################
# CONFIGURATION
###############################################################################
SDK_DIR=${HOME}/android-rebuilds-sdk
KEY_STORE=${HOME}/android.jks
V=2.0.5
DOWNLOAD_URL=https://github.com/eduvpn/android/releases/download/${V}/eduvpn-android-${V}.tar.xz
PROJECT_DIR=${HOME}/Projects
APP_DIR=${PROJECT_DIR}/eduvpn-android-${V}
# eduVPN
GRADLE_TASK=app:assembleBasicRelease
UNSIGNED_APK=${APP_DIR}/app/build/outputs/apk/basic/release/app-basic-release-unsigned.apk
SIGNED_APK=${PROJECT_DIR}/eduVPN-${V}.apk
# Let's Connect!
#GRADLE_TASK=app:assembleHomeRelease
#UNSIGNED_APK=${APP_DIR}/app/build/outputs/apk/home/release/app-home-release-unsigned.apk
#SIGNED_APK=${PROJECT_DIR}/LetsConnect-${V}.apk
###############################################################################
# CLONE
###############################################################################
(
mkdir -p "${PROJECT_DIR}"
cd "${PROJECT_DIR}" || exit
curl -L -o ${PROJECT_DIR}/eduvpn-android-${V}.tar.xz "${DOWNLOAD_URL}"
tar -xJf ${PROJECT_DIR}/eduvpn-android-${V}.tar.xz
)
###############################################################################
# PATCH
###############################################################################
(
SCRIPT_DIR=${PWD}
cd "${APP_DIR}" || exit
echo "Patching extracted sources"
# Checking beforehand if patch can be applied or not:
# If reversing the patch (-R) works that means the patch was already applied, do a dry run to not apply anything (--dry-run) and do not output anything extra for it (-s)
# This all means reversing the patch will fail succesfully™ (hence -s will not silence _all_ errors)
# If the patch was already applied the second command will not execute (OR operator)
# If reversing the patch does not work it will actually patch the to be changed files
patch -p1 -s < ${SCRIPT_DIR}/patches/android-rebuilds/ar.patch
echo "Patched extracted sources"
)
###############################################################################
# BUILD
###############################################################################
(
export ANDROID_HOME=${SDK_DIR}
cd "${APP_DIR}" || exit
./gradlew ${GRADLE_TASK} --warning-mode all --stacktrace || exit
)
###############################################################################
# SIGN
###############################################################################
(
# pick the newest build tools in case multiple versions are available
BUILD_TOOLS_VERSION=$(ls ${SDK_DIR}/build-tools/ | sort -r | head -1)
${SDK_DIR}/build-tools/${BUILD_TOOLS_VERSION}/apksigner sign --ks "${KEY_STORE}" "${UNSIGNED_APK}" || exit
cp "${UNSIGNED_APK}" "${SIGNED_APK}" || exit
)