Axe the if-what jungle in rpmfiDecideFateIndex()
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 23 Aug 2012 11:31:33 +0000 (14:31 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 23 Aug 2012 11:37:52 +0000 (14:37 +0300)
- Unless the file does not exist on disk, we cannot determine the
  correct action for config files and symlinks before we actually
  check them. Those are also the only types that *can* result in
  FA_ALTNAME/FA_SAVE action, anything else we can just create.
  Besides making the logic a whole lot easier to follow, it also
  fixes our remaining test-case failures. Who would've thought?
- Might be worth noting that this requires the pile of fsm fixes
  from previous commits to work.

lib/rpmfi.c
tests/rpmconfig3.at

index afc115f..b81554a 100644 (file)
@@ -612,22 +612,6 @@ rpmFileAction rpmfiDecideFateIndex(rpmfi ofi, int oix, rpmfi nfi, int nix,
     newWhat = rpmfiWhatis(rpmfiFModeIndex(nfi, nix));
 
     /*
-     * RPM >= 2.3.10 shouldn't create config directories -- we'll ignore
-     * them in older packages as well.
-     */
-    if (newWhat == XDIR)
-       return FA_CREATE;
-
-    if (diskWhat != newWhat && dbWhat != REG && dbWhat != LINK)
-       return save;
-    else if (newWhat != dbWhat && diskWhat != dbWhat)
-       return save;
-    else if (dbWhat != newWhat)
-       return FA_CREATE;
-    else if (dbWhat != LINK && dbWhat != REG)
-       return FA_CREATE;
-
-    /*
      * This order matters - we'd prefer to CREATE the file if at all
      * possible in case something else (like the timestamp) has changed.
      */
@@ -690,6 +674,9 @@ rpmFileAction rpmfiDecideFateIndex(rpmfi ofi, int oix, rpmfi nfi, int nix,
            return FA_SKIP;     /* identical file, don't bother. */
 
        /* ...but otherwise a backup will be needed */
+    } else {
+       /* Other file types cannot be %config, go ahead and create it */
+       return FA_CREATE;
     }
 
     /*
index 6191ef3..5a32c0c 100644 (file)
@@ -163,10 +163,8 @@ foo
 AT_CLEANUP
 
 # Modified config changes to config symlink
-# Broken, no backup taken
 AT_SETUP([upgrade modified config to config link])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
@@ -205,9 +203,7 @@ otherstuff
 AT_CLEANUP
 
 # Modified config link changes to config file
-# Broken, no backup taken
 AT_SETUP([upgrade modified config link to config])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_KEYWORDS([install])
 AT_CHECK([
 RPMDB_CLEAR
@@ -279,10 +275,8 @@ test -d "${cf}"
 AT_CLEANUP
 
 # Modified config changes to directory
-# Broken, no backup taken
 AT_SETUP([upgrade modified config to directory])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT