rpm/0001-Do-not-set-RPMTAG_BUIL...

51 lines
1.8 KiB
Diff

From 4b15a9e48bd3d4bef96e8a8865044346be20d6dc Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Sun, 7 Jul 2019 04:21:23 -0400
Subject: [PATCH] Do not set RPMTAG_BUILDTIME to SOURCE_DATE_EPOCH when defined
by default
Since b8a54d6a1e9bb6140b6b47e23dc707e4b967537e, when SOURCE_DATE_EPOCH
is set, RPMTAG_BUILDTIME winds up being set with that value. This is
not always desirable, particularly if you are using the build time for
filters and evaluation in certain types of package release pipelines.
This is an adaptation of the downstream patch in SUSE's rpm package
written by Michael Schroeder intended to address SuseBug:1087065.
---
build/spec.c | 2 +-
macros.in | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/build/spec.c b/build/spec.c
index f7de3d1d1..81506b4e9 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -207,7 +207,7 @@ static rpm_time_t getBuildTime(void)
char *endptr;
srcdate = getenv("SOURCE_DATE_EPOCH");
- if (srcdate) {
+ if (srcdate && rpmExpandNumeric("%{?use_source_date_epoch_as_buildtime}")) {
errno = 0;
epoch = strtol(srcdate, &endptr, 10);
if (srcdate == endptr || *endptr || errno != 0)
diff --git a/macros.in b/macros.in
index 73586a75b..3cdcca385 100644
--- a/macros.in
+++ b/macros.in
@@ -238,6 +238,11 @@ package or when debugging this package.\
# to the timestamp of the topmost changelog entry
%source_date_epoch_from_changelog 0
+# If true, make sure that buildtime in built rpms
+# is set to the value of SOURCE_DATE_EPOCH.
+# Is ignored when SOURCE_DATE_EPOCH is not set.
+%use_source_date_epoch_as_buildtime 0
+
# If true, make sure that timestamps in built rpms
# are not later than the value of SOURCE_DATE_EPOCH.
# Is ignored when SOURCE_DATE_EPOCH is not set.
--
2.22.0