From c7ccdea6386b9f9cd8be5ff459be99955b56f2ef Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 1 Sep 2010 16:49:43 +0300 Subject: [PATCH] A new saner interface for parsing spec files - For now just a wrapper around parseSpec() that returns *gasp* a pointer to a parsed spec structure. - Limit the amount of goo that needs passing - optimally we'd only need the spec + parsing flags, but due to %{buildroot} macro abuse in specs we'll need that for now too. --- build/parseSpec.c | 15 +++++++++++++++ build/rpmbuild.h | 12 ++++++++++++ build/rpmspec.h | 6 ++++++ 3 files changed, 33 insertions(+) diff --git a/build/parseSpec.c b/build/parseSpec.c index 3d99ec6..f48a132 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -696,3 +696,18 @@ errxit: spec = freeSpec(spec); return PART_ERROR; } + +rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags, + const char *buildRoot) +{ + rpmts ts = rpmtsCreate(); + rpmSpec spec = NULL; + + if (parseSpec(ts, specFile, NULL, buildRoot, 0, NULL, NULL, + (flags & RPMSPEC_ANYARCH), (flags & RPMSPEC_FORCE)) == 0) { + spec = rpmtsSetSpec(ts, NULL); + } + + rpmtsFree(ts); + return spec; +} diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 36bb1c6..a923909 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -71,6 +71,18 @@ extern int _noDirTokens; /** \ingroup rpmbuild * Parse spec file into spec control structure. + * @todo Eliminate buildRoot from here, its a build, not spec property + * + * @param specFile path to spec file + * @param flags flags to control operation + * @param buildRoot buildRoot override or NULL for default + * @return new spec control structure + */ +rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags, + const char *buildRoot); + +/** \ingroup rpmbuild + * Parse spec file into spec control structure. * @param ts transaction set (spec file control in ts->spec) * @param specFile * @param rootDir (unused) diff --git a/build/rpmspec.h b/build/rpmspec.h index 450f264..5f4331b 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -24,6 +24,12 @@ typedef struct Package_s * Package; #define RPMBUILD_DEFAULT_LANG "C" +typedef enum rpmSpecFlags_e { + RPMSPEC_NONE = 0, + RPMSPEC_ANYARCH = (1 << 0), + RPMSPEC_FORCE = (1 << 1), +} rpmSpecFlags; + /** \ingroup rpmbuild */ struct Source { -- 2.7.4