Imported Upstream version 0.6.9 08/94108/1 upstream/0.6.9
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 27 Oct 2016 05:53:59 +0000 (14:53 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 27 Oct 2016 05:53:59 +0000 (14:53 +0900)
Change-Id: Icf4a1aa6525f6c2bfc9da6f3ba1609728f39a073
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
30 files changed:
VERSION.cmake
bindings/solv.i
ext/CMakeLists.txt
ext/libsolvext.ver
ext/pool_parserpmrichdep.c [new file with mode: 0644]
ext/pool_parserpmrichdep.h [new file with mode: 0644]
ext/repo_deb.c
ext/repo_deb.h
ext/repo_rpmdb.c
ext/repo_rpmmd.c
ext/repo_susetags.c
ext/testcase.c
ext/testcase.h
package/libsolv.changes
src/knownid.h
src/libsolv.ver
src/policy.c
src/repodata.c
src/rules.c
src/rules.h
src/solver.c
src/solver.h
src/solver_private.h
test/testcases/choose/default.t [new file with mode: 0644]
test/testcases/choose/enhanced.t [new file with mode: 0644]
test/testcases/choose/oldversion.t [new file with mode: 0644]
test/testcases/choose/suggested.t [new file with mode: 0644]
test/testcases/choose/versioned.t [new file with mode: 0644]
test/testcases/choose/versioned2.t [new file with mode: 0644]
test/testcases/namespace/namespaceprovides.t

index c129470..d1494ff 100644 (file)
@@ -49,5 +49,5 @@ SET(LIBSOLVEXT_SOVERSION "0")
 
 SET(LIBSOLV_MAJOR "0")
 SET(LIBSOLV_MINOR "6")
-SET(LIBSOLV_PATCH "8")
+SET(LIBSOLV_PATCH "9")
 
index 78e0021..50f0b50 100644 (file)
@@ -593,6 +593,17 @@ typedef struct {
 } Ruleinfo;
 
 typedef struct {
+  Solver *solv;
+  Id type;
+  Id rid;
+  Id from_id;
+  Id dep_id;
+  Id chosen_id;
+  Queue choices;
+  int level;
+} Alternative;
+
+typedef struct {
   Transaction *transaction;
   int mode;
   Id type;
@@ -785,6 +796,17 @@ typedef struct {
   Id const type;
 } Solutionelement;
 
+%nodefaultctor Alternative;
+typedef struct {
+  Solver *const solv;
+  Id const type;
+  Id const rid;
+  Id const from_id;
+  Id const dep_id;
+  Id const chosen_id;
+  int level;
+} Alternative;
+
 %nodefaultctor Transaction;
 %nodefaultdtor Transaction;
 typedef struct {
@@ -2858,6 +2880,40 @@ rb_eval_string(
     *OUTPUT = new_XRule($self, ruleid);
     return reason;
   }
+
+  int alternatives_count() {
+    return solver_alternatives_count($self);
+  }
+
+  %newobject alternative;
+  Alternative *alternative(Id aid) {
+    Alternative *a = solv_calloc(1, sizeof(*a));
+    a->solv = $self;
+    queue_init(&a->choices);
+    a->type = solver_get_alternative($self, aid, &a->dep_id, &a->from_id, &a->chosen_id, &a->choices, &a->level);
+    if (!a->type) {
+      queue_free(&a->choices);
+      solv_free(a);
+      return 0;
+    }
+    if (a->type == SOLVER_ALTERNATIVE_TYPE_RULE) {
+      a->rid = a->dep_id;
+      a->dep_id = 0;
+    }
+    return a;
+  }
+
+  %typemap(out) Queue all_alternatives Queue2Array(Alternative *, 1, Solver_alternative(arg1, id));
+  %newobject all_alternatives;
+  Queue all_alternatives() {
+    Queue q;
+    int i, cnt;
+    queue_init(&q);
+    cnt = solver_alternatives_count($self);
+    for (i = 1; i <= cnt; i++)
+      queue_push(&q, i);
+    return q;
+  }
 }
 
 %extend Transaction {
@@ -3202,3 +3258,60 @@ rb_eval_string(
 #endif
 }
 #endif
+
+%extend Alternative {
+  static const int SOLVER_ALTERNATIVE_TYPE_RULE = SOLVER_ALTERNATIVE_TYPE_RULE;
+  static const int SOLVER_ALTERNATIVE_TYPE_RECOMMENDS = SOLVER_ALTERNATIVE_TYPE_RECOMMENDS;
+  static const int SOLVER_ALTERNATIVE_TYPE_SUGGESTS = SOLVER_ALTERNATIVE_TYPE_SUGGESTS;
+
+  ~Alternative() {
+    queue_free(&$self->choices);
+    solv_free($self);
+  }
+  %newobject chosen;
+  XSolvable * const chosen;
+  %newobject rule;
+  XRule * const rule;
+  %newobject depsolvable;
+  XSolvable * const depsolvable;
+  %newobject dep;
+  Dep * const dep;
+  %{
+    SWIGINTERN XSolvable *Alternative_chosen_get(Alternative *a) {
+      return new_XSolvable(a->solv->pool, a->chosen_id);
+    }
+    SWIGINTERN XRule *Alternative_rule_get(Alternative *a) {
+      return new_XRule(a->solv, a->rid);
+    }
+    SWIGINTERN XSolvable *Alternative_depsolvable_get(Alternative *a) {
+      return new_XSolvable(a->solv->pool, a->from_id);
+    }
+    SWIGINTERN Dep *Alternative_dep_get(Alternative *a) {
+      return new_Dep(a->solv->pool, a->dep_id);
+    }
+  %}
+
+  Queue choices_raw() {
+    Queue r;
+    queue_init_clone(&r, &$self->choices);
+    return r;
+  }
+
+  %typemap(out) Queue choices Queue2Array(XSolvable *, 1, new_XSolvable(arg1->solv->pool, id));
+  Queue choices() {
+    int i;
+    Queue r;
+    queue_init_clone(&r, &$self->choices);
+    for (i = 0; i < r.count; i++)
+      if (r.elements[i] < 0)
+        r.elements[i] = -r.elements[i];
+    return r;
+  }
+
+#if defined(SWIGPERL)
+  %rename("str") __str__;
+#endif
+  const char *__str__() {
+    return solver_alternative2str($self->solv, $self->type, $self->type == SOLVER_ALTERNATIVE_TYPE_RULE ? $self->rid : $self->dep_id, $self->from_id);
+  }
+}
index 5f017f2..bdf949d 100644 (file)
@@ -43,6 +43,11 @@ IF (ENABLE_SUSEREPO)
        repo_susetags.h repo_zyppdb.h)
 ENDIF (ENABLE_SUSEREPO)
 
+IF (ENABLE_COMPLEX_DEPS AND (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB))
+    SET (libsolvext_SRCS ${libsolvext_SRCS}
+       pool_parserpmrichdep.c)
+ENDIF (ENABLE_COMPLEX_DEPS AND (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB))
+
 IF (SUSE)
     SET (libsolvext_SRCS ${libsolvext_SRCS}
        repo_autopattern.c)
index 5c176e2..654469b 100644 (file)
@@ -1,5 +1,6 @@
 SOLV_1.0 {
        global:
+               pool_deb_get_autoinstalled;
                pool_findfileconflicts;
                repo_add_appdata;
                repo_add_appdata_dir;
@@ -58,6 +59,7 @@ SOLV_1.0 {
                solvsig_free;
                solvsig_verify;
                testcase_add_testtags;
+               testcase_dep2str;
                testcase_job2str;
                testcase_solvid2str;
                testcase_str2dep;
diff --git a/ext/pool_parserpmrichdep.c b/ext/pool_parserpmrichdep.c
new file mode 100644 (file)
index 0000000..742823a
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2015, SUSE Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/* this is used by repo_rpmmd, repo_rpmdb, and repo_susetags */
+
+#include <stdio.h>
+
+#include "pool.h"
+#include "pool_parserpmrichdep.h"
+
+#define REL_THEN 0
+#define REL_ELSE 0
+
+static struct RichOpComp {
+  const char *n;
+  int l;
+  Id fl;
+} RichOps[] = {
+  { "&&", 2, REL_AND },
+  { "&", 1, REL_AND },
+  { "AND", 3, REL_AND },
+  { "||", 2, REL_OR },
+  { "|", 1, REL_OR },
+  { "OR", 2, REL_OR },
+  { "IF", 2, REL_COND },
+  { "THEN", 4, REL_THEN },
+  { "?", 1, REL_THEN },
+  { "ELSE", 4, REL_ELSE },
+  { ":", 1, REL_ELSE },
+  { NULL, 0, 0},
+};
+
+static Id
+parseRichDep(Pool *pool, const char **depp, Id chainfl)
+{
+  const char *p = *depp;
+  const char *n;
+  Id id, evr;
+  int fl, bl;
+  struct RichOpComp *op;
+
+  if (!chainfl && *p++ != '(')
+    return 0;
+  while (*p == ' ')
+    p++;
+  if (*p == ')')
+    return 0;
+  if (*p == '(')
+    {
+      id = parseRichDep(pool, &p, 0);
+      if (!id)
+       return 0;
+    }
+  else
+    {
+      n = p;
+      bl = 0;
+      while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
+       if (*p++ == '(')
+         bl++;
+      if (n == p)
+       return 0;
+      id = pool_strn2id(pool, n, p - n, 1);
+      while (*p == ' ')
+       p++;
+      if (*p)
+       {
+         fl = 0;
+         for (;; p++)
+           {
+             if (*p == '<')
+               fl |= REL_LT;
+             else if (*p == '=')
+               fl |= REL_EQ;
+             else if (*p == '>')
+               fl |= REL_GT;
+             else
+               break;
+           }
+         if (fl)
+           {
+             while (*p == ' ')
+               p++;
+             n = p;
+             bl = 0;
+             while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
+               if (*p++ == '(')
+                 bl++;
+             if (p - n > 2 && n[0] == '0' && n[1] == ':')
+               n += 2;         /* strip zero epoch */
+             if (n == p)
+               return 0;
+             id = pool_rel2id(pool, id, pool_strn2id(pool, n, p - n, 1), fl, 1);
+           }
+       }
+    }
+  while (*p == ' ')
+    p++;
+  if (!*p)
+    return 0;
+  if (*p == ')')
+    {
+      *depp = p + 1;
+      return id;
+    }
+  n = p;
+  while (*p && *p != ' ')
+    p++;
+  for (op = RichOps; op->n; op++)
+    if (p - n == op->l && !strncmp(n, op->n, op->l))
+      break;
+  fl = op->fl;
+  if (!fl)
+    return 0;
+  if (chainfl == REL_THEN && fl == REL_ELSE)
+    chainfl = 0;
+  if (chainfl && fl != chainfl)
+    return 0;
+  evr = parseRichDep(pool, &p, fl);
+  if (!evr)
+    return 0;
+  *depp = p;
+  return pool_rel2id(pool, id, evr, fl, 1);
+}
+
+Id
+pool_parserpmrichdep(Pool *pool, const char *dep)
+{
+  Id id = parseRichDep(pool, &dep, 0);
+  if (id && *dep)
+    id = 0;
+  return id;
+}
+
diff --git a/ext/pool_parserpmrichdep.h b/ext/pool_parserpmrichdep.h
new file mode 100644 (file)
index 0000000..09dce2c
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2014, SUSE Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+#ifndef POOL_PARSERPMRICHDEP_H
+#define POOL_PARSERPMRICHDEP_H
+
+#include "pool.h"
+
+extern Id pool_parserpmrichdep(Pool *pool, const char *dep);
+
+#endif
index 5af0c70..05d731b 100644 (file)
@@ -17,6 +17,7 @@
 #include "pool.h"
 #include "repo.h"
 #include "util.h"
+#include "solver.h"    /* for GET_USERINSTALLED_ flags */
 #include "chksum.h"
 #include "repo_deb.h"
 
@@ -204,7 +205,7 @@ control2solvable(Solvable *s, Repodata *data, char *control)
       if (*p)
         *p++ = 0;
       /* strip trailing space */
-      while (end >= control && *end == ' ' && *end == '\t')
+      while (end >= control && (*end == ' ' || *end == '\t'))
        *end-- = 0;
       tag = control;
       control = p;
@@ -313,6 +314,10 @@ control2solvable(Solvable *s, Repodata *data, char *control)
              havesource = 1;
            }
          break;
+       case 'S' << 8 | 'T':
+         if (!strcasecmp(tag, "status"))
+           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_INSTALLSTATUS, q);
+         break;
        case 'S' << 8 | 'U':
          if (!strcasecmp(tag, "suggests"))
            s->suggests = makedeps(repo, q, s->suggests, 0);
@@ -613,3 +618,92 @@ repo_add_deb(Repo *repo, const char *deb, int flags)
     repodata_internalize(data);
   return s - pool->solvables;
 }
+
+void
+pool_deb_get_autoinstalled(Pool *pool, FILE *fp, Queue *q, int flags)
+{
+  Id name = 0, arch = 0;
+  int autoinstalled = -1;
+  char *buf, *bp;
+  int x, l, bufl, eof = 0;
+  Id p, pp;
+
+  queue_empty(q);
+  buf = solv_malloc(4096);
+  bufl = 4096;
+  l = 0;
+  while (!eof)
+    {
+      while (bufl - l < 1024)
+       {
+         bufl += 4096;
+         if (bufl > 1024 * 64)
+           break;      /* hmm? */
+         buf = solv_realloc(buf, bufl);
+       }
+      if (!fgets(buf + l, bufl - l, fp))
+       {
+         eof = 1;
+         buf[l] = '\n';
+         buf[l + 1] = 0;
+       }
+      l = strlen(buf);
+      if (l && buf[l - 1] == '\n')
+       buf[--l] = 0;
+      if (!*buf || eof)
+       {
+         l = 0;
+         if (name && autoinstalled > 0)
+           {
+             if ((flags & GET_USERINSTALLED_NAMES) != 0)
+               queue_push(q, name);
+             else
+               {
+                 FOR_PROVIDES(p, pp, name)
+                   {
+                     Solvable *s = pool->solvables + p;
+                     if (s->name != name)
+                       continue;
+                     if (arch && s->arch != arch)
+                       continue;
+                     queue_push(q, p);
+                   }
+               }
+           }
+         name = arch = 0;
+         autoinstalled = -1;
+         continue;
+       }
+      /* strip trailing space */
+      while (l && (buf[l - 1] == ' ' || buf[l - 1] == '\t'))
+       buf[--l] = 0;
+      l = 0;
+
+      bp = strchr(buf, ':');
+      if (!bp || bp - buf < 4)
+       continue;
+      *bp++ = 0;
+      while (*bp == ' ' || *bp == '\t')
+       bp++;
+      x = '@' + (buf[0] & 0x1f);
+      x = (x << 8) + '@' + (buf[1] & 0x1f);
+      switch(x)
+       {
+       case 'P' << 8 | 'A':
+         if (!strcasecmp(buf, "package"))
+           name = pool_str2id(pool, bp, 1);
+         break;
+       case 'A' << 8 | 'R':
+         if (!strcasecmp(buf, "architecture"))
+           arch = pool_str2id(pool, bp, 1);
+         break;
+       case 'A' << 8 | 'U':
+         if (!strcasecmp(buf, "auto-installed"))
+           autoinstalled = atoi(bp);
+         break;
+       default:
+         break;
+       }
+    }
+}
+
index 7057da6..5993991 100644 (file)
@@ -8,5 +8,6 @@
 extern int repo_add_debpackages(Repo *repo, FILE *fp, int flags);
 extern int repo_add_debdb(Repo *repo, int flags);
 extern Id repo_add_deb(Repo *repo, const char *deb, int flags);
+extern void pool_deb_get_autoinstalled(Pool *pool, FILE *fp, Queue *q, int flags);
 
 #define DEBS_ADD_WITH_PKGID    (1 << 8)
index b4541c3..71c69ab 100644 (file)
@@ -47,6 +47,9 @@
 #include "chksum.h"
 #include "repo_rpmdb.h"
 #include "repo_solv.h"
+#ifdef ENABLE_COMPLEX_DEPS
+#include "pool_parserpmrichdep.h"
+#endif
 
 /* 3: added triggers */
 /* 4: fixed triggers */
 #define DEP_STRONG             (1 << 27)
 #define DEP_PRE_IN             ((1 << 6) | (1 << 9) | (1 << 10))
 #define DEP_PRE_UN             ((1 << 6) | (1 << 11) | (1 << 12))
+#define DEP_RICH               (1 << 29)
 
 #define FILEFLAG_GHOST         (1 <<  6)
 
@@ -404,7 +408,6 @@ setutf8string(Repodata *repodata, Id handle, Id tag, const char *str)
     repodata_set_str(repodata, handle, tag, str);
 }
 
