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 50a4ed783c
  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
This commit is contained in:
Panu Matilainen 2009-01-30 08:28:57 +02:00
parent 81afe5e6a2
commit 64335052e3
2 changed files with 14 additions and 15 deletions

View 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);
}
}

View 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);
}