Blob Blame History Raw
From b598ce37d76bde5b8a6029008531aba6d2fbf594 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 12 Mar 2015 15:34:39 +0100
Subject: [PATCH] Skip directory if contains subdirectory that contains only
 skipped files.

Previously directory was skipped from installation if it contained only
skipped files. But it wasn't skipped if it contained some subdirectory.
Now if subdirectory contains also only skipped files then subdirectory
and also parent directory are skipped. It is achieved by solving
subdirectories at first and then solving parent directories.
(rhbz#1192625)
---
 lib/transaction.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/transaction.c b/lib/transaction.c
index 0f39732..af1deb8 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -851,7 +851,8 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
     }
 
     /* Skip (now empty) directories that had skipped files. */
-    for (j = 0; j < dc; j++) {
+    /* Iterate over dirs in reversed order to solve subdirs at first */
+    for (j = dc; j >= 0; j--) {
 	const char * dn, * bn;
 	size_t dnlen, bnlen;
 
@@ -892,6 +893,11 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
 		continue;
 	    rpmlog(RPMLOG_DEBUG, "excluding directory %s\n", dn);
 	    rpmfsSetAction(fs, i, FA_SKIPNSTATE);
+	    ix = rpmfiDX(fi);
+	    /* Decrease count of files for parent directory */
+	    drc[ix]--;
+	    /* Mark directory because something was removed from them */
+	    dff[ix] = 1;
 	    break;
 	}
     }
-- 
1.9.3