From: ewt Date: Wed, 17 Feb 1999 04:32:55 +0000 (+0000) Subject: added checks for installation of old packages X-Git-Tag: rpm-4.4-release~3111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1959865f841ae4e408a8166592b58e2e3efd852;p=platform%2Fupstream%2Frpm.git added checks for installation of old packages CVS patchset: 2802 CVS date: 1999/02/17 04:32:55 --- diff --git a/CHANGES b/CHANGES index f2e02e1..a5e10e3 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ - fixed --noscript, --notriggers, --excludedocs, and a bunch of other install/remove flags - fixed noreplace handling + - complain about old packages being installed 2.5.x -> 2.90 - added --excludepath diff --git a/lib/problems.c b/lib/problems.c index 3225921..debd200 100644 --- a/lib/problems.c +++ b/lib/problems.c @@ -57,6 +57,12 @@ char * rpmProblemString(rpmProblem prob) { release, altName, altVersion, altRelease); break; + case RPMPROB_OLDPACKAGE: + sprintf(buf, _("package %s-%s-%s (which is newer then %s-%s-%s) is " + "already installed"), altName, altVersion, altRelease, + name, version, release); + break; + default: sprintf(buf, _("unknown error %d encountered while manipulating " "package %s-%s-%s"), prob.type, name, version, release); @@ -84,6 +90,8 @@ void rpmProblemSetFilter(rpmProblemSet ps, int flags) { flag = RPMPROB_FILTER_REPLACENEWFILES; break; case RPMPROB_FILE_CONFLICT: flag = RPMPROB_FILTER_REPLACEOLDFILES; break; + case RPMPROB_OLDPACKAGE: + flag = RPMPROB_FILTER_OLDPACKAGE; break; default: flag = 0; } diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 4b3e625..9b5d35c 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -382,6 +382,7 @@ typedef enum rpmProblemType_e { RPMPROB_BADARCH, RPMPROB_CONFLICT, RPMPROB_NEW_FILE_CONFLICT, RPMPROB_FILE_CONFLICT, + RPMPROB_OLDPACKAGE, } rpmProblemType; typedef struct rpmProblem_s { @@ -411,7 +412,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, #define RPMPROB_FILTER_FORCERELOCATE (1 << 3) #define RPMPROB_FILTER_REPLACENEWFILES (1 << 4) #define RPMPROB_FILTER_REPLACEOLDFILES (1 << 5) -#define RPMPROB_FILTER_UPGRADETOOLD (1 << 6) +#define RPMPROB_FILTER_OLDPACKAGE (1 << 6) /** messages.c **/ diff --git a/lib/transaction.c b/lib/transaction.c index f8c7db0..f284cc0 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -57,6 +57,8 @@ static int handleRmvdInstalledFiles(struct fileInfo * fi, rpmdb db, int sharedCount); void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, rpmProblemSet probs); +static int ensureOlder(rpmdb db, Header new, int dbOffset, rpmProblemSet probs, + const void * key); #define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b)))) @@ -68,7 +70,6 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, int i, j; struct availableList * al = &ts->addedPackages; int rc, ourrc = 0; - rpmProblem prob; struct availablePackage * alp; rpmProblemSet probs; dbiIndexSet dbi, * matches; @@ -101,11 +102,21 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, psAppend(probs, RPMPROB_BADOS, alp->key, alp->h, NULL, NULL); } + rc = rpmdbFindPackage(ts->db, alp->name, &dbi); + if (rc == 2) { + return -1; + } else if (!rc) { + for (i = 0; i < dbi.count; i++) + ensureOlder(ts->db, alp->h, dbi.recs[i].recOffset, + probs, alp->key); + + dbiFreeIndexRecord(dbi); + } + rc = findMatches(ts->db, alp->name, alp->version, alp->release, &dbi); if (rc == 2) { return -1; } else if (!rc) { - prob.key = alp->key; psAppend(probs, RPMPROB_PKG_INSTALLED, alp->key, alp->h, NULL, NULL); dbiFreeIndexRecord(dbi); @@ -949,3 +960,24 @@ void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, } } } + +static int ensureOlder(rpmdb db, Header new, int dbOffset, rpmProblemSet probs, + const void * key) { + Header old; + int result, rc = 0; + + old = rpmdbGetRecord(db, dbOffset); + if (old == NULL) return 1; + + result = rpmVersionCompare(old, new); + if (result <= 0) + rc = 0; + else if (result > 0) { + rc = 1; + psAppend(probs, RPMPROB_OLDPACKAGE, key, new, NULL, old); + } + + headerFree(old); + + return rc; +} diff --git a/rpm.c b/rpm.c index 32fed3b..b58f23a 100755 --- a/rpm.c +++ b/rpm.c @@ -1280,13 +1280,13 @@ int main(int argc, char ** argv) { probFilter |= RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | - RPMPROB_FILTER_UPGRADETOOLD; + RPMPROB_FILTER_OLDPACKAGE; } if (replaceFiles) probFilter |= RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES; if (badReloc) probFilter |= RPMPROB_FILTER_FORCERELOCATE; if (replacePackages) probFilter |= RPMPROB_FILTER_REPLACEPKG; - if (oldPackage) probFilter |= RPMPROB_FILTER_UPGRADETOOLD; + if (oldPackage) probFilter |= RPMPROB_FILTER_OLDPACKAGE; if (ignoreArch) probFilter |= RPMPROB_FILTER_IGNOREARCH; if (ignoreOs) probFilter |= RPMPROB_FILTER_IGNOREOS;