#!/bin/sh# Help create a deterministic distribution tarball with timestamps# based on the time of the latest git commit.set -eudistdir="$1"# This will work for git or for tarball## Note: we give the .tarball file the exact same timestamp as the git commit,# so producing a tarball from a tarball should also create the exact same# output.stamp="$(cd "${0%/*}/.." && git show --format=%ct --no-patch 2>/dev/null || stat -c %Y version.m4)"test -n "${stamp}"timestamp() {find "$@" -exec touch -d "@${stamp}" '{}' '+'stamp="$((stamp + 1))"}# we add the date of the release to the Cockpit Client metainfosed -i "s/@DATE@/$(date -d@${stamp} +'%Y-%m-%d')/" \"${distdir}/src/client/org.cockpit_project.CockpitClient.metainfo.xml"# all files get the same timestamp as the commit datetimestamp "${distdir}"# aclocal.m4 comes nexttimestamp "${distdir}/aclocal.m4"# then the other automake generated filestimestamp \"${distdir}/config.h.in" \"${distdir}/configure" \"${distdir}/Makefile.in"# package-lock.json needs to be newer than package.jsontimestamp "${distdir}/package-lock.json"# and dist/ needs to be newer than thattimestamp "${distdir}/dist"# finally, the directories should be newer than everything elsetimestamp "${distdir}" -type d