public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: Fix RPM_BUILD_ROOT regression on a %__spec_install_pre override
@ 2026-11-23  9:35 Panu Matilainen
  0 siblings, 0 replies; only message in thread
From: Panu Matilainen @ 2026-11-23  9:35 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/rpm
            Branch : pmatilai-v6
            Commit : e5a338248df5cb4513c81dfb4d6544ef34fa65aa
            Author : Panu Matilainen <pmatilai@redhat.com>
            Date   : 2024-05-31T12:19:18+03:00
            Stats  : +109/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/rpm/c/e5a338248df5cb4513c81dfb4d6544ef34fa65aa?branch=pmatilai-v6

            Log:
            Fix RPM_BUILD_ROOT regression on a %__spec_install_pre override

Fixes: #2284036

---
diff --git a/0001-Fix-a-buildroot-regression-on-an-early-__spec_instal.patch b/0001-Fix-a-buildroot-regression-on-an-early-__spec_instal.patch
new file mode 100644
index 0000000..18f30d0
--- /dev/null
+++ b/0001-Fix-a-buildroot-regression-on-an-early-__spec_instal.patch
@@ -0,0 +1,104 @@
+From b20c731a5e916649b0257875febe260b5dfe3d72 Mon Sep 17 00:00:00 2001
+Message-ID: <b20c731a5e916649b0257875febe260b5dfe3d72.1717146759.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 31 May 2024 11:44:39 +0300
+Subject: [PATCH] Fix a %buildroot regression on an early %__spec_install_pre
+ %global override
+
+The Fedora kernel.spec overrides %__spec_install_pre with this very
+early in the spec:
+
+	%global __spec_install_pre %{___build_pre}
+
+This happens long before Name and all that is defined, so half of
+the environment setup in %___build_pre just falls through with
+unexpanded macros as the values (eg RPM_PACKAGE_NAME=%{NAME}) at this
+stage, and get their real values on the re-expansion before the actual
+scriptlet execution. But, due to pre-historical reasons, RPM_BUILD_ROOT
+setting is conditional, depending on whether %buildroot is defined or
+not. It used to be defined in the main macros file, so RPM_BUILD_ROOT
+would also get that template-style value at this point in the spec,
+but since 9d35c8df497534e1fbd806a4dc78802bcf35d7cb it no longer is.
+And that causes RPM_BUILD_ROOT to be *dropped* from the pre-environment
+"template" at this early stage of spec parsing.
+
+Add a simple reproducer test, this level of meddling in packages is of
+playing with fire and we may not be able to guarantee it always stays
+this way, but at least we'll be aware of possible changes in behavior.
+
+Commit 0a4e182e4003be1497452658b7b3327975694641 from 1998 is the first
+macro version of this conditional that came back to bite us. It
+should've been removed in 9d35c8df497534e1fbd806a4dc78802bcf35d7cb.
+
+Reported in https://bugzilla.redhat.com/show_bug.cgi?id=2284036
+---
+ macros.in                          |  4 ++--
+ tests/data/SPECS/install-hack.spec | 20 ++++++++++++++++++++
+ tests/rpmbuild.at                  | 12 ++++++++++++
+ 3 files changed, 34 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/SPECS/install-hack.spec
+
+diff --git a/macros.in b/macros.in
+index ba661d80a..44af70288 100644
+--- a/macros.in
++++ b/macros.in
+@@ -770,8 +770,8 @@ Supplements:   (%{name} = %{version}-%{release} and langpacks-%{1})\
+   unset CDPATH DISPLAY ||:\
+   unset DEBUGINFOD_URLS ||:\
+   unset RPM_CONFIG_DIR ||:\
+-  %{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\
+-  export RPM_BUILD_ROOT}\
++  RPM_BUILD_ROOT=\"%{buildroot}\"\
++  export RPM_BUILD_ROOT\
+   %{?_javaclasspath:CLASSPATH=\"%{_javaclasspath}\"\
+   export CLASSPATH}\
+   PKG_CONFIG_PATH=\"${PKG_CONFIG_PATH}:%{_libdir}/pkgconfig:%{_datadir}/pkgconfig\"\
+diff --git a/tests/data/SPECS/install-hack.spec b/tests/data/SPECS/install-hack.spec
+new file mode 100644
+index 000000000..42ecbed18
+--- /dev/null
++++ b/tests/data/SPECS/install-hack.spec
+@@ -0,0 +1,20 @@
++# Mimic what fedora kernel.spec does. Whether this is a legitimate
++# thing for a package to or not is another question, but at least we'll
++# be aware if the behavior changes.
++%global __spec_install_pre %{___build_pre}
++
++Summary: install scriptlet section override hack
++Name: install-hack
++Version: 1.0
++Release: 1
++License: GPL
++Buildarch: noarch
++
++%description
++%{summary}
++
++%install
++mkdir -p $RPM_BUILD_ROOT/usr/local/bin
++
++%files
++/usr/local/bin/
+diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
+index 38fe476a3..a77ceeca4 100644
+--- a/tests/rpmbuild.at
++++ b/tests/rpmbuild.at
+@@ -3277,3 +3277,15 @@ BUILD_POST noarch noarch noarch
+ ],
+ [])
+ RPMTEST_CLEANUP
++
++AT_SETUP([rpmbuild install_pre override])
++AT_KEYWORDS([build])
++RPMDB_INIT
++RPMTEST_CHECK([
++runroot rpmbuild -bb /data/SPECS/install-hack.spec
++],
++[0],
++[ignore],
++[ignore])
++RPMTEST_CLEANUP
++
+-- 
+2.45.1
+

diff --git a/rpm.spec b/rpm.spec
index 6975b39..b832c39 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -27,7 +27,7 @@
 
 %global rpmver 4.19.91
 #global snapver rc1
-%global baserelease 4
+%global baserelease 5
 %global sover 10
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -155,6 +155,7 @@ rpm-4.19.91-weak-user-group.patch
 0001-Fix-incomplete-header-on-plain-src.rpm-build-modes-r.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
 
 # These are not yet upstream
 rpm-4.7.1-geode-i686.patch
@@ -657,6 +658,9 @@ fi
 %doc %{_defaultdocdir}/rpm/API/
 
 %changelog
+* Fri May 31 2024 Panu Matilainen <pmatilai@redhat.com> - 4.19.91-5
+- Fix RPM_BUILD_ROOT regression on a %__spec_install_pre override (#2284036)
+
 * Wed May 29 2024 Michal Domonkos <mdomonko@redhat.com> - 4.19.91-4
 - Fix regression on subpackage debuginfo RPMTAG_SOURCERPM missing
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23  9:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  9:35 [rpms/rpm] pmatilai-v6: Fix RPM_BUILD_ROOT regression on a %__spec_install_pre override Panu Matilainen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox