Commit 18ac6041 authored by Torsten Grote's avatar Torsten Grote

Merge branch 'sources-jar' into 'master'

Create sources jar and POM for JCenter

See merge request !1
parents 6b72028f 697326b8
Pipeline #1894 passed with stages
in 32 minutes and 28 seconds
......@@ -9,6 +9,7 @@ ADD build-tor.py ./
ADD install*.sh ./
ADD tor-versions.json ./
ADD utils.py ./
ADD template.pom ./
RUN ./install.sh
......
......@@ -4,7 +4,7 @@ import sys
from shutil import move, copy, rmtree
from subprocess import check_call
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_final_file_name, get_version
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_tor_version, get_final_file_name, get_sources_file_name, get_pom_file_name, get_version
NDK_DIR = 'android-ndk'
......@@ -38,8 +38,14 @@ def main():
zip_name = get_final_file_name(versions)
check_call(['zip', '-D', '-X', zip_name] + file_list, cwd=REPO_DIR)
# create sources jar
jar_name = create_sources_jar(versions)
# create POM file from template
pom_name = create_pom_file(versions)
# print hashes for debug purposes
for file in file_list + [zip_name]:
for file in file_list + [zip_name, jar_name, pom_name]:
sha256hash = get_sha256(os.path.join(REPO_DIR, file))
print("%s: %s" % (file, sha256hash))
......@@ -152,5 +158,29 @@ def reset_time(filename):
check_call(['touch', '--no-dereference', '-t', '197001010000.00', filename])
def create_sources_jar(versions):
external_dir = os.path.join(REPO_DIR, 'external')
check_call(['git', 'clean', '-dfx'], cwd=external_dir)
jar_files = []
for root, dirnames, filenames in os.walk(external_dir):
for f in filenames: jar_files.append(os.path.join(root, f))
for file in jar_files: reset_time(file)
jar_name = get_sources_file_name(versions)
jar_path = os.path.abspath(os.path.join(REPO_DIR, jar_name))
rel_paths = [os.path.relpath(f, external_dir) for f in sorted(jar_files)]
check_call(['jar', 'cf', jar_path] + rel_paths, cwd=external_dir)
return jar_name
def create_pom_file(versions):
tor_version = get_tor_version(versions)
pom_name = get_pom_file_name(versions)
with open('template.pom', 'rt') as infile:
with open(os.path.join(REPO_DIR, pom_name), 'wt') as outfile:
for line in infile:
outfile.write(line.replace('VERSION', tor_version))
return pom_name
if __name__ == "__main__":
main()
......@@ -12,4 +12,5 @@ apt-get install -y --no-install-recommends \
autopoint \
libtool \
automake \
binutils-multiarch
binutils-multiarch \
fastjar
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.briarproject</groupId>
<artifactId>tor-android</artifactId>
<version>VERSION</version>
<url>https://github.com/n8fr8/tor-android</url>
<description>Repo for building Tor for Android.</description>
<licenses>
<license>
<name>BSD-3-clause</name>
<url>https://github.com/n8fr8/tor-android/blob/master/LICENSE</url>
</license>
</licenses>
<developers>
<developer>
<id>dingledine</id>
<name>Roger Dingledine</name>
<email>arma@mit.edu</email>
</developer>
<developer>
<id>mathewson</id>
<name>Nick Mathewson</name>
<email>nickm@torproject.org</email>
</developer>
<developer>
<id>torproject</id>
<name>Tor Project</name>
<email>frontdesk@rt.torproject.org</email>
</developer>
<developer>
<id>n8fr8</id>
<name>Nathan Freitas</name>
<email>nathan@guardianproject.info</email>
</developer>
</developers>
<scm>
<connection>scm:https://github.com/n8fr8/tor-android.git</connection>
<developerConnection>scm:git@github.com:n8fr8/tor-android.git</developerConnection>
<url>scm:https://github.com/n8fr8/tor-android</url>
</scm>
</project>
......@@ -38,5 +38,17 @@ def get_sha256(filename, block_size=65536):
return sha256.hexdigest()
def get_tor_version(versions):
return versions['tor'].split('-')[1]
def get_final_file_name(versions):
return 'tor-android-%s.zip' % versions['tor'].split('-')[1]
return 'tor-android-%s.zip' % get_tor_version(versions)
def get_sources_file_name(versions):
return 'tor-android-%s-sources.jar' % get_tor_version(versions)
def get_pom_file_name(versions):
return 'tor-android-%s.pom' % get_tor_version(versions)
......@@ -3,7 +3,7 @@ import os
import sys
from subprocess import check_call, CalledProcessError
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_final_file_name, get_version
from utils import REPO_DIR, get_sha256, fail, get_build_versions, get_final_file_name, get_version, get_tor_version
def main():
......@@ -47,7 +47,7 @@ def main():
def get_url(versions, fallback=False):
version = versions['tor'].split('-')[1]
version = get_tor_version(versions)
file = get_final_file_name(versions)
if not fallback:
return "https://jcenter.bintray.com/org/briarproject/tor-android/%s/%s" % (version, file)
......
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