From 2fc2a5762a88c6e4fce47fc20f7a06153fd4ff03 Mon Sep 17 00:00:00 2001
From: mlschroe <>
Date: Feb 22 2024 20:05:19 +0000
Subject: Update rpm to version 4.19.1.1 / rev 314 via SR 1146851
https://build.opensuse.org/request/show/1146851
by user mlschroe + anag+factory
Changed this how you suggested.
- Add patches to enable reproducible builds by default (bsc#1148824). For
upstream versions see:
https://github.com/rpm-software-management/rpm/pull/2880
0001-Add-option-to-set-mtime-of-files-in-rpms.patch
0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
0003-Error-out-on-a-missing-changelog-date.patch (forwarded request 1146788 from jzerebecki)
---
diff --git a/.files b/.files
index 473800d..a039e60 100644
Binary files a/.files and b/.files differ
diff --git a/.rev b/.rev
index 4c88b36..a5f8049 100644
--- a/.rev
+++ b/.rev
@@ -2515,4 +2515,19 @@ See bugzilla 1167537 for the gory details.
- update to rpm-4.19.1.11145411
+
+ b888911ad2c07d280f572e25b52fa791
+ 4.19.1.1
+
+ anag+factory
+ Changed this how you suggested.
+
+- Add patches to enable reproducible builds by default (bsc#1148824). For
+ upstream versions see:
+ https://github.com/rpm-software-management/rpm/pull/2880
+ 0001-Add-option-to-set-mtime-of-files-in-rpms.patch
+ 0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
+ 0003-Error-out-on-a-missing-changelog-date.patch (forwarded request 1146788 from jzerebecki)
+ 1146851
+
diff --git a/0001-Add-option-to-set-mtime-of-files-in-rpms.patch b/0001-Add-option-to-set-mtime-of-files-in-rpms.patch
new file mode 100644
index 0000000..f9a2f96
--- /dev/null
+++ b/0001-Add-option-to-set-mtime-of-files-in-rpms.patch
@@ -0,0 +1,122 @@
+From fc04a1bde1941d2c61a9e33e55c5c492327674ba Mon Sep 17 00:00:00 2001
+From: Jan Zerebecki
+Date: Thu, 15 Feb 2024 09:57:35 +0100
+Subject: [PATCH 1/3] Add option to set mtime of files in rpms
+
+to SOURCE_DATE_EPOCH.
+
+For backwards compatibility the option clamp / limit the maximum mtime
+is retained.
+
+Setting it ouright avoids problems with an incorrectly older clock. It
+also avoids problems with build scrips that incorrectly change file
+mtimes when SOURCE_DATE_EPOCH_MTIME is in use.
+
+mtimes are required to increase with new versions and releases
+of an rpm with the same name, as rsync without --checksum and similar
+tools would get confused if the content changes without newer mtime.
+
+If SOURCE_DATE_EPOCH_MTIME is set use it instead for file modification time
+stamps. It is supposed to be newer. This can be used if we might want to
+compare if the file content remains the same when a build dependency
+changes while a build script embeds SOURCE_DATE_EPOCH in the file
+content.
+
+This can be used to support automatic rebuilds. Normally automatic
+rebuilds work, but together with reproducible builds an undesirable
+situation may occur. If a build e.g. embeds SOURCE_DATE_EPOCH in the
+output, then the output changes every time such a rebuild happens, which
+can be very often. This is to be avoided as updating packages without
+necessity is too expensive.
+---
+ build/files.c | 33 ++++++++++++++++++++++++++++-----
+ docs/manual/buildprocess.md | 5 +++--
+ 2 files changed, 31 insertions(+), 7 deletions(-)
+
+diff --git a/build/files.c b/build/files.c
+index c403c806e..cec7999ca 100644
+--- a/build/files.c
++++ b/build/files.c
+@@ -1033,14 +1033,34 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
+ rpm_loff_t totalFileSize = 0;
+ Header h = pkg->header; /* just a shortcut */
+ int override_date = 0;
++ int set_mtime = 0;
+ time_t source_date_epoch = 0;
+ char *srcdate = getenv("SOURCE_DATE_EPOCH");
++ char *msrcdate = getenv("SOURCE_DATE_EPOCH_MTIME");
+
+- /* Limit the maximum date to SOURCE_DATE_EPOCH if defined
+- * similar to the tar --clamp-mtime option
++ /* If SOURCE_DATE_EPOCH_MTIME is set use it for file modification time
++ * stamps, it is supposed to be newer. This can be used if we might want to
++ * compare if the file content remains the same when a build dependency
++ * changes while a build script embeds SOURCE_DATE_EPOCH in the file
++ * content. mtimes are required to increase with new versions and releases
++ * of an rpm with the same name, as rsync without --checksum and similar
++ * tools would get confused if the content changes without newer mtime. */
++ if (msrcdate != NULL) {
++ srcdate = msrcdate;
++ }
++
++ /* Set the file mtime to SOURCE_DATE_EPOCH it if requested to make the
++ * resulting rpm reproducible.
+ * https://reproducible-builds.org/specs/source-date-epoch/
++ *
++ * For backwards compatibility clamp / limit the maximum mtime if requested
++ * similar the tar --clamp-mtime option. Setting it ouright avoids problems
++ * with an incorrectly older clock. It also avoids problems with build
++ * scrips that incorrectly change file mtimes when SOURCE_DATE_EPOCH_MTIME
++ * is in use.
+ */
+- if (srcdate && rpmExpandNumeric("%{?clamp_mtime_to_source_date_epoch}")) {
++ if (srcdate && (rpmExpandNumeric("%{?clamp_mtime_to_source_date_epoch}")
++ || rpmExpandNumeric("%{?set_mtime_to_source_date_epoch}"))) {
+ char *endptr;
+ errno = 0;
+ source_date_epoch = strtol(srcdate, &endptr, 10);
+@@ -1049,6 +1069,9 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
+ fl->processingFailed = 1;
+ }
+ override_date = 1;
++ if (rpmExpandNumeric("%{?set_mtime_to_source_date_epoch}")) {
++ set_mtime = 1;
++ }
+ }
+
+ /*
+@@ -1191,8 +1214,8 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
+ totalFileSize += flp->fl_size;
+ }
+ }
+-
+- if (override_date && flp->fl_mtime > source_date_epoch) {
++
++ if (override_date && (flp->fl_mtime > source_date_epoch || set_mtime)) {
+ flp->fl_mtime = source_date_epoch;
+ }
+ /*
+diff --git a/docs/manual/buildprocess.md b/docs/manual/buildprocess.md
+index 1ceb47a7e..64cd35626 100644
+--- a/docs/manual/buildprocess.md
++++ b/docs/manual/buildprocess.md
+@@ -94,13 +94,14 @@ Macro name | Description
+ `%_build_pkgcheck` | Progam to run on each generated binary package
+ `%_build_pkcheck_set` | Program to run on the generated binary package set
+
+-### Reproducability
++### Reproducibility
+
+ Macro name | Description
+ --------------------------------------|-----------
+ `%source_date_epoch_from_changelog` | Set `SOURCE_DATE_EPOCH` from latest `%changelog` entry
+ `%use_source_date_epoch_as_buildtime` | Set package BuildTime to `SOURCE_DATE_EPOCH`
+-`%clamp_mtime_to_source_date_epoch` | Ensure file timestamps are not newer than `SOURCE_DATE_EPOCH`
++`%set_mtime_to_source_date_epoch` | Set file modification timestamps to `SOURCE_DATE_EPOCH_MTIME` or as fallback to `SOURCE_DATE_EPOCH`
++`%clamp_mtime_to_source_date_epoch` | You should use the above instead, it is for backwards compatibility only. Ensure file timestamps are not newer than `SOURCE_DATE_EPOCH`
+
+ ### Vendor defaults
+
+--
+2.30.2
+
diff --git a/0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch b/0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
new file mode 100644
index 0000000..745ed05
--- /dev/null
+++ b/0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
@@ -0,0 +1,29 @@
+From e0a8b84f68993fccbe70c4fb1cd8402fa7371147 Mon Sep 17 00:00:00 2001
+From: Jan Zerebecki
+Date: Thu, 15 Feb 2024 07:58:44 +0100
+Subject: [PATCH 2/3] log build time if it is set from SOURCE_DATE_EPOCH
+
+---
+ build/build.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/build/build.c b/build/build.c
+index f2cf98c8b..2693d80b3 100644
+--- a/build/build.c
++++ b/build/build.c
+@@ -35,8 +35,11 @@ static rpm_time_t getBuildTime(void)
+ epoch = strtol(srcdate, &endptr, 10);
+ if (srcdate == endptr || *endptr || errno != 0)
+ rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
+- else
++ else {
+ buildTime = (uint32_t) epoch;
++ rpmlog(RPMLOG_NOTICE, _("using %s with value %ld as build time\n"),
++ "SOURCE_DATE_EPOCH", buildTime);
++ }
+ } else
+ buildTime = (uint32_t) time(NULL);
+
+--
+2.30.2
+
diff --git a/0003-Error-out-on-a-missing-changelog-date.patch b/0003-Error-out-on-a-missing-changelog-date.patch
new file mode 100644
index 0000000..2f65169
--- /dev/null
+++ b/0003-Error-out-on-a-missing-changelog-date.patch
@@ -0,0 +1,30 @@
+From 973f94bafea8e641ed747d3c420ea1bc2e1cb37f Mon Sep 17 00:00:00 2001
+From: Jan Zerebecki
+Date: Thu, 15 Feb 2024 08:03:05 +0100
+Subject: [PATCH 3/3] Error out on a missing changelog date
+
+if it is needed as the source for SOURCE_DATE_EPOCH, instead of only
+logging a warning.
+---
+ build/build.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/build/build.c b/build/build.c
+index 2693d80b3..ce7bc8b88 100644
+--- a/build/build.c
++++ b/build/build.c
+@@ -344,8 +344,10 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+ setenv("SOURCE_DATE_EPOCH", sdestr, 0);
+ rpmtdFreeData(&td);
+ } else {
+- rpmlog(RPMLOG_WARNING, _("source_date_epoch_from_changelog set but "
++ rpmlog(RPMLOG_ERR, _("source_date_epoch_from_changelog set but "
+ "%%changelog is missing\n"));
++ rc = RPMRC_FAIL;
++ goto exit;
+ }
+ }
+
+--
+2.30.2
+
diff --git a/rpm.changes b/rpm.changes
index 34102a5..f1ebd17 100644
--- a/rpm.changes
+++ b/rpm.changes
@@ -1,4 +1,14 @@
-------------------------------------------------------------------
+Thu Feb 15 10:14:07 UTC 2024 - Jan Zerebecki
+
+- Add patches to enable reproducible builds by default (bsc#1148824). For
+ upstream versions see:
+ https://github.com/rpm-software-management/rpm/pull/2880
+ 0001-Add-option-to-set-mtime-of-files-in-rpms.patch
+ 0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
+ 0003-Error-out-on-a-missing-changelog-date.patch
+
+-------------------------------------------------------------------
Fri Feb 9 11:34:31 CET 2024 - mls@suse.de
- update to rpm-4.19.1.1
diff --git a/rpm.spec b/rpm.spec
index 0dce4d3..1617a10 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -113,6 +113,9 @@ Patch135: selinux_transactional_update.patch
Patch136: rpmsort_reverse.diff
Patch138: canongnu.diff
Patch139: cmake_python_version.diff
+Patch140: 0001-Add-option-to-set-mtime-of-files-in-rpms.patch
+Patch141: 0002-log-build-time-if-it-is-set-from-SOURCE_DATE_EPOCH.patch
+Patch142: 0003-Error-out-on-a-missing-changelog-date.patch
Patch6464: auto-config-update-aarch64-ppc64le.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#
@@ -227,6 +230,7 @@ rm -rf sqlite
%patch -P 122 -P 123
%patch -P 131 -P 133 -P 134 -P 135 -P 136 -P 138
%patch -P 139
+%patch -P 140 -P 141 -P 142 -p1
%ifarch aarch64 ppc64le riscv64
%patch6464