Browse Source

tools/build-release.sh: make zipfile deterministic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pr-2391
Rusty Russell 6 years ago
committed by neil saitug
parent
commit
6e44073bb0
  1. 28
      tools/build-release.sh

28
tools/build-release.sh

@ -13,13 +13,16 @@ if [ x"$1" = x"--inside-docker" ]; then
exit 0 exit 0
fi fi
ALL_TARGETS="bin-Fedora-28-amd64 bin-Ubuntu-16.04-amd64 bin-Ubuntu-16.04-i386 tarball sign" ALL_TARGETS="bin-Fedora-28-amd64 bin-Ubuntu-16.04-amd64 bin-Ubuntu-16.04-i386 zipfile sign"
FORCE_VERSION= FORCE_VERSION=
FORCE_UNCLEAN=false FORCE_UNCLEAN=false
for arg; do for arg; do
case "$arg" in case "$arg" in
--force-mtime=*)
FORCE_MTIME=${arg#*=}
;;
--force-version=*) --force-version=*)
FORCE_VERSION=${arg#*=} FORCE_VERSION=${arg#*=}
;; ;;
@ -27,7 +30,7 @@ for arg; do
FORCE_UNCLEAN=true FORCE_UNCLEAN=true
;; ;;
--help) --help)
echo "Usage: [--force-version=<ver>] [--force-unclean] [TARGETS]" echo "Usage: [--force-version=<ver>] [--force-unclean] [--force-mtime=YYYY-MM-DD] [TARGETS]"
echo Known targets: "$ALL_TARGETS" echo Known targets: "$ALL_TARGETS"
exit 0 exit 0
;; ;;
@ -61,6 +64,12 @@ if [ "$VERSION" = "" ]; then
exit 1 exit 1
fi fi
MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[$VERSION\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
if [ -z "$MTIME" ]; then
echo "No date found for $VERSION in CHANGELOG.md" >&2
exit 1
fi
rm -rf release rm -rf release
mkdir -p release mkdir -p release
for target in $TARGETS; do for target in $TARGETS; do
@ -89,13 +98,14 @@ for target in $TARGETS; do
docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform" /build docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform" /build
done done
if [ -z "${TARGETS##* tarball *}" ]; then if [ -z "${TARGETS##* zipfile *}" ]; then
# git archive won't go into submodules :( mkdir "release/clightning-$VERSION"
ln -sf .. "release/clightning-$VERSION" # git archive won't go into submodules :(; We use tar to copy
FILES=$(git ls-files --recurse-submodules | sed "s,^,clightning-$VERSION/,") git ls-files -z --recurse-submodules | tar --null --files-from=- -c -f - | (cd "release/clightning-$VERSION" && tar xf -)
# shellcheck disable=SC2086 # tar can set dates on files, but zip cares about dates in directories!
(cd release && zip "clightning-$VERSION.zip" $FILES) find "release/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME 00:00Z"
rm "release/clightning-$VERSION" (cd release && zip -r -X "clightning-$VERSION.zip" "clightning-$VERSION")
rm -r "release/clightning-$VERSION"
fi fi
if [ -z "${TARGETS##* sign *}" ]; then if [ -z "${TARGETS##* sign *}" ]; then

Loading…
Cancel
Save