From 016b9511d2fd6bac25a42ea15c298451a6daad30 Mon Sep 17 00:00:00 2001 From: fosslinux Date: Fri, 14 Jan 2022 16:24:39 +1100 Subject: [PATCH] Make gzip-1.2.4 and tar-1.12 not include timestamps There is no way for gzip 1.2.4 and tar 1.12 to disable the inclusion of timestamps into the tarball/gzip, which creates non-reproducible tarballs and hence packages. While it is theoretically possible to set the timestamps to unix time 0 using touch, in reality this is not possible because mes libc does not support utime() which sets the timestamp of a file from userspace. So we need to ignore it rather than (re)set it. --- sysa/gzip-1.2.4/checksums | 2 +- sysa/gzip-1.2.4/files/stat_override.c | 30 +++++++++++++++++++++++++++ sysa/gzip-1.2.4/gzip-1.2.4.kaem | 7 +++++++ sysa/tar-1.12/checksums | 2 +- sysa/tar-1.12/files/stat_override.c | 30 +++++++++++++++++++++++++++ sysa/tar-1.12/tar-1.12.kaem | 2 ++ 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 sysa/gzip-1.2.4/files/stat_override.c create mode 100644 sysa/tar-1.12/files/stat_override.c diff --git a/sysa/gzip-1.2.4/checksums b/sysa/gzip-1.2.4/checksums index 18cb52b..90c6461 100644 --- a/sysa/gzip-1.2.4/checksums +++ b/sysa/gzip-1.2.4/checksums @@ -1 +1 @@ -304cead634e6766db915155d422049269f66b2ff34a20a7f20819a0c69193d33 /usr/bin/gzip +062e34d3f2d4bcb339ce3be80a1b6bc0ff805d70c8c13d9a6ad6e7a93914a1bf /usr/bin/gzip diff --git a/sysa/gzip-1.2.4/files/stat_override.c b/sysa/gzip-1.2.4/files/stat_override.c new file mode 100644 index 0000000..1481a3a --- /dev/null +++ b/sysa/gzip-1.2.4/files/stat_override.c @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2022 fosslinux + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +int _stat(const char *path, struct stat *buf) { + int rc = stat(path, buf); + if (rc == 0) { + buf->st_atime = 0; + buf->st_mtime = 0; + } + return rc; +} + +int _lstat(const char *path, struct stat *buf) { + int rc = lstat(path, buf); + if (rc == 0) { + buf->st_atime = 0; + buf->st_mtime = 0; + } + return rc; +} + +#define stat(a,b) _stat(a,b) +#define lstat(a,b) _lstat(a,b) diff --git a/sysa/gzip-1.2.4/gzip-1.2.4.kaem b/sysa/gzip-1.2.4/gzip-1.2.4.kaem index e30f6af..a6b2917 100755 --- a/sysa/gzip-1.2.4/gzip-1.2.4.kaem +++ b/sysa/gzip-1.2.4/gzip-1.2.4.kaem @@ -11,11 +11,18 @@ set -ex mkdir build cd build +catm gzip.c.new ../../files/stat_override.c gzip.c +cp gzip.c.new gzip.c + # Extract ungz ../src/${pkg}.tar.gz untar ../src/${pkg}.tar cd ${pkg} +# Prepare +catm gzip.c.new ../../files/stat_override.c gzip.c +cp gzip.c.new gzip.c + # Compile tcc -c -DNO_UTIME gzip.c tcc -c bits.c diff --git a/sysa/tar-1.12/checksums b/sysa/tar-1.12/checksums index 466d471..b3328a6 100644 --- a/sysa/tar-1.12/checksums +++ b/sysa/tar-1.12/checksums @@ -1 +1 @@ -d4ac49a136cb18e47fa4be447657746b3620d6e5bc15daa0b825f44734945a7c /usr/bin/tar +3d67caa46470a7c1f3b00b8301977bc1093fab333943aabfd84afaa1bd77a609 /usr/bin/tar diff --git a/sysa/tar-1.12/files/stat_override.c b/sysa/tar-1.12/files/stat_override.c new file mode 100644 index 0000000..1481a3a --- /dev/null +++ b/sysa/tar-1.12/files/stat_override.c @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2022 fosslinux + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +int _stat(const char *path, struct stat *buf) { + int rc = stat(path, buf); + if (rc == 0) { + buf->st_atime = 0; + buf->st_mtime = 0; + } + return rc; +} + +int _lstat(const char *path, struct stat *buf) { + int rc = lstat(path, buf); + if (rc == 0) { + buf->st_atime = 0; + buf->st_mtime = 0; + } + return rc; +} + +#define stat(a,b) _stat(a,b) +#define lstat(a,b) _lstat(a,b) diff --git a/sysa/tar-1.12/tar-1.12.kaem b/sysa/tar-1.12/tar-1.12.kaem index ebea144..116543d 100755 --- a/sysa/tar-1.12/tar-1.12.kaem +++ b/sysa/tar-1.12/tar-1.12.kaem @@ -18,6 +18,8 @@ untar ../src/${pkg}.tar cd ${pkg} cp ../../files/getdate_stub.c lib/getdate_stub.c +catm src/create.c.new ../../files/stat_override.c src/create.c +cp src/create.c.new src/create.c # Compile