-
 /*
  * strong: 0: ignore strongness
  *         1: filter to strong
@@ -512,6 +515,7 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf,
   ida = repo->idarraydata + olddeps;
   for (i = 0; ; i++)
     {
+      Id id;
       if (i == nc)
        {
          if (haspre != 1)
@@ -532,9 +536,21 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf,
       if ((flags & RPM_ADD_NO_RPMLIBREQS) != 0)
        if (!strncmp(n[i], "rpmlib(", 7))
          continue;
+#ifdef ENABLE_COMPLEX_DEPS
+      if ((f[i] & (DEP_RICH|DEP_LESS| DEP_EQUAL|DEP_GREATER)) == DEP_RICH && n[i][0] == '(')
+       {
+         id = pool_parserpmrichdep(pool, n[i]);
+         if (id)
+           *ida++ = id;
+         else
+           cc--;
+         continue;
+       }
+#endif
+      id = pool_str2id(pool, n[i], 1);
       if (f[i] & (DEP_LESS|DEP_GREATER|DEP_EQUAL))
        {
-         Id name, evr;
+         Id evr;
          int fl = 0;
          if ((f[i] & DEP_LESS) != 0)
            fl |= REL_LT;
@@ -542,15 +558,13 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf,
            fl |= REL_EQ;
          if ((f[i] & DEP_GREATER) != 0)
            fl |= REL_GT;
-         name = pool_str2id(pool, n[i], 1);
          if (v[i][0] == '0' && v[i][1] == ':' && v[i][2])
            evr = pool_str2id(pool, v[i] + 2, 1);
          else
            evr = pool_str2id(pool, v[i], 1);
-         *ida++ = pool_rel2id(pool, name, evr, fl, 1);
+         id = pool_rel2id(pool, id, evr, fl, 1);
        }
-      else
-        *ida++ = pool_str2id(pool, n[i], 1);
+      *ida++ = id;
     }
   *ida++ = 0;
   repo->idarraysize += cc + 1;
index 21dd913..4272b6f 100644 (file)
@@ -19,7 +19,9 @@
 #include "tools_util.h"
 #include "repo_rpmmd.h"
 #include "chksum.h"
-
+#ifdef ENABLE_COMPLEX_DEPS
+#include "pool_parserpmrichdep.h"
+#endif
 
 enum state {
   STATE_START,
@@ -466,7 +468,7 @@ static char *flagtab[] = {
 static unsigned int
 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq)
 {
-  Id id, name, marker;
+  Id id, marker;
   const char *n, *f, *k;
   const char **a;
 
@@ -496,10 +498,18 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts
          pd->acontent = l + 256;
        }
       sprintf(pd->content, "%s:%s", k, n);
-      name = pool_str2id(pool, pd->content, 1);
+      id = pool_str2id(pool, pd->content, 1);
+    }
+#ifdef ENABLE_COMPLEX_DEPS
+  else if (!f && n[0] == '(')
+    {
+      id = pool_parserpmrichdep(pool, n);
+      if (!id)
+       return olddeps;
     }
+#endif
   else
-    name = pool_str2id(pool, (char *)n, 1);
+    id = pool_str2id(pool, (char *)n, 1);
   if (f)
     {
       Id evr = makeevr_atts(pool, pd, atts);
@@ -508,10 +518,8 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts
        if (!strcmp(f, flagtab[flags]))
          break;
       flags = flags < 6 ? flags + 1 : 0;
-      id = pool_rel2id(pool, name, evr, flags, 1);
+      id = pool_rel2id(pool, id, evr, flags, 1);
     }
-  else
-    id = name;
 #if 0
   fprintf(stderr, "new dep %s\n", pool_dep2str(pool, id));
 #endif
index 440e2d5..a96ba97 100644 (file)
@@ -18,6 +18,9 @@
 #include "chksum.h"
 #include "tools_util.h"
 #include "repo_susetags.h"
+#ifdef ENABLE_COMPLEX_DEPS
+#include "pool_parserpmrichdep.h"
+#endif
 
 struct datashare {
   Id name;
@@ -87,6 +90,17 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id ma
       /* A file dependency. Do not try to parse it */
       id = pool_str2id(pool, line + 6, 1);
     }
+#ifdef ENABLE_COMPLEX_DEPS
+  else if (line[6] == '(')
+    {
+      id = pool_parserpmrichdep(pool, line + 6);
+      if (!id)
+       {
+         pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
+          return olddeps;
+       }
+    }
+#endif
   else
     {
       i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
index fa9c807..f0057e6 100644 (file)
@@ -77,6 +77,7 @@ static struct resultflags2str {
   { TESTCASE_RESULT_ORPHANED,          "orphaned" },
   { TESTCASE_RESULT_RECOMMENDED,       "recommended" },
   { TESTCASE_RESULT_UNNEEDED,          "unneeded" },
+  { TESTCASE_RESULT_ALTERNATIVES,      "alternatives" },
   { 0, 0 }
 };
 
@@ -284,151 +285,339 @@ strqueue_diff(Strqueue *sq1, Strqueue *sq2, Strqueue *osq)
     strqueue_pushjoin(osq, "+", sq2->str[j++], 0);
 }
 
-static inline int
-pool_isknownarch(Pool *pool, Id id)
-{
-  if (!id || id == ID_EMPTY)
-    return 0;
-  if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
-    return 1;
-  if (!pool->id2arch || (id > pool->lastarch || !pool->id2arch[id]))
-    return 0;
-  return 1;
-}
 
