File 0001-Fix-incomplete-header-on-plain-src.rpm-build-modes-r.patch of Package rpm
From e464af747b1ad97b9a088cc2045263864f283566 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Mon, 27 May 2024 13:53:32 +0300
Subject: [PATCH] Fix incomplete header on plain src.rpm build modes regression
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since 9165963de8bb5d5ad0a24ea4656d6d04d733f6bc, the main header wasn't
getting properly filled on plain src.rpm build modes like -bs. So a lot
of things was missing, but spotted in particular because %packager
wasn't getting set as per macros in Koji. Fix by letting rpm finalize
the spec after parse when no dynamic spec parts are to be executed.
Add a bunch of tests around this - we can't possibly test every single
build scenario but this should cover at least the most common ones
pretty well.
Reported-by: Miro HronĨok <miro@hroncok.cz>
---
tests/rpmbuild.at | 54 ++++++++++++++++++++++++++++++++++++++++++++++-
tools/rpmbuild.c | 14 ++++++------
2 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index a665a6bce..2243afcf4 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -26,6 +26,7 @@ RPMDB_INIT
RPMTEST_CHECK([
run rpmbuild \
+ --define "packager Iam" \
-ba ${RPMDATA}/SPECS/hello.spec
],
[0],
@@ -42,6 +43,38 @@ runroot rpm -qp --qf "%{license}\n" /build/RPMS/*/hello-1.0-1.*.rpm
GPL
],
[])
+
+RPMTEST_CHECK([
+runroot rpm -qp --qf "%{packager}\n" /build/SRPMS/hello-1.0-1.src.rpm
+runroot rpm -qp --qf "%{packager}\n" /build/RPMS/*/hello-1.0-1.*.rpm
+],
+[0],
+[Iam
+Iam
+],
+[])
+RPMTEST_CLEANUP
+
+AT_SETUP([rpmbuild -bs spec])
+AT_KEYWORDS([build])
+RPMDB_INIT
+
+RPMTEST_CHECK([
+runroot rpmbuild -bs \
+ --define "packager Iam" \
+ ${RPMDATA}/SPECS/hello.spec
+],
+[0],
+[ignore],
+[ignore])
+
+RPMTEST_CHECK([
+runroot rpm -q --qf "%{packager}\n" /build/SRPMS/hello-1.0-1.src.rpm
+],
+[0],
+[Iam
+],
+[])
RPMTEST_CLEANUP
AT_SETUP([rpmbuild -b buildsystem])
@@ -471,11 +504,20 @@ RPMDB_INIT
RPMTEST_CHECK([
run rpmbuild \
+ --define "packager Iam" \
--rebuild ${RPMDATA}/SRPMS/hello-1.0-1.src.rpm
],
[0],
[ignore],
[ignore])
+
+RPMTEST_CHECK([
+runroot rpm -qp --qf "%{packager}\n" /build/RPMS/*/hello-1.0-1.*.rpm
+],
+[0],
+[Iam
+],
+[])
RPMTEST_CLEANUP
AT_SETUP([rpmbuild --short-circuit -bl])
@@ -512,7 +554,9 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([
-runroot rpmbuild --quiet -ts /data/SOURCES/hello-2.0.tar.gz
+runroot rpmbuild --quiet \
+ --define "packager Iam" \
+ -ts /data/SOURCES/hello-2.0.tar.gz
runroot rpm -qpl /build/SRPMS/hello-2.0-1.src.rpm
],
[0],
@@ -520,6 +564,14 @@ runroot rpm -qpl /build/SRPMS/hello-2.0-1.src.rpm
hello.spec
],
[])
+
+RPMTEST_CHECK([
+runroot rpm -q --qf "%{packager}\n" /build/SRPMS/hello-2.0-1.src.rpm
+],
+[0],
+[Iam
+],
+[])
RPMTEST_CLEANUP
# weird filename survival test
diff --git a/tools/rpmbuild.c b/tools/rpmbuild.c
index dd36e24d8..6e6d2cfe4 100644
--- a/tools/rpmbuild.c
+++ b/tools/rpmbuild.c
@@ -79,6 +79,14 @@ static void buildArgCallback( poptContext con,
BTA_t rba = &rpmBTArgs;
switch (opt->val) {
+ case POPT_BS:
+ case POPT_RS:
+ case POPT_TS:
+ case POPT_BR:
+ case POPT_RR:
+ case POPT_TR:
+ /* If only building src.rpm, there are no dynamic parts to include */
+ spec_flags &= ~RPMSPEC_NOFINALIZE;
case POPT_REBUILD:
case POPT_RECOMPILE:
case POPT_BA:
@@ -89,8 +97,6 @@ static void buildArgCallback( poptContext con,
case POPT_BI:
case POPT_BL:
case POPT_BP:
- case POPT_BS:
- case POPT_BR:
case POPT_RA:
/* case POPT_RB: same value as POPT_REBUILD */
case POPT_RC:
@@ -99,8 +105,6 @@ static void buildArgCallback( poptContext con,
case POPT_RI:
case POPT_RL:
case POPT_RP:
- case POPT_RS:
- case POPT_RR:
case POPT_TA:
case POPT_TB:
case POPT_TC:
@@ -109,8 +113,6 @@ static void buildArgCallback( poptContext con,
case POPT_TI:
case POPT_TL:
case POPT_TP:
- case POPT_TS:
- case POPT_TR:
if (opt->val == POPT_BS || opt->val == POPT_TS)
noDeps = 1;
if (buildMode == '\0' && buildChar == '\0') {
--
2.45.1