From fe7296a49bac31ae1255aeac6d490e2617ac20fc Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bernhard+gitcommit lsmod.de>
Date: Mon, 13 Nov 2023 16:11:41 +0100
Subject: [PATCH] Add option to not store expanded spec

because some usages of macros are hard to make reproducible

Fixes #2343

This patch was done while working on reproducible builds for openSUSE.
---
 build/pack.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/build/pack.c b/build/pack.c
index f7dac6d9a4..370ab3b1c6 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -805,7 +805,9 @@ rpmRC packageSources(rpmSpec spec, char **cookie)
     headerPutUint32(sourcePkg->header, RPMTAG_SOURCEPACKAGE, &one, 1);
 
     /* Include spec in parsed and expanded form */
-    headerPutString(sourcePkg->header, RPMTAG_SPEC, getStringBuf(spec->parsed));
+    if (!rpmExpandNumeric("%{?no_store_expanded_spec}")) {
+	headerPutString(sourcePkg->header, RPMTAG_SPEC, getStringBuf(spec->parsed));
+    }
 
     if (spec->buildrequires) {
 	(void) rpmlibNeedsFeature(sourcePkg, "DynamicBuildRequires", "4.15.0-1");