- kill stillborn KINDS_SEPARATELY, use getopt() in tools
authorMichael Schroeder <mls@suse.de>
Fri, 7 Jan 2011 14:32:09 +0000 (15:32 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 7 Jan 2011 14:33:38 +0000 (15:33 +0100)
ext/repo_rpmmd.h
ext/repo_susetags.c
ext/repo_susetags.h
ext/repo_zyppdb.c
tools/deltainfoxml2solv.c
tools/diskusagexml2solv.c
tools/dumpsolv.c
tools/rpmmd2solv.c
tools/susetags2solv.c
tools/updateinfoxml2solv.c

index 9b021b2..931a7f3 100644 (file)
@@ -5,6 +5,4 @@
  * for further information
  */
 
-#define RPMMD_KINDS_SEPARATELY (1 << 2)
-
 extern void repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags);
index d8daa7f..b5fff0c 100644 (file)
@@ -567,11 +567,6 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
          cummulate = 0;
          switch (tag_from_string(line))       /* check if accumulation is needed */
            {
-             case CTAG('+', 'P', 'r', 'q'):
-             case CTAG('+', 'P', 'r', 'c'):
-             case CTAG('+', 'P', 's', 'g'):
-               if (!pd.kind || !(flags & SUSETAGS_KINDS_SEPARATELY))
-                 break;
              case CTAG('+', 'D', 'e', 's'):
              case CTAG('+', 'E', 'u', 'l'):
              case CTAG('+', 'I', 'n', 's'):
@@ -579,6 +574,9 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
              case CTAG('+', 'A', 'u', 't'):
                if (line[4] == ':')
                  cummulate = 1;
+               break;
+             default:
+               break;
            }
          line[0] = '=';                       /* handle lines between +Key:/-Key: as =Key: */
          line[intag + keylen - 1] = ' ';
@@ -706,10 +704,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
           case CTAG('=', 'P', 'r', 'q'):                                        /* pre-requires / packages required */
            if (pd.kind)
              {
-               if (flags & SUSETAGS_KINDS_SEPARATELY)
-                 repodata_set_poolstr(data, handle, str2id(pool, "solvable:must", 1), line + 6);
-               else
-                 s->requires = adddep(pool, &pd, s->requires, line, 0, 0);           /* patterns: a required package */
+               s->requires = adddep(pool, &pd, s->requires, line, 0, 0);           /* patterns: a required package */
              }
            else
              s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
@@ -736,46 +731,25 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
            freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
            continue;
           case CTAG('=', 'P', 'r', 'c'):                                        /* packages recommended */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             repodata_set_poolstr(data, handle, str2id(pool, "solvable:should", 1), line + 6);
-           else
-             s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
+           s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
            continue;
           case CTAG('=', 'P', 's', 'g'):                                        /* packages suggested */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             repodata_set_poolstr(data, handle, str2id(pool, "solvable:may", 1), line + 6);
-           else
-             s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
+           s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
            continue;
           case CTAG('=', 'P', 'c', 'n'):                                        /* pattern: package conflicts */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             fprintf(stderr, "Unsupported: pattern -> package conflicts\n");
-           else
-             s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
+           s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
            continue;
          case CTAG('=', 'P', 'o', 'b'):                                        /* pattern: package obsoletes */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             fprintf(stderr, "Unsupported: pattern -> package obsoletes\n");
-           else
-             s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
+           s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
            continue;
           case CTAG('=', 'P', 'f', 'r'):                                        /* pattern: package freshens */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             fprintf(stderr, "Unsupported: pattern -> package freshens\n");
-           else
-             freshens = adddep(pool, &pd, freshens, line, 0, 0);
+           freshens = adddep(pool, &pd, freshens, line, 0, 0);
            continue;
           case CTAG('=', 'P', 's', 'p'):                                        /* pattern: package supplements */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             fprintf(stderr, "Unsupported: pattern -> package supplements\n");
-           else
-             s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
+           s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
            continue;
           case CTAG('=', 'P', 'e', 'n'):                                        /* pattern: package enhances */
-           if (flags & SUSETAGS_KINDS_SEPARATELY)
-             fprintf(stderr, "Unsupported: pattern -> package enhances\n");
-           else
-             s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
+           s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
            continue;
           case CTAG('=', 'V', 'e', 'r'):                                        /* - version - */
            last_found_pack = 0;
