From 05ef6555f5f563ae55689e0d06a27c337b5eb8ce Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 11 Jun 2007 13:22:25 +0300 Subject: Fix query output when querying for non-installed . (rhbz#124016) --- lib/query.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/query.c b/lib/query.c index 27dec1059..b55b57b0e 100644 --- a/lib/query.c +++ b/lib/query.c @@ -663,15 +663,23 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg) } break; case RPMQV_PACKAGE: - /* XXX HACK to get rpmdbFindByLabel out of the API */ + { + int matches = 0; qva->qva_mi = rpmtsInitIterator(ts, RPMDBI_LABEL, arg, 0); - if (qva->qva_mi == NULL) { + while (rpmdbNextIterator(qva->qva_mi) != NULL) { + matches++; + } + if (! matches) { rpmError(RPMERR_QUERYINFO, _("package %s is not installed\n"), arg); res = 1; - } else + } else { + qva->qva_mi = rpmtsInitIterator(ts, RPMDBI_LABEL, arg, 0); res = rpmcliShowMatches(qva, ts); + } break; } + + } /*@=branchstate@*/ return res; -- cgit v1.2.3