]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Fix getinstalledrpmdbids handling of the match attribute
authorMichael Schroeder <mls@suse.de>
Wed, 18 Jul 2018 19:50:10 +0000 (21:50 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 18 Jul 2018 19:50:10 +0000 (21:50 +0200)
We currently have to iterate through all package names
because rpm lacks an interface to just get one specific name.

ext/repo_rpmdb_librpm.h

index 60efb07e15826de5aedaa528c4b12649383a76ea..aa901ca1acef78a6477b2b06386cf0f7cbe71be0 100644 (file)
@@ -114,7 +114,7 @@ static struct rpmdbentry *
 getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *match, int *nentriesp, char **namedatap)
 {
   const void * key;
-  size_t keylen;
+  size_t keylen, matchl = 0;
   Id nameoff;
 
   char *namedata = 0;
@@ -132,13 +132,19 @@ getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *ma
   if (state->dbenvopened != 1 && !opendbenv(state))
     return 0;
 
+  if (match)
+    matchl = strlen(match);
   ii = rpmdbIndexIteratorInit(rpmtsGetRdb(state->ts), RPMDBI_NAME);
 
   while (rpmdbIndexIteratorNext(ii, &key, &keylen) == 0)
     {
-
-      if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10))
-       continue;
+      if (match)
+       {
+         if (keylen != matchl || memcmp(key, match, keylen) != 0)
+           continue;
+       }
+      else if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10))
+        continue;
       nameoff = namedatal;
       if (namedatap)
        {