make repodata_stringify return the result string
[platform/upstream/libsolv.git] / tools / archrepo2solv.c
index e671c49..6dcb076 100644 (file)
@@ -35,6 +35,7 @@ usage(int status)
   fprintf(stderr, "\nUsage:\n"
           "archrepo2solv\n"
           "  reads a repository from <stdin> and writes a .solv file to <stdout>\n"
+          "  -l <dbdir> : read local database\n"
           "  -h : print help & exit\n"
          );
    exit(status);
@@ -45,15 +46,19 @@ main(int argc, char **argv)
 {
   Pool *pool;
   Repo *repo;
-  int c;
+  int c, ret;
+  const char *localdb = 0;
 
-  while ((c = getopt(argc, argv, "h")) >= 0)
+  while ((c = getopt(argc, argv, "hl:")) >= 0)
     {
       switch(c)
        {
        case 'h':
          usage(0);
          break;
+       case 'l':
+         localdb = optarg;
+         break;
        default:
          usage(1);
          break;
@@ -61,7 +66,15 @@ main(int argc, char **argv)
     }
   pool = pool_create();
   repo = repo_create(pool, "<stdin>");
-  repo_add_arch_repo(repo, stdin, 0);
+  if (localdb)
+    ret = repo_add_arch_local(repo, localdb, 0);
+  else
+    ret = repo_add_arch_repo(repo, stdin, 0);
+  if (ret)
+    {
+      fprintf(stderr, "archrepo2solv: %s\n", pool_errstr(pool));
+      exit(1);
+    }
   tool_write(repo, 0, 0);
   pool_free(pool);
   exit(0);