From 5ae167d67d5958e93b5b48ad65f8593054a85f5a Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 18:33:20 +0200 Subject: [PATCH 1/6] android build: place binaries in ./dist/ instead of ./bin/ Let's try to consolidate and have all build scripts put binaries into ./dist/ --- .travis.yml | 4 ++-- contrib/android/Readme.md | 6 +++--- contrib/android/buildozer.spec | 3 +++ contrib/android/make_apk | 4 ++-- contrib/release.sh | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5907a4632..dc2016f8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,8 +78,8 @@ jobs: - sudo docker run -it -u 1000:1000 --rm --name electrum-android-builder-cont --env CI=true -v $PWD:/home/user/wspace/electrum --workdir /home/user/wspace/electrum electrum-android-builder-img ./contrib/android/make_apk # kill background sleep loop - kill %1 - - ls -la bin - - if [ $(ls bin | grep -c Electrum-*) -eq 0 ]; then exit 1; fi + - ls -la dist + - if [ $(ls dist | grep -c Electrum-*) -eq 0 ]; then exit 1; fi after_success: true # disabled for now as travis started to always time out: - if: false AND ((branch = master) OR (tag IS present)) diff --git a/contrib/android/Readme.md b/contrib/android/Readme.md index 5281cfbf8..8db6102ca 100644 --- a/contrib/android/Readme.md +++ b/contrib/android/Readme.md @@ -63,7 +63,7 @@ folder. and so the modifications will affect it, e.g. `.buildozer` folder will be created. -5. The generated binary is in `./bin`. +5. The generated binary is in `./dist`. ## Verifying reproducibility and comparing against official binary @@ -95,7 +95,7 @@ You probably need to clear the cache: `rm -rf .buildozer/android/platform/build- ### How do I deploy on connected phone for quick testing? Assuming `adb` is installed: ``` -$ adb -d install -r bin/Electrum-*-arm64-v8a-debug.apk +$ adb -d install -r dist/Electrum-*-arm64-v8a-debug.apk $ adb shell monkey -p org.electrum.electrum 1 ``` @@ -154,7 +154,7 @@ $ run-as org.electrum.electrum cp /data/data/org.electrum.electrum/files/data/wa ### How to investigate diff between binaries if reproducibility fails? ``` -cd bin/ +cd dist/ unzip Electrum-*.apk1 -d apk1 mkdir apk1/assets/private_mp3/ tar -xzvf apk1/assets/private.mp3 --directory apk1/assets/private_mp3/ diff --git a/contrib/android/buildozer.spec b/contrib/android/buildozer.spec index 43d505352..aadb5c5b5 100644 --- a/contrib/android/buildozer.spec +++ b/contrib/android/buildozer.spec @@ -206,6 +206,9 @@ p4a.local_recipes = %(source.dir)s/contrib/android/p4a_recipes/ # (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) log_level = 1 +# (str) Path to build output (i.e. .apk, .ipa) storage +bin_dir = ./dist + # ----------------------------------------------------------------------------- # List as sections diff --git a/contrib/android/make_apk b/contrib/android/make_apk index 655d9da42..3248c3769 100755 --- a/contrib/android/make_apk +++ b/contrib/android/make_apk @@ -82,5 +82,5 @@ popd info "done." -ls -la "$PROJECT_ROOT/bin" -sha256sum "$PROJECT_ROOT/bin"/* +ls -la "$PROJECT_ROOT/dist" +sha256sum "$PROJECT_ROOT/dist"/* diff --git a/contrib/release.sh b/contrib/release.sh index fe8d898e1..5b6dba1b8 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -132,8 +132,8 @@ else ./contrib/android/make_apk release popd - cp contrib/android/fresh_clone/electrum/bin/$target1 dist/ - cp contrib/android/fresh_clone/electrum/bin/$target2 dist/ + cp contrib/android/fresh_clone/electrum/dist/$target1 dist/ + cp contrib/android/fresh_clone/electrum/dist/$target2 dist/ fi From 0842f4977b3bb7eab4f712802b9450a014f1bea4 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 18:46:04 +0200 Subject: [PATCH 2/6] build: fresh_clone: turns out we can just clone from a local dir :P this saves us some network requests, and reduces trust in github --- contrib/android/Readme.md | 10 ++++----- contrib/build-linux/sdist/README.md | 10 ++++----- contrib/build-wine/README.md | 11 +++++----- contrib/release.sh | 33 ++++++++++++----------------- 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/contrib/android/Readme.md b/contrib/android/Readme.md index 8db6102ca..b61cc7291 100644 --- a/contrib/android/Readme.md +++ b/contrib/android/Readme.md @@ -33,13 +33,11 @@ folder. (but you can skip this if reproducibility is not necessary). ``` - $ FRESH_CLONE=contrib/android/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ + $ FRESH_CLONE="contrib/android/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ umask 0022 && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git && \ - cd electrum + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" ``` And then build from this directory: diff --git a/contrib/build-linux/sdist/README.md b/contrib/build-linux/sdist/README.md index 20aef2b56..9381dc87d 100644 --- a/contrib/build-linux/sdist/README.md +++ b/contrib/build-linux/sdist/README.md @@ -29,13 +29,11 @@ folder. (but you can skip this if reproducibility is not necessary). ``` - $ FRESH_CLONE=contrib/build-linux/sdist/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ + $ FRESH_CLONE="contrib/build-linux/sdist/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ umask 0022 && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git && \ - cd electrum + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" ``` And then build from this directory: diff --git a/contrib/build-wine/README.md b/contrib/build-wine/README.md index 41bd906cd..b244850d6 100644 --- a/contrib/build-wine/README.md +++ b/contrib/build-wine/README.md @@ -35,12 +35,11 @@ folder. (but you can skip this if reproducibility is not necessary). ``` - $ FRESH_CLONE=contrib/build-wine/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git && \ - cd electrum + $ FRESH_CLONE="contrib/build-wine/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ + umask 0022 && \ + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" ``` And then build from this directory: diff --git a/contrib/release.sh b/contrib/release.sh index 5b6dba1b8..23156f572 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -37,13 +37,11 @@ if test -f dist/$target; then else pushd . sudo docker build -t electrum-sdist-builder-img contrib/build-linux/sdist - FRESH_CLONE=contrib/build-linux/sdist/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ - umask 0022 && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git &&\ - cd electrum + FRESH_CLONE="contrib/build-linux/sdist/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ + umask 0022 && \ + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" git checkout "${COMMIT}^{commit}" sudo docker run -it \ --name electrum-sdist-builder-cont \ @@ -83,12 +81,11 @@ if test -f dist/$target; then echo "file exists: $target" else pushd . - FRESH_CLONE=contrib/build-wine/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git && \ - cd electrum + FRESH_CLONE="contrib/build-wine/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ + umask 0022 && \ + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" git checkout "${COMMIT}^{commit}" sudo docker run -it \ --name electrum-wine-builder-cont \ @@ -113,13 +110,11 @@ if test -f dist/$target1; then else pushd . ./contrib/android/build_docker_image.sh - FRESH_CLONE=contrib/android/fresh_clone && \ - sudo rm -rf $FRESH_CLONE && \ + FRESH_CLONE="contrib/android/fresh_clone/electrum" && \ + sudo rm -rf "$FRESH_CLONE" && \ umask 0022 && \ - mkdir -p $FRESH_CLONE && \ - cd $FRESH_CLONE && \ - git clone https://github.com/spesmilo/electrum.git && \ - cd electrum + git clone . "$FRESH_CLONE" && \ + cd "$FRESH_CLONE" git checkout "${COMMIT}^{commit}" mkdir --parents $PWD/.buildozer/.gradle sudo docker run -it --rm \ From 3df1c3bbf7583b48c999060c24557f665cd87236 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 19:03:23 +0200 Subject: [PATCH 3/6] build: rename some scripts also, merge sdist/build.sh and sdist/make_tgz into sdist/make_sdist.sh --- .travis.yml | 6 +- contrib/build-linux/appimage/README.md | 2 +- .../appimage/{build.sh => make_appimage.sh} | 0 contrib/build-linux/sdist/README.md | 2 +- contrib/build-linux/sdist/build.sh | 32 ---------- contrib/build-linux/sdist/make_sdist.sh | 60 +++++++++++++++++++ contrib/build-linux/sdist/make_tgz | 43 ------------- contrib/build-wine/README.md | 24 ++++---- contrib/build-wine/{build.sh => make_win.sh} | 4 +- contrib/release.sh | 16 ++--- 10 files changed, 87 insertions(+), 102 deletions(-) rename contrib/build-linux/appimage/{build.sh => make_appimage.sh} (100%) delete mode 100755 contrib/build-linux/sdist/build.sh create mode 100755 contrib/build-linux/sdist/make_sdist.sh delete mode 100755 contrib/build-linux/sdist/make_tgz rename contrib/build-wine/{build.sh => make_win.sh} (93%) diff --git a/.travis.yml b/.travis.yml index dc2016f8b..42bcdc8ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ jobs: install: - sudo docker build --no-cache -t electrum-wine-builder-img ./contrib/build-wine/ script: - - sudo docker run --name electrum-wine-builder-cont -v $PWD:/opt/wine64/drive_c/electrum --rm --workdir /opt/wine64/drive_c/electrum/contrib/build-wine electrum-wine-builder-img ./build.sh + - sudo docker run --name electrum-wine-builder-cont -v $PWD:/opt/wine64/drive_c/electrum --rm --workdir /opt/wine64/drive_c/electrum/contrib/build-wine electrum-wine-builder-img ./make_win.sh after_success: true - if: (branch = master) OR (tag IS present) name: "Android build" @@ -103,7 +103,7 @@ jobs: install: - sudo docker build --no-cache -t electrum-appimage-builder-img ./contrib/build-linux/appimage/ script: - - sudo docker run --name electrum-appimage-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/appimage electrum-appimage-builder-img ./build.sh + - sudo docker run --name electrum-appimage-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/appimage electrum-appimage-builder-img ./make_appimage.sh after_success: true - if: (branch = master) OR (tag IS present) name: "tarball build" @@ -123,7 +123,7 @@ jobs: - sudo docker build --no-cache -t electrum-sdist-builder-img ./contrib/build-linux/sdist/ script: - echo "Building sdist at $PWD" - - sudo docker run --name electrum-sdist-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/sdist electrum-sdist-builder-img ./build.sh + - sudo docker run --name electrum-sdist-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/sdist electrum-sdist-builder-img ./make_sdist.sh after_success: true - stage: release check install: diff --git a/contrib/build-linux/appimage/README.md b/contrib/build-linux/appimage/README.md index 0b50ec7e3..b4712c000 100644 --- a/contrib/build-linux/appimage/README.md +++ b/contrib/build-linux/appimage/README.md @@ -37,7 +37,7 @@ see [issue #5159](https://github.com/spesmilo/electrum/issues/5159). --rm \ --workdir /opt/electrum/contrib/build-linux/appimage \ electrum-appimage-builder-img \ - ./build.sh + ./make_appimage.sh ``` 4. The generated binary is in `./dist`. diff --git a/contrib/build-linux/appimage/build.sh b/contrib/build-linux/appimage/make_appimage.sh similarity index 100% rename from contrib/build-linux/appimage/build.sh rename to contrib/build-linux/appimage/make_appimage.sh diff --git a/contrib/build-linux/sdist/README.md b/contrib/build-linux/sdist/README.md index 9381dc87d..d0b09f8c2 100644 --- a/contrib/build-linux/sdist/README.md +++ b/contrib/build-linux/sdist/README.md @@ -45,6 +45,6 @@ folder. --rm \ --workdir /opt/electrum/contrib/build-linux/sdist \ electrum-sdist-builder-img \ - ./build.sh + ./make_sdist.sh ``` 4. The generated distributables are in `./dist`. diff --git a/contrib/build-linux/sdist/build.sh b/contrib/build-linux/sdist/build.sh deleted file mode 100755 index 16d2bcd28..000000000 --- a/contrib/build-linux/sdist/build.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -e - -PROJECT_ROOT="$(dirname "$(readlink -e "$0")")/../../.." -CONTRIB="$PROJECT_ROOT/contrib" -CONTRIB_SDIST="$CONTRIB/build-linux/sdist" -DISTDIR="$PROJECT_ROOT/dist" - -. "$CONTRIB"/build_tools_util.sh - -# note that at least py3.7 is needed, to have https://bugs.python.org/issue30693 -python3 --version || fail "python interpreter not found" - -break_legacy_easy_install - -# upgrade to modern pip so that it knows the flags we need. -# we will then install a pinned version of pip as part of requirements-build-sdist -python3 -m pip install --upgrade pip - -info "Installing pinned requirements." -python3 -m pip install --no-dependencies --no-warn-script-location -r "$CONTRIB"/deterministic-build/requirements-build-sdist.txt - - -"$CONTRIB"/make_packages || fail "make_packages failed" - -"$CONTRIB_SDIST"/make_tgz || fail "make_tgz failed" - - -info "done." -ls -la "$DISTDIR" -sha256sum "$DISTDIR"/* diff --git a/contrib/build-linux/sdist/make_sdist.sh b/contrib/build-linux/sdist/make_sdist.sh new file mode 100755 index 000000000..7aae3f423 --- /dev/null +++ b/contrib/build-linux/sdist/make_sdist.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +PROJECT_ROOT="$(dirname "$(readlink -e "$0")")/../../.." +CONTRIB="$PROJECT_ROOT/contrib" +CONTRIB_SDIST="$CONTRIB/build-linux/sdist" +DISTDIR="$PROJECT_ROOT/dist" +LOCALE="$PROJECT_ROOT/electrum/locale/" + +. "$CONTRIB"/build_tools_util.sh + +# note that at least py3.7 is needed, to have https://bugs.python.org/issue30693 +python3 --version || fail "python interpreter not found" + +break_legacy_easy_install + +# upgrade to modern pip so that it knows the flags we need. +# we will then install a pinned version of pip as part of requirements-build-sdist +python3 -m pip install --upgrade pip + +info "Installing pinned requirements." +python3 -m pip install --no-dependencies --no-warn-script-location -r "$CONTRIB"/deterministic-build/requirements-build-sdist.txt + + +"$CONTRIB"/make_packages || fail "make_packages failed" + +git submodule update --init + +( + cd "$CONTRIB/deterministic-build/electrum-locale/" + if ! which msgfmt > /dev/null 2>&1; then + echo "Please install gettext" + exit 1 + fi + # We include both source (.po) and compiled (.mo) locale files in the source dist. + # Maybe we should exclude the compiled locale files? see https://askubuntu.com/a/144139 + # (also see MANIFEST.in) + rm -rf "$LOCALE" + for i in ./locale/*; do + dir="$PROJECT_ROOT/electrum/$i/LC_MESSAGES" + mkdir -p "$dir" + msgfmt --output-file="$dir/electrum.mo" "$i/electrum.po" || true + cp $i/electrum.po "$PROJECT_ROOT/electrum/$i/electrum.po" + done +) + +( + cd "$PROJECT_ROOT" + + find -exec touch -h -d '2000-11-11T11:11:11+00:00' {} + + + # note: .zip sdists would not be reproducible due to https://bugs.python.org/issue40963 + TZ=UTC faketime -f '2000-11-11 11:11:11' python3 setup.py --quiet sdist --format=gztar +) + + +info "done." +ls -la "$DISTDIR" +sha256sum "$DISTDIR"/* diff --git a/contrib/build-linux/sdist/make_tgz b/contrib/build-linux/sdist/make_tgz deleted file mode 100755 index b61bbbbbc..000000000 --- a/contrib/build-linux/sdist/make_tgz +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -e - -CONTRIB_SDIST="$(dirname "$(readlink -e "$0")")" -CONTRIB="$CONTRIB_SDIST"/../.. -ROOT_FOLDER="$CONTRIB"/.. -PACKAGES="$ROOT_FOLDER"/packages/ -LOCALE="$ROOT_FOLDER"/electrum/locale/ - -if [ ! -d "$PACKAGES" ]; then - echo "Run make_packages first!" - exit 1 -fi - -git submodule update --init - -( - cd "$CONTRIB/deterministic-build/electrum-locale/" - if ! which msgfmt > /dev/null 2>&1; then - echo "Please install gettext" - exit 1 - fi - # We include both source (.po) and compiled (.mo) locale files in the source dist. - # Maybe we should exclude the compiled locale files? see https://askubuntu.com/a/144139 - # (also see MANIFEST.in) - rm -rf "$LOCALE" - for i in ./locale/*; do - dir="$ROOT_FOLDER/electrum/$i/LC_MESSAGES" - mkdir -p "$dir" - msgfmt --output-file="$dir/electrum.mo" "$i/electrum.po" || true - cp $i/electrum.po "$ROOT_FOLDER/electrum/$i/electrum.po" - done -) - -( - cd "$ROOT_FOLDER" - - find -exec touch -h -d '2000-11-11T11:11:11+00:00' {} + - - # note: .zip sdists would not be reproducible due to https://bugs.python.org/issue40963 - TZ=UTC faketime -f '2000-11-11 11:11:11' python3 setup.py --quiet sdist --format=gztar -) diff --git a/contrib/build-wine/README.md b/contrib/build-wine/README.md index b244850d6..e213a98c8 100644 --- a/contrib/build-wine/README.md +++ b/contrib/build-wine/README.md @@ -51,7 +51,7 @@ folder. --rm \ --workdir /opt/wine64/drive_c/electrum/contrib/build-wine \ electrum-wine-builder-img \ - ./build.sh + ./make_win.sh ``` 4. The generated binaries are in `./contrib/build-wine/dist`. @@ -70,18 +70,18 @@ The release signing procedure involves a signer (the holder of the certificate/key) and one or multiple trusted verifiers: -| Signer | Verifier | -|-----------------------------------------------------------|-----------------------------------| -| Build .exe files using `build.sh` | | -| Sign .exe with `./sign.sh` | | -| Upload signed files to download server | | -| | Build .exe files using `build.sh` | -| | Compare files using `unsign.sh` | -| | Sign .exe file using `gpg -b` | +| Signer | Verifier | +|-----------------------------------------------------------|--------------------------------------| +| Build .exe files using `make_win.sh` | | +| Sign .exe with `./sign.sh` | | +| Upload signed files to download server | | +| | Build .exe files using `make_win.sh` | +| | Compare files using `unsign.sh` | +| | Sign .exe file using `gpg -b` | -| Signer and verifiers: | -|-----------------------------------------------------------------------------------------------| -| Upload signatures to 'electrum-signatures' repo, as `$version/$filename.$builder.asc` | +| Signer and verifiers: | +|--------------------------------------------------------------------------------------------------| +| Upload signatures to 'electrum-signatures' repo, as `$version/$filename.$builder.asc` | diff --git a/contrib/build-wine/build.sh b/contrib/build-wine/make_win.sh similarity index 93% rename from contrib/build-wine/build.sh rename to contrib/build-wine/make_win.sh index fee22bed9..5ee803e6a 100755 --- a/contrib/build-wine/build.sh +++ b/contrib/build-wine/make_win.sh @@ -53,7 +53,7 @@ else "$CONTRIB"/make_zbar.sh || fail "Could not build zbar" fi -$here/prepare-wine.sh || fail "prepare-wine failed" +"$here/prepare-wine.sh" || fail "prepare-wine failed" info "Resetting modification time in C:\Python..." # (Because of some bugs in pyinstaller) @@ -62,6 +62,6 @@ find -exec touch -d '2000-11-11T11:11:11+00:00' {} + popd ls -l /opt/wine64/drive_c/python* -$here/build-electrum-git.sh || fail "build-electrum-git failed" +"$here/build-electrum-git.sh" || fail "build-electrum-git failed" info "Done." diff --git a/contrib/release.sh b/contrib/release.sh index 23156f572..64791a544 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -49,7 +49,7 @@ else --rm \ --workdir /opt/electrum/contrib/build-linux/sdist \ electrum-sdist-builder-img \ - ./build.sh + ./make_sdist.sh popd cp /opt/electrum/contrib/build-linux/sdist/fresh_clone/electrum/dist/$target dist/ fi @@ -66,12 +66,12 @@ if test -f dist/$target; then else sudo docker build -t electrum-appimage-builder-img contrib/build-linux/appimage sudo docker run -it \ - --name electrum-appimage-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/appimage \ - electrum-appimage-builder-img \ - ./build.sh + --name electrum-appimage-builder-cont \ + -v $PWD:/opt/electrum \ + --rm \ + --workdir /opt/electrum/contrib/build-linux/appimage \ + electrum-appimage-builder-img \ + ./make_appimage.sh fi @@ -93,7 +93,7 @@ else --rm \ --workdir /opt/wine64/drive_c/electrum/contrib/build-wine \ electrum-wine-builder-img \ - ./build.sh + ./make_win.sh # do this in the fresh clone directory! cd contrib/build-wine/ ./sign.sh From 47ebc49c4c4df39d3d52575f9e10f94ad64418f5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 19:08:05 +0200 Subject: [PATCH 4/6] (trivial) build/release.sh: convert indents to spaces was mixed tabs/spaces --- contrib/release.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/contrib/release.sh b/contrib/release.sh index 64791a544..8df03f2bd 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -44,12 +44,12 @@ else cd "$FRESH_CLONE" git checkout "${COMMIT}^{commit}" sudo docker run -it \ - --name electrum-sdist-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/sdist \ - electrum-sdist-builder-img \ - ./make_sdist.sh + --name electrum-sdist-builder-cont \ + -v $PWD:/opt/electrum \ + --rm \ + --workdir /opt/electrum/contrib/build-linux/sdist \ + electrum-sdist-builder-img \ + ./make_sdist.sh popd cp /opt/electrum/contrib/build-linux/sdist/fresh_clone/electrum/dist/$target dist/ fi @@ -67,11 +67,11 @@ else sudo docker build -t electrum-appimage-builder-img contrib/build-linux/appimage sudo docker run -it \ --name electrum-appimage-builder-cont \ - -v $PWD:/opt/electrum \ + -v $PWD:/opt/electrum \ --rm \ - --workdir /opt/electrum/contrib/build-linux/appimage \ + --workdir /opt/electrum/contrib/build-linux/appimage \ electrum-appimage-builder-img \ - ./make_appimage.sh + ./make_appimage.sh fi @@ -136,10 +136,10 @@ fi # wait for dmg before signing if test -f dist/electrum-$VERSION.dmg; then if test -f dist/electrum-$VERSION.dmg.asc; then - echo "packages are already signed" + echo "packages are already signed" else - echo "signing packages" - ./contrib/sign_packages ThomasV + echo "signing packages" + ./contrib/sign_packages ThomasV fi else echo "dmg is missing, aborting" From 91c913dc0b6f1a7a0225f16d57c9ef9ab242daf2 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 19:09:41 +0200 Subject: [PATCH 5/6] build/release.sh: add some comments --- contrib/release.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/contrib/release.sh b/contrib/release.sh index 8df03f2bd..fa33b491a 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -1,10 +1,14 @@ -# -# Note: update locale before: -# 1. cd /opt/electrum-locale && ./update && push -# 2. cd to the submodule dir, and git pull -# 3. cd .. && git push #!/bin/bash +# Note: steps before doing a new release: +# +# - update locale: +# 1. cd /opt/electrum-locale && ./update && push +# 2. cd to the submodule dir, and git pull +# 3. cd .. && git push +# - update RELEASE-NOTES and version.py +# - git tag + ELECTRUM_DIR=/opt/electrum WWW_DIR=/opt/electrum-web From 9d46fe775aa09ec93b159cb96f0b5bb275f574fa Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 17 Jun 2021 19:41:37 +0200 Subject: [PATCH 6/6] build: try to consolidate instructions and decr codedupe in release.sh --- .travis.yml | 25 ++------- contrib/android/Readme.md | 44 +++------------- contrib/android/build.sh | 68 +++++++++++++++++++++++++ contrib/android/build_docker_image.sh | 10 ---- contrib/build-linux/appimage/README.md | 19 ++----- contrib/build-linux/appimage/build.sh | 57 +++++++++++++++++++++ contrib/build-linux/sdist/README.md | 33 +++--------- contrib/build-linux/sdist/build.sh | 57 +++++++++++++++++++++ contrib/build-wine/README.md | 35 +++---------- contrib/build-wine/build.sh | 56 +++++++++++++++++++++ contrib/release.sh | 70 +++----------------------- 11 files changed, 275 insertions(+), 199 deletions(-) create mode 100755 contrib/android/build.sh delete mode 100755 contrib/android/build_docker_image.sh create mode 100755 contrib/build-linux/appimage/build.sh create mode 100755 contrib/build-linux/sdist/build.sh create mode 100755 contrib/build-wine/build.sh diff --git a/.travis.yml b/.travis.yml index 42bcdc8ab..fef9701bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,10 +58,8 @@ jobs: - sudo apt-get update - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - docker version - install: - - sudo docker build --no-cache -t electrum-wine-builder-img ./contrib/build-wine/ script: - - sudo docker run --name electrum-wine-builder-cont -v $PWD:/opt/wine64/drive_c/electrum --rm --workdir /opt/wine64/drive_c/electrum/contrib/build-wine electrum-wine-builder-img ./make_win.sh + - ELECBUILD_COMMIT=HEAD ./contrib/build-wine/build.sh after_success: true - if: (branch = master) OR (tag IS present) name: "Android build" @@ -69,13 +67,11 @@ jobs: python: 3.7 services: - docker - install: - - ./contrib/android/build_docker_image.sh script: - sudo chown -R 1000:1000 . # Output something every minute or Travis kills the job - while sleep 60; do echo "=====[ $SECONDS seconds still running ]====="; done & - - sudo docker run -it -u 1000:1000 --rm --name electrum-android-builder-cont --env CI=true -v $PWD:/home/user/wspace/electrum --workdir /home/user/wspace/electrum electrum-android-builder-img ./contrib/android/make_apk + - ELECBUILD_COMMIT=HEAD ./contrib/android/build.sh # kill background sleep loop - kill %1 - ls -la dist @@ -100,10 +96,8 @@ jobs: python: false services: - docker - install: - - sudo docker build --no-cache -t electrum-appimage-builder-img ./contrib/build-linux/appimage/ script: - - sudo docker run --name electrum-appimage-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/appimage electrum-appimage-builder-img ./make_appimage.sh + - ELECBUILD_COMMIT=HEAD ./contrib/build-linux/appimage/build.sh after_success: true - if: (branch = master) OR (tag IS present) name: "tarball build" @@ -111,19 +105,8 @@ jobs: python: false services: - docker - before_install: - # hack: travis already cloned the repo, but we re-clone now, as we need to have umask set BEFORE cloning - - umask 0022 - - mkdir fresh_clone && cd fresh_clone - - git clone https://github.com/$TRAVIS_REPO_SLUG.git && cd electrum - - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then git fetch origin pull/$TRAVIS_PULL_REQUEST/merge; fi - - git checkout $TRAVIS_COMMIT - - echo "Second git clone ready at $PWD" - install: - - sudo docker build --no-cache -t electrum-sdist-builder-img ./contrib/build-linux/sdist/ script: - - echo "Building sdist at $PWD" - - sudo docker run --name electrum-sdist-builder-cont -v $PWD:/opt/electrum --rm --workdir /opt/electrum/contrib/build-linux/sdist electrum-sdist-builder-img ./make_sdist.sh + - ELECBUILD_COMMIT=HEAD ./contrib/build-linux/sdist/build.sh after_success: true - stage: release check install: diff --git a/contrib/android/Readme.md b/contrib/android/Readme.md index b61cc7291..9ecaebd26 100644 --- a/contrib/android/Readme.md +++ b/contrib/android/Readme.md @@ -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" + $ ELECBUILD_COMMIT=HEAD ELECBUILD_NOCACHE=1 ./build.sh release-unsigned ``` - - 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 - ``` - - 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 diff --git a/contrib/android/build.sh b/contrib/android/build.sh new file mode 100755 index 000000000..f199eb533 --- /dev/null +++ b/contrib/android/build.sh @@ -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 diff --git a/contrib/android/build_docker_image.sh b/contrib/android/build_docker_image.sh deleted file mode 100755 index 3eae956c5..000000000 --- a/contrib/android/build_docker_image.sh +++ /dev/null @@ -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" diff --git a/contrib/build-linux/appimage/README.md b/contrib/build-linux/appimage/README.md index b4712c000..838777b87 100644 --- a/contrib/build-linux/appimage/README.md +++ b/contrib/build-linux/appimage/README.md @@ -6,7 +6,6 @@ AppImage binary for Electrum This assumes an Ubuntu host, but it should not be too hard to adapt to another similar system. The host architecture should be x86_64 (amd64). -The docker commands should be executed in the project's root folder. We currently only build a single AppImage, for x86_64 architecture. Help to adapt these scripts to build for (some flavor of) ARM would be welcome, @@ -22,25 +21,17 @@ see [issue #5159](https://github.com/spesmilo/electrum/issues/5159). $ sudo apt-get install -y docker-ce ``` -2. Build image +2. Build binary ``` - $ sudo docker build -t electrum-appimage-builder-img contrib/build-linux/appimage + $ ./build.sh ``` - -3. Build binary - + If you want reproducibility, try instead e.g.: ``` - $ sudo docker run -it \ - --name electrum-appimage-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/appimage \ - electrum-appimage-builder-img \ - ./make_appimage.sh + $ ELECBUILD_COMMIT=HEAD ELECBUILD_NOCACHE=1 ./build.sh ``` -4. The generated binary is in `./dist`. +3. The generated binary is in `./dist`. ## FAQ diff --git a/contrib/build-linux/appimage/build.sh b/contrib/build-linux/appimage/build.sh new file mode 100755 index 000000000..65b361081 --- /dev/null +++ b/contrib/build-linux/appimage/build.sh @@ -0,0 +1,57 @@ +#!/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_APPIMAGE="$CONTRIB/build-linux/appimage" +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." +sudo docker build \ + $DOCKER_BUILD_FLAGS \ + -t electrum-appimage-builder-img \ + "$CONTRIB_APPIMAGE" + +# maybe do fresh clone +if [ ! -z "$ELECBUILD_COMMIT" ] ; then + info "ELECBUILD_COMMIT=$ELECBUILD_COMMIT. doing fresh clone and git checkout." + FRESH_CLONE="$CONTRIB_APPIMAGE/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 + +info "building binary..." +sudo docker run -it \ + --name electrum-appimage-builder-cont \ + -v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/electrum \ + --rm \ + --workdir /opt/electrum/contrib/build-linux/appimage \ + electrum-appimage-builder-img \ + ./make_appimage.sh + +# 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 diff --git a/contrib/build-linux/sdist/README.md b/contrib/build-linux/sdist/README.md index d0b09f8c2..2ff3ed011 100644 --- a/contrib/build-linux/sdist/README.md +++ b/contrib/build-linux/sdist/README.md @@ -5,8 +5,7 @@ Source tarballs distributables 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 @@ -17,34 +16,14 @@ folder. $ sudo apt-get install -y docker-ce ``` -2. Build image +2. Build source tarball ``` - $ sudo docker build -t electrum-sdist-builder-img contrib/build-linux/sdist + $ ./build.sh ``` - -3. Build source tarballs - - 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/build-linux/sdist/fresh_clone/electrum" && \ - sudo rm -rf "$FRESH_CLONE" && \ - umask 0022 && \ - git clone . "$FRESH_CLONE" && \ - cd "$FRESH_CLONE" + $ ELECBUILD_COMMIT=HEAD ELECBUILD_NOCACHE=1 ./build.sh ``` - And then build from this directory: - ``` - $ git checkout $REV - $ sudo docker run -it \ - --name electrum-sdist-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/sdist \ - electrum-sdist-builder-img \ - ./make_sdist.sh - ``` -4. The generated distributables are in `./dist`. +3. The generated distributables are in `./dist`. diff --git a/contrib/build-linux/sdist/build.sh b/contrib/build-linux/sdist/build.sh new file mode 100755 index 000000000..5f64c160e --- /dev/null +++ b/contrib/build-linux/sdist/build.sh @@ -0,0 +1,57 @@ +#!/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_SDIST="$CONTRIB/build-linux/sdist" +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." +sudo docker build \ + $DOCKER_BUILD_FLAGS \ + -t electrum-sdist-builder-img \ + "$CONTRIB_SDIST" + +# maybe do fresh clone +if [ ! -z "$ELECBUILD_COMMIT" ] ; then + info "ELECBUILD_COMMIT=$ELECBUILD_COMMIT. doing fresh clone and git checkout." + FRESH_CLONE="$CONTRIB_SDIST/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 + +info "building binary..." +sudo docker run -it \ + --name electrum-sdist-builder-cont \ + -v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/electrum \ + --rm \ + --workdir /opt/electrum/contrib/build-linux/sdist \ + electrum-sdist-builder-img \ + ./make_sdist.sh + +# 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 diff --git a/contrib/build-wine/README.md b/contrib/build-wine/README.md index e213a98c8..61fdf205d 100644 --- a/contrib/build-wine/README.md +++ b/contrib/build-wine/README.md @@ -5,8 +5,7 @@ Windows binaries 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,39 +20,17 @@ folder. (see [#6971](https://github.com/spesmilo/electrum/issues/6971)). If having problems, try to upgrade to at least `docker 20.10`. -2. Build image +2. Build Windows binaries ``` - $ sudo docker build -t electrum-wine-builder-img contrib/build-wine + $ ./build.sh ``` - - Note: see [this](https://stackoverflow.com/a/40516974/7499128) if having dns problems - -3. Build Windows 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/build-wine/fresh_clone/electrum" && \ - sudo rm -rf "$FRESH_CLONE" && \ - umask 0022 && \ - git clone . "$FRESH_CLONE" && \ - cd "$FRESH_CLONE" + $ ELECBUILD_COMMIT=HEAD ELECBUILD_NOCACHE=1 ./build.sh ``` - And then build from this directory: - ``` - $ git checkout $REV - $ sudo docker run -it \ - --name electrum-wine-builder-cont \ - -v $PWD:/opt/wine64/drive_c/electrum \ - --rm \ - --workdir /opt/wine64/drive_c/electrum/contrib/build-wine \ - electrum-wine-builder-img \ - ./make_win.sh - ``` -4. The generated binaries are in `./contrib/build-wine/dist`. +3. The generated binaries are in `./contrib/build-wine/dist`. diff --git a/contrib/build-wine/build.sh b/contrib/build-wine/build.sh new file mode 100755 index 000000000..ff0c062da --- /dev/null +++ b/contrib/build-wine/build.sh @@ -0,0 +1,56 @@ +#!/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_WINE="$CONTRIB/build-wine" + +. "$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." +sudo docker build \ + $DOCKER_BUILD_FLAGS \ + -t electrum-wine-builder-img \ + "$CONTRIB_WINE" + +# maybe do fresh clone +if [ ! -z "$ELECBUILD_COMMIT" ] ; then + info "ELECBUILD_COMMIT=$ELECBUILD_COMMIT. doing fresh clone and git checkout." + FRESH_CLONE="$CONTRIB_WINE/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 + +info "building binary..." +sudo docker run -it \ + --name electrum-wine-builder-cont \ + -v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/wine64/drive_c/electrum \ + --rm \ + --workdir /opt/wine64/drive_c/electrum/contrib/build-wine \ + electrum-wine-builder-img \ + ./make_win.sh + +# make sure resulting binary location is independent of fresh_clone +if [ ! -z "$ELECBUILD_COMMIT" ] ; then + mkdir --parents "$PROJECT_ROOT/contrib/build-wine/dist/" + sudo cp -f "$FRESH_CLONE/contrib/build-wine/dist"/* "$PROJECT_ROOT/contrib/build-wine/dist/" +fi diff --git a/contrib/release.sh b/contrib/release.sh index fa33b491a..f91945562 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -24,6 +24,9 @@ REV=`git describe --tags` echo "REV: $REV" COMMIT=$(git rev-parse HEAD) +export ELECBUILD_COMMIT="${COMMIT}^{commit}" +#export ELECBUILD_NOCACHE=1 + git_status=$(git status --porcelain) if [ ! -z "$git_status" ]; then @@ -39,23 +42,7 @@ target=Electrum-$VERSION.tar.gz if test -f dist/$target; then echo "file exists: $target" else - pushd . - sudo docker build -t electrum-sdist-builder-img contrib/build-linux/sdist - FRESH_CLONE="contrib/build-linux/sdist/fresh_clone/electrum" && \ - sudo rm -rf "$FRESH_CLONE" && \ - umask 0022 && \ - git clone . "$FRESH_CLONE" && \ - cd "$FRESH_CLONE" - git checkout "${COMMIT}^{commit}" - sudo docker run -it \ - --name electrum-sdist-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/sdist \ - electrum-sdist-builder-img \ - ./make_sdist.sh - popd - cp /opt/electrum/contrib/build-linux/sdist/fresh_clone/electrum/dist/$target dist/ + ./contrib/build-linux/sdist/build.sh fi # appimage @@ -68,14 +55,7 @@ fi if test -f dist/$target; then echo "file exists: $target" else - sudo docker build -t electrum-appimage-builder-img contrib/build-linux/appimage - sudo docker run -it \ - --name electrum-appimage-builder-cont \ - -v $PWD:/opt/electrum \ - --rm \ - --workdir /opt/electrum/contrib/build-linux/appimage \ - electrum-appimage-builder-img \ - ./make_appimage.sh + ./contrib/build-linux/appimage/build.sh fi @@ -85,20 +65,7 @@ if test -f dist/$target; then echo "file exists: $target" else pushd . - FRESH_CLONE="contrib/build-wine/fresh_clone/electrum" && \ - sudo rm -rf "$FRESH_CLONE" && \ - umask 0022 && \ - git clone . "$FRESH_CLONE" && \ - cd "$FRESH_CLONE" - git checkout "${COMMIT}^{commit}" - sudo docker run -it \ - --name electrum-wine-builder-cont \ - -v $PWD:/opt/wine64/drive_c/electrum \ - --rm \ - --workdir /opt/wine64/drive_c/electrum/contrib/build-wine \ - electrum-wine-builder-img \ - ./make_win.sh - # do this in the fresh clone directory! + ./contrib/build-wine/build.sh cd contrib/build-wine/ ./sign.sh cp ./signed/*.exe /opt/electrum/dist/ @@ -112,28 +79,7 @@ target2=Electrum-$VERSION.0-arm64-v8a-release.apk if test -f dist/$target1; then echo "file exists: $target1" else - pushd . - ./contrib/android/build_docker_image.sh - FRESH_CLONE="contrib/android/fresh_clone/electrum" && \ - sudo rm -rf "$FRESH_CLONE" && \ - umask 0022 && \ - git clone . "$FRESH_CLONE" && \ - cd "$FRESH_CLONE" - git checkout "${COMMIT}^{commit}" - 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 release - popd - - cp contrib/android/fresh_clone/electrum/dist/$target1 dist/ - cp contrib/android/fresh_clone/electrum/dist/$target2 dist/ - + ./contrib/android/build.sh release fi @@ -153,7 +99,7 @@ fi echo "build complete" sha256sum dist/*.tar.gz sha256sum dist/*.AppImage -sha256sum contrib/build-wine/fresh_clone/electrum/contrib/build-wine/dist/*.exe +sha256sum contrib/build-wine/dist/*.exe echo -n "proceed (y/n)? " read answer