From b738bdd14eb5692653a5bc1d067c85ddd09938e7 Mon Sep 17 00:00:00 2001 From: Nico Alt Date: Wed, 3 Mar 2021 12:00:00 +0000 Subject: [PATCH 1/3] Actually make headless work on arm aarch64 Following the two comments at https://code.briarproject.org/briar/briar/-/issues/1854#note_44340 .jar files now get built with $ ./gradlew --configure-on-demand briar-headless:x86LinuxJar $ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar Related to #1854 --- .../plugin/tor/UnixTorPluginFactory.java | 6 ++++ briar-headless/README.md | 5 +-- briar-headless/build.gradle | 33 ++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java index 35fe3cc90..0f7117c65 100644 --- a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java +++ b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java @@ -96,15 +96,21 @@ public class UnixTorPluginFactory implements DuplexPluginFactory { String architecture = null; if (isLinux()) { String arch = System.getProperty("os.arch"); + LOG.info("System's os.arch is " + arch); if (arch.equals("amd64")) { architecture = "linux-x86_64"; } + else if (arch.equals("aarch64")) { + architecture = "linux-aarch64"; + } } if (architecture == null) { LOG.info("Tor is not supported on this architecture"); return null; } + LOG.info("The selected architecture for Tor is " + architecture); + Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL, MAX_POLLING_INTERVAL, BACKOFF_BASE); TorRendezvousCrypto torRendezvousCrypto = new TorRendezvousCryptoImpl(); diff --git a/briar-headless/README.md b/briar-headless/README.md index 3b37bd571..bc050a925 100644 --- a/briar-headless/README.md +++ b/briar-headless/README.md @@ -11,9 +11,10 @@ The REST API peer comes as a `jar` file and needs a Java Runtime Environment (JRE) that supports at least Java 8. It currently works only on GNU/Linux operating systems. -To build the `jar` file, you can do this: +To build the `jar` file, you need to specify the combination of architecture and platform: - $ ./gradlew --configure-on-demand briar-headless:jar + $ ./gradlew --configure-on-demand briar-headless:x86LinuxJar + $ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar You can start the peer (and its API server) like this: diff --git a/briar-headless/build.gradle b/briar-headless/build.gradle index 4357f06fe..641ca400e 100644 --- a/briar-headless/build.gradle +++ b/briar-headless/build.gradle @@ -44,18 +44,32 @@ dependencies { kaptTest "com.google.dagger:dagger-compiler:$daggerVersion" } -jar { - manifest { +void jarFactory(Jar jarTask, jarArchitecture) { + jarTask.doFirst { + println 'Building ' + jarArchitecture + ' version has started' + } + jarTask.manifest { attributes( 'Main-Class': 'org.briarproject.briar.headless.MainKt' ) } - from { + jarTask.setArchiveClassifier(jarArchitecture) + jarTask.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - doLast() { + { + String[] architectures = ["linux-aarch64", "linux-x86_64"] + for (String arch : architectures) { + if (arch != jarArchitecture) { + exclude "obfs4proxy_" + arch + ".zip" + exclude "tor_" + arch + ".zip" + } + } + } + jarTask.with jar + jarTask.doLast { // Rename the original jar - File jar = project.jar.archivePath + File jar = jarTask.archivePath String srcPath = jar.toString().replaceFirst('\\.jar$', '.unsorted.jar') File srcFile = new File(srcPath) jar.renameTo(srcFile) @@ -80,9 +94,18 @@ jar { } destStream.close() srcJarFile.close() + println 'Building ' + jarArchitecture + ' version has finished' } } +task aarch64LinuxJar(type: Jar) { + jarFactory(it, 'linux-aarch64') +} + +task x86LinuxJar(type: Jar) { + jarFactory(it, 'linux-x86_64') +} + // At the moment for non-Android projects we need to explicitly mark the code generated by kapt // as 'generated source code' for correct highlighting and resolve in IDE. idea { From d7afbdf690af2964a3f443381be91af955a22eec Mon Sep 17 00:00:00 2001 From: Nico Alt Date: Tue, 9 Mar 2021 12:00:00 +0000 Subject: [PATCH 2/3] Use Tor binary for armhf (armv7) Example devices are Nexus 5 and Raspberry Pi v2. Based on https://code.briarproject.org/briar/briar/-/merge_requests/1376 Related to https://code.briarproject.org/briar/briar/-/issues/1854 --- .../bramble/plugin/tor/UnixTorPluginFactory.java | 14 ++++++++++---- briar-headless/README.md | 1 + briar-headless/build.gradle | 6 +++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java index 0f7117c65..d5efba41c 100644 --- a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java +++ b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java @@ -25,6 +25,7 @@ import javax.annotation.concurrent.Immutable; import javax.inject.Inject; import javax.net.SocketFactory; +import static java.util.logging.Level.INFO; import static java.util.logging.Logger.getLogger; import static org.briarproject.bramble.util.OsUtils.isLinux; @@ -96,12 +97,15 @@ public class UnixTorPluginFactory implements DuplexPluginFactory { String architecture = null; if (isLinux()) { String arch = System.getProperty("os.arch"); - LOG.info("System's os.arch is " + arch); + if (LOG.isLoggable(INFO)) { + LOG.info("System's os.arch is " + arch); + } if (arch.equals("amd64")) { architecture = "linux-x86_64"; - } - else if (arch.equals("aarch64")) { + } else if (arch.equals("aarch64")) { architecture = "linux-aarch64"; + } else if (arch.equals("arm")) { + architecture = "linux-armhf"; } } if (architecture == null) { @@ -109,7 +113,9 @@ public class UnixTorPluginFactory implements DuplexPluginFactory { return null; } - LOG.info("The selected architecture for Tor is " + architecture); + if (LOG.isLoggable(INFO)) { + LOG.info("The selected architecture for Tor is " + architecture); + } Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL, MAX_POLLING_INTERVAL, BACKOFF_BASE); diff --git a/briar-headless/README.md b/briar-headless/README.md index bc050a925..0b446467a 100644 --- a/briar-headless/README.md +++ b/briar-headless/README.md @@ -15,6 +15,7 @@ To build the `jar` file, you need to specify the combination of architecture and $ ./gradlew --configure-on-demand briar-headless:x86LinuxJar $ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar + $ ./gradlew --configure-on-demand briar-headless:armhfLinuxJar You can start the peer (and its API server) like this: diff --git a/briar-headless/build.gradle b/briar-headless/build.gradle index 641ca400e..53eae7bb0 100644 --- a/briar-headless/build.gradle +++ b/briar-headless/build.gradle @@ -58,7 +58,7 @@ void jarFactory(Jar jarTask, jarArchitecture) { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } { - String[] architectures = ["linux-aarch64", "linux-x86_64"] + String[] architectures = ["linux-aarch64", "linux-armhf", "linux-x86_64"] for (String arch : architectures) { if (arch != jarArchitecture) { exclude "obfs4proxy_" + arch + ".zip" @@ -102,6 +102,10 @@ task aarch64LinuxJar(type: Jar) { jarFactory(it, 'linux-aarch64') } +task armhfLinuxJar(type: Jar) { + jarFactory(it, 'linux-armhf') +} + task x86LinuxJar(type: Jar) { jarFactory(it, 'linux-x86_64') } From e21e6267d744f6bf5738e22df84aa11abf2a899f Mon Sep 17 00:00:00 2001 From: Nico Alt Date: Mon, 8 Mar 2021 12:00:00 +0000 Subject: [PATCH 3/3] Update Tor dependency to include armhf binary Related MR: https://code.briarproject.org/briar/tor-reproducer/-/merge_requests/13 --- bramble-java/build.gradle | 2 +- bramble-java/witness.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bramble-java/build.gradle b/bramble-java/build.gradle index 8b3211c9e..3d51e8fec 100644 --- a/bramble-java/build.gradle +++ b/bramble-java/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation fileTree(dir: 'libs', include: '*.jar') implementation 'net.java.dev.jna:jna:4.5.2' implementation 'net.java.dev.jna:jna-platform:4.5.2' - tor 'org.briarproject:tor:0.3.5.13@zip' + tor 'org.briarproject:tor:0.3.5.13-1@zip' tor 'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a@zip' annotationProcessor 'com.google.dagger:dagger-compiler:2.24' diff --git a/bramble-java/witness.gradle b/bramble-java/witness.gradle index 02a7bb626..a6b8c8672 100644 --- a/bramble-java/witness.gradle +++ b/bramble-java/witness.gradle @@ -24,7 +24,7 @@ dependencyVerification { 'org.apache.ant:ant:1.9.4:ant-1.9.4.jar:649ae0730251de07b8913f49286d46bba7b92d47c5f332610aa426c4f02161d8', 'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8', 'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a:obfs4proxy-0.0.12-dev-40245c4a.zip:172029e7058b3a83ac93ac4991a44bf76e16ce8d46f558f5836d57da3cb3a766', - 'org.briarproject:tor:0.3.5.13:tor-0.3.5.13.zip:1c5f0b821ee2aadb0ea04aa96caab3ca0a08370cce8de81c2dfe04d172f8a2a0', + 'org.briarproject:tor:0.3.5.13-1:tor-0.3.5.13-1.zip:ef35c16bf8dc1f4c75ed71d9f55e4514f383d124ec96b859aca647c990927c99', 'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d', 'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a', 'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',