-static Id
-testcase_str2dep_simple(Pool *pool, const char **sp)
+static const char *
+testcase_id2str(Pool *pool, Id id, int isname)
 {
-  const char *s = *sp;
-  const char *n, *a;
-  Id id, evr;
-  int flags;
-
-  while (*s == ' ' || *s == '\t')
-    s++;
-  n = s;
-  while (*s && *s != ' ' && *s != '\t' && *s != '<' && *s != '=' && *s != '>')
-    {
-      if (*s == '(')
+  const char *s = pool_id2str(pool, id);
+  const char *ss;
+  char *s2, *s2p;
+  int bad = 0, paren = 0, parenbad = 0;
+
+  if (id == 0)
+    return "<NULL>";
+  if (id == 1)
+    return "\\00";
+  if (strchr("[(<=>!", *s))
+    bad++;
+  if (!strncmp(s, "namespace:", 10))
+    bad++;
+  for (ss = s + bad; *ss; ss++)
+    {
+      if (*ss == ' ' || *ss == '\\' || *(unsigned char *)ss < 32 || *ss == '(' || *ss == ')')
+        bad++;
+      if (*ss == '(')
+       paren = paren == 0 ? 1 : -1;
+      else if (*ss == ')')
        {
-         while (*s && *s != ')')
-           s++;
-         continue;
+         paren = paren == 1 ? 0 : -1;
+         if (!paren)
+           parenbad += 2;
        }
-      s++;
     }
-  if ((a = strchr(n, '.')) != 0 && a + 1 < s && s[-1] != ')')
+  if (isname && ss - s > 4 && !strcmp(ss - 4, ":any"))
+    bad++;
+  if (!paren && !(bad - parenbad))
+    return s;
+
+  /* we need escaping! */
+  s2 = s2p = pool_alloctmpspace(pool, strlen(s) + bad * 2 + 1);
+  ss = s;
+  if (!strncmp(s, "namespace:", 10))
     {
-      Id archid = pool_strn2id(pool, a + 1, s - (a + 1), 0);
-      if (pool_isknownarch(pool, archid))
+      strcpy(s2p, "namespace\\3a");
+      s2p += 12;
+      s += 10;
+    }
+  for (; *ss; ss++)
+    {
+      *s2p++ = *ss;
+      if ((ss == s && strchr("[(<=>!", *s)) || *ss == ' ' || *ss == '\\' || *(unsigned char *)ss < 32 || *ss == '(' || *ss == ')')
        {
-          id = pool_strn2id(pool, n, a - n, 1);
-         id = pool_rel2id(pool, id, archid, REL_ARCH, 1);
+         s2p[-1] = '\\';
+         solv_bin2hex((unsigned char *)ss, 1, s2p);
+         s2p += 2;
        }
-      else
-        id = pool_strn2id(pool, n, s - n, 1);
     }
-  else if (s - n > 4 && s[-4] == ':' && !strncmp(s - 4, ":any", 4))
+  *s2p = 0;
+  if (isname && s2p - s2 > 4 && !strcmp(s2p - 4, ":any"))
+    strcpy(s2p - 4, "\\3aany");
+  return s2;
+}
+
+struct oplist {
+  Id flags;
+  const char *opname;
+} oplist[] = {
+  { REL_EQ, "=" },
+  { REL_GT | REL_LT | REL_EQ, "<=>" },
+  { REL_LT | REL_EQ, "<=" },
+  { REL_GT | REL_EQ, ">=" },
+  { REL_GT, ">" },
+  { REL_GT | REL_LT, "<>" },
+  { REL_AND,   "&" },
+  { REL_OR ,   "|" },
+  { REL_WITH , "+" },
+  { REL_NAMESPACE , "<NAMESPACE>" },
+  { REL_ARCH,       "." },
+  { REL_MULTIARCH,  "<MULTIARCH>" },
+  { REL_FILECONFLICT,  "<FILECONFLICT>" },
+  { REL_COND,  "<IF>" },
+  { REL_COMPAT,  "compat >=" },
+  { REL_KIND,  "<KIND>" },
+  { REL_LT, "<" },
+  { 0, 0 }
+};
+
+static const char *
+testcase_dep2str_complex(Pool *pool, Id id, int addparens)
+{
+  Reldep *rd;
+  char *s;
+  const char *s2;
+  int needparens;
+  struct oplist *op;
+
+  if (!ISRELDEP(id))
+    return testcase_id2str(pool, id, 1);
+  rd = GETRELDEP(pool, id);
+
+  /* check for special shortcuts */
+  if (rd->flags == REL_NAMESPACE && !ISRELDEP(rd->name) && !strncmp(pool_id2str(pool, rd->name), "namespace:", 10))
     {
-      id = pool_strn2id(pool, n, s - n - 4, 1);
-      id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
+      const char *ns = pool_id2str(pool, rd->name);
+      int nslen = strlen(ns);
+      /* special namespace formatting */
+      const char *evrs = testcase_dep2str_complex(pool, rd->evr, 0);
+      s = pool_tmpappend(pool, evrs, ns, "()");
+      memmove(s + nslen + 1, s, strlen(s) - nslen - 2);
+      memcpy(s, ns, nslen);
+      s[nslen] = '(';
+      return s;
+    }
+  if (rd->flags == REL_MULTIARCH && !ISRELDEP(rd->name) && rd->evr == ARCH_ANY)
+    {
+      /* special :any suffix */
+      const char *ns = testcase_id2str(pool, rd->name, 1);
+      return pool_tmpappend(pool, ns, ":any", 0);
+    }
+
+  needparens = 0;
+  if (ISRELDEP(rd->name))
+    {
+      Reldep *rd2 = GETRELDEP(pool, rd->name);
+      needparens = 1;
+      if (rd->flags > 7 && rd->flags != REL_COMPAT && rd2->flags && rd2->flags <= 7)
+       needparens = 0;
+    }
+  s = (char *)testcase_dep2str_complex(pool, rd->name, needparens);
+
+  if (addparens)
+    {
+      s = pool_tmpappend(pool, s, "(", 0);
+      memmove(s + 1, s, strlen(s + 1));
+      s[0] = '(';
+    }
+  for (op = oplist; op->flags; op++)
+    if (rd->flags == op->flags)
+      break;
+  if (op->flags)
+    {
+      s = pool_tmpappend(pool, s, " ", op->opname);
+      s = pool_tmpappend(pool, s, " ", 0);
     }
   else
-    id = pool_strn2id(pool, n, s - n, 1);
-  if (!*s)
     {
-      *sp = s;
-      return id;
+      char buf[64];
+      sprintf(buf, " <%u> ", rd->flags);
+      s = pool_tmpappend(pool, s, buf, 0);
     }
-  while (*s == ' ' || *s == '\t')
-    s++;
-  flags = 0;
-  if (*s == '!' && s[1] == '=')        /* support != as synonym for <> */
+
+  needparens = 0;
+  if (ISRELDEP(rd->evr))
+    {
+      Reldep *rd2 = GETRELDEP(pool, rd->evr);
+      needparens = 1;
+      if (rd->flags > 7 && rd2->flags && rd2->flags <= 7)
+       needparens = 0;
+      if (rd->flags == REL_AND && rd2->flags == REL_AND)
+       needparens = 0; /* chain */
+      if (rd->flags == REL_OR && rd2->flags == REL_OR)
+       needparens = 0; /* chain */
+      if (rd->flags > 0 && rd->flags < 8 && rd2->flags == REL_COMPAT)
+       needparens = 0; /* chain */
+    }
+  if (!ISRELDEP(rd->evr))
+    s2 = testcase_id2str(pool, rd->evr, 0);
+  else
+    s2 = testcase_dep2str_complex(pool, rd->evr, needparens);
+  if (addparens)
+    s = pool_tmpappend(pool, s, s2, ")");
+  else
+    s = pool_tmpappend(pool, s, s2, 0);
+  pool_freetmpspace(pool, s2);
+  return s;
+}
+
+const char *
+testcase_dep2str(Pool *pool, Id id)
+{
+  return testcase_dep2str_complex(pool, id, 0);
+}
+
+
+/* Convert a simple string. Also handle the :any suffix */
+static Id
+testcase_str2dep_simple(Pool *pool, const char **sp, int isname)
+{
+  int haveesc = 0;
+  int paren = 0;
+  int isany = 0;
+  Id id;
+  const char *s;
+  for (s = *sp; *s; s++)
     {
-      flags = REL_LT | REL_GT;
-      s += 2;
+      if (*s == '\\')
+       haveesc++;
+      if (*s == ' ' || *(unsigned char *)s < 32)
+       break;
+      if (*s == '(')
+       paren++;
+      if (*s == ')' && paren-- <= 0)
+       break;
     }
-  for (;;s++)
+  if (isname && s - *sp > 4 && !strncmp(s - 4, ":any", 4))
     {
-      if (*s == '<')
-       flags |= REL_LT;
-      else if (*s == '=')
-       flags |= REL_EQ;
-      else if (*s == '>')
-       flags |= REL_GT;
+      isany = 1;
+      s -= 4;
+    }
+  if (!haveesc)
+    {
+      if (s - *sp == 6 && !strncmp(*sp, "<NULL>", 6))
+       id = 0;
       else
-       break;
+        id = pool_strn2id(pool, *sp, s - *sp, 1);
     }
-  if (!flags)
+  else if (s - *sp == 3 && !strncmp(*sp, "\\00", 3))
+    id = 1;
+  else
     {
-      *sp = s;
-      return id;
+      char buf[128], *bp, *bp2;
+      const char *sp2;
+      bp = s - *sp >= 128 ? solv_malloc(s - *sp + 1) : buf;
+      for (bp2 = bp, sp2 = *sp; sp2 < s;)
+       {
+         *bp2++ = *sp2++;
+         if (bp2[-1] == '\\')
+           solv_hex2bin(&sp2, (unsigned char *)bp2 - 1, 1);
+       }
+      *bp2 = 0;
+      id = pool_str2id(pool, bp, 1);
+      if (bp != buf)
+       solv_free(bp);
     }
-  while (*s == ' ' || *s == '\t')
-    s++;
-  n = s;
-  while (*s && *s != ' ' && *s != '\t')
-    s++;
-  evr = pool_strn2id(pool, n, s - n, 1);
-  if (*s == ' ' && !strcmp(s, " compat >= "))
+  if (isany)
     {
-      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);
+      id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
+      s += 4;
     }
   *sp = s;
-  return pool_rel2id(pool, id, evr, flags, 1);
+  return id;
 }
 
+
 static Id
-testcase_str2dep_complex(Pool *pool, const char **sp)
+testcase_str2dep_complex(Pool *pool, const char **sp, int relop)
 {
   const char *s = *sp;
-  Id id;
-#ifdef ENABLE_COMPLEX_DEPS
+  Id flags, id, id2, namespaceid = 0;
+  struct oplist *op;
+
   while (*s == ' ' || *s == '\t')
     s++;
-  if (*s == '(')
+  if (!strncmp(s, "namespace:", 10))
     {
-      s++;
-      id = testcase_str2dep_complex(pool, &s);
-      if (*s == ')')
-       s++;
-      while (*s == ' ' || *s == '\t')
-       s++;
+      /* special namespace hack */
+      const char *s2;
+      for (s2 = s + 10; *s2 && *s2 != '('; s2++)
+       ;
+      if (*s2 == '(')
+       {
+         namespaceid = pool_strn2id(pool, s, s2 - s, 1);
+         s = s2;
+       }
     }
-  else
-#endif
-    id = testcase_str2dep_simple(pool, &s);
-  if (*s == '|')
+  if (*s == '(')
     {
       s++;
-      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_OR, 1);
-    }
-  else if (*s == '&')
-    {
+      id = testcase_str2dep_complex(pool, &s, 0);
+      if (!s || *s != ')')
+       {
+         *sp = 0;
+         return 0;
+       }
       s++;
-      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_AND, 1);
     }
-  else if (*s == 'I' && s[1] == 'F' && (s[2] == ' ' || s[2] == '\t'))
+  else
+    id = testcase_str2dep_simple(pool, &s, relop ? 0 : 1);
+  if (namespaceid)
+    id = pool_rel2id(pool, namespaceid, id, REL_NAMESPACE, 1);
+    
+  for (;;)
     {
-      s += 2;
-      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_COND, 1);
+      while (*s == ' ' || *s == '\t')
+       s++;
+      if (!*s || *s == ')' || (relop && strncmp(s, "compat >= ", 10) != 0))
+       {
+         *sp = s;
+         return id;
+       }
+
+      /* we have an op! Find the end */
+      flags = -1;
+      if (s[0] == '<' && (s[1] >= '0' && s[1] <= '9'))
+       {
+         const char *s2;
+         for (s2 = s + 1; *s2 >= '0' && *s2 <= '9'; s2++)
+           ;
+         if (*s2 == '>')
+           {
+             flags = strtoul(s + 1, 0, 10);
+             s = s2 + 1;
+           }
+       }
+      if (flags == -1)
+       {
+         for (op = oplist; op->flags; op++)
+           if (!strncmp(s, op->opname, strlen(op->opname)))
+             break;
+         if (!op->flags)
+           {
+             *sp = 0;
+             return 0;
+           }
+         flags = op->flags;
+         s += strlen(op->opname);
+       }
+      id2 = testcase_str2dep_complex(pool, &s, flags > 0 && flags < 8);
+      if (!s)
+       {
+         *sp = 0;
+         return 0;
+       }
+      id = pool_rel2id(pool, id, id2, flags, 1);
     }
-  *sp = s;
-  return id;
 }
 
 Id
 testcase_str2dep(Pool *pool, const char *s)
 {
-  return testcase_str2dep_complex(pool, &s);
+  Id id = testcase_str2dep_complex(pool, &s, 0);
+  return s && !*s ? id : 0;
 }
 
+/**********************************************************/
+
 const char *
 testcase_repoid2str(Pool *pool, Id repoid)
 {
@@ -597,12 +786,12 @@ testcase_job2str(Pool *pool, Id how, Id what)
   else if (select == SOLVER_SOLVABLE_NAME)
     {
       selstr = " name ";
-      pkgstr = pool_dep2str(pool, what);
+      pkgstr = testcase_dep2str(pool, what);
     }
   else if (select == SOLVER_SOLVABLE_PROVIDES)
     {
       selstr = " provides ";
-      pkgstr = pool_dep2str(pool, what);
+      pkgstr = testcase_dep2str(pool, what);
     }
   else if (select == SOLVER_SOLVABLE_ONE_OF)
     {
@@ -920,14 +1109,13 @@ static void
 writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off)
 {
   Pool *pool = repo->pool;
-  Id id, *dp, *prvdp;
+  Id id, *dp;
   int tagwritten = 0;
   const char *idstr;
 
   if (!off)
     return;
   dp = repo->idarraydata + off;
-  prvdp = 0;
   while ((id = *dp++) != 0)
     {
       if (key == SOLVABLE_REQUIRES && id == SOLVABLE_PREREQMARKER)
@@ -939,68 +1127,8 @@ writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off
          continue;
        }
       if (key == SOLVABLE_PROVIDES && id == SOLVABLE_FILEMARKER)
-       {
-         prvdp = dp;
-         continue;
-       }
-      idstr = pool_dep2str(pool, id);
-      if (ISRELDEP(id))
-       {
-         Reldep *rd = GETRELDEP(pool, id);
-         if (key == SOLVABLE_CONFLICTS && rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_OTHERPROVIDERS)
-           {
-             if (!strncmp(idstr, "namespace:", 10))
-               idstr += 10;
-           }
-         if (key == SOLVABLE_SUPPLEMENTS)
-           {
-             if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_FILESYSTEM)
-               {
-                 if (!strncmp(idstr, "namespace:", 10))
-                   idstr += 10;
-               }
-             else if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_MODALIAS)
-               {
-                 if (!strncmp(idstr, "namespace:", 10))
-                   idstr += 10;
-               }
-             else if (rd->flags == REL_AND)
-               {
-                 /* either packageand chain or modalias */
-                 idstr = 0;
-                 if (ISRELDEP(rd->evr))
-                   {
-                     Reldep *mrd = GETRELDEP(pool, rd->evr);
-                     if (mrd->flags == REL_NAMESPACE && mrd->name == NAMESPACE_MODALIAS)
-                       {
-                         idstr = pool_tmpjoin(pool, "modalias(", pool_dep2str(pool, rd->name), ":");
-                         idstr = pool_tmpappend(pool, idstr, pool_dep2str(pool, mrd->evr), ")");
-                       }
-                     else if (mrd->flags >= 8)
-                       continue;
-                   }
-                 if (!idstr)
-                   {
-                     /* must be and chain */
-                     idstr = pool_dep2str(pool, rd->evr);
-                     for (;;)
-                       {
-                         id = rd->name;
-                         if (!ISRELDEP(id))
-                           break;
-                         rd = GETRELDEP(pool, id);
-                         if (rd->flags != REL_AND)
-                           break;
-                         idstr = pool_tmpjoin(pool, pool_dep2str(pool, rd->evr), ":", idstr);
-                       }
-                     idstr = pool_tmpjoin(pool, pool_dep2str(pool, id), ":", idstr);
-                     idstr = pool_tmpjoin(pool, "packageand(", idstr, ")");
-                   }
-               }
-             else if (rd->flags >= 8)
-               continue;
-           }
-       }
+       continue;
+      idstr = testcase_dep2str(pool, id);
       if (!tagwritten)
        {
          fprintf(fp, "+%s\n", tag);
@@ -1008,36 +1136,31 @@ writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off
        }
       fprintf(fp, "%s\n", idstr);
     }
-  if (key == SOLVABLE_PROVIDES)
+  if (tagwritten)
+    fprintf(fp, "-%s\n", tag);
+}
+
+static void
+writefilelist(Repo *repo, FILE *fp, const char *tag, Solvable *s)
+{
+  Pool *pool = repo->pool;
+  int tagwritten = 0;
+  Dataiterator di;
+
+  dataiterator_init(&di, pool, repo, s - pool->solvables, SOLVABLE_FILELIST, 0, 0);
+  while (dataiterator_step(&di))
     {
-      /* add the filelist */
-      Dataiterator di;
-      dataiterator_init(&di, pool, repo, s - pool->solvables, SOLVABLE_FILELIST, 0, 0);
-      while (dataiterator_step(&di))
+      const char *s = repodata_dir2str(di.data, di.kv.id, di.kv.str);
+      if (!tagwritten)
        {
-         const char *s = repodata_dir2str(di.data, di.kv.id, di.kv.str);
-         if (prvdp)
-           {
-             Id id = pool_str2id(pool, s, 0);
-             if (id)
-               {
-                 for (dp = prvdp; *dp; dp++)
-                   if (*dp == id)
-                     break;
-                 if (*dp)
-                   continue;   /* already included */
-               }
-           }
-         if (!tagwritten)
-           {
-             fprintf(fp, "+%s", tag);
-             tagwritten = 1;
-           }
-         fprintf(fp, "%s\n", s);
+         fprintf(fp, "+%s\n", tag);
+         tagwritten = 1;
        }
+      fprintf(fp, "%s\n", s);
     }
   if (tagwritten)
     fprintf(fp, "-%s\n", tag);
+  dataiterator_free(&di);
 }
 
 int
@@ -1053,7 +1176,7 @@ testcase_write_testtags(Repo *repo, FILE *fp)
   const char *tmp;
   unsigned int ti;
 
-  fprintf(fp, "=Ver: 2.0\n");
+  fprintf(fp, "=Ver: 3.0\n");
   FOR_REPO_SOLVABLES(repo, p, s)
     {
       name = pool_id2str(pool, s->name);
@@ -1079,6 +1202,7 @@ testcase_write_testtags(Repo *repo, FILE *fp)
       ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
       if (ti)
        fprintf(fp, "=Tim: %u\n", ti);
+      writefilelist(repo, fp, "Fls:", s);
     }
   return 0;
 }
@@ -1091,7 +1215,7 @@ adddep(Repo *repo, Offset olddeps, char *str, Id marker)
 }
 
 static void
-finish_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
+finish_v2_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
 {
   if (nfilelist)
     {
@@ -1110,8 +1234,6 @@ finish_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfi
          repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
        }
     }
-  if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
-    s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
   s->supplements = repo_fix_supplements(s->repo, s->provides, s->supplements, 0);
   s->conflicts = repo_fix_conflicts(s->repo, s->conflicts);
 }
@@ -1132,6 +1254,8 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags)
   char *filelist = 0;
   int afilelist = 0;
   int nfilelist = 0;
+  int tagsversion = 0;
+  int addselfprovides = 1;     /* for compat reasons */
 
   data = repo_add_repodata(repo, flags);
   s = 0;
@@ -1181,9 +1305,18 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags)
       tag = line[1] << 16 | line[2] << 8 | line[3];
       switch(tag)
         {
+       case 'V' << 16 | 'e' << 8 | 'r':
+         tagsversion = atoi(line + 6);
+         addselfprovides = tagsversion < 3 || strstr(line + 6, "addselfprovides") != 0;
+         break;
        case 'P' << 16 | 'k' << 8 | 'g':
          if (s)
-           finish_solvable(pool, data, s, filelist, nfilelist);
+           {
+             if (tagsversion == 2)
+               finish_v2_solvable(pool, data, s, filelist, nfilelist);
+             if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+               s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
+           }
          nfilelist = 0;
          if (split(line + 5, sp, 5) != 4)
            break;
@@ -1213,27 +1346,44 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags)
          s->requires = adddep(repo, s->requires, line + 6, SOLVABLE_PREREQMARKER);
          break;
        case 'P' << 16 | 'r' << 8 | 'v':
-         if (line[6] == '/')
+         /* version 2 had the file list at the end of the provides */
+         if (tagsversion == 2)
            {
-             int l = strlen(line + 6) + 1;
-             if (nfilelist + l > afilelist)
+             if (line[6] == '/')
                {
-                 afilelist = nfilelist + l + 512;
-                 filelist = solv_realloc(filelist, afilelist);
+                 int l = strlen(line + 6) + 1;
+                 if (nfilelist + l > afilelist)
+                   {
+                     afilelist = nfilelist + l + 512;
+                     filelist = solv_realloc(filelist, afilelist);
+                   }
+                 memcpy(filelist + nfilelist, line + 6, l);
+                 nfilelist += l;
+                 break;
+               }
+             if (nfilelist)
+               {
+                 int l;
+                 for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
+                   s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
+                 nfilelist = 0;
                }
-             memcpy(filelist + nfilelist, line + 6, l);
-             nfilelist += l;
-             break;
-           }
-         if (nfilelist)
-           {
-             int l;
-             for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
-                s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
-              nfilelist = 0;
            }
          s->provides = adddep(repo, s->provides, line + 6, 0);
          break;
+       case 'F' << 16 | 'l' << 8 | 's':
+         {
+           char *p = strrchr(line + 6, '/');
+           Id did;
+           if (!p)
+             break;
+           *p++ = 0;
+           did = repodata_str2dir(data, line + 6, 1);
+           if (!did)
+             did = repodata_str2dir(data, "/", 1);
+           repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
+           break;
+         }
        case 'O' << 16 | 'b' << 8 | 's':
          s->obsoletes = adddep(repo, s->obsoletes, line + 6, 0);
          break;
@@ -1257,7 +1407,12 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags)
         }
     }
   if (s)
-    finish_solvable(pool, data, s, filelist, nfilelist);
+    {
+      if (tagsversion == 2)
+       finish_v2_solvable(pool, data, s, filelist, nfilelist);
+      if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+        s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
+    }
   solv_free(line);
   solv_free(filelist);
   repodata_free_dircache(data);
@@ -1470,6 +1625,33 @@ testcase_solutionid(Solver *solv, Id problem, Id solution)
   return s;
 }
 
+static const char *
+testcase_alternativeid(Solver *solv, int type, Id id, Id from)
+{
+  const char *s;
+  Pool *pool = solv->pool;
+  Chksum *chk;
+  const unsigned char *md5;
+  int md5l;
+  chk = solv_chksum_create(REPOKEY_TYPE_MD5);
+  if (type == SOLVER_ALTERNATIVE_TYPE_RECOMMENDS)
+    {
+      s = testcase_solvid2str(pool, from);
+      solv_chksum_add(chk, s, strlen(s) + 1);
+      s = testcase_dep2str(pool, id);
+      solv_chksum_add(chk, s, strlen(s) + 1);
+    }
+  else if (type == SOLVER_ALTERNATIVE_TYPE_RULE)
+    {
+      s = testcase_ruleid(solv, id);
+      solv_chksum_add(chk, s, strlen(s) + 1);
+    }
+  md5 = solv_chksum_get(chk, &md5l);
+  s = pool_bin2hex(pool, md5, 4);
+  chk = solv_chksum_free(chk, 0);
+  return s;
+}
+
 static struct class2str {
   Id class;
   const char *str;
@@ -1626,6 +1808,72 @@ testcase_solverresult(Solver *solv, int resultflags)
       queue_free(&q);
       queue_free(&qf);
     }
