From 4da917bfef96aaaed02717a3a8952325086e7084 Mon Sep 17 00:00:00 2001 From: Paul Nasrat Date: Tue, 1 May 2007 05:55:14 +0100 Subject: [PATCH] Enable configurable preferable elf colour policy (#235757) Patch from: dwmw2 at redhat.com --- lib/rpmts.c | 6 ++++++ lib/rpmts.h | 9 +++++++++ lib/transaction.c | 16 +++++++++------- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/rpmts.c b/lib/rpmts.c index 26eb563..ef26613 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -1475,6 +1475,11 @@ uint_32 rpmtsSetColor(rpmts ts, uint_32 color) return ocolor; } +uint_32 rpmtsPrefColor(rpmts ts) +{ + return (ts != NULL ? ts->prefcolor : 0); +} + rpmop rpmtsOp(rpmts ts, rpmtsOpX opx) { rpmop op = NULL; @@ -1554,6 +1559,7 @@ rpmts rpmtsCreate(void) ts->delta = 5; ts->color = rpmExpandNumeric("%{?_transaction_color}"); + ts->prefcolor = rpmExpandNumeric("%{?_prefer_color}")?:2; ts->numRemovedPackages = 0; ts->allocedRemovedPackages = ts->delta; diff --git a/lib/rpmts.h b/lib/rpmts.h index cd924bd..1948c1e 100644 --- a/lib/rpmts.h +++ b/lib/rpmts.h @@ -309,6 +309,7 @@ struct rpmts_s { int_32 tid; /*!< Transaction id. */ uint_32 color; /*!< Transaction color bits. */ + uint_32 prefcolor; /*!< Preferred file color. */ rpmVSFlags vsflags; /*!< Signature/digest verification flags. */ @@ -983,6 +984,14 @@ uint_32 rpmtsColor(rpmts ts) /*@*/; /** + * Retrieve prefered file color + * @param ts transaction set + * @return color bits + */ +uint_32 rpmtsPrefColor(rpmts ts) + /*@*/; + +/** * Set color bits of transaction set. * @param ts transaction set * @param color new color bits diff --git a/lib/transaction.c b/lib/transaction.c index cac8e7f..9fa4f7f 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -122,6 +122,7 @@ static int handleInstInstalledFiles(const rpmts ts, /*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/ { uint_32 tscolor = rpmtsColor(ts); + uint_32 prefcolor = rpmtsPrefColor(ts); uint_32 otecolor, tecolor; uint_32 oFColor, FColor; const char * altNEVR = NULL; @@ -201,11 +202,11 @@ static int handleInstInstalledFiles(const rpmts ts, /* Resolve file conflicts to prefer Elf64 (if not forced). */ if (tscolor != 0 && FColor != 0 && FColor != oFColor) { - if (oFColor & 0x2) { + if (oFColor & prefcolor) { fi->actions[fileNum] = FA_SKIPCOLOR; rConflicts = 0; } else - if (FColor & 0x2) { + if (FColor & prefcolor) { fi->actions[fileNum] = FA_CREATE; rConflicts = 0; } @@ -460,6 +461,7 @@ static void handleOverlappedFiles(const rpmts ts, if (fi != NULL) while ((i = rpmfiNext(fi)) >= 0) { uint_32 tscolor = rpmtsColor(ts); + uint_32 prefcolor = rpmtsPrefColor(ts); uint_32 oFColor, FColor; struct fingerPrint_s * fiFps; int otherPkgNum, otherFileNum; @@ -572,19 +574,19 @@ assert(otherFi != NULL); rConflicts = reportConflicts; /* Resolve file conflicts to prefer Elf64 (if not forced) ... */ if (tscolor != 0) { - if (FColor & 0x2) { - /* ... last Elf64 file is installed ... */ + if (FColor & prefcolor) { + /* ... last file of preferred colour is installed ... */ if (!XFA_SKIPPING(fi->actions[i])) { /* XXX static helpers are order dependent. Ick. */ if (strcmp(fn, "/usr/sbin/libgcc_post_upgrade") && strcmp(fn, "/usr/sbin/glibc_post_upgrade")) - otherFi->actions[otherFileNum] = FA_SKIP; + otherFi->actions[otherFileNum] = FA_SKIPCOLOR; } fi->actions[i] = FA_CREATE; rConflicts = 0; } else - if (oFColor & 0x2) { - /* ... first Elf64 file is installed ... */ + if (oFColor & prefcolor) { + /* ... first file of preferred colour is installed ... */ if (XFA_SKIPPING(fi->actions[i])) otherFi->actions[otherFileNum] = FA_CREATE; fi->actions[i] = FA_SKIPCOLOR; -- 2.7.4