support -k option in rpms2solv to convert a gpg pubkey
authorMichael Schroeder <mls@suse.de>
Mon, 22 Jul 2013 13:51:02 +0000 (15:51 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 23 Jul 2013 13:54:50 +0000 (15:54 +0200)
tools/rpms2solv.c

index 54ea4e9..63a7f28 100644 (file)
@@ -20,6 +20,9 @@
 #include "pool.h"
 #include "repo.h"
 #include "repo_rpmdb.h"
+#ifdef ENABLE_RPMDB_PUBKEY
+#include "repo_rpmdb_pubkey.h"
+#endif
 #include "repo_solv.h"
 #include "common_write.h"
 
@@ -58,8 +61,11 @@ main(int argc, char **argv)
   FILE *fp;
   char buf[4096], *p;
   const char *basefile = 0;
+#ifdef ENABLE_RPMDB_PUBKEY
+  int pubkeys = 0;
+#endif
 
-  while ((c = getopt(argc, argv, "0b:m:")) >= 0)
+  while ((c = getopt(argc, argv, "0kb:m:")) >= 0)
     {
       switch(c)
        {
@@ -72,6 +78,11 @@ main(int argc, char **argv)
        case '0':
          manifest0 = 1;
          break;
+#ifdef ENABLE_RPMDB_PUBKEY
+       case 'k':
+         pubkeys = 1;
+         break;
+#endif
        default:
          exit(1);
        }
@@ -115,6 +126,17 @@ main(int argc, char **argv)
   res = 0;
   for (i = 0; i < nrpms; i++)
     {
+#ifdef ENABLE_RPMDB_PUBKEY
+     if (pubkeys)
+       {
+         if (repo_add_pubkey(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
+           {
+             fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
+             res = 1;
+           }
+         continue;
+       }
+#endif
       if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
        {
          fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));