Panu Matilainen 9f5580
From 701736a18a4625557a5181df3a4f3aed7ac13506 Mon Sep 17 00:00:00 2001
Panu Matilainen 9f5580
Message-Id: <701736a18a4625557a5181df3a4f3aed7ac13506.1587381334.git.pmatilai@redhat.com>
Panu Matilainen 9f5580
From: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 9f5580
Date: Wed, 8 Apr 2020 14:38:46 +0300
Panu Matilainen 9f5580
Subject: [PATCH] Warn on undefined components in buildtree macros
Panu Matilainen 9f5580
Panu Matilainen 9f5580
Issue a warning if buildtree macros (%_sourcedir etc) contain undefined
Panu Matilainen 9f5580
macro(s) after expansion, such as things only defined during spec parse.
Panu Matilainen 9f5580
This always was a murky case that doesn't work in all scenarios, so
Panu Matilainen 9f5580
a warning seems appropriate. Actual behavior doesn't change here though.
Panu Matilainen 9f5580
---
Panu Matilainen 9f5580
 rpmio/rpmfileutil.c | 2 ++
Panu Matilainen 9f5580
 1 file changed, 2 insertions(+)
Panu Matilainen 9f5580
Panu Matilainen 9f5580
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c
Panu Matilainen 9f5580
index 84ee34f4d..4a939dbfe 100644
Panu Matilainen 9f5580
--- a/rpmio/rpmfileutil.c
Panu Matilainen 9f5580
+++ b/rpmio/rpmfileutil.c
Panu Matilainen 9f5580
@@ -439,6 +439,8 @@ int rpmMkdirs(const char *root, const char *pathstr)
Panu Matilainen 9f5580
     
Panu Matilainen 9f5580
     for (char **d = dirs; *d; d++) {
Panu Matilainen 9f5580
 	char *path = rpmGetPath(root ? root : "", *d, NULL);
Panu Matilainen 9f5580
+	if (strstr(path, "%{"))
Panu Matilainen 9f5580
+	    rpmlog(RPMLOG_WARNING, ("undefined macro(s) in %s: %s\n"), *d, path);
Panu Matilainen 9f5580
 	if ((rc = rpmioMkpath(path, 0755, -1, -1)) != 0) {
Panu Matilainen 9f5580
 	    const char *msg = _("failed to create directory");
Panu Matilainen 9f5580
 	    /* try to be more informative if the failing part was a macro */
Panu Matilainen 9f5580
-- 
Panu Matilainen 9f5580
2.25.2
Panu Matilainen 9f5580