Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit cb169a2

Browse files
bluemarvinkeianhzo
authored andcommitted
Support v1 signing for Oculus Go APK (#2196)
1 parent 3a5a1bc commit cb169a2

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

.taskcluster.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ tasks:
143143
&& cp tools/gradle/taskcluster.properties ./user.properties
144144
&& ./gradlew --no-daemon --console=plain clean `python tools/taskcluster/build_targets.py ${event.release.tag_name}`
145145
&& python tools/taskcluster/fetch_secret.py -s project/firefoxreality/fr/release-signing-token -o token -n token
146-
&& python tools/taskcluster/sign_apk.py -t token -r
146+
&& python tools/taskcluster/fetch_secret.py -s project/firefoxreality/fr/release-signing-token -o v1token -n v1
147+
&& python tools/taskcluster/sign_apk.py -t token -c v1token -r
147148
&& python tools/taskcluster/archive_debug_apk.py
148149
&& . tools/taskcluster/upload_symbols.sh
149150
artifacts:

tools/taskcluster/sign_apk.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,28 @@
1111
import subprocess
1212
import sys
1313

14+
v1_platforms = {
15+
'oculusvr3dofstore',
16+
}
17+
1418
def main(name, argv):
1519
token = ''
20+
v1_token = ''
1621
sign_url = 'https://edge.stage.autograph.services.mozaws.net/sign'
1722
release = False
18-
feature_name = ""
23+
feature_name = ''
1924
try:
20-
opts, args = getopt.getopt(argv,"hrt:f:")
25+
opts, args = getopt.getopt(argv,"hrt:c:f:")
2126
except getopt.GetoptError:
22-
print name + ' -t <token file name> -r -f <feature name>'
27+
print name + ' -t <token file name> -c <v1 token file name> -r -f <feature name>'
2328
sys.exit(2)
2429
for opt, arg in opts:
2530
if opt == '-h':
26-
print name + ' -t <token file name> -r -f <feature name>'
31+
print name + ' -t <token file name> -c <v1 token file name> -r -f <feature name>'
2732
sys.exit()
33+
elif opt in ("-c"):
34+
with open(arg, 'r') as tokenfile:
35+
v1_token = tokenfile.read().rstrip()
2836
elif opt in ("-t"):
2937
with open(arg, 'r') as tokenfile:
3038
token = tokenfile.read().rstrip()
@@ -34,30 +42,56 @@ def main(name, argv):
3442
elif opt in ('-f'):
3543
feature_name = arg.replace('/','-') + '-'
3644

45+
if not release and v1_token != '':
46+
print "Warning, v1 signing is only supported in production"
3747

3848
build_output_path = './app/build/outputs/apk'
49+
3950
# Create folder for saving build artifacts
4051
artifacts_path = './builds'
4152
if not os.path.exists(artifacts_path):
4253
os.makedirs(artifacts_path)
4354

4455
# Sign APKs
4556
for apk in glob.glob(build_output_path + "/*/*/*-unsigned.apk"):
57+
print "=" * 80
58+
cred = token
4659
target = apk.replace('-unsigned', '-signed')
60+
align = False
61+
4762
if not release:
4863
target = target.replace('-release-', '-staging-' + feature_name)
64+
else:
65+
for platform in v1_platforms:
66+
if platform in target.lower():
67+
print "Using v1 signing on target:", target
68+
cred = v1_token
69+
align = True
70+
4971
print "Signing", apk
5072
print "Target ", target
51-
print subprocess.check_output([
52-
"curl",
53-
"-F", "input=@" + apk,
54-
"-o", target,
55-
"-H", "Authorization: " + token,
56-
sign_url])
73+
cmd = ["curl", "-F", "input=@" + apk, "-o", target, "-H", "Authorization: " + cred, sign_url]
74+
75+
try:
76+
print subprocess.check_output(cmd)
77+
except subprocess.CalledProcessError as err:
78+
cmd = ' '.join(err.cmd).replace(cred, "XXX")
79+
print "Signing apk failed:", cmd
80+
print "Output:", err.output
81+
sys.exit(err.returncode)
82+
83+
if align:
84+
split = os.path.splitext(target)
85+
orig = target;
86+
target = split[0] + "-aligned" + split[1]
87+
print subprocess.check_output(["zipalign", "-f", "-v", "-p", "4", orig, target])
88+
5789
print "Verifying", target
58-
print subprocess.check_output(['apksigner', 'verify', target])
90+
print subprocess.check_output(['apksigner', 'verify', '--verbose', target])
5991
print "Archiving", target
6092
os.rename(target, artifacts_path + "/" + os.path.basename(target))
93+
print "=" * 80
94+
print "Done Signing"
6195

6296
if __name__ == "__main__":
6397
main(sys.argv[0], sys.argv[1:])

0 commit comments

Comments
 (0)