From e8a6c87d48c1ac135f75bf8a67e0ba9d6fc74a66 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 21 Aug 2012 09:08:05 +0300 Subject: [PATCH] Fix %config backup on erasure regression - After commit 1845c1d711b88723e596c88e8a7730a360029089 erasure no longer calls fsmCommit(), missing the backup step entirely. Simply split the backup code to a function of its own and call as needed. The details look somewhat fishy but what in fsm doesn't... --- lib/fsm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/fsm.c b/lib/fsm.c index 0cd7f35..7a1628e 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -1521,12 +1521,13 @@ static int fsmVerify(FSM_t fsm) (_x)[sizeof("/dev/log")-1] == ';')) -static int fsmCommit(FSM_t fsm) + +/* Rename pre-existing modified or unmanaged file. */ +static int fsmBackup(FSM_t fsm) { int rc = 0; struct stat * st = &fsm->sb; - /* Rename pre-existing modified or unmanaged file. */ if (fsm->osuffix && fsm->diskchecked && (fsm->exists || (fsm->goal == FSM_PKGINSTALL && S_ISREG(st->st_mode)))) { @@ -1540,6 +1541,15 @@ static int fsmCommit(FSM_t fsm) free(path); free(opath); } + return rc; +} + +static int fsmCommit(FSM_t fsm) +{ + int rc = 0; + struct stat * st = &fsm->sb; + + rc = fsmBackup(fsm); /* XXX Special case /dev/log, which shouldn't be packaged anyways */ if (!S_ISSOCK(st->st_mode) && !IS_DEV_LOG(fsm->path)) { @@ -1826,6 +1836,9 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi, rc = fsmInit(fsm); + if (!fsm->postpone) + rc = fsmBackup(fsm); + /* Remove erased files. */ if (!fsm->postpone && fsm->action == FA_ERASE) { int missingok = (fsm->fflags & (RPMFILE_MISSINGOK | RPMFILE_GHOST)); -- 2.7.4