From 924f4246396655bd3b15f60eb688ead84ff4e77b Mon Sep 17 00:00:00 2001 From: Luis Miguel Date: Wed, 24 Aug 2022 15:32:25 +0200 Subject: [PATCH] Reproducible builds (#1055) * Simplre reproducible builds * clone the branch you're reproducing * fix branch/tag argument taking + use master as default * be able to execute build.sh more than once * Simplifiying process * Updating rn-nodeify to 10.3.0 to avoid issue * Deleting compile and Dockerfile as they're not used anymore * Updated simplified build script and README file with instructions to build * Simplify / beautify build script * Commenting out the singning process for release in build.gradle * Build and sign every apk * Cut apk location up to current location for easy location of files * Remove signing code * Delete unused variables * Updated instructions * README: update reproducible instructions * build.sh: lock in Docker image version reactnativecommunity/react-native-android:5.4 Co-authored-by: Evan Kaloudis --- README.md | 21 +++++++++++++++++++++ android/app/build.gradle | 2 +- build.sh | 20 ++++++++++++++++++++ package.json | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 build.sh diff --git a/README.md b/README.md index f7ff91114..bc50ff96e 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,27 @@ Zeus is proud to be integrated on the following platforms: 3. `cd ios && pod install` 4. open `ios/zeus.xcworkspace` in Xcode and hit Run. NOTE: if you're using an M1 mac, you may need to right click Xcode > get info > check `Open using Rosetta` before opening `zeus.xcworkspace`. +## Reproducible builds + +Reproducible builds are available for Android only right now. You'll need Docker installed to be able to build the app this way: + +1. Clone Zeus git for the branch/tag that you want to build. For example: `git clone --depth 1 --branch v0.6.6 https://github.com/ZeusLN/zeus.git` + You can also remove the `--branch v0.6.6` parameter to build APKs for `master`. +2. Change to the zeus directory: `cd zeus` +3. Execute the build script: `./build.sh` +4. If everything goes well, the script will print a list of all the generated APK files and MD5 for each one of them: armv7, armv8, x86, x86_64, universal. The equivalent to the one provided in the web page is the one ending in 'universal'. You can compare MD5s with the ones provided on the [GitHub releases page](https://github.com/ZeusLN/zeus/releases) +5. Download the oficial apk from [GitHub releases page](https://github.com/ZeusLN/zeus/releases) or from the [Zeus homepage](https://zeusln.app/): `wget https://zeusln.app/zeus-v0.6.6.apk` +6. Compare both APKs with a suitable utility like `diffoscope`, `apksigcopier` or by running `diff --brief --recursive ./unpacked_oficial_apk ./unpacked_built_apk`. You should only get differences for the certificates used to sign the official APK + +If you want to install the APK built this way onto your own smartphone, you'll need to sign it yourself (see next section). Note that the first time you install a build made using this procedure, you'll need to uninstall your current version of Zeus and then install the one built here because certificates will not match. You'll lose your connection details and you'll need to reconfigure Zeus again to connect to your nodes. + +### Signing APKs + +1. Install signing utilities: `apt-get install -y apksigner` +2. Create your certificate, if you haven't done so already. If you already have the certificate from previous builds, it's advised that you use the same one so you are able to upgrade from one APK to the next one without reinstalling first: `keytool -genkeypair -alias zeus -keystore zeus.pfx -v -storetype PKCS12 -keyalg RSA -keysize 2048 -storepass your_keystore_password -keypass your_key_password -validity 10000 -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown"` +3. Sign the chosen APK file using this command: `java -jar /usr/bin/apksigner sign -v --ks zeus.pfx --ks-key-alias zeus --ks-pass pass:your_keystore_password --key-pass pass:your_key_password zeus-universal.apk` +4. Copy the signed APK to your smartphone and install it by tapping over the file. If you get an error, you'll have to uninstall your currently installed version of Zeus first. Note that you'll lose your connections and you'll need to reconfigure Zeus again to connect to your node. + ## Contributing Please be sure to run `npm run tsc` to check for type errors, `npm run test` to run all tests, and `npm run prettier` to run the prettier diff --git a/android/app/build.gradle b/android/app/build.gradle index a30dfbbda..51e314cd5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -167,7 +167,7 @@ android { shrinkResources true minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - signingConfig signingConfigs.release + //signingConfig signingConfigs.release } } // applicationVariants are e.g. debug, release diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..4a5abc025 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash +BUILDER_IMAGE="reactnativecommunity/react-native-android:5.4" +CONTAINER_NAME="zeus_builder_container" +ZEUS_PATH=/olympus/zeus + +docker run --rm --name $CONTAINER_NAME -v `pwd`:$ZEUS_PATH $BUILDER_IMAGE bash -c \ + 'echo -e "\n\n********************************\n*** Building Zeus...\n********************************\n" && \ + cd /olympus/zeus ; yarn install && \ + cd /olympus/zeus/android ; ./gradlew assembleRelease && \ + + echo -e "\n\n********************************\n**** APKs and MD5\n********************************\n" && \ + cd /olympus/zeus && \ + for f in android/app/build/outputs/apk/release/*.apk; + do + RENAMED_FILENAME=$(echo $f | sed -e "s/app-/zeus-/" | sed -e "s/-release-unsigned//") + mv $f $RENAMED_FILENAME + md5sum $RENAMED_FILENAME + done && \ + echo -e "\n" '; + diff --git a/package.json b/package.json index 25eb3b5a8..8b0947d52 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "metro-react-native-babel-preset": "0.67.0", "prettier": "2.4.1", "react-test-renderer": "16.6.3", - "rn-nodeify": "10.2.0", + "rn-nodeify": "10.3.0", "typescript": "3.7.5" }, "react-native": {