diff options
author | jbj <devnull@localhost> | 2001-06-13 20:57:06 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-06-13 20:57:06 +0000 |
commit | 22b9de5f331285fef6b353b9441d121dcc639ea2 (patch) | |
tree | 2c92e8a791f48317d8a3a12011fc97472e91802f /lib | |
parent | 7233e3ad7373eec14ca47dc292806deb986519b1 (diff) | |
download | rpm-22b9de5f331285fef6b353b9441d121dcc639ea2.tar.gz rpm-22b9de5f331285fef6b353b9441d121dcc639ea2.tar.bz2 rpm-22b9de5f331285fef6b353b9441d121dcc639ea2.zip |
- add rpmdbSetIteratorRE() for regex matching in database iterators.
- permit rpm -qa to take RE args applied to name tag.
- permit dbiFindMatches() to use version/release patterns.
- eliminate all uses of rpmdbSetIterator{Version,Release}.
CVS patchset: 4859
CVS date: 2001/06/13 20:57:06
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psm.c | 9 | ||||
-rw-r--r-- | lib/query.c | 12 | ||||
-rw-r--r-- | lib/rpmcli.h | 1 | ||||
-rw-r--r-- | lib/rpmlib.h | 29 | ||||
-rw-r--r-- | lib/transaction.c | 9 |
5 files changed, 48 insertions, 12 deletions
@@ -1332,8 +1332,13 @@ int psmStage(PSM_t psm, pkgStage stage) assert(psm->mi == NULL); psm->mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, fi->name, 0); - rpmdbSetIteratorVersion(psm->mi, fi->version); - rpmdbSetIteratorRelease(psm->mi, fi->release); +#ifdef DYING + (void) rpmdbSetIteratorVersion(psm->mi, fi->version); + (void) rpmdbSetIteratorRelease(psm->mi, fi->release); +#else + (void) rpmdbSetIteratorRE(psm->mi, RPMTAG_VERSION, fi->version); + (void) rpmdbSetIteratorRE(psm->mi, RPMTAG_RELEASE, fi->release); +#endif while ((psm->oh = rpmdbNextIterator(psm->mi))) { fi->record = rpmdbGetIteratorOffset(psm->mi); if (ts->transFlags & RPMTRANS_FLAG_MULTILIB) diff --git a/lib/query.c b/lib/query.c index 309a55654..b9bbb2b69 100644 --- a/lib/query.c +++ b/lib/query.c @@ -497,12 +497,12 @@ int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg, int rc; int isSource; int retcode = 0; + const char ** av = NULL; char * end = NULL; switch (source) { case RPMQV_RPM: { int ac = 0; - const char ** av = NULL; const char * fileURL = NULL; rpmRC rpmrc; int i; @@ -632,7 +632,15 @@ restart: rpmError(RPMERR_QUERYINFO, _("no packages\n")); retcode = 1; } else { - retcode = showMatches(qva, mi, showPackage); + for (av = (const char **) arg; av && *av; av++) { + if (!rpmdbSetIteratorRE(mi, RPMTAG_NAME, *av)) + continue; + mi = rpmdbFreeIterator(mi); + retcode = 1; + /*@loopbreak@*/ break; + } + if (!retcode) + retcode = showMatches(qva, mi, showPackage); } break; diff --git a/lib/rpmcli.h b/lib/rpmcli.h index a4f334b5f..358a43854 100644 --- a/lib/rpmcli.h +++ b/lib/rpmcli.h @@ -177,6 +177,7 @@ int showQueryPackage(QVA_t qva, rpmdb db, Header h) /** \ingroup rpmcli * Display package information. + * @todo hack: RPMQV_ALL can pass char ** arglist = NULL, not char * arg. Union? * @param qva parsed query/verify options * @param source type of source to query * @param arg name of source to query diff --git a/lib/rpmlib.h b/lib/rpmlib.h index d1f7657aa..557a56662 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -763,22 +763,39 @@ int rpmdbPruneIterator(/*@null@*/ rpmdbMatchIterator mi, /*@modifies mi, hdrNums @*/; /** \ingroup rpmdb + * Add regular expression to iterator selector. + * @param mi rpm database iterator + * @param tag rpm tag + * @param pattern regex pattern to match + * @return 0 on success + */ +int rpmdbSetIteratorRE(/*@null@*/ rpmdbMatchIterator mi, rpmTag tag, + /*@null@*/ const char * pattern) + /*@modifies mi @*/; + +/** \ingroup rpmdb * Modify iterator to filter out headers that do not match version. - * @todo Replace with a more general mechanism using RE's on tag content. + * @deprecated Use rpmdbSetIteratorRE(mi, RPMTAG_VERSION, version) instead. + * @todo Eliminate from API. * @param mi rpm database iterator - * @param version version to check for + * @param version version to match (can be a regex pattern) + * @return 0 on success */ -void rpmdbSetIteratorVersion(/*@null@*/ rpmdbMatchIterator mi, +/*@unused@*/ +int rpmdbSetIteratorVersion(/*@null@*/ rpmdbMatchIterator mi, /*@null@*/ const char * version) /*@modifies mi @*/; /** \ingroup rpmdb * Modify iterator to filter out headers that do not match release. - * @todo Replace with a more general mechanism using RE's on tag content. + * @deprecated Use rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, release) instead. + * @todo Eliminate from API. * @param mi rpm database iterator - * @param release release to check for + * @param release release to match (can be a regex pattern) + * @return 0 on success */ -void rpmdbSetIteratorRelease(/*@null@*/ rpmdbMatchIterator mi, +/*@unused@*/ +int rpmdbSetIteratorRelease(/*@null@*/ rpmdbMatchIterator mi, /*@null@*/ const char * release) /*@modifies mi @*/; diff --git a/lib/transaction.c b/lib/transaction.c index 20d6acf4c..da80a78bb 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1650,8 +1650,13 @@ int rpmRunTransactions( rpmTransactionSet ts, if (!(ts->ignoreSet & RPMPROB_FILTER_REPLACEPKG) && !alp->multiLib) { rpmdbMatchIterator mi; mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, alp->name, 0); - rpmdbSetIteratorVersion(mi, alp->version); - rpmdbSetIteratorRelease(mi, alp->release); +#ifdef DYING + (void) rpmdbSetIteratorVersion(mi, alp->version); + (void) rpmdbSetIteratorRelease(mi, alp->release); +#else + (void) rpmdbSetIteratorRE(mi, RPMTAG_VERSION, alp->version); + (void) rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, alp->release); +#endif while (rpmdbNextIterator(mi) != NULL) { psAppend(ts->probs, RPMPROB_PKG_INSTALLED, alp, NULL, NULL, NULL, 0); |