build: try to consolidate instructions and decr codedupe in release.sh
This commit is contained in:
@@ -9,8 +9,7 @@ To generate an APK file, follow these instructions.
|
||||
binaries that match the official releases._
|
||||
|
||||
This assumes an Ubuntu (x86_64) host, but it should not be too hard to adapt to another
|
||||
similar system. The docker commands should be executed in the project's root
|
||||
folder.
|
||||
similar system.
|
||||
|
||||
1. Install Docker
|
||||
|
||||
@@ -21,47 +20,20 @@ folder.
|
||||
$ sudo apt-get install -y docker-ce
|
||||
```
|
||||
|
||||
2. Build image
|
||||
2. Build binaries
|
||||
|
||||
```
|
||||
$ ./contrib/android/build_docker_image.sh
|
||||
$ ./build.sh
|
||||
```
|
||||
|
||||
3. Build binaries
|
||||
|
||||
It's recommended to build from a fresh clone
|
||||
(but you can skip this if reproducibility is not necessary).
|
||||
|
||||
If you want reproducibility, try instead e.g.:
|
||||
```
|
||||
$ FRESH_CLONE="contrib/android/fresh_clone/electrum" && \
|
||||
sudo rm -rf "$FRESH_CLONE" && \
|
||||
umask 0022 && \
|
||||
git clone . "$FRESH_CLONE" && \
|
||||
cd "$FRESH_CLONE"
|
||||
```
|
||||
|
||||
And then build from this directory:
|
||||
```
|
||||
$ git checkout $REV
|
||||
$ mkdir --parents $PWD/.buildozer/.gradle
|
||||
$ sudo docker run -it --rm \
|
||||
--name electrum-android-builder-cont \
|
||||
-v $PWD:/home/user/wspace/electrum \
|
||||
-v $PWD/.buildozer/.gradle:/home/user/.gradle \
|
||||
-v ~/.keystore:/home/user/.keystore \
|
||||
--workdir /home/user/wspace/electrum \
|
||||
electrum-android-builder-img \
|
||||
./contrib/android/make_apk
|
||||
$ ELECBUILD_COMMIT=HEAD ELECBUILD_NOCACHE=1 ./build.sh release-unsigned
|
||||
```
|
||||
|
||||
Note: this builds a debug apk. `make_apk` takes an optional parameter
|
||||
which can be either `release` or `release-unsigned`.
|
||||
|
||||
This mounts the project dir inside the container,
|
||||
and so the modifications will affect it, e.g. `.buildozer` folder
|
||||
will be created.
|
||||
Note: `build.sh` takes an optional parameter which can be
|
||||
`release`, `release-unsigned`, or `debug` (default).
|
||||
|
||||
5. The generated binary is in `./dist`.
|
||||
3. The generated binary is in `./dist`.
|
||||
|
||||
|
||||
## Verifying reproducibility and comparing against official binary
|
||||
|
||||
68
contrib/android/build.sh
Executable file
68
contrib/android/build.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# env vars:
|
||||
# - ELECBUILD_NOCACHE: if set, forces rebuild of docker image
|
||||
# - ELECBUILD_COMMIT: if set, do a fresh clone and git checkout
|
||||
|
||||
set -e
|
||||
|
||||
PROJECT_ROOT="$(dirname "$(readlink -e "$0")")/../.."
|
||||
PROJECT_ROOT_OR_FRESHCLONE_ROOT="$PROJECT_ROOT"
|
||||
CONTRIB="$PROJECT_ROOT/contrib"
|
||||
CONTRIB_ANDROID="$CONTRIB/android"
|
||||
DISTDIR="$PROJECT_ROOT/dist"
|
||||
|
||||
. "$CONTRIB"/build_tools_util.sh
|
||||
|
||||
|
||||
DOCKER_BUILD_FLAGS=""
|
||||
if [ ! -z "$ELECBUILD_NOCACHE" ] ; then
|
||||
info "ELECBUILD_NOCACHE is set. forcing rebuild of docker image."
|
||||
DOCKER_BUILD_FLAGS="--pull --no-cache"
|
||||
fi
|
||||
|
||||
info "building docker image."
|
||||
cp "$CONTRIB/deterministic-build/requirements-build-android.txt" "$CONTRIB_ANDROID/requirements-build-android.txt"
|
||||
sudo docker build \
|
||||
$DOCKER_BUILD_FLAGS \
|
||||
-t electrum-android-builder-img \
|
||||
"$CONTRIB_ANDROID"
|
||||
rm "$CONTRIB_ANDROID/requirements-build-android.txt"
|
||||
|
||||
|
||||
# maybe do fresh clone
|
||||
if [ ! -z "$ELECBUILD_COMMIT" ] ; then
|
||||
info "ELECBUILD_COMMIT=$ELECBUILD_COMMIT. doing fresh clone and git checkout."
|
||||
FRESH_CLONE="$CONTRIB_ANDROID/fresh_clone/electrum" && \
|
||||
sudo rm -rf "$FRESH_CLONE" && \
|
||||
umask 0022 && \
|
||||
git clone "$PROJECT_ROOT" "$FRESH_CLONE" && \
|
||||
cd "$FRESH_CLONE"
|
||||
git checkout "$ELECBUILD_COMMIT"
|
||||
PROJECT_ROOT_OR_FRESHCLONE_ROOT="$FRESH_CLONE"
|
||||
else
|
||||
info "not doing fresh clone."
|
||||
fi
|
||||
|
||||
DOCKER_RUN_FLAGS=""
|
||||
if [[ -n "$1" && "$1" == "release" ]] ; then
|
||||
info "'release' mode selected. mounting ~/.keystore inside container."
|
||||
DOCKER_RUN_FLAGS="-v $HOME/.keystore:/home/user/.keystore"
|
||||
fi
|
||||
|
||||
info "building binary..."
|
||||
mkdir --parents "$PROJECT_ROOT_OR_FRESHCLONE_ROOT"/.buildozer/.gradle
|
||||
sudo docker run -it --rm \
|
||||
--name electrum-android-builder-cont \
|
||||
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/home/user/wspace/electrum \
|
||||
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT"/.buildozer/.gradle:/home/user/.gradle \
|
||||
$DOCKER_RUN_FLAGS \
|
||||
--workdir /home/user/wspace/electrum \
|
||||
electrum-android-builder-img \
|
||||
./contrib/android/make_apk "$@"
|
||||
|
||||
# make sure resulting binary location is independent of fresh_clone
|
||||
if [ ! -z "$ELECBUILD_COMMIT" ] ; then
|
||||
mkdir --parents "$DISTDIR/"
|
||||
sudo cp -f "$FRESH_CLONE/dist"/* "$DISTDIR/"
|
||||
fi
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CONTRIB_ANDROID="$(dirname "$(readlink -e "$0")")"
|
||||
CONTRIB="$CONTRIB_ANDROID"/..
|
||||
|
||||
cp "$CONTRIB/deterministic-build/requirements-build-android.txt" "$CONTRIB_ANDROID/requirements-build-android.txt"
|
||||
sudo docker build -t electrum-android-builder-img "$CONTRIB_ANDROID"
|
||||
rm "$CONTRIB_ANDROID/requirements-build-android.txt"
|
||||
Reference in New Issue
Block a user