Igor Gnatenko 889695
From daf5b95c2b2a9c2e869520240651f4b3c673da38 Mon Sep 17 00:00:00 2001
Igor Gnatenko 53960f
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 53960f
Date: Fri, 28 Jul 2017 15:21:00 +0200
Igor Gnatenko 53960f
Subject: [PATCH] exclude respective debug files for files which are excluded
Igor Gnatenko 53960f
Igor Gnatenko 53960f
Closes: https://github.com/rpm-software-management/rpm/issues/284
Igor Gnatenko 889695
Reviewed-by: Mark Wielaard <mark@klomp.org>
Igor Gnatenko 53960f
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 889695
(cherry picked from commit 1e7d3c58fc7c55e2dd20b5ca459f36a1cd2a3d8e)
Igor Gnatenko 53960f
---
Igor Gnatenko 889695
 build/files.c | 15 +++++++++++++++
Igor Gnatenko 889695
 1 file changed, 15 insertions(+)
Igor Gnatenko 53960f
Igor Gnatenko 53960f
diff --git a/build/files.c b/build/files.c
Igor Gnatenko 889695
index b9716b4d8..36e1ed5ea 100644
Igor Gnatenko 53960f
--- a/build/files.c
Igor Gnatenko 53960f
+++ b/build/files.c
Igor Gnatenko 889695
@@ -2803,6 +2803,21 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
Igor Gnatenko 53960f
 	}
Igor Gnatenko 53960f
 	path = _free(path);
Igor Gnatenko 53960f
     }
Igor Gnatenko 53960f
+    /* Exclude debug files for files which were excluded in respective non-debug package */
Igor Gnatenko 53960f
+    for (ARGV_const_t excl = pkg->fileExcludeList; excl && *excl; excl++) {
Igor Gnatenko 53960f
+        const char *name = *excl;
Igor Gnatenko 53960f
+
Igor Gnatenko 53960f
+	/* generate path */
Igor Gnatenko 53960f
+	rasprintf(&path, "%s%s%s%s.debug", buildroot, DEBUG_LIB_DIR, name, uniquearch);
Igor Gnatenko 53960f
+	/* Exclude only debuginfo files which actually exist */
Igor Gnatenko 53960f
+	if (access(path, F_OK) == 0) {
Igor Gnatenko 53960f
+	    char *line = NULL;
Igor Gnatenko 53960f
+	    rasprintf(&line, "%%exclude %s", path + buildrootlen);
Igor Gnatenko 53960f
+	    argvAdd(&files, line);
Igor Gnatenko 53960f
+	    _free(line);
Igor Gnatenko 53960f
+	}
Igor Gnatenko 53960f
+	path = _free(path);
Igor Gnatenko 53960f
+    }
Igor Gnatenko 53960f
 
Igor Gnatenko 53960f
     /* add collected directories to file list */
Igor Gnatenko 53960f
     if (dirs) {