Add code for packaging for jcenter

parent 23e1d973
Pipeline #2523 failed with stages
in 17 seconds
......@@ -4,5 +4,7 @@
/jni
/android-ndk
/android-ndk.zip
/obfs4proxy_*.zip
/obfs4proxy*.zip
/obfs4proxy*.pom
/obfs4proxy*.jar
/obfs4
\ No newline at end of file
#!/usr/bin/env python3
from glob import glob
import os
from glob import glob
from shutil import move, rmtree
from subprocess import check_call
from utils import get_build_versions, ex, get_sha256, fail, zip_file
from utils import get_build_versions, ex, get_sha256, fail, zip_files, get_final_file_name, \
get_sources_file_name, get_pom_file_name, reset_time, get_obfs4_version
NDK_DIR = 'android-ndk'
REPO_DIR = 'obfs4'
......@@ -24,12 +25,17 @@ def main():
# Install dependencies (of git HEAD)
ex(['go', 'get', '-d', versions['obfs4']['got-get']])
# Build for various Android versions
# Build for various Android versions and create package
build_android()
# Build for 64-bit Linux
# Build for 64-bit Linux and create package
build_linux()
# Package both builds
package_android(versions)
print()
package_linux(versions)
def setup_android_ndk(versions):
if os.path.isdir(NDK_DIR):
......@@ -124,22 +130,60 @@ def build_android_arch(env, tool, ndk_arch, pie):
ex(['%s/bin/%s-strip' % (toolchain, tool), '-D', 'obfs4proxy'])
pie_suffix = '_pie' if pie else ''
zip_file('obfs4proxy', 'obfs4proxy_%s%s.zip' % (ndk_arch, pie_suffix))
zip_files(['obfs4proxy'], 'obfs4proxy_%s%s.zip' % (ndk_arch, pie_suffix))
os.remove('obfs4proxy')
def build_linux():
ex(['go', 'build', '-o', 'obfs4proxy'] + glob(SOURCE))
ex(['strip', '-D', 'obfs4proxy'])
zip_file('obfs4proxy', 'obfs4proxy_linux-x86_64.zip')
zip_files(['obfs4proxy'], 'obfs4proxy_linux-x86_64.zip')
os.remove('obfs4proxy')
def get_source_files():
files = []
for file_name in glob(SOURCE):
print(file_name)
return files
def package_android(versions):
file_list = ['obfs4proxy_arm.zip', 'obfs4proxy_arm_pie.zip',
'obfs4proxy_x86.zip', 'obfs4proxy_x86_pie.zip']
package(versions, file_list, android=True)
def package_linux(versions):
file_list = ['obfs4proxy_linux-x86_64.zip']
package(versions, file_list, android=False)
def package(versions, file_list, android):
zip_file = get_final_file_name(versions, android)
zip_files(file_list, zip_file)
jar_file = create_sources_jar(versions)
pom_file = create_pom_file(versions, android)
# print hashes for debug purposes
for file in file_list + [jar_file, pom_file, zip_file]:
sha256hash = get_sha256(file)
print("%s: %s" % (file, sha256hash))
def create_sources_jar(versions):
check_call(['git', 'clean', '-dfx'], cwd=REPO_DIR)
jar_files = glob(SOURCE)
for file in jar_files:
reset_time(file)
jar_file = get_sources_file_name(versions)
jar_path = os.path.abspath(jar_file)
check_call(['jar', 'cf', jar_path] + jar_files)
return jar_file
def create_pom_file(versions, android=False):
tor_version = get_obfs4_version(versions)
pom_file = get_pom_file_name(versions, android)
template = 'template-android.pom' if android else 'template.pom'
with open(template, 'rt') as infile:
with open(pom_file, 'wt') as outfile:
for line in infile:
outfile.write(line.replace('VERSION', tor_version))
return pom_file
if __name__ == "__main__":
......
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.briarproject</groupId>
<artifactId>obfs4proxy-android</artifactId>
<version>VERSION</version>
<url>https://torproject.org</url>
<description>Repo for building obfs4proxy for Android.</description>
<licenses>
<license>
<name>BSD-3-clause</name>
<url>https://gitweb.torproject.org/pluggable-transports/obfs4.git/tree/LICENSE</url>
</license>
</licenses>
<developers>
<developer>
<id>yawning</id>
<name>Yawning Angel</name>
<email>yawning at torproject dot org</email>
</developer>
<developer>
<id>torproject</id>
<name>Tor Project</name>
<email>frontdesk@rt.torproject.org</email>
</developer>
</developers>
<scm>
<connection>scm:https://git.torproject.org/pluggable-transports/obfs4.git</connection>
<developerConnection>scm:git@gitweb.torproject.org/pluggable-transports/obfs4.git</developerConnection>
<url>scm:https://gitweb.torproject.org/pluggable-transports/obfs4.git</url>
</scm>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.briarproject</groupId>
<artifactId>obfs4proxy</artifactId>
<version>VERSION</version>
<url>https://torproject.org</url>
<description>Repo for building obfs4proxy for Linux.</description>
<licenses>
<license>
<name>BSD-3-clause</name>
<url>https://gitweb.torproject.org/pluggable-transports/obfs4.git/tree/LICENSE</url>
</license>
</licenses>
<developers>
<developer>
<id>yawning</id>
<name>Yawning Angel</name>
<email>yawning at torproject dot org</email>
</developer>
<developer>
<id>torproject</id>
<name>Tor Project</name>
<email>frontdesk@rt.torproject.org</email>
</developer>
</developers>
<scm>
<connection>scm:https://git.torproject.org/pluggable-transports/obfs4.git</connection>
<developerConnection>scm:git@gitweb.torproject.org/pluggable-transports/obfs4.git</developerConnection>
<url>scm:https://gitweb.torproject.org/pluggable-transports/obfs4.git</url>
</scm>
</project>
......@@ -4,8 +4,6 @@ import sys
from collections import OrderedDict
from subprocess import check_call
REPO_DIR = 'tor-android'
def get_version():
if len(sys.argv) > 2:
......@@ -42,6 +40,32 @@ def get_sha256(filename, block_size=65536):
return sha256.hexdigest()
def zip_file(file_name, zip_name):
ex(['touch', '--no-dereference', '-t', '197001010000.00', file_name])
ex(['zip', '-X', zip_name, file_name])
def reset_time(file_name):
check_call(['touch', '--no-dereference', '-t', '197001010000.00', file_name])
def zip_files(files, zip_name):
for file_name in files:
reset_time(file_name)
ex(['zip', '-D', '-X', zip_name] + files)
def get_obfs4_version(versions):
return versions['obfs4']['tag'].split('-')[1]
def get_file_suffix(versions, android=False):
version = get_obfs4_version(versions)
return "%s-%s" % ("android", version) if android else version
def get_final_file_name(versions, android=False):
return 'obfs4proxy-%s.zip' % get_file_suffix(versions, android)
def get_sources_file_name(versions, android=False):
return 'obfs4proxy-%s-sources.jar' % get_file_suffix(versions, android)
def get_pom_file_name(versions, android=False):
return 'obfs4proxy-%s.pom' % get_file_suffix(versions, android)
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