From 25e68ab6e28ba3a167ea77924c8c752564d79fab Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 29 Aug 2011 14:04:28 +0300 Subject: [PATCH] Use correct file state for colored file replacements - 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 | 7 ++++--- lib/rpmfs.c | 4 +++- lib/rpmfs.h | 4 +++- lib/transaction.c | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/psm.c b/lib/psm.c index 34809d6..1bbf60e 100644 --- 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; diff --git a/lib/rpmfs.c b/lib/rpmfs.c index 00f55d0..29b5377 100644 --- a/lib/rpmfs.c +++ b/lib/rpmfs.c @@ -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; diff --git a/lib/rpmfs.h b/lib/rpmfs.h index 129bc65..ef478ad 100644 --- a/lib/rpmfs.h +++ b/lib/rpmfs.h @@ -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); diff --git a/lib/transaction.c b/lib/transaction.c index 6090f2c..f2f7e47 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -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)); } -- 2.7.4