Commit cc1f6f29 authored by akwizgran's avatar akwizgran

Reproduce briar-headless.jar.

parent d0ebf7e1
Pipeline #4814 failed with stages
in 6 minutes and 46 seconds
......@@ -5,11 +5,14 @@ import sys
from subprocess import call, check_call, check_output
REPO_DIR = "briar"
REFERENCE_URL = 'https://briarproject.org/apk/briar-%s.apk'
GRADLE_TASK = "briar-android:assembleRelease"
REFERENCE_APK_URL = 'https://briarproject.org/apk/briar-%s.apk'
REFERENCE_JAR_URL = 'https://briarproject.org/jar/briar-headless-%s.jar'
GRADLE_APK_TASK = "briar-android:assembleRelease"
GRADLE_JAR_TASK = "briar-headless:assemble"
APK_PATH = "briar-android/build/outputs/apk/official/release/" + \
"briar-android-official-release-unsigned.apk"
OLD_APK_PATH = "briar-android/build/outputs/apk/release/briar-android-release-unsigned.apk"
JAR_PATH= "briar-headless/build/libs/briar-headless.jar"
BUILD_DIR = "briar-build"
......@@ -21,11 +24,14 @@ def main():
# clone/reset repo and checkout tag
tag = prepare_repo(tag)
# download reference binary (before building to detect missing file early on)
# download reference binaries (before building to detect missing file early on)
version = tag.split('-')[1]
url = REFERENCE_URL % version
apk_url = REFERENCE_APK_URL % version
reference_apk = "briar-%s.apk" % version
check_call(['wget', '--no-verbose', url, '-O', reference_apk])
jar_url = REFERENCE_JAR_URL % version
reference_jar = "briar-headless-%s.jar" % version
check_call(['wget', '--no-verbose', apk_url, '-O', reference_apk])
check_call(['wget', '--no-verbose', jar_url, '-O', reference_jar])
# use non-deterministic file system for building the app to detect issues
if not os.path.exists(BUILD_DIR):
......@@ -33,16 +39,20 @@ def main():
check_call(['disorderfs', '--shuffle-dirents=yes', REPO_DIR, BUILD_DIR])
# build the app
check_call(["./gradlew", "--no-daemon", GRADLE_TASK], cwd=BUILD_DIR)
check_call(["./gradlew", "--no-daemon", GRADLE_APK_TASK, GRADLE_JAR_TASK], cwd=BUILD_DIR)
# check if both APKs match
apk = os.path.join(BUILD_DIR, APK_PATH if version >= "1.1.0" else OLD_APK_PATH)
if call(['./verify-apk.py', reference_apk, apk]) == 0:
print("Version '%s' was built reproducible! :)" % tag)
sys.exit(0)
else:
if call(['./verify-apk.py', reference_apk, apk]) != 0:
sys.exit(1)
# check if both jars match
jar = os.path.join(BUILD_DIR, JAR_PATH)
if call(['./verify-jar.py', reference_jar, jar]) != 0:
sys.exit(1)
print("Version '%s' was built reproducible! :)" % tag)
def prepare_repo(tag):
if os.path.isdir(REPO_DIR):
......
#!/usr/bin/env python3
import hashlib
import os
import re
import subprocess
import sys
import tempfile
import zipfile
from verify import calc_hash, fail
APK_SIG_FILE = re.compile(r'META-INF/[0-9A-Za-z_\-]+\.(SF|RSA|DSA|EC|MF)')
......@@ -60,18 +60,5 @@ def repack_apk(zip_file, new_zip_file):
tmp.writestr(info, f.read(info.filename))
def calc_hash(filename, block_size=65536):
sha512 = hashlib.sha512()
with open(filename, 'rb') as f:
for block in iter(lambda: f.read(block_size), b''):
sha512.update(block)
return sha512.hexdigest()
def fail(msg=""):
sys.stderr.write(msg + "\n")
sys.exit(1)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import os
import subprocess
import sys
from verify import calc_hash, fail
def main():
if len(sys.argv) != 3:
fail("Usage: %s reference_jar built_jar" % sys.argv[0])
verify(sys.argv[1], sys.argv[2])
def verify(reference_jar, built_jar):
if not os.path.isfile(reference_jar):
fail("Cannot verify: Reference jar '%s' does not exist" % reference_jar)
if not os.path.isfile(built_jar):
fail("Cannot verify: Built jar '%s' does not exist" % built_jar)
if calc_hash(reference_jar) != calc_hash(built_jar):
sys.stderr.write("Mismatch detected. Trying to find reason...\n")
subprocess.call(['diffoscope', reference_jar, built_jar])
fail("Files do NOT match! :(")
else:
print("Files match! :)")
sys.exit(0)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import hashlib
import sys
def calc_hash(filename, block_size=65536):
sha512 = hashlib.sha512()
with open(filename, 'rb') as f:
for block in iter(lambda: f.read(block_size), b''):
sha512.update(block)
return sha512.hexdigest()
def fail(msg=""):
sys.stderr.write(msg + "\n")
sys.exit(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment