Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
reflex-frp
GitHub Repository: reflex-frp/reflex-platform
Path: blob/develop/android/deploy.sh
1 views
1
#!/usr/bin/env bash
2
3
PATH="$PATH:@java@/bin:@adb@/bin:@coreutils@/bin"
4
5
APK="$(echo @out@/*.apk)"
6
7
sign=
8
store_file=
9
key_alias=
10
store_password=
11
key_password=
12
while [ $# -gt 0 ]; do
13
case "$1" in
14
--sign)
15
sign=1
16
shift
17
;;
18
--store-file)
19
shift
20
store_file="$1"
21
shift
22
;;
23
--store-password)
24
shift
25
store_password="$1"
26
shift
27
;;
28
--key-alias)
29
shift
30
key_alias="$1"
31
shift
32
;;
33
--key-password)
34
shift
35
key_password="$1"
36
shift
37
;;
38
*)
39
>&2 echo Unrecognized argument "$1"
40
exit 1
41
;;
42
esac
43
done
44
45
# Sign at deploy time to prevent private information from leaking to
46
# the Nix store.
47
if [ -n "$sign" ]; then
48
if [ -z "$store_file" ] || [ -z "$key_alias" ] || [ -z "$store_password" ] || [ -z "$key_password" ]; then
49
>&2 echo Please pass arguments for --store-file, --key-alias, --store-password, AND --key-password
50
exit 1
51
fi
52
53
# Create writable temp file
54
signed_apk=$(mktemp --suffix=.apk)
55
cp "$APK" "$signed_apk"
56
chmod +w "$signed_apk"
57
APK="$signed_apk"
58
59
# This should be the equivalent to what Gradle does with
60
# ‘signingConfig’. Using
61
# https://stackoverflow.com/questions/21457538/how-to-use-jarsigner-for-signing-an-apk/21458940
62
# as a reference.
63
64
jarsigner -sigalg SHA1withRSA \
65
-digestalg SHA1 \
66
-keystore "$store_file" \
67
-keypass "$key_password" \
68
-storepass "$store_password" \
69
"$APK" \
70
"$key_alias"
71
72
fi
73
74
adb install -r "$APK"
75
76