From: Jan-Simon Möller <[email protected]>

This makes sure that if we enforce SOURCE_DATE_EPOCH
we do also set this for entries returned by the fakeStat
function of rpm.

Upstream status: pending

Signed-off-by: Jan-Simon Möller <[email protected]>
---
 ...-the-timestamps-returned-by-fakeStat.patch | 46 +++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_4.16.1.2.bb     |  1 +
 2 files changed, 47 insertions(+)
 create mode 100644 
meta/recipes-devtools/rpm/files/0001-Also-clamp-the-timestamps-returned-by-fakeStat.patch

diff --git 
a/meta/recipes-devtools/rpm/files/0001-Also-clamp-the-timestamps-returned-by-fakeStat.patch
 
b/meta/recipes-devtools/rpm/files/0001-Also-clamp-the-timestamps-returned-by-fakeStat.patch
new file mode 100644
index 0000000000..d5c3536856
--- /dev/null
+++ 
b/meta/recipes-devtools/rpm/files/0001-Also-clamp-the-timestamps-returned-by-fakeStat.patch
@@ -0,0 +1,46 @@
+From b79d505fc408a41616d51329895a27c99cbbaeaf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= <[email protected]>
+Date: Thu, 18 Feb 2021 16:26:58 +0100
+Subject: [PATCH] Also clamp the timestamps returned by fakeStat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Use the source_data_epoch also for the fakeStat supplied entries.
+
+Upstream status: pending
+
+Signed-off-by: Jan-Simon Möller <[email protected]>
+---
+ build/files.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/build/files.c b/build/files.c
+index 47625905c..75ec0792f 100644
+--- a/build/files.c
++++ b/build/files.c
+@@ -1304,6 +1304,24 @@ static rpmRC recurseDir(FileList fl, const char * 
diskPath);
+ static struct stat * fakeStat(FileEntry cur, struct stat * statp)
+ {
+     time_t now = time(NULL);
++    time_t source_date_epoch = 0;
++    char *srcdate = getenv("SOURCE_DATE_EPOCH");
++
++    /* Limit the maximum date to SOURCE_DATE_EPOCH if defined
++     * similar to the tar --clamp-mtime option
++     * https://reproducible-builds.org/specs/source-date-epoch/
++     */
++    if (srcdate && rpmExpandNumeric("%{?clamp_mtime_to_source_date_epoch}")) {
++       char *endptr;
++       errno = 0;
++       source_date_epoch = strtol(srcdate, &endptr, 10);
++       if (srcdate == endptr || *endptr || errno != 0) {
++           rpmlog(RPMLOG_ERR, _("unable to parse %s=%s\n"), 
"SOURCE_DATE_EPOCH", srcdate);
++       } else {
++       now = source_date_epoch;
++       }
++    }
++
+
+     if (cur->devtype) {
+       statp->st_rdev = ((cur->devmajor & 0xff) << 8) | (cur->devminor & 0xff);
diff --git a/meta/recipes-devtools/rpm/rpm_4.16.1.2.bb 
b/meta/recipes-devtools/rpm/rpm_4.16.1.2.bb
index 9195d66dd1..a5c7a0f071 100644
--- a/meta/recipes-devtools/rpm/rpm_4.16.1.2.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.16.1.2.bb
@@ -40,6 +40,7 @@ SRC_URI = 
"git://github.com/rpm-software-management/rpm;branch=rpm-4.16.x \
            
file://0016-rpmscript.c-change-logging-level-around-scriptlets-t.patch \
            
file://0001-lib-transaction.c-fix-file-conflicts-for-MIPS64-N32.patch \
            file://0001-tools-Add-error.h-for-non-glibc-case.patch \
+           file://0001-Also-clamp-the-timestamps-returned-by-fakeStat.patch \
            "

 PE = "1"
--
2.26.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#148373): 
https://lists.openembedded.org/g/openembedded-core/message/148373
Mute This Topic: https://lists.openembedded.org/mt/80783705/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to