From 1c6e8eeda368057d28a1053b46be1b0fb2e66851 Mon Sep 17 00:00:00 2001 From: Matthew Nelson Date: Thu, 21 Dec 2023 09:42:03 -0500 Subject: [PATCH] Update BUILD documentation for 2.0.0 --- BUILD.md | 108 ++++++++++++++++++++++++++++++------------------------- tooling | 10 ++++-- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/BUILD.md b/BUILD.md index d1f0e7dd..67dbb996 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,56 +1,66 @@ # BUILD -For those who wish to verify reproducibility of the binaries being distributed -via MavenCentral, you can do so by following along below. +For those who wish to verify reproducibility of the binaries being distributed, +you can do so by following along below. - What you will need: - - `Linux` or `macOS` + - A `Linux x86_64` machine - Git - - Gradle - - Java 11 or higher - -- Clone the repository - ```shell - git clone https://github.com/05nelsonm/kmp-tor-binary.git - cd kmp-tor-binary - ``` - -- Build `tor` binaries: - - This step will: - - Build all platforms supported by `kmp-tor-binary` - - Archive desktop binaries to the `binary-build/built` directory - - Move android binaries to `kmp-tor-binary-android` module - `src/androidMain/jniLibs` directory. - - Initialize the `tor-browser-build` submodule - ```shell - git submodule update --init - ``` - - Open up the `tor-browser-build` submodule's `README` and install - packages needed to build `tor` - ```shell - cat library/binary-build/tor-browser-build/README - ``` - - Run the build script - ```shell - ./library/binary-build/scripts/build_tor.sh all - ``` - -- Running `git diff` at this point should show **no** changes to the project. - -- Resource creation: - - This step will: - - Apply detached signatures to `macOS`/`Windows` binaries - - Reproducibly built binaries for `macOS` and `Windows` are codesigned - before being packaged as resources. The [diff-cli](tools/diff-cli/README.md) tool - is used to create and apply detached signatures. - - `gzip` all files - - Move them to their respective `kmp-tor-binary-` module resource directory - - Update `kmp-tor-binary-extract` constants (sha256 & manifest values) - - Run the resource creation script - ```shell - ./library/binary-build/scripts/resources_create.sh all - ``` - -- Running `git diff` at this point should show **no** changes to the project. + - Docker + - Java 17+ + + +1) Clone the repository + ```shell + git clone -b master --single-branch https://github.com/05nelsonm/kmp-tor-binary.git + cd kmp-tor-binary + ``` + + + +3) Build `tor` binaries (go touch grass for a little bit): + ```shell + ./external/task.sh build:all + ``` + +4) Package them: + ```shell + ./external/task.sh package + ``` + +5) Clean: + ```shell + ./gradlew clean -PKMP_TARGETS="JVM,LINUX_ARM64,LINUX_X64,MACOS_ARM64,MACOS_X64,MINGW_X64,IOS_ARM64,IOS_SIMULATOR_ARM64,IOS_X64,TVOS_ARM64,TVOS_SIMULATOR_ARM64,TVOS_X64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_SIMULATOR_ARM64,WATCHOS_X64" + ``` + +6) Sync the project: + ```shell + ./gradlew prepareKotlinBuildScriptModel -PKMP_TARGETS="JVM,LINUX_ARM64,LINUX_X64,MACOS_ARM64,MACOS_X64,MINGW_X64,IOS_ARM64,IOS_SIMULATOR_ARM64,IOS_X64,TVOS_ARM64,TVOS_SIMULATOR_ARM64,TVOS_X64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_SIMULATOR_ARM64,WATCHOS_X64" + ``` + +7) Check the generated reports for any errors: + ```shell + ( + set +e + ERRS=$(ls library/binary/build/reports/resource-validation/binary | grep ".err") + echo "" + for file_err in $ERRS; do + echo "$file_err:" + cat "library/binary/build/reports/resource-validation/binary/$file_err" + done + echo "" + ) + ``` + +If the output is blank, all built/packaged resources matched the expected sha256 hash values +defined in `build-logic/src/main/kotlin/resources/TorResources.kt`. + +Any error output is pretty self-explanatory (either the file didn't exist or hashes did not +match what was expected for the given platform/architecture). That's it. diff --git a/tooling b/tooling index 83df4fc6..31a33a49 100755 --- a/tooling +++ b/tooling @@ -16,7 +16,11 @@ TOOL="$1"; shift 1 readonly DIR_SCRIPT=$( cd "$( dirname "$0" )" >/dev/null && pwd ) -if [ -z "${TOOL}" ] || [ "${TOOL}" = "cli-core" ] || [ ! -d "$DIR_SCRIPT/tools/${TOOL}" ]; then +if [ -z "${TOOL}" ] || + [ "${TOOL}" = "cli-core" ] || + [ "${TOOL}" = "check-publication" ] || + [ ! -d "$DIR_SCRIPT/tools/${TOOL}" ]; then + echo "Unknown tool: '${TOOL}'" exit 1 fi @@ -27,7 +31,7 @@ args="${args%"${args##*[![:space:]]}"}" cd "$DIR_SCRIPT" || exit 3 if [ -z "$args" ]; then - ./gradlew --quiet ":tools:${TOOL}:jvmRun" + ./gradlew --quiet ":tools:${TOOL}:jvmRun" -PKMP_TARGETS="JVM" else - ./gradlew --quiet ":tools:${TOOL}:jvmRun" --args="$args" + ./gradlew --quiet ":tools:${TOOL}:jvmRun" --args="$args" -PKMP_TARGETS="JVM" fi