diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-09-06 15:58:35 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-09-06 15:58:35 +0300 |
commit | 628ad2fae22cd29786c1f36f97e68142fe8f5ec7 (patch) | |
tree | d8f0d90083dc41ed1e9fbcc73a09e99856a5d8a3 /lib/tagexts.c | |
parent | 31d807ffa8cdf91addf7c39fdf9abf6c61d77944 (diff) | |
download | librpm-tizen-628ad2fae22cd29786c1f36f97e68142fe8f5ec7.tar.gz librpm-tizen-628ad2fae22cd29786c1f36f97e68142fe8f5ec7.tar.bz2 librpm-tizen-628ad2fae22cd29786c1f36f97e68142fe8f5ec7.zip |
Add four new extension tags for pretty-formatting dependencies
- The current method that --requires and friends use is kinda
cumbersome and outputs extra whitespace for dependencies which
dont have flags+version attached. Adding extensions for this
is likely to be easier than teaching query formatting to
permit conditionalizing on current value instead of just tag existence.
Diffstat (limited to 'lib/tagexts.c')
-rw-r--r-- | lib/tagexts.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/tagexts.c b/lib/tagexts.c index d316396ff..bc12d2b90 100644 --- a/lib/tagexts.c +++ b/lib/tagexts.c @@ -726,6 +726,47 @@ static int epochnumTag(Header h, rpmtd td, headerGetFlags hgflags) return 1; } +static int depnevrsTag(Header h, rpmtd td, headerGetFlags hgflags, + rpmTagVal tag) +{ + rpmds ds = rpmdsNew(h, tag, 0); + int ndeps = rpmdsCount(ds); + + if (ndeps > 0) { + char **deps = xmalloc(sizeof(*deps) * ndeps); + int i; + while ((i = rpmdsNext(ds)) >= 0) { + deps[i] = rpmdsNewDNEVR(NULL, ds); + } + td->data = deps; + td->type = RPM_STRING_ARRAY_TYPE; + td->count = ndeps; + td->flags |= (RPMTD_ALLOCED | RPMTD_PTR_ALLOCED); + } + rpmdsFree(ds); + return (ndeps > 0); +} + +static int requirenevrsTag(Header h, rpmtd td, headerGetFlags hgflags) +{ + return depnevrsTag(h, td, hgflags, RPMTAG_REQUIRENAME); +} + +static int providenevrsTag(Header h, rpmtd td, headerGetFlags hgflags) +{ + return depnevrsTag(h, td, hgflags, RPMTAG_PROVIDENAME); +} + +static int obsoletenevrsTag(Header h, rpmtd td, headerGetFlags hgflags) +{ + return depnevrsTag(h, td, hgflags, RPMTAG_OBSOLETENAME); +} + +static int conflictnevrsTag(Header h, rpmtd td, headerGetFlags hgflags) +{ + return depnevrsTag(h, td, hgflags, RPMTAG_CONFLICTNAME); +} + static const struct headerTagFunc_s rpmHeaderTagExtensions[] = { { RPMTAG_GROUP, groupTag }, { RPMTAG_DESCRIPTION, descriptionTag }, @@ -751,6 +792,10 @@ static const struct headerTagFunc_s rpmHeaderTagExtensions[] = { { RPMTAG_VERBOSE, verboseTag }, { RPMTAG_EPOCHNUM, epochnumTag }, { RPMTAG_INSTFILENAMES, instfilenamesTag }, + { RPMTAG_REQUIRENEVRS, requirenevrsTag }, + { RPMTAG_PROVIDENEVRS, providenevrsTag }, + { RPMTAG_OBSOLETENEVRS, obsoletenevrsTag }, + { RPMTAG_CONFLICTNEVRS, conflictnevrsTag }, { 0, NULL } }; |