2018-10-26 03:47:07 +02:00
|
|
|
#! /bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# When run inside docker (from below), we do build and drop result in /release
|
2021-09-02 01:54:23 +02:00
|
|
|
if [ "$1" = "--inside-docker" ]; then
|
2018-10-26 03:47:07 +02:00
|
|
|
VER="$2"
|
|
|
|
git clone /src /build
|
|
|
|
cd /build
|
|
|
|
./configure
|
2020-04-17 23:07:21 +02:00
|
|
|
make
|
2022-03-23 11:50:36 +01:00
|
|
|
make install DESTDIR=/"$VER" RUST_PROFILE=release
|
2019-03-01 11:27:47 +01:00
|
|
|
cd /"$VER" && tar cvfz /release/clightning-"$VER".tar.gz -- *
|
2018-10-26 03:47:07 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-08-19 04:13:57 +02:00
|
|
|
# bin-Ubuntu-16.04-amd64 was superceded by the reproducible built 18.04 version.
|
2022-01-26 19:11:29 +01:00
|
|
|
ALL_TARGETS="bin-Fedora-28-amd64 zipfile tarball deb"
|
2019-02-07 21:34:50 +01:00
|
|
|
|
|
|
|
FORCE_VERSION=
|
|
|
|
FORCE_UNCLEAN=false
|
|
|
|
|
|
|
|
for arg; do
|
|
|
|
case "$arg" in
|
2019-02-22 04:04:37 +01:00
|
|
|
--force-mtime=*)
|
|
|
|
FORCE_MTIME=${arg#*=}
|
|
|
|
;;
|
2019-02-07 21:34:50 +01:00
|
|
|
--force-version=*)
|
|
|
|
FORCE_VERSION=${arg#*=}
|
|
|
|
;;
|
|
|
|
--force-unclean)
|
|
|
|
FORCE_UNCLEAN=true
|
|
|
|
;;
|
|
|
|
--help)
|
2019-02-22 04:04:37 +01:00
|
|
|
echo "Usage: [--force-version=<ver>] [--force-unclean] [--force-mtime=YYYY-MM-DD] [TARGETS]"
|
2019-02-07 21:34:50 +01:00
|
|
|
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
|
|
|
|
|
2019-02-22 04:03:37 +01:00
|
|
|
# `status --porcelain -u no` suppressed modified! Bug reported...
|
|
|
|
if [ "$(git diff --name-only)" != "" ] && ! $FORCE_UNCLEAN; then
|
2018-10-26 03:47:07 +02:00
|
|
|
echo "Not a clean git directory" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION=$(git tag --points-at HEAD)
|
2019-02-07 21:34:50 +01:00
|
|
|
VERSION=${VERSION:-$FORCE_VERSION}
|
2018-10-26 03:47:07 +02:00
|
|
|
if [ "$VERSION" = "" ]; then
|
|
|
|
echo "No tagged version at HEAD?" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-02-26 03:07:28 +01:00
|
|
|
# Skip 'v' here in $VERSION
|
2021-01-12 13:15:29 +01:00
|
|
|
MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[.*${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
|
2019-02-22 04:04:37 +01:00
|
|
|
if [ -z "$MTIME" ]; then
|
|
|
|
echo "No date found for $VERSION in CHANGELOG.md" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-09-22 03:44:35 +02:00
|
|
|
# submodcheck needs to know if we have lowdown
|
|
|
|
./configure --reconfigure
|
2019-02-22 04:05:37 +01:00
|
|
|
# If it's a completely clean directory, we need submodules!
|
|
|
|
make submodcheck
|
2018-10-26 03:47:07 +02:00
|
|
|
mkdir -p release
|
2019-02-07 21:34:50 +01:00
|
|
|
for target in $TARGETS; do
|
|
|
|
platform=${target#bin-}
|
|
|
|
[ "$platform" != "$target" ] || continue
|
2018-10-26 03:47:07 +02:00
|
|
|
case $platform in
|
|
|
|
Fedora-28-amd64)
|
2022-04-25 12:12:12 +02:00
|
|
|
DOCKERFILE=contrib/docker/Dockerfile.builder.fedora
|
2018-10-26 03:47:07 +02:00
|
|
|
TAG=fedora
|
|
|
|
;;
|
|
|
|
Ubuntu-16.04-amd64)
|
2022-04-25 12:12:12 +02:00
|
|
|
DOCKERFILE=contrib/docker/Dockerfile.builder
|
2018-10-26 03:47:07 +02:00
|
|
|
TAG=ubuntu-amd64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "No Dockerfile for $platform" >&2
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
docker build -f $DOCKERFILE -t $TAG .
|
|
|
|
docker run --rm=true -v "$(pwd)":/src:ro -v "$(pwd)"/release:/release $TAG /src/tools/build-release.sh --inside-docker "$VERSION-$platform"
|
|
|
|
docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform" /build
|
|
|
|
done
|
|
|
|
|
2019-02-22 04:04:37 +01:00
|
|
|
if [ -z "${TARGETS##* zipfile *}" ]; then
|
|
|
|
mkdir "release/clightning-$VERSION"
|
|
|
|
# git archive won't go into submodules :(; We use tar to copy
|
|
|
|
git ls-files -z --recurse-submodules | tar --null --files-from=- -c -f - | (cd "release/clightning-$VERSION" && tar xf -)
|
|
|
|
# tar can set dates on files, but zip cares about dates in directories!
|
2019-02-25 05:49:50 +01:00
|
|
|
# We set to local time (not "$MTIME 00:00Z") because zip uses local time!
|
|
|
|
find "release/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME"
|
|
|
|
# Seriously, we can have differing permissions, too. Normalize.
|
|
|
|
# Directories become drwxr-xr-x
|
|
|
|
find "release/clightning-$VERSION" -type d -print0 | xargs -0r chmod 755
|
|
|
|
# Executables become -rwxr-xr-x
|
|
|
|
find "release/clightning-$VERSION" -type f -perm -100 -print0 | xargs -0r chmod 755
|
|
|
|
# Non-executables become -rw-r--r--
|
|
|
|
find "release/clightning-$VERSION" -type f ! -perm -100 -print0 | xargs -0r chmod 644
|
|
|
|
# zip -r doesn't have a deterministic order, and git ls-files does.
|
|
|
|
LANG=C git ls-files --recurse-submodules | sed "s@^@clightning-$VERSION/@" | (cd release && zip -@ -X "clightning-$VERSION.zip")
|
2019-02-22 04:04:37 +01:00
|
|
|
rm -r "release/clightning-$VERSION"
|
2019-02-07 21:34:50 +01:00
|
|
|
fi
|
2018-10-26 03:47:07 +02:00
|
|
|
|
2022-01-26 19:11:29 +01:00
|
|
|
RELEASEDIR="$(pwd)/release"
|
|
|
|
BARE_VERSION="$(echo "${VERSION}" | sed 's/^v//g')"
|
|
|
|
TARBALL="${RELEASEDIR}/lightningd_${BARE_VERSION}.orig.tar.bz2"
|
|
|
|
DATE=$(date +%Y%m%d%H%M%S)
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "${TARGETS##* tarball *}" ]; then
|
|
|
|
TMPDIR="$(mktemp -d /tmp/lightningd-tarball.XXXXXX)"
|
|
|
|
DIR="${TMPDIR}/lightningd_${BARE_VERSION}"
|
|
|
|
DESTINATION="${RELEASEDIR}/lightningd_${BARE_VERSION}.orig.tar.bz2"
|
|
|
|
echo "Bundling tarball in ${DIR}"
|
|
|
|
git clone --recursive . "${DIR}"
|
|
|
|
(
|
|
|
|
cd "${DIR}"
|
|
|
|
# Materialize the version in the Makefile, allows us to skip
|
|
|
|
# the git dependency
|
|
|
|
sed -i "/^VERSION=/c\VERSION=v${BARE_VERSION}" "Makefile"
|
2023-05-22 02:51:44 +02:00
|
|
|
./configure --disable-valgrind --enable-developer
|
2022-01-26 19:11:29 +01:00
|
|
|
make doc-all check-gen-updated clean
|
|
|
|
find . -name .git -type d -print0 | xargs -0 /bin/rm -rf
|
|
|
|
)
|
|
|
|
|
|
|
|
(
|
|
|
|
cd "$TMPDIR"
|
|
|
|
tar -cjvf "${DESTINATION}" "lightningd_${BARE_VERSION}"
|
|
|
|
)
|
|
|
|
|
|
|
|
rm -rf "${TMPDIR}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${TARGETS##* deb *}" ]; then
|
|
|
|
TMPDIR="$(mktemp -d /tmp/lightningd-deb.XXXXXX)"
|
|
|
|
SRCDIR="$(pwd)"
|
|
|
|
BLDDIR="${TMPDIR}/clightning-${VERSION}"
|
|
|
|
ARCH="$(dpkg-architecture -q DEB_BUILD_ARCH)"
|
|
|
|
|
|
|
|
for SUITE in bionic focal hirsute xenial hirsute impish; do
|
|
|
|
|
|
|
|
mkdir -p "${BLDDIR}"
|
|
|
|
echo "Building ${BARE_VERSION} in ${TMPDIR}"
|
|
|
|
|
|
|
|
# Stage the source directory, with the debian directory bolted on
|
|
|
|
# until we add it to contrib
|
|
|
|
tar --directory="$BLDDIR" --strip-components=1 -xjf "${TARBALL}"
|
|
|
|
cp -R "${SRCDIR}/debian" "${BLDDIR}"
|
|
|
|
|
|
|
|
# Stage the tarball so `debuild` can find it in the parent of the
|
|
|
|
# source directory.
|
|
|
|
cp "${TARBALL}" "${TMPDIR}"
|
|
|
|
cp "${TARBALL}" "${TMPDIR}/lightningd_${BARE_VERSION}~${DATE}~${SUITE}.orig.tar.bz2"
|
|
|
|
|
|
|
|
# Now actually build all the artifacts.
|
|
|
|
#(cd "${BLDDIR}" && debuild -i -us -uc -b)
|
|
|
|
(
|
|
|
|
cd "${BLDDIR}"
|
|
|
|
# Add a dummy changelog entry
|
|
|
|
dch -D "${SUITE}" -v "${BARE_VERSION}~${DATE}~${SUITE}" "Upstream release $BARE_VERSION"
|
|
|
|
head debian/changelog
|
|
|
|
debuild -k5B7EE09E54473A764A23515B25B5BC531246001A -S
|
|
|
|
debuild -k5B7EE09E54473A764A23515B25B5BC531246001A -b
|
|
|
|
)
|
|
|
|
rm -rf "${BLDDIR}"
|
|
|
|
|
|
|
|
# Save the debs locally
|
|
|
|
cp -v "${TMPDIR}/lightningd_${BARE_VERSION}~${DATE}~${SUITE}_${ARCH}.deb" "${RELEASEDIR}"
|
|
|
|
cp -v "${TMPDIR}/lightningd-dbgsym_${BARE_VERSION}~${DATE}~${SUITE}_${ARCH}.ddeb" "${RELEASEDIR}"
|
|
|
|
|
|
|
|
# Send to PPA
|
|
|
|
dput ppa:cdecker/clightning "${TMPDIR}/lightningd_${BARE_VERSION}~${DATE}~${SUITE}_source.changes"
|
|
|
|
done
|
|
|
|
rm -rf "${TMPDIR}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${TARGETS##* docker *}" ]; then
|
|
|
|
TMPDIR="$(mktemp -d /tmp/lightningd-docker.XXXXXX)"
|
|
|
|
SRCDIR="$(pwd)"
|
|
|
|
echo "Bundling tarball in ${TMPDIR}"
|
|
|
|
git clone --recursive . "${TMPDIR}"
|
|
|
|
(
|
|
|
|
cd "${TMPDIR}"
|
|
|
|
git checkout "v${BARE_VERSION}"
|
|
|
|
cp "${SRCDIR}/Dockerfile" "${TMPDIR}/"
|
|
|
|
sudo docker build -t elementsproject/lightningd:latest .
|
|
|
|
sudo docker tag "elementsproject/lightningd:latest" "elementsproject/lightningd:v${BARE_VERSION}"
|
|
|
|
)
|
|
|
|
rm -rf "${TMPDIR}"
|
|
|
|
fi
|
|
|
|
|
2019-02-07 21:34:50 +01:00
|
|
|
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
|