Bug 1288713 - [PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME
Summary: [PATCH] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 24
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-05 13:30 UTC by Dhiru Kholia
Modified: 2016-03-04 16:05 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-02-29 16:49:14 UTC
Type: Bug
Embargoed:


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

Description Dhiru Kholia 2015-12-05 13:30:22 UTC
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 18:29:52 UTC
In case packaging-team-maint is to lazy to download the patch file:

From 8af7f08fd3308b61edbf4dfd20a656c2909a673f Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm>
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>
---
 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 21:39:56 UTC
I meant too busy. Sorry.

Comment 3 Ľuboš Kardoš 2016-02-02 12:49:44 UTC
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 16:15:05 UTC
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 14:05:46 UTC
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 16:49:14 UTC
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 16:03:16 UTC
Also feel free to post the patch for the file time stamps early. I just started a thread about reproducible builds on rpm-ecosystem.org. That would be one of the appropriate places to post it and ask for a review

Comment 8 Nicolas Vigier 2016-03-04 16:05:23 UTC
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.