index 91acd2a..f922dbf 100644 (file)
@@ -9,7 +9,6 @@
  * if <attrname> given, write attributes as '<attrname>.attr'
  */
 
-#define SUSETAGS_KINDS_SEPARATELY      (1 << 8)
 #define SUSETAGS_EXTEND                        (1 << 9)
 
 extern void repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags);
index f69c7bf..b4f7b90 100644 (file)
@@ -141,7 +141,7 @@ startElement(void *userData, const char *name, const char **atts)
   struct stateswitch *sw;
 
 #if 0
-      fprintf(stderr, "start: [%d]%s\n", pd->state, name);
+  fprintf(stderr, "start: [%d]%s\n", pd->state, name);
 #endif
   if (pd->depth != pd->statedepth)
     {
@@ -214,7 +214,7 @@ endElement(void *userData, const char *name)
   Solvable *s = pd->solvable;
 
 #if 0
-      fprintf(stderr, "end: [%d]%s\n", pd->state, name);
+  fprintf(stderr, "end: [%d]%s\n", pd->state, name);
 #endif
   if (pd->depth != pd->statedepth)
     {
@@ -262,7 +262,7 @@ endElement(void *userData, const char *name)
   pd->docontent = 0;
 
 #if 0
-      fprintf(stderr, "end: [%s] -> %d\n", name, pd->state);
+  fprintf(stderr, "end: [%s] -> %d\n", name, pd->state);
 #endif
 }
 
@@ -273,14 +273,8 @@ characterData(void *userData, const XML_Char *s, int len)
   struct parsedata *pd = userData;
   int l;
   char *c;
-  if (!pd->docontent) {
-#if 0
-    char *dup = strndup( s, len );
-  fprintf(stderr, "Content: [%d]'%s'\n", pd->state, dup );
-  free( dup );
-#endif
+  if (!pd->docontent)
     return;
-  }
   l = pd->lcontent + len + 1;
   if (l > pd->acontent)
     {
index a0fe6c2..1528df2 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "pool.h"
 #include "repo.h"
 #include "common_write.h"
 
 static void
-usage(const char *err)
+usage(int status)
 {
-  if (err)
-    fprintf(stderr, "\n** Error:\n  %s\n", err);
   fprintf(stderr, "\nUsage:\n"
-          "deltainfoxml2solv [-a][-h][-k][-n <attrname>]\n"
+          "deltainfoxml2solv [-a][-h][-n <attrname>]\n"
          "  reads a 'deltainfo.xml' file from <stdin> and writes a .solv file to <stdout>\n"
          "  -h : print help & exit\n"
-         "  -k : don't mix kinds (experimental!)\n"
          "  -n <name>: save attributes as <name>.attr\n"
         );
-   exit(0);
+  exit(status);
 }
 
 int
 main(int argc, char **argv)
 {
-  int flags = 0;
+  int c, flags = 0;
   char *attrname = 0;
   
   Pool *pool = pool_create();
   Repo *repo = repo_create(pool, "<stdin>");
 
-  argv++;
-  argc--;
-  while (argc--)
-    {
-      const char *s = argv[0];
-      if (*s++ == '-')
-        while (*s)
-          switch (*s++)
-           {
-             case 'h': usage(NULL); break;
-             case 'n':
-               if (argc)
-                 {
-                   attrname = argv[1];
-                   argv++;
-                   argc--;
-                 }
-               else
-                 usage("argument required for '-n'");
-               break;
-             case 'k':
-             break;
-             default : break;
-           }
-      argv++;
+  while ((c = getopt(argc, argv, "hn:")) >= 0)
+    {   
+      switch(c)
+       {
+       case 'h':
+         usage(0);
+         break;
+       case 'n':
+         attrname = optarg;
+         break;
+       default:
+         usage(1);
+         break;
+       }
     }
-
   repo_add_deltainfoxml(repo, stdin, flags);
-  tool_write(repo, 0, 0);
+  tool_write(repo, 0, attrname);
   pool_free(pool);
   exit(0);
 }
index fd9e564..bfc775f 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "pool.h"
 #include "repo.h"
 #include "common_write.h"
 
 static void
-usage(const char *err)
+usage(int status)
 {
-  if (err)
-    fprintf(stderr, "\n** Error:\n  %s\n", err);
   fprintf(stderr, "\nUsage:\n"
-          "diskusagexml2solv [-a][-h][-k][-n <attrname>]\n"
+          "diskusagexml2solv [-a][-h][-n <attrname>]\n"
          "  reads a 'diskusage.xml' file from <stdin> and writes a .solv file to <stdout>\n"
          "  -h : print help & exit\n"
-         "  -k : don't mix kinds (experimental!)\n"
          "  -n <name>: save attributes as <name>.attr\n"
         );
-   exit(0);
+  exit(status);
 }
 
 int
 main(int argc, char **argv)
 {
-  int flags = 0;
+  int c, flags = 0;
   char *attrname = 0;
   
   Pool *pool = pool_create();
   Repo *repo = repo_create(pool, "<stdin>");
 
-  argv++;
-  argc--;
-  while (argc--)
-    {
-      const char *s = argv[0];
-      if (*s++ == '-')
-        while (*s)
-          switch (*s++)
-           {
-             case 'h': usage(NULL); break;
-             case 'n':
-               if (argc)
-                 {
-                   attrname = argv[1];
-                   argv++;
-                   argc--;
-                 }
-               else
-                 usage("argument required for '-n'");
-               break;
-             case 'k':
-             break;
-             default : break;
-           }
-      argv++;
+  while ((c = getopt(argc, argv, "hn:")) >= 0)
+    {   
+      switch(c)
+       {
+       case 'h':
+         usage(0);
+         break;
+       case 'n':
+         attrname = optarg;
+         break;
+       default:
+         usage(1);
+         break;
+       }
     }
-
   repo_add_diskusagexml(repo, stdin, flags);
-  tool_write(repo, 0, 0);
+  tool_write(repo, 0, attrname);
   pool_free(pool);
   exit(0);
 }
index 061f3d0..77a5a35 100644 (file)
@@ -200,15 +200,13 @@ printf("loc %s\n", location);
 
 
 static void
-usage( const char *err )
+usage(int status)
 {
-  if (err)
-    fprintf (stderr, "\n** Error:\n  %s\n", err);
   fprintf( stderr, "\nUsage:\n"
           "dumpsolv [-a] [<solvfile>]\n"
           "  -a  read attributes.\n"
           );
-  exit(0);
+  exit(status);
 }
 
 #if 0
@@ -247,40 +245,39 @@ int main(int argc, char **argv)
 {
   Repo *repo;
   Pool *pool;
-  int i, j, n;
+  int c, i, j, n;
   Solvable *s;
   
   pool = pool_create();
   pool_setdebuglevel(pool, 1);
   pool_setloadcallback(pool, loadcallback, 0);
 
-  argv++;
-  argc--;
-  while (argc--)
+  while ((c = getopt(argc, argv, "ha")) >= 0)
     {
-      const char *s = argv[0];
-      if (*s++ == '-')
-        while (*s)
-          switch (*s++)
-           {
-             case 'h': usage(NULL); break;
-             case 'a': with_attr = 1; break;
-             default : break;
-           }
-      else
+      switch(c)
        {
-         if (freopen (argv[0], "r", stdin) == 0)
-           {
-             perror(argv[0]);
-             exit(1);
-           }
-         repo = repo_create(pool, argv[0]);
-         if (repo_add_solv(repo, stdin))
-           printf("could not read repository\n");
+       case 'h':
+         usage(0);
+         break;
+       case 'a':
+         with_attr = 1;
+         break;
+       default:
+          usage(1);
+          break;
        }
-      argv++;
     }
-
+  for (; optind < argc; optind++)
+    {
+      if (freopen(argv[optind], "r", stdin) == 0)
+       {
+         perror(argv[optind]);
+         exit(1);
+       }
+      repo = repo_create(pool, argv[optind]);
+      if (repo_add_solv(repo, stdin))
+       printf("could not read repository\n");
+    }
   if (!pool->nrepos)
     {
       repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
index f08bbe8..e5c2c84 100644 (file)
@@ -59,10 +59,9 @@ static void
 usage(int status)
 {
   fprintf(stderr, "\nUsage:\n"
-          "rpmmd2solv [-a][-h][-k][-n <attrname>][-l <locale>]\n"
+          "rpmmd2solv [-a][-h][-n <attrname>][-l <locale>]\n"
          "  reads 'primary' from a 'rpmmd' repository from <stdin> and writes a .solv file to <stdout>\n"
          "  -h : print help & exit\n"
-         "  -k : don't mix kinds (experimental!)\n"
          "  -n <name>: save attributes as <name>.attr\n"
          "  -l <locale>: parse localization data for <locale>\n"
         );
@@ -81,16 +80,13 @@ main(int argc, char **argv)
   Pool *pool = pool_create();
   Repo *repo = repo_create(pool, "<stdin>");
 
-  while ((c = getopt (argc, argv, "hkn:b:d:l:")) >= 0)
+  while ((c = getopt (argc, argv, "hn:b:d:l:")) >= 0)
     {
       switch(c)
        {
         case 'h':
           usage(0);
           break;
-        case 'k':
-          flags |= RPMMD_KINDS_SEPARATELY;   /* do not use! */
-          break;
         case 'n':
           attrname = optarg;
           break;
index daf7249..a0fd08e 100644 (file)
@@ -27,13 +27,12 @@ static void
 usage(int status)
 {
   fprintf(stderr, "\nUsage:\n"
-          "susetags2solv [-b <base>][-c <content>][-d <descrdir>][-h][-k][-n <name>]\n"
+          "susetags2solv [-b <base>][-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"
-         "  -k : don't mix kinds (experimental!)\n"
          "  -n <name>: save attributes as <name>.attr\n"
         );
    exit(status);
@@ -101,16 +100,13 @@ main(int argc, char **argv)
   int flags = 0;
   int c;
 
-  while ((c = getopt(argc, argv, "hkn:c:d:b:q:")) >= 0)
+  while ((c = getopt(argc, argv, "hn:c:d:b:q:")) >= 0)
     {
       switch (c)
        {
        case 'h':
          usage(0);
          break;
-       case 'k':
-         flags |= SUSETAGS_KINDS_SEPARATELY;   /* do not use! */
-         break;
        case 'n':
          attrname = optarg;
          break;
index e893c1b..921538f 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "pool.h"
 #include "repo.h"
 #include "common_write.h"
 
 static void
-usage(const char *err)
+usage(int status)
 {
-  if (err)
-    fprintf(stderr, "\n** Error:\n  %s\n", err);
   fprintf(stderr, "\nUsage:\n"
-          "updateinfoxml2solv [-a][-h][-k][-n <attrname>]\n"
+          "updateinfoxml2solv [-h][-n <attrname>]\n"
          "  reads a 'updateinfo.xml' file from <stdin> and writes a .solv file to <stdout>\n"
          "  -h : print help & exit\n"
-         "  -k : don't mix kinds (experimental!)\n"
          "  -n <name>: save attributes as <name>.attr\n"
         );
-   exit(0);
+  exit(status);
 }
 
 int
 main(int argc, char **argv)
 {
-  int flags = 0;
+  int c, flags = 0;
   char *attrname = 0;
   
   Pool *pool = pool_create();
   Repo *repo = repo_create(pool, "<stdin>");
 
-  argv++;
-  argc--;
-  while (argc--)
+  while ((c = getopt(argc, argv, "hn:")) >= 0)
     {
-      const char *s = argv[0];
-      if (*s++ == '-')
-        while (*s)
-          switch (*s++)
-           {
-             case 'h': usage(NULL); break;
-             case 'n':
-               if (argc)
-                 {
-                   attrname = argv[1];
-                   argv++;
-                   argc--;
-                 }
-               else
-                 usage("argument required for '-n'");
-               break;
-             case 'k':
-             break;
-             default : break;
-           }
-      argv++;
+      switch(c)
+       {
+       case 'h':
+         usage(0);
+         break;
+       case 'n':
+         attrname = optarg;
+         break;
+       default:
+         usage(1);
+         break;
+       }
     }
-
   repo_add_updateinfoxml(repo, stdin, flags);
-  tool_write(repo, 0, 0);
+  tool_write(repo, 0, attrname);
   pool_free(pool);
   exit(0);
 }