From f68681c2a1bb7b5fed83050ba014b704f7263af1 Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Tue, 31 Dec 2024 14:11:36 +0000 Subject: [PATCH 1/4] Add lyrebird 0.5.0. --- .gitignore | 3 ++- build-binary.py | 12 +++++++----- template-lyrebird-android.pom | 33 +++++++++++++++++++++++++++++++++ template-lyrebird-linux.pom | 33 +++++++++++++++++++++++++++++++++ template-lyrebird-macos.pom | 33 +++++++++++++++++++++++++++++++++ template-lyrebird-windows.pom | 33 +++++++++++++++++++++++++++++++++ utils.py | 2 ++ versions.json | 21 ++++++++++++++++++++- 8 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 template-lyrebird-android.pom create mode 100644 template-lyrebird-linux.pom create mode 100644 template-lyrebird-macos.pom create mode 100644 template-lyrebird-windows.pom diff --git a/.gitignore b/.gitignore index d17f346..5f5db0d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ /snowflake*.zip /snowflake*.pom /snowflake*.jar -/reference \ No newline at end of file +/reference +/output diff --git a/build-binary.py b/build-binary.py index 6dd281d..3df8c54 100755 --- a/build-binary.py +++ b/build-binary.py @@ -5,7 +5,8 @@ from subprocess import check_call from utils import get_build_versions, ex, get_sha256, zip_files, get_final_file_path, \ get_sources_file_path, get_pom_file_path, reset_time, get_version_number, check_go_version, \ - get_version_and_tool, get_output_dir, get_platform_output_dir, GO_PATH, GO_ROOT, NDK_DIR + get_version_and_tool, get_output_dir, get_platform_output_dir, get_ld_flags, \ + GO_PATH, GO_ROOT, NDK_DIR def main(): @@ -105,8 +106,7 @@ def build_android(tool, versions): def build_android_arch(tool, versions, env, clang_arch, ndk_arch, abi): - # TODO: Raise API level and upgrade NDK when we drop support for Android 4 - min_api = '21' if ndk_arch.endswith('64') else '16' + min_api = '21' clang = "%s/toolchains/llvm/prebuilt/linux-x86_64/bin/%s%s-clang" % (NDK_DIR, clang_arch, min_api) env['CC'] = os.path.abspath(clang) @@ -122,8 +122,9 @@ def build_android_arch(tool, versions, env, clang_arch, ndk_arch, abi): output_file = os.path.abspath(os.path.join(os.path.curdir, tool)) go_flags = ['-asmflags', '-trimpath', '-o', output_file] + ld_flags = ["-ldflags=-w -s -extldflags=-pie %s" % get_ld_flags(versions)] repo_dir = get_repo_dir(versions) - ex(['go', 'build', '-buildmode=pie', '-ldflags', '-w -s -extldflags=-pie'] + go_flags + + ex(['go', 'build', '-buildmode=pie'] + ld_flags + go_flags + [os.path.join('.', versions['build_path'])], env=env, cwd=repo_dir) shutil.copy(output_file, tool_path) @@ -165,8 +166,9 @@ def build_desktop_arch(tool, versions, platform, arch, goarch, goarm=None, outpu output_file = os.path.abspath(os.path.join(os.path.curdir, tool)) go_flags = ['-asmflags', '-trimpath', '-o', output_file] + ld_flags = ["-ldflags=-w -s %s" % get_ld_flags(versions)] repo_dir = get_repo_dir(versions) - ex(['go', 'build', '-ldflags', '-w -s'] + go_flags + [build_path], env=env, cwd=repo_dir) + ex(['go', 'build'] + ld_flags + go_flags + [build_path], env=env, cwd=repo_dir) shutil.copy(output_file, tool_path) diff --git a/template-lyrebird-android.pom b/template-lyrebird-android.pom new file mode 100644 index 0000000..74eacc2 --- /dev/null +++ b/template-lyrebird-android.pom @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.briarproject</groupId> + <artifactId>lyrebird-android</artifactId> + <name>lyrebird-android</name> + <version>VERSION</version> + <url>https://torproject.org</url> + <description>Repo for building lyrebird for Android.</description> + <licenses> + <license> + <name>BSD-3-clause</name> + <url>https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/blob/main/LICENSE</url> + </license> + </licenses> + <developers> + <developer> + <id>yawning</id> + <name>Yawning Angel</name> + <email>yawning at schwanenlied dot me</email> + </developer> + <developer> + <id>torproject</id> + <name>Tor Project</name> + <email>frontdesk@rt.torproject.org</email> + </developer> + </developers> + <scm> + <connection>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</connection> + <developerConnection>scm:git@gitlab.torproject.org:tpo/anti-censorship/pluggable-transports/lyrebird.git</developerConnection> + <url>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</url> + </scm> +</project> diff --git a/template-lyrebird-linux.pom b/template-lyrebird-linux.pom new file mode 100644 index 0000000..f010b11 --- /dev/null +++ b/template-lyrebird-linux.pom @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.briarproject</groupId> + <artifactId>lyrebird-linux</artifactId> + <name>lyrebird-linux</name> + <version>VERSION</version> + <url>https://torproject.org</url> + <description>Repo for building lyrebird for Linux.</description> + <licenses> + <license> + <name>BSD-3-clause</name> + <url>https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/blob/main/LICENSE</url> + </license> + </licenses> + <developers> + <developer> + <id>yawning</id> + <name>Yawning Angel</name> + <email>yawning at schwanenlied dot me</email> + </developer> + <developer> + <id>torproject</id> + <name>Tor Project</name> + <email>frontdesk@rt.torproject.org</email> + </developer> + </developers> + <scm> + <connection>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</connection> + <developerConnection>scm:git@gitlab.torproject.org:tpo/anti-censorship/pluggable-transports/lyrebird.git</developerConnection> + <url>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</url> + </scm> +</project> diff --git a/template-lyrebird-macos.pom b/template-lyrebird-macos.pom new file mode 100644 index 0000000..4671290 --- /dev/null +++ b/template-lyrebird-macos.pom @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.briarproject</groupId> + <artifactId>lyrebird-macos</artifactId> + <name>lyrebird-macos</name> + <version>VERSION</version> + <url>https://torproject.org</url> + <description>Repo for building lyrebird for macOS.</description> + <licenses> + <license> + <name>BSD-3-clause</name> + <url>https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/blob/main/LICENSE</url> + </license> + </licenses> + <developers> + <developer> + <id>yawning</id> + <name>Yawning Angel</name> + <email>yawning at schwanenlied dot me</email> + </developer> + <developer> + <id>torproject</id> + <name>Tor Project</name> + <email>frontdesk@rt.torproject.org</email> + </developer> + </developers> + <scm> + <connection>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</connection> + <developerConnection>scm:git@gitlab.torproject.org:tpo/anti-censorship/pluggable-transports/lyrebird.git</developerConnection> + <url>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</url> + </scm> +</project> diff --git a/template-lyrebird-windows.pom b/template-lyrebird-windows.pom new file mode 100644 index 0000000..ddee643 --- /dev/null +++ b/template-lyrebird-windows.pom @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.briarproject</groupId> + <artifactId>lyrebird-windows</artifactId> + <name>lyrebird-windows</name> + <version>VERSION</version> + <url>https://torproject.org</url> + <description>Repo for building lyrebird for Windows.</description> + <licenses> + <license> + <name>BSD-3-clause</name> + <url>https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/blob/main/LICENSE</url> + </license> + </licenses> + <developers> + <developer> + <id>yawning</id> + <name>Yawning Angel</name> + <email>yawning at schwanenlied dot me</email> + </developer> + <developer> + <id>torproject</id> + <name>Tor Project</name> + <email>frontdesk@rt.torproject.org</email> + </developer> + </developers> + <scm> + <connection>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</connection> + <developerConnection>scm:git@gitlab.torproject.org:tpo/anti-censorship/pluggable-transports/lyrebird.git</developerConnection> + <url>scm:https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git</url> + </scm> +</project> diff --git a/utils.py b/utils.py index c45e88d..bf27408 100644 --- a/utils.py +++ b/utils.py @@ -31,6 +31,8 @@ def get_build_versions(tool, tag): versions[tool][tag]['tag'] = tag return tag, versions[tool][tag] +def get_ld_flags(versions): + return versions['ld_flags'] if 'ld_flags' in versions else '' def check_go_version(versions): # Check if proper Go version is installed (trailing space, because 'go1.10' in 'go1.10.1') diff --git a/versions.json b/versions.json index 9987860..e58e847 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,23 @@ { + "lyrebird": { + "0.5.0": { + "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git", + "revision": "297ae51866f56146f0523bcf2fd84e0b6ee8a88a", + "ld_flags": "-X main.lyrebirdVersion=0.5.0", + "build_path": "cmd/lyrebird", + "repo_dir": "lyrebird", + "go": { + "version": "go1.21.13", + "sha256": "71fb31606a1de48d129d591e8717a63e0c5565ffba09a24ea9f899a13214c34d" + }, + "ndk": { + "url": "https://dl.google.com/android/repository/android-ndk-r27c-linux.zip", + "revision": "27.2.12479018", + "sha256": "59c2f6dc96743b5daf5d1626684640b20a6bd2b1d85b13156b90333741bad5cc" + }, + "timestamp": "201001010000.00" + } + }, "obfs4proxy": { "0.0.14-tor2": { "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/obfs4.git", @@ -177,4 +196,4 @@ "timestamp": "201001010000.00" } } -} \ No newline at end of file +} -- GitLab From 9d11d9b7acec703de035ee27f9c1bbd1a2b29025 Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Tue, 31 Dec 2024 14:38:04 +0000 Subject: [PATCH 2/4] Update CI config, remove trailing space from ldflags. --- .gitlab-ci.yml | 25 +++++-------------------- build-binary.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b58127..0ec0d84 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,27 +21,14 @@ build: - docker build -t ${TEST_IMAGE} . - docker push $TEST_IMAGE -test_obfs4proxy: +test_lyrebird: stage: test script: - - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./build-binary.py obfs4proxy && ./verify-binary.py obfs4proxy" + - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./build-binary.py lyrebird && ./verify-binary.py lyrebird" allow_failure: true artifacts: paths: - - output/obfs4proxy - expire_in: 1 week - when: always - except: - - tags - -test_snowflake: - stage: test - script: - - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./build-binary.py snowflake && ./verify-binary.py snowflake" - allow_failure: true - artifacts: - paths: - - output/snowflake + - output/lyrebird expire_in: 1 week when: always except: @@ -50,12 +37,10 @@ test_snowflake: test_tag: stage: test script: - - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./verify-binary.py obfs4proxy ${CI_COMMIT_REF_NAME}" - - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./verify-binary.py snowflake ${CI_COMMIT_REF_NAME}" + - docker run -v `pwd`/output:/opt/go-reproducer/output ${TEST_IMAGE} /bin/bash -c "./verify-binary.py lyrebird ${CI_COMMIT_REF_NAME}" artifacts: paths: - - output/obfs4proxy - - output/snowflake + - output/lyrebird expire_in: 1 week when: always only: diff --git a/build-binary.py b/build-binary.py index 3df8c54..ff714ab 100755 --- a/build-binary.py +++ b/build-binary.py @@ -122,7 +122,12 @@ def build_android_arch(tool, versions, env, clang_arch, ndk_arch, abi): output_file = os.path.abspath(os.path.join(os.path.curdir, tool)) go_flags = ['-asmflags', '-trimpath', '-o', output_file] - ld_flags = ["-ldflags=-w -s -extldflags=-pie %s" % get_ld_flags(versions)] + base_ld_flags = '-w -s -extldflags=-pie' + config_ld_flags = get_ld_flags(versions) + if config_ld_flags: + ld_flags = ['-ldflags', "%s %s" % (base_ld_flags, config_ld_flags)] + else: + ld_flags = ['-ldflags', base_ld_flags] repo_dir = get_repo_dir(versions) ex(['go', 'build', '-buildmode=pie'] + ld_flags + go_flags + [os.path.join('.', versions['build_path'])], env=env, cwd=repo_dir) @@ -166,7 +171,12 @@ def build_desktop_arch(tool, versions, platform, arch, goarch, goarm=None, outpu output_file = os.path.abspath(os.path.join(os.path.curdir, tool)) go_flags = ['-asmflags', '-trimpath', '-o', output_file] - ld_flags = ["-ldflags=-w -s %s" % get_ld_flags(versions)] + base_ld_flags = '-w -s' + config_ld_flags = get_ld_flags(versions) + if config_ld_flags: + ld_flags = ['-ldflags', "%s %s" % (base_ld_flags, config_ld_flags)] + else: + ld_flags = ['-ldflags', base_ld_flags] repo_dir = get_repo_dir(versions) ex(['go', 'build'] + ld_flags + go_flags + [build_path], env=env, cwd=repo_dir) shutil.copy(output_file, tool_path) -- GitLab From 899ff0e67bfb389e9b1cfd6b11ec8d705e6535db Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Tue, 31 Dec 2024 15:29:31 +0000 Subject: [PATCH 3/4] Add lyrebird 0.5.0-1 compatible with Android 4. --- build-binary.py | 3 ++- versions.json | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/build-binary.py b/build-binary.py index ff714ab..2ca9fc6 100755 --- a/build-binary.py +++ b/build-binary.py @@ -106,7 +106,8 @@ def build_android(tool, versions): def build_android_arch(tool, versions, env, clang_arch, ndk_arch, abi): - min_api = '21' + # TODO: Raise API level and upgrade NDK when we drop support for Android 4 + min_api = '21' if ndk_arch.endswith('64') else '16' clang = "%s/toolchains/llvm/prebuilt/linux-x86_64/bin/%s%s-clang" % (NDK_DIR, clang_arch, min_api) env['CC'] = os.path.abspath(clang) diff --git a/versions.json b/versions.json index e58e847..2816458 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,22 @@ { "lyrebird": { + "0.5.0-1": { + "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git", + "revision": "297ae51866f56146f0523bcf2fd84e0b6ee8a88a", + "ld_flags": "-X main.lyrebirdVersion=0.5.0", + "build_path": "cmd/lyrebird", + "repo_dir": "lyrebird", + "go": { + "version": "go1.21.13", + "sha256": "71fb31606a1de48d129d591e8717a63e0c5565ffba09a24ea9f899a13214c34d" + }, + "ndk": { + "url": "https://dl.google.com/android/repository/android-ndk-r23c-linux.zip", + "revision": "23.2.8568313", + "sha256": "6ce94604b77d28113ecd588d425363624a5228d9662450c48d2e4053f8039242" + }, + "timestamp": "201001010000.00" + }, "0.5.0": { "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git", "revision": "297ae51866f56146f0523bcf2fd84e0b6ee8a88a", -- GitLab From e40858af5e3c81ba528966faf3d312397fdb4a07 Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Tue, 31 Dec 2024 16:24:01 +0000 Subject: [PATCH 4/4] Add 0.5.0-2 because Android binaries depend on build path. --- versions.json | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/versions.json b/versions.json index 2816458..99565d7 100644 --- a/versions.json +++ b/versions.json @@ -1,6 +1,6 @@ { "lyrebird": { - "0.5.0-1": { + "0.5.0-2": { "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git", "revision": "297ae51866f56146f0523bcf2fd84e0b6ee8a88a", "ld_flags": "-X main.lyrebirdVersion=0.5.0", @@ -16,23 +16,6 @@ "sha256": "6ce94604b77d28113ecd588d425363624a5228d9662450c48d2e4053f8039242" }, "timestamp": "201001010000.00" - }, - "0.5.0": { - "repo_url": "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird.git", - "revision": "297ae51866f56146f0523bcf2fd84e0b6ee8a88a", - "ld_flags": "-X main.lyrebirdVersion=0.5.0", - "build_path": "cmd/lyrebird", - "repo_dir": "lyrebird", - "go": { - "version": "go1.21.13", - "sha256": "71fb31606a1de48d129d591e8717a63e0c5565ffba09a24ea9f899a13214c34d" - }, - "ndk": { - "url": "https://dl.google.com/android/repository/android-ndk-r27c-linux.zip", - "revision": "27.2.12479018", - "sha256": "59c2f6dc96743b5daf5d1626684640b20a6bd2b1d85b13156b90333741bad5cc" - }, - "timestamp": "201001010000.00" } }, "obfs4proxy": { -- GitLab