teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.11.x-reset-fileactions.patch

Panu Matilainen 600ff2
diff --git a/lib/rpmfs.c b/lib/rpmfs.c
Panu Matilainen 600ff2
index 764618d..916f6eb 100644
Panu Matilainen 600ff2
--- a/lib/rpmfs.c
Panu Matilainen 600ff2
+++ b/lib/rpmfs.c
Panu Matilainen 600ff2
@@ -18,7 +18,7 @@ rpmfs rpmfsNew(rpm_count_t fc, int initState)
Panu Matilainen 600ff2
     rpmfs fs = xcalloc(1, sizeof(*fs));
Panu Matilainen 600ff2
     fs->fc = fc;
Panu Matilainen 600ff2
     fs->actions = xmalloc(fs->fc * sizeof(*fs->actions));
Panu Matilainen 600ff2
-    memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
Panu Matilainen 600ff2
+    rpmfsResetActions(fs);
Panu Matilainen 600ff2
     if (initState) {
Panu Matilainen 600ff2
 	fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
Panu Matilainen 600ff2
 	memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
Panu Matilainen 600ff2
@@ -115,3 +115,10 @@ void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action)
Panu Matilainen 600ff2
 	fs->actions[ix] = action;
Panu Matilainen 600ff2
     }
Panu Matilainen 600ff2
 }
Panu Matilainen 600ff2
+
Panu Matilainen 600ff2
+void rpmfsResetActions(rpmfs fs)
Panu Matilainen 600ff2
+{
Panu Matilainen 600ff2
+    if (fs && fs->actions) {
Panu Matilainen 600ff2
+	memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
Panu Matilainen 600ff2
+    }
Panu Matilainen 600ff2
+}
Panu Matilainen 600ff2
diff --git a/lib/rpmfs.h b/lib/rpmfs.h
Panu Matilainen 600ff2
index 5f74753..83f99d1 100644
Panu Matilainen 600ff2
--- a/lib/rpmfs.h
Panu Matilainen 600ff2
+++ b/lib/rpmfs.h
Panu Matilainen 600ff2
@@ -57,6 +57,9 @@ rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
Panu Matilainen 600ff2
 RPM_GNUC_INTERNAL
Panu Matilainen 600ff2
 void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
Panu Matilainen 600ff2
 
Panu Matilainen 600ff2
+RPM_GNUC_INTERNAL
Panu Matilainen 600ff2
+void rpmfsResetActions(rpmfs fs);
Panu Matilainen 600ff2
+
Panu Matilainen 600ff2
 #ifdef __cplusplus
Panu Matilainen 600ff2
 }
Panu Matilainen 600ff2
 #endif
Panu Matilainen 600ff2
diff --git a/lib/transaction.c b/lib/transaction.c
Panu Matilainen 600ff2
index 02badc6..09c199a 100644
Panu Matilainen 600ff2
--- a/lib/transaction.c
Panu Matilainen 600ff2
+++ b/lib/transaction.c
Panu Matilainen 600ff2
@@ -1323,11 +1323,14 @@ static int rpmtsPrepare(rpmts ts)
Panu Matilainen 600ff2
 
Panu Matilainen 600ff2
     rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);
Panu Matilainen 600ff2
 
Panu Matilainen 600ff2
-    /* Skip netshared paths, not our i18n files, and excluded docs */
Panu Matilainen 600ff2
+    /* Reset actions, set skip for netshared paths and excluded files */
Panu Matilainen 600ff2
     pi = rpmtsiInit(ts);
Panu Matilainen 600ff2
     while ((p = rpmtsiNext(pi, 0)) != NULL) {
Panu Matilainen 600ff2
 	if (rpmfiFC(rpmteFI(p)) == 0)
Panu Matilainen 600ff2
 	    continue;
Panu Matilainen 600ff2
+	/* Ensure clean state, this could get called more than once. */
Panu Matilainen 600ff2
+	rpmfs fs = rpmteGetFileStates(p);
Panu Matilainen 600ff2
+	rpmfsResetActions(fs);
Panu Matilainen 600ff2
 	if (rpmteType(p) == TR_ADDED) {
Panu Matilainen 600ff2
 	    skipInstallFiles(ts, p);
Panu Matilainen 600ff2
 	} else {