From dce58393cb837444fb0ee089112a4ddf1962e18f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 25 Feb 2019 15:19:50 +1030 Subject: [PATCH] build-release.sh: fix zipfile determinism. I tried building zipfile on a fresh clone inside KVM, and got 1. Different times inside the zipfile, since zip seems to save *local* times. 2. A different zipfile order, since zip seems to use filesystem order. Fix both of these. I don't know if LANG=C is necessary for git ls-files, but it can't hurt. Signed-off-by: Rusty Russell --- tools/build-release.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/build-release.sh b/tools/build-release.sh index 6a631caa5..0986978dd 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -106,8 +106,17 @@ if [ -z "${TARGETS##* zipfile *}" ]; then # 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! - find "release/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME 00:00Z" - (cd release && zip -r -X "clightning-$VERSION.zip" "clightning-$VERSION") + # 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") rm -r "release/clightning-$VERSION" fi