diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-06-17 13:53:43 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-06-17 13:53:43 +0300 |
commit | c881ee9e81c35f5a4733c5797e50aaabb1c7d1d5 (patch) | |
tree | 22b69b5fd06f4c49e14da92e71099f82c6a934b9 /rpmspec.c | |
parent | c38504c4ba539ccbfb37edccc0cc0ad3cdae58b3 (diff) | |
download | librpm-tizen-c881ee9e81c35f5a4733c5797e50aaabb1c7d1d5.tar.gz librpm-tizen-c881ee9e81c35f5a4733c5797e50aaabb1c7d1d5.tar.bz2 librpm-tizen-c881ee9e81c35f5a4733c5797e50aaabb1c7d1d5.zip |
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.
Diffstat (limited to 'rpmspec.c')
-rw-r--r-- | rpmspec.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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); |