+  if ((resultflags & TESTCASE_RESULT_ALTERNATIVES) != 0)
+    {
+      char *altprefix;
+      Queue q, rq;
+      int cnt;
+      Id alternative;
+      queue_init(&q);
+      queue_init(&rq);
+      cnt = solver_alternatives_count(solv);
+      for (alternative = 1; alternative <= cnt; alternative++)
+       {
+         Id id, from, chosen;
+         char num[20];
+         int type = solver_get_alternative(solv, alternative, &id, &from, &chosen, &q, 0);
+         altprefix = solv_dupjoin("alternative ", testcase_alternativeid(solv, type, id, from), " ");
+         strcpy(num, " 0 ");
+         if (type == SOLVER_ALTERNATIVE_TYPE_RECOMMENDS)
+           {
+             char *s = pool_tmpjoin(pool, altprefix, num, testcase_solvid2str(pool, from));
+             s = pool_tmpappend(pool, s, " recommends ", testcase_dep2str(pool, id));
+             strqueue_push(&sq, s);
+           }
+         else if (type == SOLVER_ALTERNATIVE_TYPE_RULE)
+           {
+             /* map choice rules back to pkg rules */
+             if (solver_ruleclass(solv, id) == SOLVER_RULE_CHOICE)
+               id = solver_rule2pkgrule(solv, id);
+             solver_allruleinfos(solv, id, &rq);
+             for (i = 0; i < rq.count; i += 4)
+               {
+                 int rtype = rq.elements[i];
+                 if ((rtype & SOLVER_RULE_TYPEMASK) == SOLVER_RULE_JOB)
+                   {
+                     const char *js = testcase_job2str(pool, rq.elements[i + 2], rq.elements[i + 3]);
+                     char *s = pool_tmpjoin(pool, altprefix, num, " job ");
+                     s = pool_tmpappend(pool, s, js, 0);
+                     strqueue_push(&sq, s);
+                   }
+                 else if (rtype == SOLVER_RULE_PKG_REQUIRES)
+                   {
+                     char *s = pool_tmpjoin(pool, altprefix, num, testcase_solvid2str(pool, rq.elements[i + 1]));
+                     s = pool_tmpappend(pool, s, " requires ", testcase_dep2str(pool, rq.elements[i + 3]));
+                     strqueue_push(&sq, s);
+                   }
+               }
+           }
+         for (i = 0; i < q.count; i++)
+           {
+             Id p = q.elements[i];
+             if (i >= 9)
+               num[0] = '0' + (i + 1) / 10;
+             num[1] = '0' + (i + 1) % 10;
+             if (-p == chosen)
+               s = pool_tmpjoin(pool, altprefix, num, "+ ");
+             else if (p < 0)
+               s = pool_tmpjoin(pool, altprefix, num, "- ");
+             else if (p >= 0)
+               s = pool_tmpjoin(pool, altprefix, num, "  ");
+             s = pool_tmpappend(pool, s,  testcase_solvid2str(pool, p < 0 ? -p : p), 0);
+             strqueue_push(&sq, s);
+           }
+         solv_free(altprefix);
+       }
+      queue_free(&q);
+      queue_free(&rq);
+    }
 
   strqueue_sort(&sq);
   result = strqueue_join(&sq);
index 4243e4f..14a2cca 100644 (file)
 #define TESTCASE_RESULT_ORPHANED       (1 << 2)
 #define TESTCASE_RESULT_RECOMMENDED    (1 << 3)
 #define TESTCASE_RESULT_UNNEEDED       (1 << 4)
+#define TESTCASE_RESULT_ALTERNATIVES   (1 << 5)
 
 extern Id testcase_str2dep(Pool *pool, const char *s);
+extern const char *testcase_dep2str(Pool *pool, Id id);
 extern const char *testcase_repoid2str(Pool *pool, Id repoid);
 extern const char *testcase_solvid2str(Pool *pool, Id p);
 extern Repo *testcase_str2repo(Pool *pool, const char *str);
index 9579927..57dede3 100644 (file)
@@ -1,4 +1,16 @@
 -------------------------------------------------------------------
+Mon Mar  9 16:42:35 CET 2015 - mls@suse.de
+
+- rework splitprovides handling [bnc#921332]
+- improve package choosing code
+- new testcase dependency format
+- add alternatives introspection
+- make reorder_dq_for_jobrules also look at recommends/suggests
+- rework branch handling
+- add parser for rpm rich deps
+- bump version to 0.6.9
+
+-------------------------------------------------------------------
 Wed Jan 14 08:58:46 CET 2015 - ma@suse.de
 
 - fixes to build with swig 3.0.3
index a229121..c094bf5 100644 (file)
@@ -258,6 +258,8 @@ KNOWNID(SIGNATURE_DATA,                     "signature:data"),
 
 KNOWNID(PRODUCT_REGISTER_FLAVOR,       "product:regflavor"),           /* installed and available product */
 
+KNOWNID(SOLVABLE_INSTALLSTATUS,                "solvable:installstatus"),      /* debian install status */
+
 KNOWNID(ID_NUM_INTERNAL,               0)
 
 #ifdef KNOWNID_INITIALIZE
index 91337ea..c795b7a 100644 (file)
@@ -314,6 +314,8 @@ SOLV_1.0 {
                solvable_trivial_installable_repo;
                solvable_unset;
                solver_allruleinfos;
+               solver_alternative2str;
+               solver_alternatives_count;
                solver_calc_duchanges;
                solver_calc_installsizechange;
                solver_calculate_multiversionmap;
@@ -329,6 +331,7 @@ SOLV_1.0 {
                solver_findproblemrule;
                solver_free;
                solver_freedupmaps;
+               solver_get_alternative;
                solver_get_decisionblock;
                solver_get_decisionlevel;
                solver_get_decisionqueue;
@@ -360,6 +363,7 @@ SOLV_1.0 {
                solver_problemruleinfo2str;
                solver_rule2job;
                solver_rule2jobidx;
+               solver_rule2pkgrule;
                solver_rule2rules;
                solver_rule2solvable;
                solver_ruleclass;
index 9e5a934..a0ecec1 100644 (file)
@@ -406,11 +406,41 @@ policy_update_recommendsmap(Solver *solv)
     }
 }
 
+/* bring suggested/enhanced packages to front
+ * installed packages count as suggested */
+static void
+prefer_suggested(Solver *solv, Queue *plist)
+{
+  Pool *pool = solv->pool;
+  int i, count;
+
+  /* update our recommendsmap/suggestsmap */
+  if (solv->recommends_index < solv->decisionq.count)
+    policy_update_recommendsmap(solv);
+
+  for (i = 0, count = plist->count; i < count; i++)
+    {
+      Id p = plist->elements[i];
+      Solvable *s = pool->solvables + p;
+      if ((pool->installed && s->repo == pool->installed) ||
+          MAPTST(&solv->suggestsmap, p) ||
+          solver_is_enhancing(solv, s))
+       continue;       /* good package */
+      /* bring to back */
+     if (i < plist->count - 1)
+       {
+         memmove(plist->elements + i, plist->elements + i + 1, (plist->count - 1 - i) * sizeof(Id));
+         plist->elements[plist->count - 1] = p;
+       }
+      i--;
+      count--;
+    }
+}
+
 /*
  * prune to recommended/suggested packages.
  * does not prune installed packages (they are also somewhat recommended).
  */
-
 static void
 prune_to_recommended(Solver *solv, Queue *plist)
 {
@@ -467,6 +497,7 @@ prune_to_recommended(Solver *solv, Queue *plist)
   if (j)
     plist->count = j;
 
+#if 0
   /* anything left to prune? */
   if (plist->count - ninst < 2)
     return;
@@ -500,6 +531,7 @@ prune_to_recommended(Solver *solv, Queue *plist)
     }
   if (j)
     plist->count = j;
+#endif
 }
 
 static void
@@ -836,6 +868,240 @@ prune_to_best_version(Pool *pool, Queue *plist)
 }
 
 
