Bug 1288713 - [PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME
[PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
24
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-05 08:30 EST by Dhiru Kholia
Modified: 2016-03-04 11:05 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-29 11:49:14 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
[PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME (1.40 KB, application/mbox)
2015-12-05 08:30 EST, Dhiru Kholia
no flags Details

  None (edit)
Description Dhiru Kholia 2015-12-05 08:30:22 EST
Created attachment 1102524 [details]
[PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME

SOURCE_DATE_EPOCH environment variable is a distribution-agnostic
standard for build systems to exchange a timestamp.

SOURCE_DATE_EPOCH specification is available at:
https://reproducible-builds.org/specs/source-date-epoch

...

This patch helps in making reproducible builds for Fedora more possible than before.

https://reproducible-builds.org/docs/
https://github.com/kholia/ReproducibleBuilds
Comment 1 Moez Roy 2016-01-12 13:29:52 EST
In case packaging-team-maint@redhat.com is to lazy to download the patch file:

From 8af7f08fd3308b61edbf4dfd20a656c2909a673f Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm@torproject.org>
Date: Thu, 3 Dec 2015 12:57:22 +0100
Subject: [PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME

SOURCE_DATE_EPOCH environment variable is a distribution-agnostic
standard for build systems to exchange a timestamp.

SOURCE_DATE_EPOCH specification is available at:
https://reproducible-builds.org/specs/source-date-epoch

Signed-off-by: Dhiru Kholia <dhiru@openwall.com>
---
 build/pack.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/build/pack.c b/build/pack.c
index bfb4c73..f9fb3a0 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -154,9 +154,23 @@ exit:
 static rpm_time_t * getBuildTime(void)
 {
     static rpm_time_t buildTime[1];
+    char *srcdate;
+    time_t epoch;
+    char *endptr;
+
+    if (buildTime[0] == 0) {
+        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
+                buildTime[0] = (int32_t) epoch;
+        } else
+            buildTime[0] = (int32_t) time(NULL);
+    }
 
-    if (buildTime[0] == 0)
-	buildTime[0] = (int32_t) time(NULL);
     return buildTime;
 }
 
-- 
2.6.3
Comment 2 Moez Roy 2016-01-14 16:39:56 EST
I meant too busy. Sorry.
Comment 3 Ľuboš Kardoš 2016-02-02 07:49:44 EST
I think that overriding RPMTAG_BUILDTIME is not enough for reproducible builds. You need to override also RPMTAG_FILEMTIMES and probably also RPMTAG_BUILDHOST.
Comment 4 Dhiru Kholia 2016-02-02 11:15:05 EST
Right.

I have a very hacky patch for handling RPMTAG_FILEMTIMES values. I can improve it a bit, and post it in another Bugzilla request.

Thanks for taking a look :-)
Comment 5 Jan Kurik 2016-02-24 09:05:46 EST
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase
Comment 6 Florian Festi 2016-02-29 11:49:14 EST
Added upstream as b8a54d6a1e9bb6140b6b47e23dc707e4b967537e. As there are still parts missing I am not pushing this into the Fedora package right now. Feel free to bug me for inclusion in Fedora as soon as all parts are done and upstream.
Comment 7 Florian Festi 2016-03-01 11:03:16 EST
Also feel free to post the patch for the file time stamps early. I just started a thread about reproducible builds on rpm-ecosystem@lists.rpm.org. That would be one of the appropriate places to post it and ask for a review
Comment 8 Nicolas Vigier 2016-03-04 11:05:23 EST
I posted a patch for the file time stamps in the thread:
http://lists.rpm.org/pipermail/rpm-ecosystem/2016-March/000322.html

Note You need to log in before you can comment on or make changes to this bug.