Skip to content

Commit

Permalink
Build ARMv7/v8 releases (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Sep 28, 2020
1 parent 44c378b commit 647473d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ ar = "x86_64-apple-darwin15-ar"
# use --no-insert-timestamp to drop PE timestamps in Windows builds for reproducibility
# https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries#building_with_mingw-w64
rustflags = [ "-C", "link-arg=-Wl,--no-insert-timestamp" ]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Reproducible builds using Docker (#51)

- Pre-built binary releases for macOS (#24)
- Pre-built binary releases for macOS (#24) and ARMv7/v8 (#19)

- Scriptable transaction broadcast command via `--tx-broadcast-cmd <cmd>` (#7)

Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ thiserror = "1.0.20"
tokio = { version = "0.2.20", features = ["macros"], optional = true }
warp = { version = "0.2.3", optional = true }
reqwest = { version = "0.10.6", optional = true, features = ["json", "blocking"] }


# Statically link OpenSSL when cross-compiling to ARM
# OpenSSL is currently disabled on ARM, see https://github.com/shesek/bwt/issues/52

# [target.'cfg(any(target_arch = "arm", target_arch = "aarch64"))'.dependencies]
# openssl = { version = "0.10", features = ["vendored"], optional = true }
# webhooks = [ "reqwest", "openssl" ]
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Get yourself a synced Bitcoin Core node (v0.19 is recommended, v0.17 is sufficie

#### Signed pre-built binaries

Available for download on [the releases page](https://github.com/shesek/bwt/releases) (Linux and Windows).
Available for download on [the releases page](https://github.com/shesek/bwt/releases) (Linux, Mac, Windows and ARM).

The releases are signed by Nadav Ivgi (@shesek).
The public key can be verified on [keybase](https://keybase.io/nadav),
Expand Down Expand Up @@ -264,7 +264,7 @@ Download the `electrum_plugin` package from the [releases page](https://github.c
After restarting Electrum, you should see bwt in the list of installed plugins under `Tools -> Plugins`.

The supported Electrum version is 3.3.8.
The plugin is currently available for Linux and Windows.
The plugin is available for Linux, Mac, Windows and ARM.

Note that it is not possible to install external plugins with the Electrum AppImage or standalone Windows executable.
You will need to [run from tar.gz](https://github.com/spesmilo/electrum/#running-from-targz) on Linux, use the Windows installer, or [run from source](https://github.com/spesmilo/electrum/#development-version-git-clone).
Expand Down Expand Up @@ -1141,7 +1141,9 @@ Dumps the contents of the index store as a debug string.

## Web Hooks

> If you're building bwt from source, you'll need to set `--features webhooks` to enable web hooks support. This will also require to `apt install libssl-dev pkg-config`. The main pre-built binary and the `shesek/bwt` docker image come with webhooks support enabled by default.
> If you're building bwt from source, you'll need to set `--features webhooks` to enable web hooks support. This will also require to `apt install libssl-dev pkg-config`.
>
> The pre-built binaries ([except for ARM](https://github.com/shesek/bwt/issues/52)) and the `shesek/bwt` docker image come with webhooks support enabled by default.
You can set `--webhook-url <url>` to have bwt send push notifications as a `POST` request to the provided `<url>`. Requests will be sent with a JSON-serialized *array* of one or more index updates as the body.

Expand Down Expand Up @@ -1214,7 +1216,7 @@ The builds can be reproduced in a Docker container environment as follows:
```
$ git clone https://github.com/shesek/bwt && cd bwt
# Linux & Windows
# Linux, Windows & ARM
$ docker build -t bwt-builder -f scripts/builder.Dockerfile .
$ docker run -it --rm -v `pwd`:/usr/src/bwt bwt-builder
Expand Down
34 changes: 22 additions & 12 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -xeo pipefail

# `osx` is also available, but requires osxcross installed (see builder-os.Dockerfile)
TARGETS=${TARGETS:-linux,win}
# `x86_64-osx` is also available, but requires osxcross installed (see builder-os.Dockerfile)
TARGETS=${TARGETS:-x86_64-linux,x86_64-win,arm32v7,arm64v8}

build() {
name=$1; target=$2; features=$3
Expand All @@ -16,7 +16,10 @@ build() {

mv target/$target/release/bwt$ext $dest

[[ $target == *"-apple-"* ]] || strip $dest/bwt$ext
if [[ $target == "x86_64-"* && $target != *"-apple-"* ]]; then
# doesn't work for macOS and ARM binaries
strip $dest/bwt$ext
fi

cp README.md LICENSE $dest/

Expand All @@ -28,7 +31,7 @@ pack() {
name=$1; dir=${2:-$1}
pushd dist
touch -t 1711081658 $name $name/*
if [[ $name == *"-linux" ]]; then
if [[ $name == *"-linux" || $name == *"-arm"* ]]; then
TZ=UTC tar --mtime='2017-11-08 16:58:00' --owner=0 --sort=name -I 'gzip --no-name' -chf $name.tar.gz $dir
else
find -H $dir | sort | xargs zip -X -q $name.zip
Expand All @@ -38,25 +41,32 @@ pack() {

version=`cat Cargo.toml | egrep '^version =' | cut -d'"' -f2`

for cfg in linux,x86_64-unknown-linux-gnu \
win,x86_64-pc-windows-gnu \
osx,x86_64-apple-darwin; do
for cfg in x86_64-linux,x86_64-unknown-linux-gnu \
x86_64-osx,x86_64-apple-darwin \
x86_64-win,x86_64-pc-windows-gnu \
arm32v7,armv7-unknown-linux-gnueabihf \
arm64v8,aarch64-unknown-linux-gnu; do
IFS=',' read platform target <<< $cfg
if [[ $TARGETS != *"$platform"* ]]; then continue; fi

build bwt-$version-x86_64-$platform $target http,electrum,webhooks,track-spends
build bwt-$version-electrum_only-x86_64-$platform $target electrum
# The OpenSSL dependency enabled by the webhooks feature causes the following error on ARM targets:
# /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by bwt-0.1.4-arm64v8/bwt)
# Disable it for now on ARM, follow up at https://github.com/shesek/bwt/issues/52
features=http,electrum,track-spends$([[ $platform == "arm"* ]] || echo ',webhooks')

build bwt-$version-$platform $target $features
build bwt-$version-electrum_only-$platform $target electrum
done

echo Building electrum plugin
for platform in linux win osx; do
for platform in x86_64-linux x86_64-win x86_64-osx arm32v7 arm64v8; do
if [[ $TARGETS != *"$platform"* ]]; then continue; fi

name=bwt-$version-electrum_plugin-x86_64-$platform
name=bwt-$version-electrum_plugin-$platform
dest=dist/$name
mkdir $dest
cp contrib/electrum-plugin/*.py $dest
cp dist/bwt-$version-electrum_only-x86_64-$platform/* $dest
cp dist/bwt-$version-electrum_only-$platform/* $dest
# needs to be inside a directory with a name that matches the plugin module name for electrum to load it,
# create a temporary link to get tar/zip to pack it properly. (can also be done for tar.gz with --transform)
ln -s $name dist/bwt
Expand Down
2 changes: 1 addition & 1 deletion scripts/builder-osx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN git clone https://github.com/tpoechtrager/osxcross /usr/src/osxcross && \
echo "$OSX_SDK_SHASUM tarballs/MacOSX$OSX_SDK_VERSION.sdk.tar.xz" | sha256sum -c - && \
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh

ENV TARGETS=osx
ENV TARGETS=x86_64-osx
ENV CC=x86_64-apple-darwin15-cc
ENV AR=x86_64-apple-darwin15-ar
ENV PATH=$PATH:/usr/src/osxcross/target/bin
10 changes: 7 additions & 3 deletions scripts/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM rust:1.46-slim as builder
RUN apt-get update && apt-get install -y pkg-config libssl-dev gcc-mingw-w64-x86-64 zip && \
rustup target add x86_64-pc-windows-gnu
RUN apt-get update && apt-get install -y pkg-config make zip \
libssl-dev gcc-mingw-w64-x86-64 gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu && \
rustup target add x86_64-pc-windows-gnu && \
rustup target add armv7-unknown-linux-gnueabihf && \
rustup target add aarch64-unknown-linux-gnu
# macOS is built using a separate image, see builder-osx.Dockerfile

WORKDIR /usr/src/bwt
VOLUME /usr/src/bwt
ENV TARGETS=linux,win
ENV TARGETS=x86_64-linux,x86_64-win,arm32v7,arm64v8
ENTRYPOINT [ "/usr/src/bwt/scripts/build.sh" ]
2 changes: 1 addition & 1 deletion scripts/release-footer.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ See [more details here](https://github.com/shesek/bwt#reproducible-builds).

#### Electrum plugin

The [Electrum plugin](https://github.com/shesek/bwt#electrum-plugin) is available for download for Linux and Windows, as the `electrum_plugin` package.
The [Electrum plugin](https://github.com/shesek/bwt#electrum-plugin) is available for download for Linux, Mac, Windows and ARM as the `electrum_plugin` package.

> ⚠️ **NOTE:** The plugin supports watch-only wallets only and **cannot be used with hot wallets**. This is done as a security measure, which is expected to eventually be lifted. You can use the plugin with hardware wallets or with an offline Electrum setup. For hot wallets, you will need to setup a standalone server instead of using the plugin, ideally far away from your keys.

0 comments on commit 647473d

Please sign in to comment.