Commit 381bedbc authored by akwizgran's avatar akwizgran

Merge branch '64bit' into 'master'

Build 64-bit versions of Tor

See merge request !8
parents 538d0ff9 100f9f04
Pipeline #3741 passed with stages
in 55 minutes and 11 seconds
......@@ -3,7 +3,7 @@ import os
from shutil import move, copy, rmtree
from subprocess import check_call
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_tor_version, \
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_version_tag, \
get_final_file_name, get_sources_file_name, get_pom_file_name, get_version
ZLIB_REPO_URL = 'https://github.com/madler/zlib.git'
......@@ -42,7 +42,8 @@ def main():
file_list = ['tor_linux-x86_64.zip', 'geoip.zip']
zip_name = pack(versions, file_list)
# zip Android binaries together
file_list_android = ['tor_arm_pie.zip', 'tor_arm.zip', 'tor_x86_pie.zip', 'tor_x86.zip',
file_list_android = ['tor_arm.zip', 'tor_arm_pie.zip', 'tor_arm64_pie.zip',
'tor_x86.zip', 'tor_x86_pie.zip', 'tor_x86_64_pie.zip',
'geoip.zip']
zip_name_android = pack(versions, file_list_android, android=True)
......@@ -93,7 +94,7 @@ def setup_android_ndk(versions):
else:
fail("Could not extract NDK: %s" % str(content))
os.putenv('ANDROID_NDK_HOME', os.path.abspath(NDK_DIR))
os.environ['ANDROID_NDK_HOME'] = os.path.abspath(NDK_DIR)
def prepare_tor_android_repo(versions):
......@@ -139,31 +140,50 @@ def checkout(name, tag, path):
def build_android():
# build arm pie
os.unsetenv('APP_ABI')
os.unsetenv('NDK_PLATFORM_LEVEL')
os.unsetenv('PIEFLAGS')
build_android_arch('tor_arm_pie.zip')
os.environ.pop("PIEFLAGS", None) # uses default PIE flags, if not present
# build arm
os.putenv('NDK_PLATFORM_LEVEL', '14')
os.putenv('PIEFLAGS', '')
build_android_arch('tor_arm.zip')
env = os.environ.copy()
env['APP_ABI'] = "armeabi-v7a"
env['NDK_PLATFORM_LEVEL'] = "14"
env['PIEFLAGS'] = "" # do not use default PIE flags
build_android_arch('tor_arm.zip', env)
# build x86 pie
os.putenv('APP_ABI', 'x86')
os.unsetenv('NDK_PLATFORM_LEVEL')
os.unsetenv('PIEFLAGS')
build_android_arch('tor_x86_pie.zip')
# build arm pie
env = os.environ.copy()
env['APP_ABI'] = "armeabi-v7a"
env['NDK_PLATFORM_LEVEL'] = "16" # first level supporting PIE
build_android_arch('tor_arm_pie.zip', env)
# build arm64 pie
env = os.environ.copy()
env['APP_ABI'] = "arm64-v8a"
env['NDK_PLATFORM_LEVEL'] = "21" # first level supporting 64-bit
build_android_arch('tor_arm64_pie.zip', env)
# build x86
os.putenv('NDK_PLATFORM_LEVEL', '14')
os.putenv('PIEFLAGS', '')
build_android_arch('tor_x86.zip')
env = os.environ.copy()
env['APP_ABI'] = "x86"
env['NDK_PLATFORM_LEVEL'] = "14"
env['PIEFLAGS'] = "" # do not use default PIE flags
build_android_arch('tor_x86.zip', env)
# build x86 pie
env = os.environ.copy()
env['APP_ABI'] = "x86"
env['NDK_PLATFORM_LEVEL'] = "16" # first level supporting PIE
build_android_arch('tor_x86_pie.zip', env)
# build x86_64 pie
env = os.environ.copy()
env['APP_ABI'] = "x86_64"
env['NDK_PLATFORM_LEVEL'] = "21" # first level supporting 64-bit
build_android_arch('tor_x86_64_pie.zip', env)
def build_android_arch(name):
check_call(['make', '-C', 'external', 'clean', 'tor'], cwd=REPO_DIR)
def build_android_arch(name, env):
print("Building %s" % name)
check_call(['make', '-C', 'external', 'clean', 'tor'], cwd=REPO_DIR, env=env)
copy(os.path.join(EXT_DIR, 'bin', 'tor'), os.path.join(REPO_DIR, 'tor'))
check_call(['strip', '-D', 'tor'], cwd=REPO_DIR)
tor_path = os.path.join(REPO_DIR, 'tor')
......@@ -261,13 +281,13 @@ def create_sources_jar(versions):
def create_pom_file(versions, android=False):
tor_version = get_tor_version(versions)
version = get_version_tag(versions)
pom_name = get_pom_file_name(versions, android)
template = 'template-android.pom' if android else 'template.pom'
with open(template, 'rt') as infile:
with open(pom_name, 'wt') as outfile:
for line in infile:
outfile.write(line.replace('VERSION', tor_version))
outfile.write(line.replace('VERSION', version))
return pom_name
......
{
"0.3.5.8-64": {
"tor": "tor-0.3.5.8",
"libevent": "release-2.1.8-stable",
"openssl": "OpenSSL_1_0_2q",
"xz": "v5.2.4",
"zlib": "v1.2.11",
"zstd": "v1.3.8",
"tor-android": "55791c108d4b732b1c12866e4db3b8b1fd826bf1",
"tor_android_repo_url": "https://github.com/n8fr8/tor-android",
"ndk": {
"url": "https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip",
"revision": "15.2.4203891",
"sha256": "f01788946733bf6294a36727b99366a18369904eb068a599dde8cca2c1d2ba3c"
}
},
"0.3.5.8": {
"tor": "tor-0.3.5.8",
"libevent": "release-2.1.8-stable",
......
......@@ -22,6 +22,7 @@ def get_build_versions(tag):
if tag is None:
# take top-most Tor version
tag = next(iter(versions))
versions[tag]['tag'] = tag
return versions[tag]
......@@ -38,12 +39,12 @@ def get_sha256(filename, block_size=65536):
return sha256.hexdigest()
def get_tor_version(versions):
return versions['tor'].split('-')[1]
def get_version_tag(versions):
return versions['tag']
def get_file_suffix(versions, android=False):
version = get_tor_version(versions)
version = get_version_tag(versions)
return "%s-%s" % ("android", version) if android else version
......
......@@ -3,8 +3,8 @@ import os
import sys
from subprocess import check_call, CalledProcessError
from utils import REPO_DIR, get_sha256, get_build_versions, get_final_file_name, \
get_version, get_tor_version
from utils import get_sha256, get_build_versions, get_final_file_name, \
get_version, get_version_tag
REF_DIR = "reference"
......@@ -53,7 +53,7 @@ def verify(version, for_android):
# compare hashes
suffix = " for Android" if for_android else ""
if reference_hash == build_hash:
print("Tor%s version %s was successfully verified! \o/" % (suffix, versions['tor']))
print("Tor%s version %s was successfully verified! \\o/" % (suffix, versions['tor']))
return True
else:
print("Hashes for Tor%s version %s do not match! :(" % (suffix, versions['tor']))
......@@ -61,7 +61,7 @@ def verify(version, for_android):
def get_url(versions, for_android, fallback=False):
version = get_tor_version(versions)
version = get_version_tag(versions)
directory = "tor-android" if for_android else "tor"
file = get_final_file_name(versions, for_android)
if not fallback:
......
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