Reset file actions between rpmtsRun() calls (RhBug:1076552)

- When the world changes underneath us (eg by %pretrans hackery)
  between test-transaction and actual transaction, in some cases
  the file action does not get recomputed if already set.
  Always reset file actions to FA_UNKNOWN before disposition
  calculations to ensure have a clean starting point.
This commit is contained in:
Panu Matilainen 2014-03-21 12:36:35 +02:00
parent e87df8ec8e
commit f311fb65ee
3 changed files with 14 additions and 2 deletions

View File

@ -18,7 +18,7 @@ rpmfs rpmfsNew(rpm_count_t fc, int initState)
rpmfs fs = xcalloc(1, sizeof(*fs));
fs->fc = fc;
fs->actions = xmalloc(fs->fc * sizeof(*fs->actions));
memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
rpmfsResetActions(fs);
if (initState) {
fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
@ -115,3 +115,10 @@ void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action)
fs->actions[ix] = action;
}
}
void rpmfsResetActions(rpmfs fs)
{
if (fs && fs->actions) {
memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
}
}

View File

@ -57,6 +57,9 @@ rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
RPM_GNUC_INTERNAL
void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
RPM_GNUC_INTERNAL
void rpmfsResetActions(rpmfs fs);
#ifdef __cplusplus
}
#endif

View File

@ -1319,12 +1319,14 @@ static int rpmtsPrepare(rpmts ts)
rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);
/* Skip netshared paths, not our i18n files, and excluded docs */
/* Reset actions, set skip for netshared paths and excluded files */
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
rpmfiles files = rpmteFiles(p);
if (rpmfilesFC(files) > 0) {
rpmfs fs = rpmteGetFileStates(p);
/* Ensure clean state, this could get called more than once. */
rpmfsResetActions(fs);
if (rpmteType(p) == TR_ADDED) {
skipInstallFiles(ts, files, fs);
} else {