diff options
author | ewt <devnull@localhost> | 1999-02-17 04:32:55 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1999-02-17 04:32:55 +0000 |
commit | c1959865f841ae4e408a8166592b58e2e3efd852 (patch) | |
tree | 3982967b70207858b57a5fb31d996dd7295bfcbd | |
parent | 784a8eeb8ad9494a40d09ade64ef6372fb18dbaa (diff) | |
download | rpm-c1959865f841ae4e408a8166592b58e2e3efd852.tar.gz rpm-c1959865f841ae4e408a8166592b58e2e3efd852.tar.bz2 rpm-c1959865f841ae4e408a8166592b58e2e3efd852.zip |
added checks for installation of old packages
CVS patchset: 2802
CVS date: 1999/02/17 04:32:55
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | lib/problems.c | 8 | ||||
-rw-r--r-- | lib/rpmlib.h | 3 | ||||
-rw-r--r-- | lib/transaction.c | 36 | ||||
-rwxr-xr-x | rpm.c | 4 |
5 files changed, 47 insertions, 5 deletions
@@ -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 322592169..debd20066 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 4b3e62540..9b5d35c11 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 f8c7db00e..f284cc0a4 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; +} @@ -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; |