-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapk_finalize.sh
More file actions
executable file
·63 lines (53 loc) · 1.12 KB
/
apk_finalize.sh
File metadata and controls
executable file
·63 lines (53 loc) · 1.12 KB
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
#!/usr/bin/env bash
# sign and zipalign .apk
#
# Arguments:
# $1: APK to sign / zipalign
# $2: Output apk
#
# Environment:
# - STOREPASS: (required) password for KEYSTORE
# - KEYSTORE: path to the keystore to use
# - KEY_ALIAS: alias of the signing key in the KEYSTORE
set -exuo pipefail
APK="${1?Missing APK}"
APK_OUT="${2?Missing Output apk}"
STOREPASS="${STOREPASS?Missing Storepass}"
KEYSTORE="${KEYSTORE:-count-release-key.keystore}"
KEY_ALIAS="${KEY_ALIAS:-count-release-key}"
ZIPALIGN_BIN="$(find \
"${ANDROID_SDK_ROOT}" \
-executable \
-name \
"zipalign" \
-print \
-quit
)"
if [ ! -f "${APK}" ]; then
echo "'${APK}' is not a file" >&2
exit 1
fi
if [ ! -x "${ZIPALIGN_BIN}" ]; then
echo "Could not locate zipalign. Tried: '${ZIPALIGN_BIN}'" >&2
exit 1
fi
APK_TMP="$(mktemp)"
function cleanup {
rm -f "${APK_TMP}"
}
trap cleanup EXIT
cp "${APK}" "${APK_TMP}"
jarsigner \
-verbose \
-sigalg SHA1withRSA \
-storepass:env STOREPASS \
-digestalg SHA1 \
-keystore "${KEYSTORE}" \
"${APK_TMP}" \
"${KEY_ALIAS}"
"${ZIPALIGN_BIN}" \
-f \
-v \
4 \
"${APK_TMP}" \
"${APK_OUT}"