From 99d550f0d4ce5e0bb81aff5712af07d9ad7dec6d Mon Sep 17 00:00:00 2001 From: Dhiru Kholia Date: Sun, 6 Dec 2015 01:49:44 +0100 Subject: [PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_FILEMTIMES --- lib/rpmfi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 640ac46..707fb2c 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -728,9 +728,20 @@ uint32_t rpmfilesFNlink(rpmfiles fi, int ix) rpm_time_t rpmfilesFMtime(rpmfiles fi, int ix) { rpm_time_t fmtime = 0; + char *srcdate; + time_t epoch; + char *endptr; if (fi != NULL && ix >= 0 && ix < rpmfilesFC(fi)) { - if (fi->fmtimes != NULL) + srcdate = getenv("SOURCE_DATE_EPOCH"); + if (srcdate) { + errno = 0; + epoch = strtol(srcdate, &endptr, 10); + if (srcdate == endptr || *endptr || errno != 0) + rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n")); + else + fmtime =(int32_t) epoch; + } else if (fi->fmtimes != NULL) fmtime = fi->fmtimes[ix]; } return fmtime; -- 2.6.3