Imported Upstream version 0.7.27
[platform/upstream/libsolv.git] / tools / susetags2solv.c
index 71c65d8..f7544dc 100644 (file)
@@ -8,14 +8,11 @@
 #define _GNU_SOURCE
 
 #include <sys/types.h>
-#include <limits.h>
-#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <dirent.h>
-#include <zlib.h>
-#include <getopt.h>
+#include <unistd.h>
 
 #include "pool.h"
 #include "repo.h"
@@ -32,13 +29,11 @@ static void
 usage(int status)
 {
   fprintf(stderr, "\nUsage:\n"
-          "susetags2solv [-b <base>][-c <content>][-d <descrdir>][-h][-n <name>]\n"
+          "susetags2solv [-c <content>][-d <descrdir>][-h][-n <name>]\n"
          "  reads a 'susetags' repository from <stdin> and writes a .solv file to <stdout>\n"
-         "  -b <base>: save as multiple files starting with <base>\n"
          "  -c <contentfile> : parse given contentfile (for product information)\n"
           "  -d <descrdir> : do not read from stdin, but use data in descrdir\n"
          "  -h : print help & exit\n"
-         "  -n <name>: save attributes as <name>.attr\n"
         );
    exit(status);
 }
@@ -64,9 +59,7 @@ int
 main(int argc, char **argv)
 {
   const char *contentfile = 0;
-  const char *attrname = 0;
   const char *descrdir = 0;
-  const char *basefile = 0;
   const char *query = 0;
   const char *mergefile = 0;
   Id defvendor = 0;
@@ -78,25 +71,19 @@ main(int argc, char **argv)
   Pool *pool;
   Repo *repo;
 
-  while ((c = getopt(argc, argv, "hn:c:d:b:q:M:X")) >= 0)
+  while ((c = getopt(argc, argv, "hc:d:q:M:X")) >= 0)
     {
       switch (c)
        {
        case 'h':
          usage(0);
          break;
-       case 'n':
-         attrname = optarg;
-         break;
        case 'c':
          contentfile = optarg;
          break;
        case 'd':
          descrdir = optarg;
          break;
-       case 'b':
-         basefile = optarg;
-         break;
        case 'q':
          query = optarg;
          break;
@@ -135,20 +122,6 @@ main(int argc, char **argv)
       fclose(fp);
     }
 
-  if (attrname)
-    {
-      /* ensure '.attr' suffix */
-      const char *dot = strrchr(attrname, '.');
-      if (!dot || strcmp(dot, ".attr"))
-      {
-       int len = strlen (attrname);
-       char *newname = (char *)malloc(len + 6); /* alloc for <attrname>+'.attr'+'\0' */
-       strcpy (newname, attrname);
-       strcpy (newname+len, ".attr");
-       attrname = newname;
-      }
-    }
-
   /*
    * descrdir path given, open files and read from there
    */
@@ -200,7 +173,7 @@ main(int argc, char **argv)
                  perror(fn);
                  exit(1);
                }
-             if (repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+             if (repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | SUSETAGS_RECORD_SHARES))
                {
                  fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool));
                  exit(1);
@@ -314,7 +287,7 @@ main(int argc, char **argv)
   if (query)
     doquery(pool, repo, query);
   else
-    tool_write(repo, basefile, attrname);
+    tool_write(repo, stdout);
   pool_free(pool);
   exit(0);
 }