[Rpm-maint] [Suse patch] Checking for identical packages on install/upgrade

Panu Matilainen pmatilai at redhat.com
Tue May 29 07:29:45 UTC 2007


For full background see 
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=104066. And yes I do 
think it's a bug that we should fix.

What JBJ does here is checks HDRID for identifying identical packages if 
present, version comparison if not. But I don't think it's actually 
identicality of headers (or not) we're really interested in here but 
upgradability. It's trivial to produce packages with different HDRID 
but same NEVRA (just rebuild the package and there you have it), I don't 
think it makes much sense to allow to packages with same NEVRA in the 
transaction, ever.

I'd rather just use rpmdsCompare() for the check rather than add yet 
another codepath for NEVRA comparison within rpm like the included patch 
does. Optionally we could check for the HDRID as well (identical packages 
are never wanted in ts) but dunno if it's worth the couple of more lines 
because most of the time we'd be doing the version comparison anyway.

 	- Panu -

---

Also compare the name and not only the version when checking if
two packages are the same. rh#104066

--- ./lib/depends.c.orig	2005-12-14 19:51:34.000000000 +0000
+++ ./lib/depends.c	2006-01-27 21:05:13.000000000 +0000
@@ -124,6 +124,24 @@ static int removePackage(rpmts ts, Heade
      return 0;
  }

+static int rpmNameVersionCompare(Header first, Header second)
+{
+    const char * one, * two;
+    int rc;
+
+    rc = headerGetEntry(first, RPMTAG_NAME, NULL, (void **) &one, NULL);
+    rc = headerGetEntry(second, RPMTAG_NAME, NULL, (void **) &two, NULL);
+    rc = strcmp(one, two);
+    if (rc)
+	return rc;
+    rc = headerGetEntry(first, RPMTAG_ARCH, NULL, (void **) &one, NULL);
+    rc = headerGetEntry(second, RPMTAG_ARCH, NULL, (void **) &two, NULL);
+    rc = strcmp(one, two);
+    if (rc)
+	return rc;
+    return rpmVersionCompare(first, second);
+}
+
  int rpmtsAddInstallElement(rpmts ts, Header h,
  			fnpyKey key, int upgrade, rpmRelocation * relocs)
  {
@@ -303,7 +322,7 @@ addheader:
  	    continue;

  	/* Skip packages that contain identical NEVR. */
-	if (rpmVersionCompare(h, oh) == 0)
+	if (rpmNameVersionCompare(h, oh) == 0)
  	    continue;

  	xx = removePackage(ts, oh, rpmdbGetIteratorOffset(mi), pkgKey);
@@ -354,11 +373,9 @@ addheader:
  	     * If no obsoletes version info is available, match all names.
  	     */
  	    if (rpmdsEVR(obsoletes) == NULL
-	     || rpmdsAnyMatchesDep(oh, obsoletes, _rpmds_nopromote)) {
+	     || rpmdsNVRMatchesDep(oh, obsoletes, _rpmds_nopromote)) {
  		const char * ohNEVRA = hGetNEVRA(oh, NULL);
-#ifdef	DYING	/* XXX see http://bugzilla.redhat.com #134497 */
-		if (rpmVersionCompare(h, oh))
-#endif
+		if (rpmNameVersionCompare(h, oh))
  		    xx = removePackage(ts, oh, rpmdbGetIteratorOffset(mi), pkgKey);
  /*@-nullptrarith@*/
  		rpmMessage(RPMMESS_DEBUG, _("  Obsoletes: %s\t\terases %s\n"),



More information about the Rpm-maint mailing list