Commit 61055fcf authored by akwizgran's avatar akwizgran

Merge branch 'non-android-verification' into 'master'

Verify non-Android Tor binary as well

See merge request !4
parents 48ac3e16 ac467dc9
Pipeline #2222 passed with stages
in 43 minutes and 17 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):
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 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',
# 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'])
print("Tor%s version %s was successfully verified! \o/" % (suffix, versions['tor']))
return True
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 "" % (version, file)
return "" % (directory, version, file)
return "" \
"/%s/%s" % (version, file)
return "" % \
(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