+static int
+sort_by_name_evr_sortcmp(const void *ap, const void *bp, void *dp)
+{
+  Pool *pool = dp;
+  Id a, *aa = (Id *)ap;
+  Id b, *bb = (Id *)bp;
+  Id r = aa[1] - bb[1];
+  if (r)
+    return r < 0 ? -1 : 1;
+  a = aa[2] < 0 ? -aa[2] : aa[2];
+  b = bb[2] < 0 ? -bb[2] : bb[2];
+  if (pool->disttype != DISTTYPE_DEB)
+    {
+      /* treat release-less versions different */
+      const char *as = pool_id2str(pool, a);
+      const char *bs = pool_id2str(pool, b);
+      if (strchr(as, '-'))
+       {
+         if (!strchr(bs, '-'))
+           return -2;
+       }
+      else
+       {
+         if (strchr(bs, '-'))
+           return 2;
+       }
+    }
+  r = pool_evrcmp(pool, b, a, EVRCMP_COMPARE);
+  if (!r && (aa[2] < 0 || bb[2] < 0))
+    {
+      if (bb[2] >= 0)
+       return 1;
+      if (aa[2] >= 0)
+       return -1;
+    }
+  if (r)
+    return r < 0 ? -1 : 1;
+  return 0;
+}
+
+/* common end of sort_by_srcversion and sort_by_common_dep */
+static void
+sort_by_name_evr_array(Pool *pool, Queue *plist, int count, int ent)
+{
+  Id lastname;
+  int i, j, bad, havebad;
+  Id *pp, *elements = plist->elements;
+
+  if (ent < 2)
+    {
+      queue_truncate(plist, count);
+      return;
+    }
+  solv_sort(elements + count * 2, ent, sizeof(Id) * 3, sort_by_name_evr_sortcmp, pool);
+  lastname = 0;
+  bad = havebad = 0;
+  for (i = 0, pp = elements + count * 2; i < ent; i++, pp += 3)
+    {
+      if (lastname && pp[1] == lastname)
+       {
+          if (pp[0] != pp[-3] && sort_by_name_evr_sortcmp(pp - 3, pp, pool) == -1)
+           {
+#if 0
+             printf("%s - %s: bad %s %s - %s\n", pool_solvid2str(pool, elements[pp[-3]]), pool_solvid2str(pool, elements[pp[0]]), pool_dep2str(pool, lastname), pool_id2str(pool, pp[-1] < 0 ? -pp[-1] : pp[-1]), pool_id2str(pool, pp[2] < 0 ? -pp[2] : pp[2]));
+#endif
+             bad++;
+             havebad = 1;
+           }
+       }
+      else
+       {
+         bad = 0;
+         lastname = pp[1];
+       }
+      elements[count + pp[0]] += bad;
+    }
+
+#if 0
+for (i = 0; i < count; i++)
+  printf("%s badness %d\n", pool_solvid2str(pool, elements[i]), elements[count + i]);
+#endif
+
+  if (havebad)
+    {
+      /* simple stable insertion sort */
+      if (pool->installed)
+       for (i = 0; i < count; i++)
+         if (pool->solvables[elements[i]].repo == pool->installed)
+           elements[i + count] = 0;
+      for (i = 1; i < count; i++)
+       for (j = i, pp = elements + count + j; j > 0; j--, pp--)
+         if (pp[-1] > pp[0])
+           {
+             Id *pp2 = pp - count;
+             Id p = pp[-1];
+             pp[-1] = pp[0];
+             pp[0] = p;
+             p = pp2[-1];
+             pp2[-1] = pp2[0];
+             pp2[0] = p;
+           }
+         else
+           break;
+    }
+  queue_truncate(plist, count);
+}
+
+#if 0
+static void
+sort_by_srcversion(Pool *pool, Queue *plist)
+{
+  int i, count = plist->count, ent = 0;
+  queue_insertn(plist, count, count, 0);
+  for (i = 0; i < count; i++)
+    {
+      Id name, evr, p = plist->elements[i];
+      Solvable *s = pool->solvables + p;
+      if (solvable_lookup_void(s, SOLVABLE_SOURCENAME))
+       name = s->name;
+      else
+        name = solvable_lookup_id(s, SOLVABLE_SOURCENAME);
+      if (solvable_lookup_void(s, SOLVABLE_SOURCEEVR))
+       evr = s->evr;
+      else
+        evr = solvable_lookup_id(s, SOLVABLE_SOURCEEVR);
+      if (!name || !evr || ISRELDEP(evr))
+       continue;
+      queue_push(plist, i);
+      queue_push2(plist, name, evr);
+      ent++;
+    }
+  sort_by_name_evr_array(pool, plist, count, ent);
+}
+#endif
+
+static void
+sort_by_common_dep(Pool *pool, Queue *plist)
+{
+  int i, count = plist->count, ent = 0;
+  Id id, *dp;
+  queue_insertn(plist, count, count, 0);
+  for (i = 0; i < count; i++)
+    {
+      Id p = plist->elements[i];
+      Solvable *s = pool->solvables + p;
+      if (!s->provides)
+       continue;
+      for (dp = s->repo->idarraydata + s->provides; (id = *dp++) != 0; )
+       {
+         Reldep *rd;
+         if (!ISRELDEP(id))
+           continue;
+         rd = GETRELDEP(pool, id);
+         if ((rd->flags == REL_EQ || rd->flags == (REL_EQ | REL_LT) || rd->flags == REL_LT) && !ISRELDEP(rd->evr))
+           {
+             if (rd->flags == REL_EQ)
+               {
+                 /* ignore hashes */
+                 const char *s = pool_id2str(pool, rd->evr);
+                 if (strlen(s) >= 4)
+                   {
+                     while ((*s >= 'a' && *s <= 'f') || (*s >= '0' && *s <= '9'))
+                       s++;
+                     if (!*s)
+                       continue;
+                   }
+               }
+             queue_push(plist, i);
+             queue_push2(plist, rd->name, rd->flags == REL_LT ? -rd->evr : rd->evr);
+             ent++;
+           }
+       }
+    }
+  sort_by_name_evr_array(pool, plist, count, ent);
+}
+
+/* check if we have an update candidate */
+static void
+dislike_old_versions(Pool *pool, Queue *plist)
+{
+  int i, count = plist->count;
+  Id *elements = plist->elements;
+  int bad = 0;
+
+  for (i = 0; i < count; i++)
+    {
+      Id p = elements[i];
+      Solvable *s = pool->solvables + p;
+      Repo *repo = s->repo;
+      Id q, qq;
+
+      if (!repo || repo == pool->installed)
+       continue;
+      FOR_PROVIDES(q, qq, s->name)
+       {
+         Solvable *qs = pool->solvables + q;
+         if (q == p)
+           continue;
+         if (s->name != qs->name || s->arch != qs->arch)
+           continue;
+         if (repo->priority != qs->repo->priority)
+           {
+             if (repo->priority > qs->repo->priority)
+               continue;
+             elements[i] = -p;
+             bad = 1;
+             break;
+           }
+         if (pool_evrcmp(pool, qs->evr, s->evr, EVRCMP_COMPARE) > 0)
+           {
+             elements[i] = -p;
+             bad = 1;
+             break;
+           }
+       }
+    }
+  if (!bad)
+    return;
+  /* now move negative elements to the back */
+  for (i = 0; i < count; i++)
+    {
+      Id p = elements[i];
+      if (p >= 0)
+       continue;
+      if (i < plist->count - 1)
+       {
+         memmove(elements + i, elements + i + 1, (plist->count - 1 - i) * sizeof(Id));
+         elements[plist->count - 1] = -p;
+       }
+      i--;
+      count--;
+    }
+}
+
 /*
  *  POLICY_MODE_CHOOSE:     default, do all pruning steps
  *  POLICY_MODE_RECOMMEND:  leave out prune_to_recommended
@@ -857,7 +1123,19 @@ policy_filter_unwanted(Solver *solv, Queue *plist, int mode)
   if (plist->count > 1)
     prune_to_best_version(pool, plist);
   if (plist->count > 1 && mode == POLICY_MODE_CHOOSE)
-    prune_to_recommended(solv, plist);
+    {
+      prune_to_recommended(solv, plist);
+      if (plist->count > 1)
+       {
+         /* do some fancy reordering */
+#if 0
+         sort_by_srcversion(pool, plist);
+#endif
+         dislike_old_versions(pool, plist);
+         sort_by_common_dep(pool, plist);
+         prefer_suggested(solv, plist);
+       }
+    }
 }
 
 
index 4d57790..4ba1345 100644 (file)
@@ -1444,6 +1444,8 @@ dataiterator_filelistcheck(Dataiterator *di)
   if (!needcomplete)
     {
       /* we don't need the complete filelist, so ignore all stubs */
+      if (data->repo->nrepodata == 2)
+       return 1;
       for (j = 1; j < data->nkeys; j++)
        if (data->keys[j].name != REPOSITORY_SOLVABLES && data->keys[j].name != SOLVABLE_FILELIST)
          return 1;
index 048cd99..c9bbf81 100644 (file)
@@ -65,7 +65,7 @@ dep_possible(Solver *solv, Id dep, Map *m)
              return dep_possible(solv, rd->evr, m);
            }
          if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
-           return solver_splitprovides(solv, rd->evr);
+           return solver_splitprovides(solv, rd->evr, m);
          if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
            return solver_dep_installed(solv, rd->evr);
        }
@@ -541,7 +541,7 @@ add_complex_deprules(Solver *solv, Id p, Id dep, int type, int dontfix, Queue *w
   queue_init(&bq);
 
   /* CNF expansion for requires, DNF + INVERT expansion for conflicts */
-  i = pool_normalize_complex_dep(pool, dep, &bq, type == SOLVER_RULE_DEP_PACKAGE_REQUIRES ? 0 : (CPLXDEPS_TODNF | CPLXDEPS_EXPAND | CPLXDEPS_INVERT));
+  i = pool_normalize_complex_dep(pool, dep, &bq, type == SOLVER_RULE_PKG_REQUIRES ? 0 : (CPLXDEPS_TODNF | CPLXDEPS_EXPAND | CPLXDEPS_INVERT));
   /* handle special cases */
   if (i == 0)
     {
@@ -2763,6 +2763,14 @@ solver_rule2solvable(Solver *solv, Id rid)
   return 0;
 }
 
+Id
+solver_rule2pkgrule(Solver *solv, Id rid)
+{
+  if (rid >= solv->choicerules && rid < solv->choicerules_end)
+    return solv->choicerules_ref[rid - solv->choicerules];
+  return 0;
+}
+
 static void
 solver_rule2rules_rec(Solver *solv, Id rid, Queue *q, Map *seen)
 {
@@ -3563,7 +3571,11 @@ check_xsupp(Solver *solv, Queue *depq, Id dep)
              return check_xsupp(solv, depq, rd->evr);
            }
          if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
+#if 0
            return solver_splitprovides(solv, rd->evr);
+#else
+           return 0;
+#endif
          if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
            return solver_dep_installed(solv, rd->evr);
        }
index 83a2679..8f55af3 100644 (file)
@@ -145,6 +145,7 @@ extern int  solver_rule2jobidx(struct _Solver *solv, Id rid);
 extern Id   solver_rule2job(struct _Solver *solv, Id rid, Id *whatp);
 extern Id   solver_rule2solvable(struct _Solver *solv, Id rid);
 extern void solver_rule2rules(struct _Solver *solv, Id rid, Queue *q, int recursive);
+extern Id   solver_rule2pkgrule(struct _Solver *solv, Id rid);
 
 /* orphan handling */
 extern void solver_breakorphans(struct _Solver *solv);
index 14fe78d..46d0ca3 100644 (file)
  * and is only true if pkg is installed and contains the specified path.
  * we also make sure that pkg is selected for an update, otherwise the
  * update would always be forced onto the user.
+ * Map m is the map used when called from dep_possible.
  */
+
+static int
+solver_is_updating(Solver *solv, Id p)
+{
+  /* check if the update rule is true */
+  Pool *pool = solv->pool;
+  Rule *r;
+  Id l, pp;
+  if (solv->decisionmap[p] >= 0)
+    return 0;  /* old package stayed */
+  r = solv->rules + solv->updaterules + (p - solv->installed->start);
+  FOR_RULELITERALS(l, pp, r)
+    if (l > 0 && l != p && solv->decisionmap[l] > 0)
+      return 1;
+  return 0;
+}
+
 int
-solver_splitprovides(Solver *solv, Id dep)
+solver_splitprovides(Solver *solv, Id dep, Map *m)
 {
   Pool *pool = solv->pool;
   Id p, pp;
   Reldep *rd;
   Solvable *s;
 
-  if (!solv->dosplitprovides || !solv->installed || (!solv->updatemap_all && !solv->updatemap.size))
+  if (!solv->dosplitprovides || !solv->installed)
     return 0;
   if (!ISRELDEP(dep))
     return 0;
@@ -76,8 +94,10 @@ solver_splitprovides(Solver *solv, Id dep)
       /* here we have packages that provide the correct name and contain the path,
        * now do extra filtering */
       s = pool->solvables + p;
-      if (s->repo == solv->installed && s->name == rd->name &&
-          (solv->updatemap_all || (solv->updatemap.size && MAPTST(&solv->updatemap, p - solv->installed->start))))
+      if (s->repo != solv->installed || s->name != rd->name)
+       continue;
+      /* check if the package is updated. if m is set, we're called from dep_possible */
+      if (m || solver_is_updating(solv, p))
        return 1;
     }
   return 0;
@@ -147,7 +167,7 @@ solver_check_installsuppdepq_dep(Solver *solv, Id dep)
           return r1 == 2 || r2 == 2 ? 2 : 1;
        }
       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
-        return solver_splitprovides(solv, rd->evr);
+        return solver_splitprovides(solv, rd->evr, 0);
       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
         return solver_dep_installed(solv, rd->evr);
       if (rd->flags == REL_NAMESPACE && (q = solv->installsuppdepq) != 0)
@@ -1243,13 +1263,7 @@ revert(Solver *solv, int level)
       solv->propagate_index = solv->decisionq.count;
     }
   while (solv->branches.count && solv->branches.elements[solv->branches.count - 1] >= level)
-    {
-      solv->branches.count--;
-      while (solv->branches.count && solv->branches.elements[solv->branches.count - 1] >= 0)
-       solv->branches.count--;
-      while (solv->branches.count && solv->branches.elements[solv->branches.count - 1] < 0)
-       solv->branches.count--;
-    }
+    solv->branches.count -= solv->branches.elements[solv->branches.count - 2];
   if (solv->recommends_index > solv->decisionq.count)
     solv->recommends_index = -1;       /* rebuild recommends/suggests maps */
   if (solv->decisionq.count < solv->decisioncnt_jobs)
@@ -1379,6 +1393,7 @@ reorder_dq_for_jobrules(Solver *solv, int level, Queue *dq)
 {
   Pool *pool = solv->pool;
   int i, j, haveone = 0, dqcount = dq->count;
+  int decisionqcount = solv->decisionq.count;
   Id p;
   Solvable *s;
 
@@ -1390,25 +1405,34 @@ reorder_dq_for_jobrules(Solver *solv, int level, Queue *dq)
        continue;
       if (solv->decisionmap[p] == 0)
        {
+         if (s->recommends || s->suggests)
+           queue_push(&solv->decisionq, p);
          solv->decisionmap[p] = level + 1;
          haveone = 1;
        }
     }
   if (!haveone)
     return;
