Verify non-Android Tor binary as well

parent 48ac3e16
Pipeline #2188 passed with stages
in 44 minutes and 53 seconds
......@@ -11,18 +11,26 @@ def main():
# get Tor version from command or show usage information
version = get_version()
if verify(version, for_android=False) and verify(version, for_android=True):
sys.exit(0)
else:
sys.exit(1)
def verify(version, for_android):
# get Tor version and versions of its dependencies
versions = get_build_versions(version)
# download reference binary
file_name = get_final_file_name(versions, android=True)
file_name = get_final_file_name(versions, for_android)
try:
# try downloading from jcenter
check_call(['wget', '--no-verbose', get_url(versions), '-O', file_name])
check_call(['wget', '--no-verbose', get_url(versions, for_android), '-O', file_name])
except CalledProcessError:
# try fallback to bintray
print("Warning: Download from jcenter failed. Trying bintray directly...")
check_call(['wget', '--no-verbose', get_url(versions, fallback=True), '-O', file_name])
check_call(['wget', '--no-verbose', get_url(versions, for_android, fallback=True), '-O',
file_name])
# check if Tor was already build
build_file_name = os.path.join(REPO_DIR, file_name)
......@@ -40,21 +48,24 @@ def main():
print("Build sha256: %s" % build_hash)
# compare hashes
suffix = " for Android" if for_android else ""
if reference_hash == build_hash:
print("Tor version %s was successfully verified! \o/" % versions['tor'])
sys.exit(0)
print("Tor%s version %s was successfully verified! \o/" % (suffix, versions['tor']))
return True
else:
fail("Hashes do not match :(")
print("Hashes for Tor%s version %s do not match! :(" % (suffix, versions['tor']))
return False
def get_url(versions, fallback=False):
def get_url(versions, for_android, fallback=False):
version = get_tor_version(versions)
file = get_final_file_name(versions, android=True)
directory = "tor-android" if for_android else "tor"
file = get_final_file_name(versions, for_android)
if not fallback:
return "https://jcenter.bintray.com/org/briarproject/tor-android/%s/%s" % (version, file)
return "https://jcenter.bintray.com/org/briarproject/%s/%s/%s" % (directory, version, file)
else:
return "https://dl.bintray.com/briarproject/org.briarproject/org/briarproject/tor-android" \
"/%s/%s" % (version, file)
return "https://dl.bintray.com/briarproject/org.briarproject/org/briarproject/%s/%s/%s" % \
(directory, version, file)
if __name__ == "__main__":
......
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