Backport patch to not set RPMTAG_BUILDTIME to SOURCE_DATE_EPOCH

We have enabled SOURCE_DATE_EPOCH, but it changed behavior of
RPMTAG_BUILDTIME. We need to restore it…

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2019-07-20 18:30:29 +02:00
parent 0052ff9134
commit b419b5cbcd
No known key found for this signature in database
GPG Key ID: 695714BD1BBC5F4C
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,50 @@
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

View File

@ -21,7 +21,7 @@
%global rpmver 4.15.0
%global snapver beta
%global rel 1
%global rel 2
%global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x}
@ -51,6 +51,8 @@ Patch5: rpm-4.12.0-rpm2cpio-hack.patch
Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
# Patches already upstream:
# https://github.com/rpm-software-management/rpm/commit/4b15a9e48bd3d4bef96e8a8865044346be20d6dc
Patch101: 0001-Do-not-set-RPMTAG_BUILDTIME-to-SOURCE_DATE_EPOCH-whe.patch
# These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch
@ -537,6 +539,9 @@ make check || (cat tests/rpmtests.log; exit 0)
%doc doc/librpm/html/*
%changelog
* Sat Jul 20 18:30:10 CEST 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.15.0-0.beta.2
- Backport patch to not set RPMTAG_BUILDTIME to SOURCE_DATE_EPOCH
* Thu Jun 27 2019 Panu Matilainen <pmatilai@redhat.com> - 4.15.0-0.beta.1
- Rebase to 4.15.0 beta