+  policy_update_recommendsmap(solv);
   for (i = 0; i < dqcount; i++)
-    if (!solver_is_enhancing(solv, pool->solvables + dq->elements[i]))
-      {
-       queue_push(dq, dq->elements[i]);
-       dq->elements[i] = 0;
-      }
+    {
+      p = dq->elements[i];
+      if (!(pool->solvables[p].repo == solv->installed || MAPTST(&solv->suggestsmap, p) || solver_is_enhancing(solv, pool->solvables + p)))
+        {
+         queue_push(dq, p);
+         dq->elements[i] = 0;
+        }
+    }
   dqcount = dq->count;
   for (i = 0; i < dqcount; i++)
-    if (dq->elements[i] && !solver_is_supplementing(solv, pool->solvables + dq->elements[i]))
-      {
-       queue_push(dq, dq->elements[i]);
-       dq->elements[i] = 0;
-      }
+    {
+      p = dq->elements[i];
+      if (p && !(pool->solvables[p].repo == solv->installed || MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
+        {
+         queue_push(dq, p);
+         dq->elements[i] = 0;
+        }
+    }
   for (i = j = 0; i < dq->count; i++)
     if (dq->elements[i])
       dq->elements[j++] = dq->elements[i];
@@ -1416,6 +1440,62 @@ reorder_dq_for_jobrules(Solver *solv, int level, Queue *dq)
   FOR_REPO_SOLVABLES(solv->installed, p, s)
     if (solv->decisionmap[p] == level + 1)
       solv->decisionmap[p] = 0;
+  if (solv->decisionq.count != decisionqcount)
+    {
+      solv->recommends_index = -1;
+      queue_truncate(&solv->decisionq, decisionqcount);
+    }
+}
+
+/*-------------------------------------------------------------------
+ *
+ * branch handling
+ */
+
+static void
+createbranch(Solver *solv, int level, Queue *dq, Id p, Id data)
+{
+  Pool *pool = solv->pool;
+  int i;
+  IF_POOLDEBUG (SOLV_DEBUG_POLICY)
+    {
+      POOL_DEBUG (SOLV_DEBUG_POLICY, "creating a branch:\n");
+      for (i = 0; i < dq->count; i++)
+       POOL_DEBUG (SOLV_DEBUG_POLICY, "  - %s\n", pool_solvid2str(pool, dq->elements[i]));
+    }
+  queue_push(&solv->branches, -dq->elements[0]);
+  for (i = 1; i < dq->count; i++)
+    queue_push(&solv->branches, dq->elements[i]);
+  queue_push2(&solv->branches, p, data);
+  queue_push2(&solv->branches, dq->count + 4, level);
+}
+
+static int
+takebranch(Solver *solv, int pos, int end, const char *msg, int disablerules)
+{
+  Pool *pool = solv->pool;
+  int level;
+  Id p, why;
+#if 0
+  {
+    int i;
+    printf("branch group level %d [%d-%d] %d %d:\n", solv->branches.elements[end - 1], start, end, solv->branches.elements[end - 4], solv->branches.elements[end - 3]);
+    for (i = end - solv->branches.elements[end - 2]; i < end - 4; i++)
+      printf("%c %c%s\n", i == pos ? 'x' : ' ', solv->branches.elements[i] >= 0 ? ' ' : '-', pool_solvid2str(pool, solv->branches.elements[i] >= 0 ? solv->branches.elements[i] : -solv->branches.elements[i]));
+  }
+#endif
+  level = solv->branches.elements[end - 1];
+  p = solv->branches.elements[pos];
+  solv->branches.elements[pos] = -p;
+  POOL_DEBUG(SOLV_DEBUG_SOLVER, "%s %d -> %d with %s\n", msg, solv->decisionmap[p], level, pool_solvid2str(pool, p));
+  /* hack: set level to zero so that revert does not remove the branch */
+  solv->branches.elements[end - 1] = 0;
+  revert(solv, level);
+  solv->branches.elements[end - 1] = level;
+  /* hack: revert simply sets the count, so we can still access the reverted elements */
+  why = -solv->decisionq_why.elements[solv->decisionq_why.count];
+  assert(why >= 0);
+  return setpropagatelearn(solv, level, p, disablerules, why);
 }
 
 /*-------------------------------------------------------------------
@@ -1434,40 +1514,18 @@ selectandinstall(Solver *solv, int level, Queue *dq, int disablerules, Id ruleid
 {
   Pool *pool = solv->pool;
   Id p;
-  int i;
 
   if (dq->count > 1)
     policy_filter_unwanted(solv, dq, POLICY_MODE_CHOOSE);
-  if (dq->count > 1)
-    {
-      /* XXX: didn't we already do that? */
-      /* XXX: shouldn't we prefer installed packages? */
-      /* XXX: move to policy.c? */
-      /* choose the supplemented one */
-      for (i = 0; i < dq->count; i++)
-       if (solver_is_supplementing(solv, pool->solvables + dq->elements[i]))
-         {
-           dq->elements[0] = dq->elements[i];
-           dq->count = 1;
-           break;
-         }
-    }
   /* if we're resolving job rules and didn't resolve the installed packages yet,
    * do some special supplements ordering */
   if (dq->count > 1 && ruleid >= solv->jobrules && ruleid < solv->jobrules_end && solv->installed && !solv->focus_installed)
     reorder_dq_for_jobrules(solv, level, dq);
+  /* if we have multiple candidates we open a branch */
   if (dq->count > 1)
-    {
-      /* multiple candidates, open a branch */
-      queue_push(&solv->branches, -dq->elements[0]);
-      for (i = 1; i < dq->count; i++)
-       queue_push(&solv->branches, dq->elements[i]);
-      queue_push(&solv->branches, level);
-    }
+    createbranch(solv, level, dq, 0, ruleid);
   p = dq->elements[0];
-
   POOL_DEBUG(SOLV_DEBUG_POLICY, "installing %s\n", pool_solvid2str(pool, p));
-
   return setpropagatelearn(solv, level, p, disablerules, ruleid);
 }
 
@@ -2528,7 +2586,6 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
           /* filter out all already supplemented packages if requested */
           if (!solv->addalreadyrecommended && dqs.count)
            {
-             int dosplitprovides_old = solv->dosplitprovides;
              /* turn off all new packages */
              for (i = 0; i < solv->decisionq.count; i++)
                {
@@ -2539,7 +2596,6 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                  if (s->repo && s->repo != solv->installed)
                    solv->decisionmap[p] = -solv->decisionmap[p];
                }
-             solv->dosplitprovides = 0;
              /* filter out old supplements */
              for (i = j = 0; i < dqs.count; i++)
                {
@@ -2563,7 +2619,6 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                  if (s->repo && s->repo != solv->installed)
                    solv->decisionmap[p] = -solv->decisionmap[p];
                }
-             solv->dosplitprovides = dosplitprovides_old;
            }
 
          /* multiversion doesn't mix well with supplements.
@@ -2679,13 +2734,10 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                      if (!dq.count)
                        continue;
                      if (dq.count > 1)
-                       {
-                         /* multiple candidates, open a branch */
-                         queue_push(&solv->branches, -dq.elements[0]);
-                         for (i = 1; i < dq.count; i++)
-                           queue_push(&solv->branches, dq.elements[i]);
-                         queue_push(&solv->branches, level);
-                       }
+                       policy_filter_unwanted(solv, &dq, POLICY_MODE_CHOOSE);
+                     /* if we have multiple candidates we open a branch */
+                     if (dq.count > 1)
+                         createbranch(solv, level, &dq, s - pool->solvables, rec);
                      p = dq.elements[0];
                      POOL_DEBUG(SOLV_DEBUG_POLICY, "installing recommended %s\n", pool_solvid2str(pool, p));
                      olevel = level;
@@ -2812,7 +2864,6 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
          if (solv->branches.count)
            {
              int l, endi = 0;
-             Id why;
              p = l = 0;
              for (i = solv->branches.count - 1; i >= 0; i--)
                {
@@ -2821,6 +2872,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                    {
                      endi = i + 1;
                      l = p;
+                     i -= 3;   /* skip: p data count */
                    }
                  else if (p > 0)
                    break;
@@ -2831,21 +2883,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                {
                  while (i > 0 && solv->branches.elements[i - 1] > 0)
                    i--;
-                 p = solv->branches.elements[i];
-                 solv->branches.elements[i] = -p;
-                 while (i > 0 && solv->branches.elements[i - 1] < 0)
-                   i--;
-                 POOL_DEBUG(SOLV_DEBUG_SOLVER, "branching with %s\n", pool_solvid2str(pool, p));
-                 queue_empty(&dq);
-                 queue_insertn(&dq, 0, endi - i, solv->branches.elements + i);
-                 level = l;
-                 revert(solv, level);
-                 queue_insertn(&solv->branches, solv->branches.count, dq.count, dq.elements);
-                 /* hack: revert simply sets the count, so we can still access the reverted elements */
-                 why = -solv->decisionq_why.elements[solv->decisionq_why.count];
-                 assert(why >= 0);
-                 olevel = level;
-                 level = setpropagatelearn(solv, level, p, disablerules, why);
+                 level = takebranch(solv, i, endi, "branching", disablerules);
                  if (level == 0)
                    break;
                  continue;
@@ -2858,82 +2896,51 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
       /* auto-minimization step */
       if (solv->branches.count)
        {
-         int l = 0, lasti = -1, lastsi = -1, endi = 0;
-         Id why;
-         p = l = 0;
+         int endi, lasti = -1, lastiend = -1;
          if (solv->recommends_index < solv->decisionq.count)
            policy_update_recommendsmap(solv);
-         for (i = solv->branches.count - 1; i >= 0; i--)
+         for (endi = solv->branches.count; endi > 0;)
            {
-             p = solv->branches.elements[i];
-             if (p > 0 && !l)
-               {
-                 l = p;
-                 endi = i + 1;
-                 lastsi = -1;
-               }
-             else if (p > 0)
+             int l, lastsi = -1, starti = endi - solv->branches.elements[endi - 2];
+             l = solv->branches.elements[endi - 1];
+             for (i = starti; i < endi - 4; i++)
                {
-                 if (solv->decisionmap[p] > l + 1)
-                   lasti = i;
-                 else
+                 p = solv->branches.elements[i];
+                 if (p <= 0)
+                   continue;
+                 if (solv->decisionmap[p] > l)
                    {
-                     if (MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p))
-                       {
-                         lastsi = p;
-                       }
+                     lasti = i;
+                     lastiend = endi;
+                     lastsi = -1;
+                     break;
                    }
+                 if (lastsi < 0 && (MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
+                   lastsi = i;
                }
-             else if (p < 0)
+             if (lastsi >= 0)
                {
-                 l = 0;
-                 if (lastsi >= 0)
+                 /* we have a recommended package that could not be installed */
+                 /* take it if our current selection is not recommended */
+                 for (i = starti; i < endi - 4; i++)
                    {
-                     p = -p;
-                     if (solv->decisionmap[p] == l)
+                     p = -solv->branches.elements[i];
+                     if (p <= 0 || solv->decisionmap[p] != l + 1)
+                       continue;
+                     if (!(MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
                        {
-                         if (!(MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
-                           lasti = lastsi;
+                         lasti = lastsi;
+                         lastiend = endi;
+                         break;
                        }
                    }
                }
+             endi = starti;
            }
          if (lasti >= 0)
            {
-             int starti;
-             /* find start of branch */
-             for (i = lasti; i && solv->branches.elements[i] >= 0; )
-               i--;
-             while (i > 0 && solv->branches.elements[i] < 0)
-               i--;
-             starti = i ? i + 1 : 0;
-#if 0
-             printf("minimization group level %d [%d-%d]:\n", solv->branches.elements[endi - 1], starti, endi);
-             for (i = starti; i < endi - 1; i++)
-               printf("%c %c%s\n", i == lasti ? 'x' : ' ', solv->branches.elements[i] >= 0 ? ' ' : '-', pool_solvid2str(pool, solv->branches.elements[i] >= 0 ? solv->branches.elements[i] : -solv->branches.elements[i]));
-#endif
-             l = solv->branches.elements[endi - 1];
-             p = solv->branches.elements[lasti];
-             solv->branches.elements[lasti] = -p;
-             POOL_DEBUG(SOLV_DEBUG_SOLVER, "minimizing %d -> %d with %s\n", solv->decisionmap[p], l, pool_solvid2str(pool, p));
              minimizationsteps++;
-             queue_empty(&dq);
-             for (i = starti; i < endi - 1; i++)
-               if (solv->branches.elements[i] < 0)
-                 queue_push(&dq, solv->branches.elements[i]);
-             for (i = starti; i < endi; i++)
-               if (solv->branches.elements[i] > 0)
-                 queue_push(&dq, solv->branches.elements[i]);
-             if (dq.elements[dq.count - 2] <= 0)
-               queue_empty(&dq);
-             level = l;
-             revert(solv, level);
-             queue_insertn(&solv->branches, solv->branches.count, dq.count, dq.elements);
-             /* hack: revert simply sets the count, so we can still access the reverted elements */
-             why = -solv->decisionq_why.elements[solv->decisionq_why.count];
-             assert(why >= 0);
-             olevel = level;
-             level = setpropagatelearn(solv, level, p, disablerules, why);
+             level = takebranch(solv, lasti, lastiend, "minimizing", disablerules);
              if (level == 0)
                break;
              continue;         /* back to main loop */
@@ -3644,7 +3651,10 @@ solver_solve(Solver *solv, Queue *job)
    * add rules for suggests, enhances
    */
   oldnrules = solv->nrules;
-  solver_addpkgrulesforweak(solv, &addedmap);
+  if (hasdupjob && !solv->updatemap_all && solv->dosplitprovides && solv->installed)
+    solver_addpkgrulesforweak(solv, &addedmap);
+  else
+    solver_addpkgrulesforweak(solv, &addedmap);
   POOL_DEBUG(SOLV_DEBUG_STATS, "added %d pkg rules because of weak dependencies\n", solv->nrules - oldnrules);
 
 #ifdef ENABLE_LINKED_PKGS
@@ -4886,6 +4896,54 @@ pool_add_userinstalled_jobs(Pool *pool, Queue *q, Queue *job, int flags)
     }
 }
 
+int
+solver_alternatives_count(Solver *solv)
+{
+  Id *elements = solv->branches.elements;
+  int res, count;
+  for (res = 0, count = solv->branches.count; count; res++)
+    count -= elements[count - 2];
+  return res;
+}
+
+int
+solver_get_alternative(Solver *solv, Id alternative, Id *idp, Id *fromp, Id *chosenp, Queue *choices, int *levelp)
+{
+  int cnt = solver_alternatives_count(solv);
+  int count = solv->branches.count;
+  Id *elements = solv->branches.elements;
+  if (choices)
+    queue_empty(choices);
+  if (alternative <= 0 || alternative > cnt)
+    return 0;
+  elements += count;
+  for (; cnt > alternative; cnt--)
+    elements -= elements[-2];
+  if (levelp)
+    *levelp = elements[-1];
+  if (fromp)
+    *fromp = elements[-4];
+  if (idp)
+    *idp = elements[-3];
+  if (chosenp)
+    {
+      int i;
+      *chosenp = 0;
+      for (i = elements[-2]; i > 4; i--)
+       {
+         Id p = -elements[-i];
+         if (p > 0 && solv->decisionmap[p] == elements[-1] + 1)
+           {
+             *chosenp = p;
+             break;
+           }
+       }
+    }
+  if (choices)
+    queue_insertn(choices, 0, elements[-2] - 4, elements - elements[-2]);
+  return elements[-4] ? SOLVER_ALTERNATIVE_TYPE_RECOMMENDS : SOLVER_ALTERNATIVE_TYPE_RULE;
+}
+
 const char *
 solver_select2str(Pool *pool, Id select, Id what)
 {
@@ -5025,3 +5083,37 @@ pool_job2str(Pool *pool, Id how, Id what, Id flagmask)
   return pool_tmpappend(pool, s, "]", 0);
 }
 
+const char *
+solver_alternative2str(Solver *solv, int type, Id id, Id from)
+{
+  Pool *pool = solv->pool;
+  if (type == SOLVER_ALTERNATIVE_TYPE_RECOMMENDS)
+    {
+      const char *s = pool_dep2str(pool, id);
+      return pool_tmpappend(pool, s, ", recommended by ", pool_solvid2str(pool, from));
+    }
+  if (type == SOLVER_ALTERNATIVE_TYPE_RULE)
+    {
+      int rtype;
+      Id depfrom, depto, dep;
+      char buf[64];
+      if (solver_ruleclass(solv, id) == SOLVER_RULE_CHOICE)
+       id = solver_rule2pkgrule(solv, id);
+      rtype = solver_ruleinfo(solv, id, &depfrom, &depto, &dep);
+      if ((rtype & SOLVER_RULE_TYPEMASK) == SOLVER_RULE_JOB)
+       {
+         if ((depto & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_PROVIDES)
+           return pool_dep2str(pool, dep);
+         return solver_select2str(pool, depto & SOLVER_SELECTMASK, dep);
+       }
+      if (rtype == SOLVER_RULE_PKG_REQUIRES)
+       {
+         const char *s = pool_dep2str(pool, dep);
+         return pool_tmpappend(pool, s, ", required by ", pool_solvid2str(pool, depfrom));
+       }
+      sprintf(buf, "Rule #%d", id);
+      return pool_tmpjoin(pool, buf, 0, 0);
+    }
+  return "unknown alternative type";
+}
+
index 2a7f060..1cb9f15 100644 (file)
@@ -299,6 +299,10 @@ typedef struct _Solver Solver;
 #define GET_USERINSTALLED_NAMES                        (1 << 0)        /* package names instead if ids */
 #define GET_USERINSTALLED_INVERTED             (1 << 1)        /* autoinstalled */
 
+#define SOLVER_ALTERNATIVE_TYPE_RULE           1
+#define SOLVER_ALTERNATIVE_TYPE_RECOMMENDS     2
+#define SOLVER_ALTERNATIVE_TYPE_SUGGESTS       3
+
 extern Solver *solver_create(Pool *pool);
 extern void solver_free(Solver *solv);
 extern int  solver_solve(Solver *solv, Queue *job);
@@ -320,6 +324,8 @@ extern void pool_add_userinstalled_jobs(Pool *pool, Queue *q, Queue *job, int fl
 extern int  solver_describe_decision(Solver *solv, Id p, Id *infop);
 extern void solver_describe_weakdep_decision(Solver *solv, Id p, Queue *whyq);
 
+extern int solver_alternatives_count(Solver *solv);
+extern int solver_get_alternative(Solver *solv, Id alternative, Id *idp, Id *fromp, Id *chosenp, Queue *choices, int *levelp);
 
 extern void solver_calculate_multiversionmap(Pool *pool, Queue *job, Map *multiversionmap);
 extern void solver_calculate_noobsmap(Pool *pool, Queue *job, Map *multiversionmap);   /* obsolete */
@@ -334,6 +340,8 @@ extern int  pool_isemptyupdatejob(Pool *pool, Id how, Id what);
 
 extern const char *solver_select2str(Pool *pool, Id select, Id what);
 extern const char *pool_job2str(Pool *pool, Id how, Id what, Id flagmask);
+extern const char *solver_alternative2str(Solver *solv, int type, Id id, Id from);
+
 
 /* iterate over all literals of a rule */
 #define FOR_RULELITERALS(l, pp, r)                             \
index 170efc2..f30b03a 100644 (file)
@@ -17,7 +17,7 @@ extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
 extern void solver_reset(Solver *solv);
 
 extern int solver_dep_installed(Solver *solv, Id dep);
-extern int solver_splitprovides(Solver *solv, Id dep);
+extern int solver_splitprovides(Solver *solv, Id dep, Map *m);
 
 static inline int
 solver_dep_fulfilled(Solver *solv, Id dep)
@@ -41,7 +41,7 @@ solver_dep_fulfilled(Solver *solv, Id dep)
           return solver_dep_fulfilled(solv, rd->evr);
        }
       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
-        return solver_splitprovides(solv, rd->evr);
+        return solver_splitprovides(solv, rd->evr, 0);
       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
         return solver_dep_installed(solv, rd->evr);
     }
diff --git a/test/testcases/choose/default.t b/test/testcases/choose/default.t
new file mode 100644 (file)
index 0000000..bb5b9f4
--- /dev/null
@@ -0,0 +1,13 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install A-1-1.noarch@test
+#>install X-1-1.noarch@test
diff --git a/test/testcases/choose/enhanced.t b/test/testcases/choose/enhanced.t
new file mode 100644 (file)
index 0000000..da6cfd5
--- /dev/null
@@ -0,0 +1,14 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y
+#>=Enh: X
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install B-1-1.noarch@test
+#>install X-1-1.noarch@test
diff --git a/test/testcases/choose/oldversion.t b/test/testcases/choose/oldversion.t
new file mode 100644 (file)
index 0000000..d83e2b6
--- /dev/null
@@ -0,0 +1,16 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y
+#>=Pkg: C 1 1 noarch
+#>=Prv: Y
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y
+#>=Pkg: A 2 1 noarch
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install B-1-1.noarch@test
+#>install X-1-1.noarch@test
diff --git a/test/testcases/choose/suggested.t b/test/testcases/choose/suggested.t
new file mode 100644 (file)
index 0000000..cad4742
--- /dev/null
@@ -0,0 +1,14 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Sug: B
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install B-1-1.noarch@test
+#>install X-1-1.noarch@test
diff --git a/test/testcases/choose/versioned.t b/test/testcases/choose/versioned.t
new file mode 100644 (file)
index 0000000..d5089c8
--- /dev/null
@@ -0,0 +1,15 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y = 2
+#>=Pkg: C 1 1 noarch
+#>=Prv: Y = 1.1
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y = 1
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install B-1-1.noarch@test
+#>install X-1-1.noarch@test
diff --git a/test/testcases/choose/versioned2.t b/test/testcases/choose/versioned2.t
new file mode 100644 (file)
index 0000000..99c5712
--- /dev/null
@@ -0,0 +1,15 @@
+repo system 0 empty
+repo test 0 testtags <inline>
+#>=Pkg: X 1 1 noarch
+#>=Req: Y
+#>=Pkg: B 1 1 noarch
+#>=Prv: Y < 2
+#>=Pkg: C 1 1 noarch
+#>=Prv: Y <= 2
+#>=Pkg: A 1 1 noarch
+#>=Prv: Y = 1
+system i686 rpm system
+job install name X
+result transaction,problems <inline>
+#>install C-1-1.noarch@test
+#>install X-1-1.noarch@test
index 1dc8872..62ca982 100644 (file)
@@ -1,8 +1,10 @@
 repo system 0 testtags <inline>
+#>=Ver: 2
 #>=Pkg: B 1 1 noarch
 #>=Prv: locale(en)
 #>=Pkg: C 1 1 noarch
 repo test 0 testtags <inline>
+#>=Ver: 2
 #>=Pkg: A 1 1 noarch
 #>=Prv: locale(de)
 #>=Pkg: C-de 1 1 noarch