add repo_verify_sigdata, refactor solv_parse_sig into solvsig_create/free/verify
[platform/upstream/libsolv.git] / ext / testcase.c
index 77b5fab..d21621d 100644 (file)
@@ -110,6 +110,7 @@ static struct poolflags2str {
   { POOL_FLAG_OBSOLETEUSESPROVIDES,         "obsoleteusesprovides", 0 },
   { POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES, "implicitobsoleteusesprovides", 0 },
   { POOL_FLAG_OBSOLETEUSESCOLORS,           "obsoleteusescolors", 0 },
+  { POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS,   "implicitobsoleteusescolors", 0 },
   { POOL_FLAG_NOINSTALLEDOBSOLETES,         "noinstalledobsoletes", 0 },
   { POOL_FLAG_HAVEDISTEPOCH,                "havedistepoch", 0 },
   { POOL_FLAG_NOOBSOLETESMULTIVERSION,      "noobsoletesmultiversion", 0 },
@@ -289,15 +290,15 @@ Id
 testcase_str2dep(Pool *pool, char *s)
 {
   char *n, *a;
-  Id id;
+  Id id, evr;
   int flags;
 
   if ((n = strchr(s, '|')) != 0)
-    {    
+    {
       id = testcase_str2dep(pool, n + 1);
-      *n = 0; 
+      *n = 0;
       id = pool_rel2id(pool, testcase_str2dep(pool, s), id, REL_OR, 1);
-      *n = '|'; 
+      *n = '|';
       return id;
     }
   while (*s == ' ' || *s == '\t')
@@ -324,6 +325,11 @@ testcase_str2dep(Pool *pool, char *s)
       else
         id = pool_strn2id(pool, n, s - n, 1);
     }
+  else if (s - n > 4 && s[-4] == ':' && !strncmp(s - 4, ":any", 4))
+    {
+      id = pool_strn2id(pool, n, s - n - 4, 1);
+      id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
+    }
   else
     id = pool_strn2id(pool, n, s - n, 1);
   if (!*s)
@@ -331,16 +337,21 @@ testcase_str2dep(Pool *pool, char *s)
   while (*s == ' ' || *s == '\t')
     s++;
   flags = 0;
+  if (*s == '!' && s[1] == '=')        /* support != as synonym for <> */
+    {
+      flags = REL_LT | REL_GT;
+      s += 2;
+    }
   for (;;s++)
-    {  
+    {
       if (*s == '<')
-        flags |= REL_LT;
+       flags |= REL_LT;
       else if (*s == '=')
-        flags |= REL_EQ;
+       flags |= REL_EQ;
       else if (*s == '>')
-        flags |= REL_GT;
+       flags |= REL_GT;
       else
-        break;
+       break;
     }
   if (!flags)
     return id;
@@ -349,7 +360,18 @@ testcase_str2dep(Pool *pool, char *s)
   n = s;
   while (*s && *s != ' ' && *s != '\t')
     s++;
-  return pool_rel2id(pool, id, pool_strn2id(pool, n, s - n, 1), flags, 1);
+  evr = pool_strn2id(pool, n, s - n, 1);
+  if (*s == ' ' && !strcmp(s, " compat >= "))
+    {
+      s += 11;
+      while (*s == ' ' || *s == '\t')
+       s++;
+      n = s;
+      while (*s && *s != ' ' && *s != '\t')
+       s++;
+      evr = pool_rel2id(pool, evr, pool_strn2id(pool, n, s - n, 1), REL_COMPAT, 1);
+    }
+  return pool_rel2id(pool, id, evr, flags, 1);
 }
 
 const char *
@@ -385,8 +407,8 @@ testcase_solvid2str(Pool *pool, Id p)
   n = pool_id2str(pool, s->name);
   e = pool_id2str(pool, s->evr);
   a = pool_id2str(pool, s->arch);
-  str = pool_alloctmpspace(pool, strlen(n) + strlen(e) + strlen(a) + 3); 
-  sprintf(str, "%s-%s.%s", n, e, a); 
+  str = pool_alloctmpspace(pool, strlen(n) + strlen(e) + strlen(a) + 3);
+  sprintf(str, "%s-%s.%s", n, e, a);
   if (!s->repo)
     return pool_tmpappend(pool, str, "@", 0);
   if (s->repo->name)
@@ -1019,15 +1041,15 @@ finish_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfi
   if (nfilelist)
     {
       int l;
-      Id did; 
-      for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1) 
+      Id did;
+      for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
        {
          char *p = strrchr(filelist + l, '/');
-         if (!p) 
+         if (!p)
            continue;
-         *p++ = 0; 
+         *p++ = 0;
          did = repodata_str2dir(data, filelist + l, 1);
-         p[-1] = '/'; 
+         p[-1] = '/';
          if (!did)
            did = repodata_str2dir(data, "/", 1);
          repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
@@ -1760,7 +1782,7 @@ read_inline_file(FILE *fp, char **bufp, char **bufpp, int *buflp)
   char *result = solv_malloc(1024);
   char *rp = result;
   int resultl = 1024;
-  
+
   for (;;)
     {
       size_t rl;
@@ -1815,7 +1837,7 @@ read_file(FILE *fp)
   char *result = solv_malloc(1024);
   char *rp = result;
   int resultl = 1024;
-  
+
   for (;;)
     {
       size_t rl;
@@ -1979,6 +2001,7 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp,
 #if 0
              else if (!strcmp(repotype, "helix"))
                {
+                 extern int repo_add_helix(Repo *repo, FILE *fp, int flags);
                  repo_add_helix(repo, rfp, 0);
                  fclose(rfp);
                }
@@ -2008,10 +2031,12 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp,
              pool_debug(pool, SOLV_ERROR, "testcase_read: system: cannot change disttype to '%s'\n", pieces[2]);
 #endif
            }
-         if (strcmp(pieces[1], "unset") != 0)
-           pool_setarch(pool, pieces[1]);
-         else
+         if (strcmp(pieces[1], "unset") == 0)
            pool_setarch(pool, 0);
+         else if (pieces[1][0] == ':')
+           pool_setarchpolicy(pool, pieces[1] + 1);
+         else
+           pool_setarch(pool, pieces[1]);
          if (npieces > 3)
            {
              Repo *repo = testcase_str2repo(pool, pieces[3]);