Igor Gnatenko 082d5d
From 9f826d903dabbc2ce199560e296224c320bb840f Mon Sep 17 00:00:00 2001
Igor Gnatenko 082d5d
From: Michael Schroeder <mls@suse.de>
Igor Gnatenko 082d5d
Date: Wed, 29 Mar 2017 14:55:10 +0200
Igor Gnatenko 3992a6
Subject: [PATCH 38/54] Also add directories to split debuginfo packages
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
This gets rid of the last difference between debuginfo subpackages
Igor Gnatenko 082d5d
and normal debuginfo packages.
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
(cherry picked from commit a517554e36666f58724620347a4b8224471d2225)
Igor Gnatenko 082d5d
---
Igor Gnatenko 082d5d
 build/files.c | 30 ++++++++++++++++++++++++++++--
Igor Gnatenko 082d5d
 1 file changed, 28 insertions(+), 2 deletions(-)
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
diff --git a/build/files.c b/build/files.c
Igor Gnatenko 082d5d
index 779a2a102..f27dcc7c1 100644
Igor Gnatenko 082d5d
--- a/build/files.c
Igor Gnatenko 082d5d
+++ b/build/files.c
Igor Gnatenko 082d5d
@@ -2707,8 +2707,9 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
Igor Gnatenko 082d5d
 {
Igor Gnatenko 082d5d
     rpmfi fi;
Igor Gnatenko 082d5d
     ARGV_t files = NULL;
Igor Gnatenko 082d5d
-    Package dbg = NULL;
Igor Gnatenko 082d5d
-    char *path = NULL;
Igor Gnatenko 082d5d
+    ARGV_t dirs = NULL;
Igor Gnatenko 082d5d
+    int lastdiridx = -1, dirsadded;
Igor Gnatenko 082d5d
+    char *path = NULL, *p, *pmin;
Igor Gnatenko 082d5d
     size_t buildrootlen = strlen(buildroot);
Igor Gnatenko 082d5d
 
Igor Gnatenko 082d5d
     /* ignore noarch subpackages */
Igor Gnatenko 082d5d
@@ -2741,12 +2742,37 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
Igor Gnatenko 082d5d
 		argvAdd(&files, "%defattr(-,root,root)");
Igor Gnatenko 082d5d
 		argvAddDir(&files, DEBUG_LIB_DIR);
Igor Gnatenko 082d5d
 	    }
Igor Gnatenko 082d5d
+
Igor Gnatenko 082d5d
 	    /* Add the files main debug-info file */
Igor Gnatenko 082d5d
 	    argvAdd(&files, path + buildrootlen);
Igor Gnatenko 082d5d
+
Igor Gnatenko 082d5d
+	    /* Add the dir(s) */
Igor Gnatenko 082d5d
+	    dirsadded = 0;
Igor Gnatenko 082d5d
+	    pmin = path + buildrootlen + strlen(DEBUG_LIB_DIR);
Igor Gnatenko 082d5d
+	    while ((p = strrchr(path + buildrootlen, '/')) != NULL && p > pmin) {
Igor Gnatenko 082d5d
+		*p = 0;
Igor Gnatenko 082d5d
+		if (lastdiridx >= 0 && !strcmp(dirs[lastdiridx], path + buildrootlen))
Igor Gnatenko 082d5d
+		    break;		/* already added this one */
Igor Gnatenko 082d5d
+		argvAdd(&dirs, path + buildrootlen);
Igor Gnatenko 082d5d
+		dirsadded++;
Igor Gnatenko 082d5d
+	    }
Igor Gnatenko 082d5d
+	    if (dirsadded)
Igor Gnatenko 082d5d
+		lastdiridx = argvCount(dirs) - dirsadded;	/* remember longest dir */
Igor Gnatenko 082d5d
 	}
Igor Gnatenko 082d5d
 	path = _free(path);
Igor Gnatenko 082d5d
     }
Igor Gnatenko 082d5d
 
Igor Gnatenko 082d5d
+    /* add collected directories to file list */
Igor Gnatenko 082d5d
+    if (dirs) {
Igor Gnatenko 082d5d
+	int i;
Igor Gnatenko 082d5d
+	argvSort(dirs, NULL);
Igor Gnatenko 082d5d
+	for (i = 0; dirs[i]; i++) {
Igor Gnatenko 082d5d
+	    if (!i || strcmp(dirs[i], dirs[i - 1]) != 0)
Igor Gnatenko 082d5d
+		argvAddDir(&files, dirs[i]);
Igor Gnatenko 082d5d
+	}
Igor Gnatenko 082d5d
+	dirs = argvFree(dirs);
Igor Gnatenko 082d5d
+    }
Igor Gnatenko 082d5d
+
Igor Gnatenko 082d5d
     if (files) {
Igor Gnatenko 082d5d
 	/* we have collected some files. Now put them in a debuginfo
Igor Gnatenko 082d5d
          * package. If this is not the main package, clone the main
Igor Gnatenko 082d5d
-- 
Igor Gnatenko 082d5d
2.13.2
Igor Gnatenko 082d5d