Fix %config backup on erasure regression
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 21 Aug 2012 06:08:05 +0000 (09:08 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 21 Aug 2012 06:08:05 +0000 (09:08 +0300)
- 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

index 0cd7f35..7a1628e 100644 (file)
--- 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));