Use rpmfiConfigConflictIndex() for modified config testing on erase too
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 22 Aug 2012 08:56:12 +0000 (11:56 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 22 Aug 2012 08:56:12 +0000 (11:56 +0300)
- Besides eliminating another copy-paste variant of the config file
  digest calculation and comparison, this fixes the case modified
  %config symlink gets silently erased. Unlike a regular config file,
  a symlink does not contain a whole lot of carefully tuned data, but
  if it's marked %config I think we should honor the %config file rules.
- Adjust test-suite expectations to match the new behavior.

lib/transaction.c
tests/rpmconfig2.at

index 80e7e3d..c0653ba 100644 (file)
@@ -544,21 +544,9 @@ assert(otherFi != NULL);
                break;
                
            /* Pre-existing modified config files need to be saved. */
-           if (S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG)) {
-               int algo = 0;
-               size_t diglen = 0;
-               const unsigned char *digest;
-               if ((digest = rpmfiFDigestIndex(fi, i, &algo, &diglen))) {
-                   unsigned char fdigest[diglen];
-                   char *fn = rpmfiFNIndex(fi, i);
-                   int modified = (!rpmDoDigest(algo, fn, 0, fdigest, NULL) &&
-                                   memcmp(digest, fdigest, diglen));
-                   free(fn);
-                   if (modified) {
-                       rpmfsSetAction(fs, i, FA_BACKUP);
-                       break;
-                   }
-               }
+           if (rpmfiConfigConflictIndex(fi, i)) {
+               rpmfsSetAction(fs, i, FA_BACKUP);
+               break;
            }
        
            /* Otherwise, we can just erase. */
index 373bdf8..1b9bb64 100644 (file)
@@ -92,10 +92,8 @@ test ! -L "${cf}"
 AT_CLEANUP
 
 # Erase modified config link
-# Broken, no backup taken
 AT_SETUP([erase changed config link])
 AT_KEYWORDS([install])
-AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT