File 0001-Hammer-in-no-debuginfo-for-noarch-packages-damn-it-r.patch of Package rpm
From 3a14eb950148514c6d196ab3cefa7a37b82bff64 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Tue, 28 May 2024 14:03:29 +0300
Subject: [PATCH] Hammer in "no debuginfo for noarch packages, damn it" rule
All the work we now do to get target platform right gets thrown away by mock
apparently always passing "--target $(uname -m)" equivalent to rpmbuild,
causing %_target_cpu and all that stuff be wrong during build scriptlet
execution. Those are right during the initial spec parse so the old
implementation just barely scraped through it all.
Hammer in a C-side test based on the package arch to disable debuginfo
packages on noarch no matter what. Pfft.
Fixes: #3115
---
build/build.c | 5 +++++
tests/rpmbuild.at | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/build/build.c b/build/build.c
index 0c2d73862..7451c9c22 100644
--- a/build/build.c
+++ b/build/build.c
@@ -386,6 +386,11 @@ static int buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
spec->buildTime = getBuildTime();
spec->buildHost = buildHost();
+ /* Don't generate debug packages on noarch no matter what --target says */
+ const char *arch = headerGetString(spec->packages->header, RPMTAG_ARCH);
+ if (rstreq(arch, "noarch"))
+ rpmPushMacro(spec->macros, "_enable_debug_packages", NULL, "0", RMIL_SPEC);
+
/* XXX TODO: rootDir is only relevant during build, eliminate from spec */
spec->rootDir = buildArgs->rootdir;
if (!spec->recursing && spec->BACount) {
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 2243afcf4..38fe476a3 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -2343,6 +2343,18 @@ runroot rpmbuild --quiet -bb \
[0],
[ignore],
[ignore])
+
+RPMTEST_CHECK([
+# mock uses --target <hostarch> everywhere, even noarch packages
+target=$(runroot rpm --eval "%{_host_cpu}")
+runroot rpmbuild --quiet -bb \
+ --target ${target} \
+ --define "%_enable_debug_packages 1" \
+ /data/SPECS/hlinktest.spec
+],
+[0],
+[ignore],
+[ignore])
RPMTEST_CLEANUP
# ------------------------------
--
2.45.1