Try to play nice with OpenPKG (rpm5.org) packages (rhbz#478907)
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 30 Jan 2009 06:28:57 +0000 (08:28 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 30 Jan 2009 06:28:57 +0000 (08:28 +0200)
- rpm5.org writes populates lead with partially bogus data, but
  does have explicit RPMTAG_SOURCEPACKAGE for srpms, dont think of them
  as binaries
- switches around the lead check in 50a4ed783c300a92948f7933a3c726d4bd2d643d
  to look at source type explicitly and retrofit RPMTAG_SOURCEPACKAGE
  for srpms early, this lets binaries without RPMTAG_SOURCERPM
  (which is documented as "information only") and with explicit
  RPMTAG_SOURCEPACKAGE be identified correctly

lib/legacy.c
lib/package.c

index b2fcc57..b5ecf70 100644 (file)
@@ -224,14 +224,8 @@ static void legacyRetrofit(Header h)
      */
      compressFilelist(h);
 
-    /* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
-    if (headerIsSource(h)) {
-       uint32_t one = 1;
-
-       if (!headerIsEntry(h, RPMTAG_SOURCEPACKAGE))
-           headerPutUint32(h, RPMTAG_SOURCEPACKAGE, &one, 1);
-    } else {
-       /* Retrofit "Provide: name = EVR" for binary packages. */
+    /* Retrofit "Provide: name = EVR" for binary packages. */
+    if (!headerIsSource(h)) {
        providePackageNVR(h);
     }
 }
index 15e9469..2d1f6ee 100644 (file)
@@ -835,20 +835,25 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
 
 exit:
     if (rc != RPMRC_FAIL && h != NULL && hdrp != NULL) {
+       /* Retrofit RPMTAG_SOURCEPACKAGE to srpms for compatibility */
+       if (leadtype == RPMLEAD_SOURCE && headerIsSource(h)) {
+           if (!headerIsEntry(h, RPMTAG_SOURCEPACKAGE)) {
+               uint32_t one = 1;
+               headerPutUint32(h, RPMTAG_SOURCEPACKAGE, &one, 1);
+           }
+       }
        /*
-        * Some binary packages in the wild don't have RPMTAG_SOURCERPM,
-        * confusing us greatly. Ensure RPMTAG_SOURCERPM is always set
-        * on binary packages.
+        * Try to make sure binary rpms have RPMTAG_SOURCERPM set as that's
+        * what we use for differentiating binary vs source elsewhere.
         */
-       if (leadtype == RPMLEAD_BINARY && headerIsSource(h)) {
-           headerPutString(h, RPMTAG_SOURCERPM, "");
+       if (!headerIsEntry(h, RPMTAG_SOURCEPACKAGE) && headerIsSource(h)) {
+           headerPutString(h, RPMTAG_SOURCERPM, "(none)");
        }
        /* 
          * Convert legacy headers on the fly. Not having "new" style compressed
          * filenames is close enough estimate for legacy indication... 
-         * Source rpms are retrofitted for the silly RPMTAG_SOURCEPACKAGE tag.
          */
-       if (!headerIsEntry(h, RPMTAG_DIRNAMES) || headerIsSource(h)) {
+       if (!headerIsEntry(h, RPMTAG_DIRNAMES)) {
            headerConvert(h, HEADERCONV_RETROFIT_V3);
        }