2017-01-13 05:30:38 +03:00
|
|
|
#!/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.
|
|
|
|
|
2019-09-27 02:17:45 +03:00
|
|
|
set -e
|
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
# 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
|
2020-01-03 12:34:11 +03:00
|
|
|
|
|
|
|
# If a tag is specified, ensure that that tag is present and checked out.
|
2020-01-22 07:46:40 +03:00
|
|
|
if [[ $TAG != $(git describe) ]]; then
|
2020-01-03 12:34:11 +03:00
|
|
|
echo "tag $TAG not checked out"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build lnd to extract version.
|
|
|
|
go build github.com/lightningnetwork/lnd/cmd/lnd
|
|
|
|
|
|
|
|
# Extract version command output.
|
|
|
|
LND_VERSION_OUTPUT=`./lnd --version`
|
|
|
|
|
|
|
|
# Use a regex to isolate the version string.
|
|
|
|
LND_VERSION_REGEX="lnd version (.+) commit"
|
|
|
|
if [[ $LND_VERSION_OUTPUT =~ $LND_VERSION_REGEX ]]; then
|
|
|
|
# Prepend 'v' to match git tag naming scheme.
|
|
|
|
LND_VERSION="v${BASH_REMATCH[1]}"
|
|
|
|
echo "version: $LND_VERSION"
|
|
|
|
|
2020-01-08 09:55:10 +03:00
|
|
|
# If tag contains a release candidate suffix, append this suffix to the
|
|
|
|
# lnd reported version before we compare.
|
|
|
|
RC_REGEX="-rc[0-9]+$"
|
|
|
|
if [[ $TAG =~ $RC_REGEX ]]; then
|
|
|
|
LND_VERSION+=${BASH_REMATCH[0]}
|
|
|
|
fi
|
|
|
|
|
2020-01-03 12:34:11 +03:00
|
|
|
# Match git tag with lnd version.
|
|
|
|
if [[ $TAG != $LND_VERSION ]]; then
|
|
|
|
echo "lnd version $LND_VERSION does not match tag $TAG"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "malformed lnd version output"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-01-13 05:30:38 +03:00
|
|
|
fi
|
|
|
|
|
2019-01-18 10:30:45 +03:00
|
|
|
go mod vendor
|
|
|
|
tar -cvzf vendor.tar.gz vendor
|
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
PACKAGE=lnd
|
|
|
|
MAINDIR=$PACKAGE-$TAG
|
|
|
|
mkdir -p $MAINDIR
|
2019-01-18 10:30:45 +03:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
cd $MAINDIR
|
|
|
|
|
2018-11-16 15:45:54 +03:00
|
|
|
# If LNDBUILDSYS is set the default list is ignored. Useful to release
|
|
|
|
# for a subset of systems/architectures.
|
2019-10-04 02:51:10 +03:00
|
|
|
SYS=${LNDBUILDSYS:-"
|
|
|
|
darwin-386
|
|
|
|
darwin-amd64
|
|
|
|
dragonfly-amd64
|
|
|
|
freebsd-386
|
|
|
|
freebsd-amd64
|
|
|
|
freebsd-arm
|
2019-10-04 02:57:32 +03:00
|
|
|
illumos-amd64
|
2019-10-04 02:51:10 +03:00
|
|
|
linux-386
|
|
|
|
linux-amd64
|
|
|
|
linux-armv6
|
|
|
|
linux-armv7
|
|
|
|
linux-arm64
|
|
|
|
linux-ppc64
|
2019-10-04 02:57:32 +03:00
|
|
|
linux-ppc64le
|
|
|
|
linux-mips
|
|
|
|
linux-mipsle
|
2019-10-04 02:51:10 +03:00
|
|
|
linux-mips64
|
|
|
|
linux-mips64le
|
2019-10-04 02:57:32 +03:00
|
|
|
linux-s390x
|
2019-10-04 02:51:10 +03:00
|
|
|
netbsd-386
|
|
|
|
netbsd-amd64
|
2019-10-04 02:57:32 +03:00
|
|
|
netbsd-arm
|
|
|
|
netbsd-arm64
|
2019-10-04 02:51:10 +03:00
|
|
|
openbsd-386
|
|
|
|
openbsd-amd64
|
2019-10-04 02:57:32 +03:00
|
|
|
openbsd-arm
|
|
|
|
openbsd-arm64
|
|
|
|
solaris-amd64
|
2019-10-04 02:51:10 +03:00
|
|
|
windows-386
|
|
|
|
windows-amd64
|
2019-10-04 02:57:32 +03:00
|
|
|
windows-arm
|
2019-10-04 02:51:10 +03:00
|
|
|
"}
|
2017-01-13 05:30:38 +03:00
|
|
|
|
|
|
|
# Use the first element of $GOPATH in the case where GOPATH is a list
|
|
|
|
# (something that is totally allowed).
|
2019-01-02 23:01:00 +03:00
|
|
|
PKG="github.com/lightningnetwork/lnd"
|
|
|
|
COMMIT=$(git describe --abbrev=40 --dirty)
|
|
|
|
COMMITFLAGS="-X $PKG/build.Commit=$COMMIT"
|
2017-01-13 05:30:38 +03:00
|
|
|
|
|
|
|
for i in $SYS; do
|
|
|
|
OS=$(echo $i | cut -f1 -d-)
|
|
|
|
ARCH=$(echo $i | cut -f2 -d-)
|
2018-09-10 23:19:21 +03:00
|
|
|
ARM=
|
2019-01-18 10:30:45 +03:00
|
|
|
|
2018-09-10 23:19:21 +03:00
|
|
|
if [[ $ARCH = "armv6" ]]; then
|
|
|
|
ARCH=arm
|
|
|
|
ARM=6
|
|
|
|
elif [[ $ARCH = "armv7" ]]; then
|
|
|
|
ARCH=arm
|
|
|
|
ARM=7
|
|
|
|
fi
|
2019-01-18 10:30:45 +03:00
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
mkdir $PACKAGE-$i-$TAG
|
|
|
|
cd $PACKAGE-$i-$TAG
|
2019-01-18 10:30:45 +03:00
|
|
|
|
2018-09-10 23:19:21 +03:00
|
|
|
echo "Building:" $OS $ARCH $ARM
|
2019-09-27 02:17:45 +03:00
|
|
|
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
|
2017-01-13 05:30:38 +03:00
|
|
|
cd ..
|
2019-01-18 10:30:45 +03:00
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
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
|
2019-01-18 10:30:45 +03:00
|
|
|
|
2017-01-13 05:30:38 +03:00
|
|
|
rm -r $PACKAGE-$i-$TAG
|
|
|
|
done
|
|
|
|
|
|
|
|
shasum -a 256 * > manifest-$TAG.txt
|