Add support for querying source rpm from spec too
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 12 Oct 2010 11:41:35 +0000 (14:41 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 12 Oct 2010 11:41:35 +0000 (14:41 +0300)
- Handle source rpm query as a new query source type RPMQV_SPECSRPM,
  rename the binary query to RPMQV_SPECRPMS, with RPMQV_SPECFILE
  as a backwards compatibility alias to RPMQV_SPECRPMS.

build/spec.c
lib/query.c
lib/rpmcli.h

index 31163e9..d43a0f1 100644 (file)
@@ -446,8 +446,12 @@ int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg)
     }
 
     res = 0;
-    for (Package pkg = spec->packages; pkg != NULL; pkg = pkg->next)
-       xx = qva->qva_showPackage(qva, ts, pkg->header);
+    if (qva->qva_source == RPMQV_SPECRPMS) {
+       for (Package pkg = spec->packages; pkg != NULL; pkg = pkg->next)
+           xx = qva->qva_showPackage(qva, ts, pkg->header);
+    } else {
+       xx = qva->qva_showPackage(qva, ts, spec->sourceHeader);
+    }
 
 exit:
     spec = rpmSpecFree(spec);
index 5ada52c..d4d712d 100644 (file)
@@ -545,7 +545,8 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv)
        gi = rpmgiFree(gi);
        break;
     }
-    case RPMQV_SPECFILE:
+    case RPMQV_SPECRPMS:
+    case RPMQV_SPECSRPM:
        for (ARGV_const_t arg = argv; arg && *arg; arg++) {
            ec += ((qva->qva_specQuery != NULL)
                    ? qva->qva_specQuery(ts, qva, *arg) : 1);
index 1637942..fed7a37 100644 (file)
@@ -85,11 +85,13 @@ enum rpmQVSources_e {
     RPMQV_WHATREQUIRES,        /*!< ... from requires db search. */
     RPMQV_TRIGGEREDBY, /*!< ... from trigger db search. */
     RPMQV_DBOFFSET,    /*!< ... from database header instance. */
-    RPMQV_SPECFILE,    /*!< ... from spec file parse (query only). */
+    RPMQV_SPECRPMS,    /*!< ... from spec file binaries (query only). */
+    RPMQV_SPECFILE = RPMQV_SPECRPMS, /*!< ... backwards compatibility */
     RPMQV_PKGID,       /*!< ... from package id (header+payload MD5). */
     RPMQV_HDRID,       /*!< ... from header id (immutable header SHA1). */
     RPMQV_FILEID,      /*!< ... from file id (file MD5). */
     RPMQV_TID,         /*!< ... from install transaction id (time stamp). */
+    RPMQV_SPECSRPM,    /*!< ... from spec file source (query only). */
 };
 
 typedef rpmFlags rpmQVSources;