- never add identical NEVRA to transaction more than once (#467822)

This commit is contained in:
Panu Matilainen 2008-10-22 07:05:48 +00:00
parent 57f2a13d99
commit 13dcfbee0a
2 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,83 @@
diff --git a/lib/depends.c b/lib/depends.c
index 58aff31..810e909 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -118,7 +118,7 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
struct rpmtd_s td;
const char * arch = NULL;
const char * os = NULL;
- rpmds oldChk, newChk;
+ rpmds oldChk = NULL, newChk = NULL, sameChk = NULL;
rpmds obsoletes;
rpmalKey pkgKey; /* addedPackages key */
int xx;
@@ -151,10 +151,13 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
}
oldChk = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_LESS));
- newChk = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_EQUAL|RPMSENSE_GREATER));
+ newChk = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_GREATER));
+ sameChk = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_EQUAL));
/* XXX can't use rpmtsiNext() filter or oc will have wrong value. */
for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) {
rpmds this;
+ const char *pkgNEVR, *addNEVR;
+ int skip = 0;
/* XXX Only added packages need be checked for dupes. */
if (rpmteType(p) == TR_REMOVED)
@@ -181,13 +184,20 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
continue; /* XXX can't happen */
/*
+ * Always skip identical NEVR.
* On upgrade, if newer NEVR was previously added,
* then skip adding older.
*/
- rc = rpmdsCompare(newChk, this);
- if (upgrade && rc != 0) {
- const char * pkgNEVR = rpmdsDNEVR(this);
- const char * addNEVR = rpmdsDNEVR(oldChk);
+ if (rpmdsCompare(sameChk, this)) {
+ skip = 1;
+ addNEVR = rpmdsDNEVR(sameChk);
+ } else if (upgrade && rpmdsCompare(newChk, this)) {
+ skip = 1;
+ addNEVR = rpmdsDNEVR(newChk);
+ }
+
+ if (skip) {
+ pkgNEVR = rpmdsDNEVR(this);
if (rpmIsVerbose())
rpmlog(RPMLOG_WARNING,
_("package %s was already added, skipping %s\n"),
@@ -203,8 +213,8 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
*/
rc = rpmdsCompare(oldChk, this);
if (upgrade && rc != 0) {
- const char * pkgNEVR = rpmdsDNEVR(this);
- const char * addNEVR = rpmdsDNEVR(newChk);
+ pkgNEVR = rpmdsDNEVR(this);
+ addNEVR = rpmdsDNEVR(newChk);
if (rpmIsVerbose())
rpmlog(RPMLOG_WARNING,
_("package %s was already added, replacing with %s\n"),
@@ -216,8 +226,6 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
}
}
pi = rpmtsiFree(pi);
- oldChk = rpmdsFree(oldChk);
- newChk = rpmdsFree(newChk);
/* If newer NEVR was already added, exit now. */
if (ec)
@@ -353,6 +361,9 @@ addheader:
ec = 0;
exit:
+ oldChk = rpmdsFree(oldChk);
+ newChk = rpmdsFree(newChk);
+ sameChk = rpmdsFree(sameChk);
pi = rpmtsiFree(pi);
return ec;
}

View File

@ -18,7 +18,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: 0.%{snapver}.2
Release: 0.%{snapver}.3
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
@ -34,6 +34,7 @@ Patch100: rpm-4.6.x-no-pkgconfig-reqs.patch
# Patches already in upstream
Patch200: rpm-4.6.0-rc1-permit-tab.patch
Patch201: rpm-4.6.0-rc1-skip-equal-nevr.patch
# These are not yet upstream
Patch300: rpm-4.5.90-posttrans.patch
@ -166,6 +167,7 @@ that will manipulate RPM packages and databases.
%patch100 -p1 -b .pkgconfig-deps
%patch200 -p1 -b .permit-tab
%patch201 -p1 -b .skip-equal-nevr
# needs a bit of upstream love first...
#%patch300 -p1 -b .posttrans
@ -357,6 +359,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Wed Oct 22 2008 Panu Matilainen <pmatilai@redhat.com>
- never add identical NEVRA to transaction more than once (#467822)
* Sun Oct 19 2008 Panu Matilainen <pmatilai@redhat.com>
- permit tab as macro argument separator (#467567)