From 64335052e35836168f18e190da464b8c2abe0373 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 30 Jan 2009 08:28:57 +0200 Subject: [PATCH] Try to play nice with OpenPKG (rpm5.org) packages (rhbz#478907) - 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 | 10 ++-------- lib/package.c | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/legacy.c b/lib/legacy.c index b2fcc57..b5ecf70 100644 --- a/lib/legacy.c +++ b/lib/legacy.c @@ -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); } } diff --git a/lib/package.c b/lib/package.c index 15e9469..2d1f6ee 100644 --- a/lib/package.c +++ b/lib/package.c @@ -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); } -- 2.7.4