Support overriding target for rpmspec queries too
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 12 Oct 2010 11:56:18 +0000 (14:56 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 12 Oct 2010 11:56:18 +0000 (14:56 +0300)
rpmspec.c

index 9e79878..ff72570 100644 (file)
--- a/rpmspec.c
+++ b/rpmspec.c
@@ -17,6 +17,7 @@ enum modes {
 
 static int mode = MODE_UNKNOWN;
 static int source = RPMQV_SPECRPMS;
+const char *target = NULL;
 
 /* the structure describing the options we take and the defaults */
 static struct poptOption optionsTable[] = {
@@ -26,6 +27,8 @@ static struct poptOption optionsTable[] = {
        N_("Operate on binary rpms generated by spec (default)"), NULL },
     { "srpm", 0, POPT_ARG_VAL, &source, RPMQV_SPECSRPM,
        N_("Operate on source rpm generated by spec"), NULL },
+    { "target", 0, POPT_ARG_STRING, &target, 0,
+       N_("override target platform"), NULL },
 
     /* XXX FIXME: only queryformat is relevant for spec queries */
     { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
@@ -50,6 +53,12 @@ int main(int argc, char *argv[])
 
     if (rpmcliPipeOutput && initPipe())
        exit(EXIT_FAILURE);
+
+    if (target) {
+       rpmFreeMacros(NULL);
+       rpmFreeRpmrc();
+       rpmReadConfigFiles(rpmcliRcfile, target);
+    }
        
     ts = rpmtsCreate();
     switch (mode) {