Lubos Kardos 4b03dd
From b598ce37d76bde5b8a6029008531aba6d2fbf594 Mon Sep 17 00:00:00 2001
Lubos Kardos 4b03dd
From: Lubos Kardos <lkardos@redhat.com>
Lubos Kardos 4b03dd
Date: Thu, 12 Mar 2015 15:34:39 +0100
Lubos Kardos 4b03dd
Subject: [PATCH] Skip directory if contains subdirectory that contains only
Lubos Kardos 4b03dd
 skipped files.
Lubos Kardos 4b03dd
Lubos Kardos 4b03dd
Previously directory was skipped from installation if it contained only
Lubos Kardos 4b03dd
skipped files. But it wasn't skipped if it contained some subdirectory.
Lubos Kardos 4b03dd
Now if subdirectory contains also only skipped files then subdirectory
Lubos Kardos 4b03dd
and also parent directory are skipped. It is achieved by solving
Lubos Kardos 4b03dd
subdirectories at first and then solving parent directories.
Lubos Kardos 4b03dd
(rhbz#1192625)
Lubos Kardos 4b03dd
---
Lubos Kardos 4b03dd
 lib/transaction.c | 8 +++++++-
Lubos Kardos 4b03dd
 1 file changed, 7 insertions(+), 1 deletion(-)
Lubos Kardos 4b03dd
Lubos Kardos 4b03dd
diff --git a/lib/transaction.c b/lib/transaction.c
Lubos Kardos 4b03dd
index 0f39732..af1deb8 100644
Lubos Kardos 4b03dd
--- a/lib/transaction.c
Lubos Kardos 4b03dd
+++ b/lib/transaction.c
Lubos Kardos 4b03dd
@@ -851,7 +851,8 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
Lubos Kardos 4b03dd
     }
Lubos Kardos 4b03dd
 
Lubos Kardos 4b03dd
     /* Skip (now empty) directories that had skipped files. */
Lubos Kardos 4b03dd
-    for (j = 0; j < dc; j++) {
Lubos Kardos 4b03dd
+    /* Iterate over dirs in reversed order to solve subdirs at first */
Lubos Kardos 4b03dd
+    for (j = dc; j >= 0; j--) {
Lubos Kardos 4b03dd
 	const char * dn, * bn;
Lubos Kardos 4b03dd
 	size_t dnlen, bnlen;
Lubos Kardos 4b03dd
 
Lubos Kardos 4b03dd
@@ -892,6 +893,11 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
Lubos Kardos 4b03dd
 		continue;
Lubos Kardos 4b03dd
 	    rpmlog(RPMLOG_DEBUG, "excluding directory %s\n", dn);
Lubos Kardos 4b03dd
 	    rpmfsSetAction(fs, i, FA_SKIPNSTATE);
Lubos Kardos 4b03dd
+	    ix = rpmfiDX(fi);
Lubos Kardos 4b03dd
+	    /* Decrease count of files for parent directory */
Lubos Kardos 4b03dd
+	    drc[ix]--;
Lubos Kardos 4b03dd
+	    /* Mark directory because something was removed from them */
Lubos Kardos 4b03dd
+	    dff[ix] = 1;
Lubos Kardos 4b03dd
 	    break;
Lubos Kardos 4b03dd
 	}
Lubos Kardos 4b03dd
     }
Lubos Kardos 4b03dd
-- 
Lubos Kardos 4b03dd
1.9.3
Lubos Kardos 4b03dd