Use correct file state for colored file replacements
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 29 Aug 2011 11:04:28 +0000 (14:04 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 29 Aug 2011 11:04:28 +0000 (14:04 +0300)
- On colored file conflict resolution, the non-preferred colored
  file state would depend on installation order: if non-preferred
  arch is installed first, and the preferred arch in another
  transaction, the non-preferred color would get marked "replaced"
  indicating a forced install when none was used. This fixes
  the file state in such cases to "wrong color" to be consistent
  of the other installation scenarios.

lib/psm.c
lib/rpmfs.c
lib/rpmfs.h
lib/transaction.c

index 34809d6..1bbf60e 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -118,7 +118,8 @@ static void rpmInstallLoadMacros(Header h)
 }
 
 /**
- * Mark files in database shared with this package as "replaced".
+ * Adjust file states in database for files shared with this package:
+ * currently either "replaced" or "wrong color".
  * @param psm          package state machine data
  * @return             0 always
  */
@@ -177,8 +178,8 @@ static rpmRC markReplacedFiles(const rpmpsm psm)
            assert(ix != -1);
 
            char *state = rpmtdGetChar(&secStates);
-           if (state && *state != RPMFILE_STATE_REPLACED) {
-               *state = RPMFILE_STATE_REPLACED;
+           if (state && *state != sfi->rstate) {
+               *state = sfi->rstate;
                if (modified == 0) {
                    /* Modified header will be rewritten. */
                    modified = 1;
index 00f55d0..29b5377 100644 (file)
@@ -49,7 +49,8 @@ rpm_count_t rpmfsFC(rpmfs fs)
     return (fs != NULL) ? fs->fc : 0;
 }
 
-void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum)
+void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, char rstate,
+                       int otherPkg, int otherFileNum)
 {
     if (!fs->replaced) {
        fs->replaced = xcalloc(3, sizeof(*fs->replaced));
@@ -60,6 +61,7 @@ void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum)
        fs->replaced = xrealloc(fs->replaced, fs->allocatedReplaced*sizeof(*fs->replaced));
     }
     fs->replaced[fs->numReplaced].pkgFileNum = pkgFileNum;
+    fs->replaced[fs->numReplaced].rstate = rstate;
     fs->replaced[fs->numReplaced].otherPkg = otherPkg;
     fs->replaced[fs->numReplaced].otherFileNum = otherFileNum;
 
index 129bc65..ef478ad 100644 (file)
@@ -16,6 +16,7 @@ struct sharedFileInfo_s {
     int pkgFileNum;
     int otherPkg;
     int otherFileNum;
+    char rstate;
 };
 
 #ifdef __cplusplus
@@ -32,7 +33,8 @@ RPM_GNUC_INTERNAL
 rpm_count_t rpmfsFC(rpmfs fs);
 
 RPM_GNUC_INTERNAL
-void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum);
+void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, char rstate,
+                       int otherPkg, int otherFileNum);
 
 RPM_GNUC_INTERNAL
 sharedFileInfo rpmfsGetReplaced(rpmfs fs);
index 6090f2c..f2f7e47 100644 (file)
@@ -341,6 +341,7 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfi fi,
        rpm_color_t FColor = rpmfiFColor(fi) & tscolor;
        rpm_color_t oFColor = rpmfiFColor(otherFi) & tscolor;
        int rConflicts;
+       char rState = RPMFILE_STATE_REPLACED;
 
        rConflicts = !(beingRemoved || (rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEOLDFILES));
        /* Resolve file conflicts to prefer Elf64 (if not forced). */
@@ -351,6 +352,7 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfi fi,
            } else if (FColor & prefcolor) {
                rpmfsSetAction(fs, fx, FA_CREATE);
                rConflicts = 0;
+               rState = RPMFILE_STATE_WRONGCOLOR;
            }
        }
 
@@ -364,7 +366,7 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfi fi,
        /* Save file identifier to mark as state REPLACED. */
        if ( !(isCfgFile || XFA_SKIPPING(rpmfsGetAction(fs, fx))) ) {
            if (!beingRemoved)
-               rpmfsAddReplaced(rpmteGetFileStates(p), rpmfiFX(fi),
+               rpmfsAddReplaced(rpmteGetFileStates(p), rpmfiFX(fi), rState,
                                 headerGetInstance(otherHeader),
                                 rpmfiFX(otherFi));
        }