public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: Backwards compatibility fixes
Date: Mon, 23 Nov 2026 09:35:26 GMT [thread overview]
Message-ID: <179542652604.1.3734618420808838557.rpms-rpm-df75392dff3e@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : df75392dff3e9a078db07f6da75162473b8bf635
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2024-06-04T08:58:21+03:00
Stats : +360/-1 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/df75392dff3e9a078db07f6da75162473b8bf635?branch=pmatilai-v6
Log:
Backwards compatibility fixes
Resurrect --buildroot option to rpmbuild, contrary to expectations this
is actually being used, by cpack (#2284124)
Make debuginfo generation depend on %{buildsubdir} being defined again,
we wanted to detach it from %setup but it there are more unsuspecting
victims than I care to count: it's all those unusual scenarios where
%setup isn't being used, such as packaging pre-build binaries where
the source is nowhere to be found and so on. It's just not worth the
carnage.
Bring back an effectively read-only, build-time definition of
%{_buildrootdir}, various packages depend on it. While this is not
something packages should ever use for anything, that never stopped them
from doing so. With the new intermediate %builddir, we can at least make
this a safe(r) place to put stuff into.
---
diff --git a/0001-Minimally-bring-back-buildroot-cli-switch-for-cpack.patch b/0001-Minimally-bring-back-buildroot-cli-switch-for-cpack.patch
new file mode 100644
index 0000000..b0ba253
--- /dev/null
+++ b/0001-Minimally-bring-back-buildroot-cli-switch-for-cpack.patch
@@ -0,0 +1,237 @@
+From 996b3ac32d244094c1d3a875d7098d459bb36c71 Mon Sep 17 00:00:00 2001
+Message-ID: <996b3ac32d244094c1d3a875d7098d459bb36c71.1717480260.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Mon, 3 Jun 2024 11:59:29 +0300
+Subject: [PATCH 1/3] Minimally bring back --buildroot cli switch for cpack
+
+Turns out cmake's cpack rpm module is using --buildroot to preinstall
+content to a known location and then point a dummy rpmbuild spec to
+that location using --buildroot.
+
+This is not how rpmbuild wants to be used but we can't very well break cpack
+(and who knows what else may be using it) just like that, commit
+9d35c8df497534e1fbd806a4dc78802bcf35d7cb went a step too far with the
+buildroot elimination.
+
+Do a partial revert of 9d35c8df497534e1fbd806a4dc78802bcf35d7cb to
+honor buildRoot argument to rpmSpecParse() again and bring back
+--buildroot cli switch to set it, just enough to cover this usage. Also
+add a test-case to mimick the "install from the outside" use that cpack does.
+---
+ build/parsePreamble.c | 20 ++++++++++++++++----
+ build/parseSpec.c | 12 +++++++-----
+ docs/man/rpmbuild.8.md | 7 ++++---
+ include/rpm/rpmbuild.h | 2 +-
+ tests/data/SPECS/brtest.spec | 11 +++++++++++
+ tests/rpmbuild.at | 25 +++++++++++++++++++++++++
+ tools/rpmbuild.c | 10 ++++++++++
+ 7 files changed, 74 insertions(+), 13 deletions(-)
+ create mode 100644 tests/data/SPECS/brtest.spec
+
+diff --git a/build/parsePreamble.c b/build/parsePreamble.c
+index cae2cea07..f62004ba0 100644
+--- a/build/parsePreamble.c
++++ b/build/parsePreamble.c
+@@ -1304,15 +1304,27 @@ int parsePreamble(rpmSpec spec, int initialPackage, enum parseStages stage)
+ rpmPushMacroFlags(spec->macros, "builddir", NULL, spec->buildDir,
+ RMIL_SPEC, RPMMACRO_LITERAL);
+
+- spec->buildRoot = rpmGetPath(spec->buildDir, "/BUILDROOT", NULL);
+- rpmPushMacroFlags(spec->macros, "buildroot", NULL, spec->buildRoot,
+- RMIL_SPEC, RPMMACRO_LITERAL);
+-
+ char *specparts = rpmGetPath(spec->buildDir, "/SPECPARTS", NULL);
+ rpmPushMacroFlags(spec->macros, "specpartsdir", NULL, specparts,
+ RMIL_SPEC, RPMMACRO_LITERAL);
+ free(specparts);
+ }
++
++ if (!spec->buildRoot) {
++ spec->buildRoot = rpmGetPath(spec->buildDir, "/BUILDROOT", NULL);
++ } else {
++ char *buildRoot = rpmGetPath(spec->buildRoot, NULL);
++ free(spec->buildRoot);
++ spec->buildRoot = buildRoot;
++ }
++
++ if (rstreq(spec->buildRoot, "") || rstreq(spec->buildRoot, "/")) {
++ rpmlog(RPMLOG_ERR, _("Invalid buildroot: '%s'\n"), spec->buildRoot);
++ goto exit;
++ }
++
++ rpmPushMacroFlags(spec->macros, "buildroot", NULL, spec->buildRoot,
++ RMIL_SPEC, RPMMACRO_LITERAL);
+ }
+
+ /* if we get down here nextPart has been set to non-error */
+diff --git a/build/parseSpec.c b/build/parseSpec.c
+index 620da0fa5..440cb0b1b 100644
+--- a/build/parseSpec.c
++++ b/build/parseSpec.c
+@@ -1068,7 +1068,7 @@ static rpmRC applyAppendPrepend(rpmSpec spec)
+ }
+
+ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
+- int recursing);
++ const char *buildRoot, int recursing);
+
+ /* is part allowed at this stage */
+ static int checkPart(int parsePart, enum parseStages stage) {
+@@ -1216,7 +1216,7 @@ static rpmRC parseSpecSection(rpmSpec *specptr, enum parseStages stage)
+ if (!rpmMachineScore(RPM_MACHTABLE_BUILDARCH, spec->BANames[x]))
+ continue;
+ rpmPushMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC);
+- spec->BASpecs[index] = parseSpec(spec->specFile, spec->flags, 1);
++ spec->BASpecs[index] = parseSpec(spec->specFile, spec->flags, spec->buildRoot, 1);
+ if (spec->BASpecs[index] == NULL) {
+ spec->BACount = index;
+ goto errxit;
+@@ -1286,7 +1286,7 @@ errxit:
+
+
+ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
+- int recursing)
++ const char *buildRoot, int recursing)
+ {
+ rpmSpec spec;
+
+@@ -1295,7 +1295,9 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
+
+ spec->specFile = rpmGetPath(specFile, NULL);
+ pushOFI(spec, spec->specFile);
+-
++ /* If explicit --buildroot was passed, grab hold of it */
++ if (buildRoot)
++ spec->buildRoot = xstrdup(buildRoot);
+ rpmPushMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
+ rpmPushMacro(NULL, "_licensedir", NULL, "%{_defaultlicensedir}", RMIL_SPEC);
+ spec->recursing = recursing;
+@@ -1378,7 +1380,7 @@ static rpmRC finalizeSpec(rpmSpec spec)
+ rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags,
+ const char *buildRoot)
+ {
+- rpmSpec spec = parseSpec(specFile, flags, 0);
++ rpmSpec spec = parseSpec(specFile, flags, buildRoot, 0);
+ if (spec && !(flags & RPMSPEC_NOFINALIZE)) {
+ finalizeSpec(spec);
+ }
+diff --git a/docs/man/rpmbuild.8.md b/docs/man/rpmbuild.8.md
+index 8c06a7712..bfd202751 100644
+--- a/docs/man/rpmbuild.8.md
++++ b/docs/man/rpmbuild.8.md
+@@ -211,10 +211,11 @@ all the stages preceding it), and is one of:
+
+ The following options may also be used:
+
+-**\--buildroot ***DIRECTORY*
++**\--buildroot ***DIRECTORY* (DEPRECATED)
+
+-: When building a package, override the BuildRoot tag with directory
+- *DIRECTORY*.
++: When building a package, override rpm's buildroot to *DIRECTORY*.
++ This option is deprecated and will be removed in the future, do
++ not introduce new usages.
+
+ **\--clean**
+
+diff --git a/include/rpm/rpmbuild.h b/include/rpm/rpmbuild.h
+index 8baafdf45..23f037d6e 100644
+--- a/include/rpm/rpmbuild.h
++++ b/include/rpm/rpmbuild.h
+@@ -78,7 +78,7 @@ typedef struct rpmBuildArguments_s * BTA_t;
+ *
+ * @param specFile path to spec file
+ * @param flags flags to control operation
+- * @param buildRoot unused
++ * @param buildRoot buildRoot override or NULL for default
+ * @return new spec control structure
+ */
+ rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags,
+diff --git a/tests/data/SPECS/brtest.spec b/tests/data/SPECS/brtest.spec
+new file mode 100644
+index 000000000..cde4d80e0
+--- /dev/null
++++ b/tests/data/SPECS/brtest.spec
+@@ -0,0 +1,11 @@
++Summary: Testing buildroot behavior
++Name: brtest
++Version: 1.0
++Release: 1
++License: GPL
++BuildArch: noarch
++
++%description
++
++%files
++/out/sider
+diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
+index a77ceeca4..19998012d 100644
+--- a/tests/rpmbuild.at
++++ b/tests/rpmbuild.at
+@@ -3289,3 +3289,28 @@ runroot rpmbuild -bb /data/SPECS/install-hack.spec
+ [ignore])
+ RPMTEST_CLEANUP
+
++# Mimick what cpack does. It's not how rpmbuild wants to be used, so
++# please don't copy this to any new usages.
++AT_SETUP([rpmbuild --buildroot])
++AT_KEYWORDS([build])
++
++RPMDB_INIT
++RPMTEST_CHECK([
++runroot_other mkdir -p /tmp/buildroot/out
++runroot_other touch /tmp/buildroot/out/sider
++runroot rpmbuild -bb --quiet \
++ --buildroot /tmp/buildroot \
++ /data/SPECS/brtest.spec
++],
++[0],
++[],
++[])
++
++RPMTEST_CHECK([
++runroot rpm -qpl /build/RPMS/noarch/brtest-1.0-1.noarch.rpm
++],
++[0],
++[/out/sider
++],
++[])
++RPMTEST_CLEANUP
+diff --git a/tools/rpmbuild.c b/tools/rpmbuild.c
+index 6e6d2cfe4..3e736444c 100644
+--- a/tools/rpmbuild.c
++++ b/tools/rpmbuild.c
+@@ -21,6 +21,7 @@ static struct rpmBuildArguments_s rpmBTArgs;
+ #define POPT_NOLANG -1012
+ #define POPT_RMSOURCE -1013
+ #define POPT_RMBUILD -1014
++#define POPT_BUILDROOT -1015
+ #define POPT_TARGETPLATFORM -1016
+ #define POPT_NOBUILD -1017
+ #define POPT_RMSPEC -1019
+@@ -127,6 +128,13 @@ static void buildArgCallback( poptContext con,
+ case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
+ case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
+ case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
++ case POPT_BUILDROOT:
++ if (rba->buildRootOverride) {
++ rpmlog(RPMLOG_ERR, _("buildroot already specified, ignoring %s\n"), arg);
++ break;
++ }
++ rba->buildRootOverride = xstrdup(arg);
++ break;
+ case POPT_TARGETPLATFORM:
+ argvSplit(&build_targets, arg, ",");
+ break;
+@@ -246,6 +254,8 @@ static struct poptOption rpmBuildPoptTable[] = {
+ N_("build through %install (%prep, %build, then install) from <source package>"),
+ N_("<source package>") },
+
++ { "buildroot", '\0', POPT_ARG_STRING, 0, POPT_BUILDROOT,
++ N_("override build root (DEPRECATED)"), "DIRECTORY" },
+ { "build-in-place", '\0', 0, 0, POPT_BUILDINPLACE,
+ N_("run build in current directory"), NULL },
+ { "clean", '\0', 0, 0, POPT_RMBUILD,
+--
+2.45.1
+
diff --git a/0002-Minimally-bring-back-_buildrootdir-for-backwards-com.patch b/0002-Minimally-bring-back-_buildrootdir-for-backwards-com.patch
new file mode 100644
index 0000000..fd0dda8
--- /dev/null
+++ b/0002-Minimally-bring-back-_buildrootdir-for-backwards-com.patch
@@ -0,0 +1,43 @@
+From 67f6bc4d9501b3db43b983ef25813a4cef8bf701 Mon Sep 17 00:00:00 2001
+Message-ID: <67f6bc4d9501b3db43b983ef25813a4cef8bf701.1717480260.git.pmatilai@redhat.com>
+In-Reply-To: <996b3ac32d244094c1d3a875d7098d459bb36c71.1717480260.git.pmatilai@redhat.com>
+References: <996b3ac32d244094c1d3a875d7098d459bb36c71.1717480260.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Mon, 3 Jun 2024 13:24:32 +0300
+Subject: [PATCH 2/3] Minimally bring back %{_buildrootdir} for backwards
+ compatibility
+
+This is yet another thing that specs use for purposes they shouldn't,
+in the traditional setup they don't own the top %{_buildrootdir} directory
+any more than they own %{_builddir}.
+
+We don't want people to muck with the %{_buildrootdir} but what we can
+do is just define it to be the dirname of %{buildroot}. This way in
+normal use, %{_buildrootdir} equals %{builddir} which is again a safe
+place for packages to fiddle around, and also works with --buildroot.
+
+Like %buildroot itself, this is now only ever defined inside a build,
+because that's the only place where it's relevant and meaningfully
+defineable.
+---
+ build/parsePreamble.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/build/parsePreamble.c b/build/parsePreamble.c
+index f62004ba0..43812f4f9 100644
+--- a/build/parsePreamble.c
++++ b/build/parsePreamble.c
+@@ -1325,6 +1325,10 @@ int parsePreamble(rpmSpec spec, int initialPackage, enum parseStages stage)
+
+ rpmPushMacroFlags(spec->macros, "buildroot", NULL, spec->buildRoot,
+ RMIL_SPEC, RPMMACRO_LITERAL);
++
++ /* Silly compat thing, but many specs use %_buildrootdir */
++ rpmPushMacroFlags(spec->macros, "_buildrootdir", NULL,
++ "%{dirname:%{buildroot}}", RMIL_GLOBAL, 0);
+ }
+
+ /* if we get down here nextPart has been set to non-error */
+--
+2.45.1
+
diff --git a/0003-Require-buildsubdir-to-be-defined-to-get-debuginfo-p.patch b/0003-Require-buildsubdir-to-be-defined-to-get-debuginfo-p.patch
new file mode 100644
index 0000000..6ee467a
--- /dev/null
+++ b/0003-Require-buildsubdir-to-be-defined-to-get-debuginfo-p.patch
@@ -0,0 +1,71 @@
+From 71e71c7b9a1100560f2f0541c83a0929425f5197 Mon Sep 17 00:00:00 2001
+Message-ID: <71e71c7b9a1100560f2f0541c83a0929425f5197.1717480260.git.pmatilai@redhat.com>
+In-Reply-To: <996b3ac32d244094c1d3a875d7098d459bb36c71.1717480260.git.pmatilai@redhat.com>
+References: <996b3ac32d244094c1d3a875d7098d459bb36c71.1717480260.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Mon, 3 Jun 2024 16:31:05 +0300
+Subject: [PATCH 3/3] Require %{buildsubdir} to be defined to get debuginfo
+ packages again
+
+One of the intentions with the debuginfo enablement rework in 4.20
+was to allow debuginfo generation on packages that don't use %setup,
+or in other words, don't have %{buildsubdir} defined. Turns out there's
+just so many things out there, relying on all these exact bits and pieces
+to be JUST SO, this causes more harm than its worth.
+
+So bring back the requirement of %{buildsubdir} macro to be defined for
+debuginfo generation to take place, update the caps testcase to cover
+both. At least we can now just define buildsubdir from the spec or even
+command line, so the promise to have debuginfo without %setup still
+holds, it's just not automatic everywhere.
+---
+ platform.in | 2 +-
+ tests/rpmbuild.at | 16 +++++++++++++++-
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/platform.in b/platform.in
+index 7ff4a29cd..2e7c6b50a 100644
+--- a/platform.in
++++ b/platform.in
+@@ -59,7 +59,7 @@
+
+ %__spec_install_template\
+ %{__spec_install_pre}\
+-%[ 0%{?_enable_debug_packages} > 0 ? "%(echo "%{debug_package}" > %{specpartsdir}/rpm-debuginfo.specpart)" : "" ]\
++%[ 0%{?_enable_debug_packages} > 0 ? "%{?buildsubdir:%(echo "%{debug_package}" > %{specpartsdir}/rpm-debuginfo.specpart)}" : "" ]\
+ %{nil}
+
+ %__spec_install_pre %{___build_pre}\
+diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
+index 19998012d..8205722d5 100644
+--- a/tests/rpmbuild.at
++++ b/tests/rpmbuild.at
+@@ -3173,10 +3173,24 @@ runroot rpm -qp --qf "%{name}\n" /build/RPMS/*/*.rpm|sort
+ ],
+ [0],
+ [caps
+-caps-debuginfo
+ ],
+ [])
+
++RPMTEST_CHECK([
++runroot rpmbuild --quiet -bb --define "buildsubdir ." /data/SPECS/caps.spec
++],
++[0],
++[],
++[])
++
++RPMTEST_CHECK([
++runroot rpm -qp --qf "%{name}\n" /build/RPMS/*/*.rpm|sort
++],
++[0],
++[caps
++caps-debuginfo
++],
++[])
+ RPMTEST_CHECK([
+ runroot rpm -q --filecaps /build/RPMS/*/caps-1.0-1.*.rpm | grep -v build-id
+ ],
+--
+2.45.1
+
diff --git a/rpm.spec b/rpm.spec
index 91e35ef..5acad2b 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -27,7 +27,7 @@
%global rpmver 4.19.91
#global snapver rc1
-%global baserelease 6
+%global baserelease 7
%global sover 10
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -156,6 +156,9 @@ rpm-4.19.91-weak-user-group.patch
0001-Hammer-in-no-debuginfo-for-noarch-packages-damn-it-r.patch
0001-Fix-regression-on-subpackage-debuginfo-RPMTAG_SOURCE.patch
0001-Fix-a-buildroot-regression-on-an-early-__spec_instal.patch
+0001-Minimally-bring-back-buildroot-cli-switch-for-cpack.patch
+0002-Minimally-bring-back-_buildrootdir-for-backwards-com.patch
+0003-Require-buildsubdir-to-be-defined-to-get-debuginfo-p.patch
# These are not yet upstream
rpm-4.7.1-geode-i686.patch
@@ -658,6 +661,11 @@ fi
%doc %{_defaultdocdir}/rpm/API/
%changelog
+* Tue Jun 04 2024 Panu Matilainen <pmatilai@redhat.com> - 4.19.91-7
+- Resurrect rpmbuild --buildroot option for cpack (#2284124)
+- Bring back %%{buildsubdir} requirement for debuginfo generation
+- Bring back %%{_buildrootdir} macro definition
+
* Fri May 31 2024 Panu Matilainen <pmatilai@redhat.com> - 4.19.91-6
- Fix unescaped changelog macro in previous build, oops
reply other threads:[~2026-11-23 9:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179542652604.1.3734618420808838557.rpms-rpm-df75392dff3e@fedoraproject.org \
--to=pmatilai@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox