Skip to content

Commit dce5839

Browse files
committed
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 <[email protected]>
1 parent 6e63d79 commit dce5839

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/build-release.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ if [ -z "${TARGETS##* zipfile *}" ]; then
106106
# git archive won't go into submodules :(; We use tar to copy
107107
git ls-files -z --recurse-submodules | tar --null --files-from=- -c -f - | (cd "release/clightning-$VERSION" && tar xf -)
108108
# tar can set dates on files, but zip cares about dates in directories!
109-
find "release/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME 00:00Z"
110-
(cd release && zip -r -X "clightning-$VERSION.zip" "clightning-$VERSION")
109+
# We set to local time (not "$MTIME 00:00Z") because zip uses local time!
110+
find "release/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME"
111+
# Seriously, we can have differing permissions, too. Normalize.
112+
# Directories become drwxr-xr-x
113+
find "release/clightning-$VERSION" -type d -print0 | xargs -0r chmod 755
114+
# Executables become -rwxr-xr-x
115+
find "release/clightning-$VERSION" -type f -perm -100 -print0 | xargs -0r chmod 755
116+
# Non-executables become -rw-r--r--
117+
find "release/clightning-$VERSION" -type f ! -perm -100 -print0 | xargs -0r chmod 644
118+
# zip -r doesn't have a deterministic order, and git ls-files does.
119+
LANG=C git ls-files --recurse-submodules | sed "s@^@clightning-$VERSION/@" | (cd release && zip -@ -X "clightning-$VERSION.zip")
111120
rm -r "release/clightning-$VERSION"
112121
fi
113122

0 commit comments

Comments
 (0)