| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Help create a deterministic distribution tarball with timestamps |
| 4 |
# based on the time of the latest git commit. |
| 5 |
|
| 6 |
set -eu |
| 7 |
|
| 8 |
distdir="$1" |
| 9 |
|
| 10 |
# This will work for git or for tarball |
| 11 |
# |
| 12 |
# Note: we give the .tarball file the exact same timestamp as the git commit, |
| 13 |
# so producing a tarball from a tarball should also create the exact same |
| 14 |
# output. |
| 15 |
|
| 16 |
stamp="$(cd "${0%/*}/.." && git show --format=%ct --no-patch 2>/dev/null || stat -c %Y version.m4)" |
| 17 |
|
| 18 |
test -n "${stamp}" |
| 19 |
|
| 20 |
timestamp() { |
| 21 |
find "$@" -exec touch -d "@${stamp}" '{}' '+' |
| 22 |
stamp="$((stamp + 1))" |
| 23 |
} |
| 24 |
|
| 25 |
# we add the date of the release to the Cockpit Client metainfo |
| 26 |
sed -i "s/@DATE@/$(date -d@${stamp} +'%Y-%m-%d')/" \ |
| 27 |
"${distdir}/src/client/org.cockpit_project.CockpitClient.metainfo.xml" |
| 28 |
|
| 29 |
# all files get the same timestamp as the commit date |
| 30 |
timestamp "${distdir}" |
| 31 |
|
| 32 |
# aclocal.m4 comes next |
| 33 |
timestamp "${distdir}/aclocal.m4" |
| 34 |
|
| 35 |
# then the other automake generated files |
| 36 |
timestamp \ |
| 37 |
"${distdir}/config.h.in" \ |
| 38 |
"${distdir}/configure" \ |
| 39 |
"${distdir}/Makefile.in" |
| 40 |
|
| 41 |
# package-lock.json needs to be newer than package.json |
| 42 |
timestamp "${distdir}/package-lock.json" |
| 43 |
|
| 44 |
# and dist/ needs to be newer than that |
| 45 |
timestamp "${distdir}/dist" |
| 46 |
|
| 47 |
# finally, the directories should be newer than everything else |
| 48 |
timestamp "${distdir}" -type d |