build/release: create new release package for reproducible builds
In this commit, we create a new `build/release` package which houses the build instructions and scripts that we need to do deterministic builds across Windows, Linux, and MacOS. With this new system, it's now possible for all `lnd` developers, as well as users to verify the posted build binaries. This wasn't possible in prior release as only in Go 1.13 did deterministic builds becomes easier/possible. See the new `README.md` for further details.
This commit is contained in:
2 files changed
+38
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# lnd's Reproducible Build System
|
||||
|
||||
This package contains the buidl script that the `lnd` project uses in order to
|
||||
build binaries for each new release. As of Go 1.13, with some new build flags,
|
||||
binaries are now reproducible, allowing developers to build the binary on
|
||||
distinct machines, and end up with a byte-for-byte identical binary. However,
|
||||
this wasn't _fully_ solved in Go 1.13, as the build system still includes the
|
||||
directory the binary is built into the binary itself. As a result, our scripts
|
||||
utilize a work around needed until Go 1.13.2.
|
||||
|
||||
## Building a New Release
|
||||
|
||||
### MacOS/Linux/Windows (WSL)
|
||||
|
||||
No prior set up is needed on Linux or MacOS is required in order to build the
|
||||
release binaries. However, on Windows, the only way to build the binaries atm
|
||||
is using the Windows Subsystem Linux. One can build the release binaries from
|
||||
one's `lnd` directory, no matter where it's located. One can download `lnd` to
|
||||
|
||||
```
|
||||
git clone https://github.com/lightningnetwork/lnd.git
|
||||
```
|
||||
|
||||
Afterwards, the release manager/verifier simply needs to run:
|
||||
`./build/release/release.sh <TAG>` (from the top-level `lnd` directory) , where
|
||||
`<TAG>` is the name of the next release/tag.
|
||||
|
||||
## Verifying a Release
|
||||
|
||||
With Go 1.13, it's now possible for third parties to verify a release binary.
|
||||
Before this release, one had to trust that release manager to build the proper
|
||||
binary. With this new system, third parties can now _independently_ run the
|
||||
release process, and verify that all the hashes in the final `manifest.txt`
|
||||
match up.
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Simple bash script to build basic lnd tools for all the platforms
|
||||
# we support with the golang cross-compiler.
|
||||
#
|
||||
# Copyright (c) 2016 Company 0, LLC.
|
||||
# Use of this source code is governed by the ISC
|
||||
# license.
|
||||
|
||||
set -e
|
||||
|
||||
# If no tag specified, use date + version otherwise use tag.
|
||||
if [[ $1x = x ]]; then
|
||||
DATE=`date +%Y%m%d`
|
||||
VERSION="01"
|
||||
TAG=$DATE-$VERSION
|
||||
else
|
||||
TAG=$1
|
||||
fi
|
||||
|
||||
go mod vendor
|
||||
tar -cvzf vendor.tar.gz vendor
|
||||
|
||||
PACKAGE=lnd
|
||||
MAINDIR=$PACKAGE-$TAG
|
||||
mkdir -p $MAINDIR
|
||||
|
||||
cp vendor.tar.gz $MAINDIR/
|
||||
rm vendor.tar.gz
|
||||
rm -r vendor
|
||||
|
||||
PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar"
|
||||
git archive -o $PACKAGESRC HEAD
|
||||
gzip -f $PACKAGESRC > "$PACKAGESRC.gz"
|
||||
|
||||
cd $MAINDIR
|
||||
|
||||
# If LNDBUILDSYS is set the default list is ignored. Useful to release
|
||||
# for a subset of systems/architectures.
|
||||
SYS=${LNDBUILDSYS:-"windows-386 windows-amd64 openbsd-386 openbsd-amd64 linux-386 linux-amd64 linux-armv6 linux-armv7 linux-arm64 darwin-386 darwin-amd64 dragonfly-amd64 freebsd-386 freebsd-amd64 freebsd-arm netbsd-386 netbsd-amd64 linux-mips64 linux-mips64le linux-ppc64"}
|
||||
|
||||
# Use the first element of $GOPATH in the case where GOPATH is a list
|
||||
# (something that is totally allowed).
|
||||
PKG="github.com/lightningnetwork/lnd"
|
||||
COMMIT=$(git describe --abbrev=40 --dirty)
|
||||
COMMITFLAGS="-X $PKG/build.Commit=$COMMIT"
|
||||
|
||||
for i in $SYS; do
|
||||
OS=$(echo $i | cut -f1 -d-)
|
||||
ARCH=$(echo $i | cut -f2 -d-)
|
||||
ARM=
|
||||
|
||||
if [[ $ARCH = "armv6" ]]; then
|
||||
ARCH=arm
|
||||
ARM=6
|
||||
elif [[ $ARCH = "armv7" ]]; then
|
||||
ARCH=arm
|
||||
ARM=7
|
||||
fi
|
||||
|
||||
mkdir $PACKAGE-$i-$TAG
|
||||
cd $PACKAGE-$i-$TAG
|
||||
|
||||
echo "Building:" $OS $ARCH $ARM
|
||||
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid= $COMMITFLAGS" -tags="autopilotrpc signrpc walletrpc chainrpc invoicesrpc routerrpc watchtowerrpc" github.com/lightningnetwork/lnd/cmd/lnd
|
||||
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid= $COMMITFLAGS" -tags="autopilotrpc invoicesrpc walletrpc routerrpc watchtowerrpc" github.com/lightningnetwork/lnd/cmd/lncli
|
||||
cd ..
|
||||
|
||||
if [[ $OS = "windows" ]]; then
|
||||
zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG
|
||||
else
|
||||
tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG
|
||||
fi
|
||||
|
||||
rm -r $PACKAGE-$i-$TAG
|
||||
done
|
||||
|
||||
shasum -a 256 * > manifest-$TAG.txt
|
||||
Reference in new issue
Block a user