teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0001-rpmfc-push-name-epoch-version-release-macro-before-i.patch

Igor Gnatenko 69ee4d
From 0d2176c9a3ae44fd0a67c9983b1a5ba0a00388fd Mon Sep 17 00:00:00 2001
Igor Gnatenko 69ee4d
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 69ee4d
Date: Mon, 15 Oct 2018 19:49:57 +0200
Igor Gnatenko 69ee4d
Subject: [PATCH] rpmfc: push name/epoch/version/release macro before invoking
Igor Gnatenko 69ee4d
 depgens
Igor Gnatenko 69ee4d
Igor Gnatenko 69ee4d
Fixes: https://github.com/rpm-software-management/rpm/issues/502
Igor Gnatenko 69ee4d
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 69ee4d
---
Igor Gnatenko 69ee4d
 build/rpmfc.c | 25 +++++++++++++++++++++++++
Igor Gnatenko 69ee4d
 1 file changed, 25 insertions(+)
Igor Gnatenko 69ee4d
Igor Gnatenko 69ee4d
diff --git a/build/rpmfc.c b/build/rpmfc.c
Igor Gnatenko 69ee4d
index 2fbfc69ab..eccd6582a 100644
Igor Gnatenko 69ee4d
--- a/build/rpmfc.c
Igor Gnatenko 69ee4d
+++ b/build/rpmfc.c
Igor Gnatenko 69ee4d
@@ -1334,9 +1334,31 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
Igor Gnatenko 69ee4d
     return rc;
Igor Gnatenko 69ee4d
 }
Igor Gnatenko 69ee4d
 
Igor Gnatenko 69ee4d
+typedef const struct macroExport_s {
Igor Gnatenko 69ee4d
+    const char * name;
Igor Gnatenko 69ee4d
+    rpmTagVal tag;
Igor Gnatenko 69ee4d
+} * macroExport;
Igor Gnatenko 69ee4d
+
Igor Gnatenko 69ee4d
+static struct macroExport_s const macroExportList[] = {
Igor Gnatenko 69ee4d
+    { "name",	RPMTAG_NAME },
Igor Gnatenko 69ee4d
+    { "epoch",	RPMTAG_EPOCH },
Igor Gnatenko 69ee4d
+    { "version",	RPMTAG_VERSION },
Igor Gnatenko 69ee4d
+    { "release",	RPMTAG_RELEASE },
Igor Gnatenko 69ee4d
+    { NULL,	0 }
Igor Gnatenko 69ee4d
+};
Igor Gnatenko 69ee4d
+
Igor Gnatenko 69ee4d
 rpmRC rpmfcApply(rpmfc fc)
Igor Gnatenko 69ee4d
 {
Igor Gnatenko 69ee4d
     rpmRC rc;
Igor Gnatenko 69ee4d
+    Package pkg = fc->pkg;
Igor Gnatenko 69ee4d
+    macroExport me;
Igor Gnatenko 69ee4d
+    for (me = macroExportList; me->name; me++) {
Igor Gnatenko 69ee4d
+	char *val = headerGetAsString(pkg->header, me->tag);
Igor Gnatenko 69ee4d
+	if (val) {
Igor Gnatenko 69ee4d
+	    rpmPushMacro(NULL, me->name, NULL, val, RMIL_SPEC);
Igor Gnatenko 69ee4d
+	    free(val);
Igor Gnatenko 69ee4d
+	}
Igor Gnatenko 69ee4d
+    }
Igor Gnatenko 69ee4d
     /* If new-fangled dependency generation is disabled ... */
Igor Gnatenko 69ee4d
     if (!rpmExpandNumeric("%{?_use_internal_dependency_generator}")) {
Igor Gnatenko 69ee4d
 	/* ... then generate dependencies using %{__find_requires} et al. */
Igor Gnatenko 69ee4d
@@ -1347,6 +1369,9 @@ rpmRC rpmfcApply(rpmfc fc)
Igor Gnatenko 69ee4d
 	/* ... otherwise generate per-file dependencies */
Igor Gnatenko 69ee4d
 	rc = rpmfcApplyInternal(fc);
Igor Gnatenko 69ee4d
     }
Igor Gnatenko 69ee4d
+    for (me = macroExportList; me->name; me++)
Igor Gnatenko 69ee4d
+	if (headerIsEntry(pkg->header, me->tag))
Igor Gnatenko 69ee4d
+	    rpmPopMacro(NULL, me->name);
Igor Gnatenko 69ee4d
     return rc;
Igor Gnatenko 69ee4d
 }
Igor Gnatenko 69ee4d
 
Igor Gnatenko 69ee4d
-- 
Igor Gnatenko 69ee4d
2.19.1
Igor Gnatenko 69ee4d