summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-06-17 13:53:43 +0300
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-15 12:21:10 +0300
commitaa3f7023da099c581fa930116d532b762240a722 (patch)
tree9ede1f892ff7e5eb4f6a3fe74429837eff893575
parentcdadcee074b20e91b4f95a0db419dd6dc0fcd3f2 (diff)
downloadrpm-aa3f7023da099c581fa930116d532b762240a722.tar.gz
Add --parse option to rpmspec tool to dump parsed spec contents
- This is somewhat like 'gcc -E', useful for analyzing/troubleshooting what happens inside the preprocessing. (cherry picked from commit c881ee9e81c35f5a4733c5797e50aaabb1c7d1d5)
-rw-r--r--rpmspec.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/rpmspec.c b/rpmspec.c
index 95cf98e1b..c4d01a918 100644
--- a/rpmspec.c
+++ b/rpmspec.c
@@ -13,6 +13,7 @@ const char *__progname;
enum modes {
MODE_UNKNOWN = 0,
MODE_QUERY = (1 << 0),
+ MODE_PARSE = (1 << 1),
};
static int mode = MODE_UNKNOWN;
@@ -21,6 +22,8 @@ const char *target = NULL;
char *queryformat = NULL;
static struct poptOption specOptsTable[] = {
+ { "parse", 'P', POPT_ARG_VAL, &mode, MODE_PARSE,
+ N_("parse spec file(s) to stdout"), NULL },
{ "query", 'q', POPT_ARG_VAL, &mode, MODE_QUERY,
N_("query spec file(s)"), NULL },
{ "rpms", 0, POPT_ARG_VAL, &source, RPMQV_SPECRPMS,
@@ -81,6 +84,23 @@ int main(int argc, char *argv[])
ec = rpmcliQuery(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
break;
+ case MODE_PARSE: {
+ const char * spath;
+ if (!poptPeekArg(optCon))
+ argerror(_("no arguments given for parse"));
+
+ while ((spath = poptGetArg(optCon)) != NULL) {
+ rpmSpec spec = rpmSpecParse(spath, 0, NULL);
+ if (spec == NULL) {
+ ec++;
+ continue;
+ }
+ fprintf(stdout, "%s", rpmSpecGetSection(spec, RPMBUILD_NONE));
+ rpmSpecFree(spec);
+ }
+ break;
+ }
+
case MODE_UNKNOWN:
if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
printUsage(optCon, stderr, 0);