public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: - never add identical NEVRA to transaction more than once (#467822)
@ 2026-11-23  9:25 Panu Matilainen
  0 siblings, 0 replies; only message in thread
From: Panu Matilainen @ 2026-11-23  9:25 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/rpm
Branch : pmatilai-v6
Commit : 13dcfbee0a44537898b78daced3c379d2f1f1b0f
Author : Panu Matilainen <pmatilai@fedoraproject.org>
Date   : 2008-10-22T07:05:48+00:00
Stats  : +89/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rpm/c/13dcfbee0a44537898b78daced3c379d2f1f1b0f?branch=pmatilai-v6

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

---
diff --git a/rpm-4.6.0-rc1-skip-equal-nevr.patch b/rpm-4.6.0-rc1-skip-equal-nevr.patch
new file mode 100644
index 0000000..cea8cee
--- /dev/null
+++ b/rpm-4.6.0-rc1-skip-equal-nevr.patch
@@ -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;
+ }

diff --git a/rpm.spec b/rpm.spec
index fc6cbe6..cb7c7ef 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -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)
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  9:25 [rpms/rpm] pmatilai-v6: - never add identical NEVRA to transaction more than once (#467822) Panu Matilainen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox