Use fsm->action to decide whether we need a backup or not.
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 23 Aug 2012 10:11:06 +0000 (13:11 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 23 Aug 2012 10:20:57 +0000 (13:20 +0300)
- We already have a carefully precalculated action decided for these
  things, use that instead of bunch of arbitrary (except for osuffix)
  conditions depending on several nasty hacks and hidden assumptions.
  Doing so fixes stuff, who would've thought of that?
- Adjust test-suite expectations

lib/fsm.c
tests/rpmconfig2.at

index f66e94c..163d469 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1526,13 +1526,9 @@ static int fsmVerify(FSM_t fsm)
 static int fsmBackup(FSM_t fsm)
 {
     int rc = 0;
-    struct stat * st = &fsm->sb;
 
-    if (fsm->osuffix && fsm->diskchecked &&
-        (fsm->exists || (fsm->goal == FSM_PKGINSTALL && S_ISREG(st->st_mode))))
-    {
-       int isDir = S_ISDIR(st->st_mode);
-        char * opath = fsmFsPath(fsm, isDir, NULL);
+    if (fsm->action == FA_SAVE || fsm->action == FA_BACKUP) {
+        char * opath = fsmFsPath(fsm, S_ISDIR(fsm->sb.st_mode), NULL);
         char * path = fsmFsPath(fsm, 0, fsm->osuffix);
         rc = fsmRename(opath, path, fsm->mapFlags);
         if (!rc) {
index 1b9bb64..04053a1 100644 (file)
@@ -3,10 +3,8 @@
 AT_BANNER([RPM config symlink behavior])
 
 # Install over existing config file
-# Broken, no backup taken
 AT_SETUP([install config on existiting symlink])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
@@ -220,10 +218,8 @@ AT_CLEANUP
 
 # ------------------------------
 # Upgrade package with locally modified config link, changed in pkg
-# Broken, no backup taken
 AT_SETUP([upgrade changing, modified config link 1])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
@@ -588,10 +584,8 @@ AT_CLEANUP
 
 # ------------------------------
 # Upgrade package with locally modified config file, changed in pkg
-# Broken, no backup taken
 AT_SETUP([upgrade changing, modified shared config link 1])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT