tools: make build-release more friendly.

You can now override sanity checks for testing, and also
specify exactly what to build.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-02-08 07:04:50 +10:30
parent b7222531fe
commit e857229de4
1 changed files with 53 additions and 11 deletions

View File

@ -13,19 +13,58 @@ if [ x"$1" = x"--inside-docker" ]; then
exit 0
fi
if [ "$(git status --porcelain -u no)" != "" ]; then
ALL_TARGETS="bin-Fedora-28-amd64 bin-Ubuntu-16.04-amd64 bin-Ubuntu-16.04-i386 tarball sign"
FORCE_VERSION=
FORCE_UNCLEAN=false
for arg; do
case "$arg" in
--force-version=*)
FORCE_VERSION=${arg#*=}
;;
--force-unclean)
FORCE_UNCLEAN=true
;;
--help)
echo "Usage: [--force-version=<ver>] [--force-unclean] [TARGETS]"
echo Known targets: "$ALL_TARGETS"
exit 0
;;
-*)
echo "Unknown arg $arg" >&2
exit 1
;;
*)
break
;;
esac
shift
done
if [ "$#" = 0 ]; then
TARGETS=" $ALL_TARGETS "
else
TARGETS=" $* "
fi
if [ "$(git status --porcelain -u no)" != "" ] && ! $FORCE_UNCLEAN; then
echo "Not a clean git directory" >&2
exit 1
fi
VERSION=$(git tag --points-at HEAD)
VERSION=${VERSION:-$FORCE_VERSION}
if [ "$VERSION" = "" ]; then
echo "No tagged version at HEAD?" >&2
exit 1
fi
rm -rf release
mkdir -p release
for platform in Fedora-28-amd64 Ubuntu-16.04-amd64 Ubuntu-16.04-i386; do
for target in $TARGETS; do
platform=${target#bin-}
[ "$platform" != "$target" ] || continue
case $platform in
Fedora-28-amd64)
DOCKERFILE=contrib/Dockerfile.builder.fedora
@ -49,13 +88,16 @@ for platform in Fedora-28-amd64 Ubuntu-16.04-amd64 Ubuntu-16.04-i386; do
docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform" /build
done
# git archive won't go into submodules :(
ln -sf .. "release/clightning-$VERSION"
FILES=$(git ls-files --recurse-submodules | sed "s,^,clightning-$VERSION/,")
# shellcheck disable=SC2086
(cd release && zip "clightning-$VERSION.zip" $FILES)
rm "release/clightning-$VERSION"
exit 0
if [ -z "${TARGETS##* tarball *}" ]; then
# git archive won't go into submodules :(
ln -sf .. "release/clightning-$VERSION"
FILES=$(git ls-files --recurse-submodules | sed "s,^,clightning-$VERSION/,")
# shellcheck disable=SC2086
(cd release && zip "clightning-$VERSION.zip" $FILES)
rm "release/clightning-$VERSION"
fi
sha256sum release/clightning-"$VERSION"* > release/SHA256SUMS
gpg -sb --armor -o release/SHA256SUMS.asc-"$(gpgconf --list-options gpg | awk -F: '$1 == "default-key" {print $10}' | tr -d '"')" release/SHA256SUMS
if [ -z "${TARGETS##* sign *}" ]; then
sha256sum release/clightning-"$VERSION"* > release/SHA256SUMS
gpg -sb --armor -o release/SHA256SUMS.asc-"$(gpgconf --list-options gpg | awk -F: '$1 == "default-key" {print $10}' | tr -d '"')" release/SHA256SUMS
fi