Browse Source

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 <rusty@rustcorp.com.au>
pr-2391
Rusty Russell 6 years ago
parent
commit
dce58393cb
  1. 13
      tools/build-release.sh

13
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

Loading…
Cancel
Save