summaryrefslogtreecommitdiff
path: root/rpmspec.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-06-17 13:53:43 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-06-17 13:53:43 +0300
commitc881ee9e81c35f5a4733c5797e50aaabb1c7d1d5 (patch)
tree22b69b5fd06f4c49e14da92e71099f82c6a934b9 /rpmspec.c
parentc38504c4ba539ccbfb37edccc0cc0ad3cdae58b3 (diff)
downloadlibrpm-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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/rpmspec.c b/rpmspec.c
index 1e06a2716..e7606988c 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);