Commit 7749c943 authored by Torsten Grote's avatar Torsten Grote

Remove non-pie versions from build

Also use custom tag as version name to allow re-builds of same version
parent eb2acc67
Pipeline #3750 passed with stages
in 10 minutes and 16 seconds
......@@ -3,7 +3,7 @@ import os
from glob import glob
from subprocess import check_call
from utils import get_build_versions, ex, get_sha256, fail, zip_files, get_final_file_name, \
from utils import get_build_versions, ex, get_sha256, zip_files, get_final_file_name, \
get_sources_file_name, get_pom_file_name, reset_time, get_obfs4_version, check_go_version, \
get_version, GO_PATH, GO_ROOT, NDK_DIR
......@@ -78,32 +78,23 @@ def build_android(versions):
env = os.environ.copy()
env['GOARCH'] = "arm"
env['GOARM'] = "7"
build_android_arch(versions, env, "arm-linux-androideabi", ndk_arch="arm", pie=False)
env = os.environ.copy()
env['GOARCH'] = "arm"
env['GOARM'] = "7"
build_android_arch(versions, env, "arm-linux-androideabi", ndk_arch="arm", pie=True)
build_android_arch(versions, env, "arm-linux-androideabi", ndk_arch="arm")
env = os.environ.copy()
env['GOARCH'] = "arm64"
env['GOARM'] = "7"
build_android_arch(versions, env, "aarch64-linux-android", ndk_arch="arm64", pie=True)
build_android_arch(versions, env, "aarch64-linux-android", ndk_arch="arm64")
env = os.environ.copy()
env['GOARCH'] = "386"
build_android_arch(versions, env, "i686-linux-android", ndk_arch="x86", pie=False)
env = os.environ.copy()
env['GOARCH'] = "386"
build_android_arch(versions, env, "i686-linux-android", ndk_arch="x86", pie=True)
build_android_arch(versions, env, "i686-linux-android", ndk_arch="x86")
env = os.environ.copy()
env['GOARCH'] = "amd64"
build_android_arch(versions, env, "x86_64-linux-android", ndk_arch="x86_64", pie=True)
build_android_arch(versions, env, "x86_64-linux-android", ndk_arch="x86_64")
def build_android_arch(versions, env, tool, ndk_arch, pie):
def build_android_arch(versions, env, tool, ndk_arch):
toolchain = os.path.join("toolchain", ndk_arch)
if not os.path.isdir(toolchain):
toolchain_maker = os.path.join(NDK_DIR, "build", "tools", "make-standalone-toolchain.sh")
......@@ -114,14 +105,15 @@ def build_android_arch(versions, env, tool, ndk_arch, pie):
env['CGO_CFLAGS'] = "-O2" # removes -g
env['GOOS'] = "android"
build_mode = "pie" if pie else "exe"
extldflags = " -extldflags=-pie" if pie else ""
build_mode = "pie"
extldflags = " -extldflags=-pie"
print("Building obfs4proxy_%s_pie.zip" % ndk_arch)
ex(['go', 'build', '-buildmode=%s' % build_mode, '-ldflags', '-w -s' + extldflags] + GO_FLAGS +
[os.path.join('.', versions['build_path'])], env=env, cwd=REPO_DIR)
pie_suffix = '_pie' if pie else ''
zip_files(['obfs4proxy'], 'obfs4proxy_%s%s.zip' % (ndk_arch, pie_suffix))
zip_files(['obfs4proxy'], 'obfs4proxy_%s_pie.zip' % ndk_arch)
os.remove('obfs4proxy')
......@@ -129,14 +121,15 @@ def build_linux(versions):
env = os.environ.copy()
env['CGO_ENABLED'] = "0"
build_path = os.path.join('.', versions['build_path'])
print("Building obfs4proxy_linux-x86_64.zip")
ex(['go', 'build', '-ldflags', '-w -s'] + GO_FLAGS + [build_path], env=env, cwd=REPO_DIR)
zip_files(['obfs4proxy'], 'obfs4proxy_linux-x86_64.zip')
os.remove('obfs4proxy')
def package_android(versions):
file_list = ['obfs4proxy_arm.zip', 'obfs4proxy_arm_pie.zip', 'obfs4proxy_arm64_pie.zip',
'obfs4proxy_x86.zip', 'obfs4proxy_x86_pie.zip', 'obfs4proxy_x86_64_pie.zip']
file_list = ['obfs4proxy_arm_pie.zip', 'obfs4proxy_arm64_pie.zip',
'obfs4proxy_x86_pie.zip', 'obfs4proxy_x86_64_pie.zip']
package(versions, file_list, android=True)
......
......@@ -16,7 +16,7 @@ then
fi
# update package sources
apt-get update --allow-releaseinfo-change
apt-get update
apt-get -y upgrade
# do not install documentation to keep image small
......
......@@ -34,6 +34,7 @@ def get_build_versions(tool, tag):
if tag is None:
# take top-most version
tag = next(iter(versions[tool]))
versions[tool][tag]['tag'] = tag
return tag, versions[tool][tag]
......@@ -76,10 +77,7 @@ def zip_files(files, zip_name):
def get_obfs4_version(versions):
version = versions['revision']
if '-' in version:
return version.split('-')[1]
return version
return versions['tag']
def get_file_suffix(versions, android=False):
......
{
"obfs4proxy": {
"0.0.11": {
"0.0.11-2": {
"repo_url": "https://git.torproject.org/pluggable-transports/obfs4.git",
"revision": "obfs4proxy-0.0.11",
"build_path": "obfs4proxy",
"go": {
"version": "go1.11.5",
"sha256": "bc1ef02bb1668835db1390a2e478dcbccb5dd16911691af9d75184bbe5aa943e"
"version": "go1.13.1",
"sha256": "81f154e69544b9fa92b1475ff5f11e64270260d46e7e36c34aafc8bc96209358"
},
"ndk": {
"url": "https://dl.google.com/android/repository/android-ndk-r18-linux-x86_64.zip",
......
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