File 0002-Minimally-bring-back-_buildrootdir-for-backwards-com.patch of Package rpm

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

openSUSE Build Service is sponsored by