update/release: if *GNU* tar, use --mtime

with --mtime, files added to the archive can be set
to a static date (in this case, the unix epoch)

the one used here is derived from git commit dates,
and it is static; if not being handled in lbmk.git,
the versiondate file never changes

this is the first patch in a series of patches designed
to bring about reproducible builds in libreboot

a solution will need to be found, for non-GNU tar
implementations, because they did not have an
equivalent option according to their manpages.
for example, BSD tar implementations.

perhaps i could systematically go around changing
file dates, on each file, as a fallback behaviour?

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-13 23:28:11 +01:00
parent c401efdd03
commit 6846c9f735
1 changed files with 8 additions and 1 deletions

View File

@ -259,8 +259,15 @@ insert_version_files()
mktarball()
{
# preserve timestamps for reproducible tarballs
tar_implementation="$(tar --version)"
tar_implementation="${tar_implementation% *}"
mtime=""
[ "${tar_implementation}" = "tar (GNU tar)" ] && \
mtime="--mtime=${versiondate}"
[ "${2%/*}" = "${2}" ] || x_ mkdir -p "${2%/*}"
x_ tar -c "${1}" | xz -T0 -9e > "${2}"
x_ tar -c "${1}" ${mtime} | xz -T0 -9e > "${2}"
(
[ "${2%/*}" != "${2}" ] && x_ cd "${2%/*}"
x_ sha512sum "${2##*/}" > "${2##*/}.sha512"