Validate rpmlib dependencies on src.rpm install (RhBug:490613)
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 16 Jun 2009 14:23:17 +0000 (17:23 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 16 Jun 2009 14:23:17 +0000 (17:23 +0300)
- other src.rpm dependencies are only relevant for building, but rpmlib
  features can affect src.rpm "install" too, such as unsupported file
  digests, payload compressors etc

lib/psm.c

index d67f223..e552c6c 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -214,6 +214,31 @@ static rpmRC markReplacedFiles(const rpmpsm psm)
     return RPMRC_OK;
 }
 
+static int rpmlibDeps(Header h)
+{
+    rpmds req = rpmdsInit(rpmdsNew(h, RPMTAG_REQUIRENAME, 0));
+    rpmds rpmlib = NULL;
+    rpmdsRpmlib(&rpmlib, NULL);
+    int rc = 1;
+    char *nvr = NULL;
+    while (rpmdsNext(req) >= 0) {
+       if (!(rpmdsFlags(req) & RPMSENSE_RPMLIB))
+           continue;
+       if (rpmdsSearch(rpmlib, req) < 0) {
+           if (!nvr) {
+               nvr = headerGetNEVRA(h, NULL);
+               rpmlog(RPMLOG_ERR, _("Missing rpmlib features for %s:\n"), nvr);
+           }
+           rpmlog(RPMLOG_ERR, "\t%s\n", rpmdsDNEVR(req)+2);
+           rc = 0;
+       }
+    }
+    rpmdsFree(req);
+    rpmdsFree(rpmlib);
+    free(nvr);
+    return rc;
+}
+
 rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
                char ** specFilePtr, char ** cookie)
 {
@@ -248,6 +273,10 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
        goto exit;
     }
 
+    /* src.rpm install can require specific rpmlib features, check them */
+    if (!rpmlibDeps(h))
+       goto exit;
+
     if (headerGet(h, RPMTAG_BASENAMES, &filenames, HEADERGET_ALLOC)) {
        struct rpmtd_s td;
        const char *str, *_cookie = NULL;