chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
Blob Blame History Raw
From 8dd8e37acc79da1ce0a36c3f86650defa474a6a9 Mon Sep 17 00:00:00 2001
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
Date: Thu, 14 Mar 2019 13:56:26 +0100
Subject: [PATCH] Show list of files only once when use rpm -ql and multiple
 rpm files

---
 lib/query.c       |  3 ++-
 tests/rpmquery.at | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/query.c b/lib/query.c
index e5408e211..7568f67aa 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -574,7 +574,8 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv)
 	    if (mi == NULL && qva->qva_source == RPMQV_PACKAGE) {
 		size_t l = strlen(*arg);
 		if (l > 4 && !strcmp(*arg + l - 4, ".rpm")) {
-		    rpmgi gi = rpmgiNew(ts, giFlags, argv);
+		    char * const argFirst[2] = { arg[0], NULL };
+		    rpmgi gi = rpmgiNew(ts, giFlags, argFirst);
 		    ecLocal = rpmgiShowMatches(qva, ts, gi);
 		    rpmgiFree(gi);
 		}
diff --git a/tests/rpmquery.at b/tests/rpmquery.at
index ab7bb3c46..0dc6d78b6 100644
--- a/tests/rpmquery.at
+++ b/tests/rpmquery.at
@@ -61,6 +61,24 @@ hello.spec
 [ignore])
 AT_CLEANUP
 
+# ------------------------------
+AT_SETUP([rpm -ql multiple *.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+runroot rpm \
+  -ql \
+  /data/SRPMS/hello-1.0-1.src.rpm /data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[hello-1.0.tar.gz
+hello.spec
+/usr/local/bin/hello
+/usr/share/doc/hello-1.0
+/usr/share/doc/hello-1.0/FAQ
+],
+[ignore])
+AT_CLEANUP
+
 # ------------------------------
 AT_SETUP([rpmspec -q])
 AT_KEYWORDS([query])
-- 
2.17.2