Imported Upstream version 0.6.5
[platform/upstream/libsolv.git] / src / pool.c
index 1f3007c..8dff38a 100644 (file)
@@ -7,7 +7,7 @@
 
 /*
  * pool.c
- * 
+ *
  * The pool contains information about solvables
  * stored optimized for memory consumption and fast retrieval.
  */
@@ -19,6 +19,7 @@
 #include <string.h>
 
 #include "pool.h"
+#include "poolvendor.h"
 #include "repo.h"
 #include "poolid.h"
 #include "poolid_private.h"
@@ -29,6 +30,7 @@
 
 #define SOLVABLE_BLOCK 255
 
+#undef LIBSOLV_KNOWNID_H
 #define KNOWNID_INITIALIZE
 #include "knownid.h"
 #undef KNOWNID_INITIALIZE
@@ -40,39 +42,55 @@ pool_create(void)
   Pool *pool;
   Solvable *s;
 
-  pool = (Pool *)sat_calloc(1, sizeof(*pool));
+  pool = (Pool *)solv_calloc(1, sizeof(*pool));
 
   stringpool_init (&pool->ss, initpool_data);
 
   /* alloc space for RelDep 0 */
-  pool->rels = sat_extend_resize(0, 1, sizeof(Reldep), REL_BLOCK);
+  pool->rels = solv_extend_resize(0, 1, sizeof(Reldep), REL_BLOCK);
   pool->nrels = 1;
   memset(pool->rels, 0, sizeof(Reldep));
 
   /* alloc space for Solvable 0 and system solvable */
-  pool->solvables = sat_extend_resize(0, 2, sizeof(Solvable), SOLVABLE_BLOCK);
+  pool->solvables = solv_extend_resize(0, 2, sizeof(Solvable), SOLVABLE_BLOCK);
   pool->nsolvables = 2;
   memset(pool->solvables, 0, 2 * sizeof(Solvable));
+
+  queue_init(&pool->vendormap);
+  queue_init(&pool->pooljobs);
+  queue_init(&pool->lazywhatprovidesq);
+
+#if defined(DEBIAN)
+  pool->disttype = DISTTYPE_DEB;
+  pool->noarchid = ARCH_ALL;
+#elif defined(ARCHLINUX)
+  pool->disttype = DISTTYPE_ARCH;
+  pool->noarchid = ARCH_ANY;
+#elif defined(HAIKU)
+  pool->disttype = DISTTYPE_HAIKU;
+  pool->noarchid = ARCH_ANY;
+  pool->obsoleteusesprovides = 1;
+#else
+  pool->disttype = DISTTYPE_RPM;
+  pool->noarchid = ARCH_NOARCH;
+#endif
+
+  /* initialize the system solvable */
   s = pool->solvables + SYSTEMSOLVABLE;
   s->name = SYSTEM_SYSTEM;
-  s->arch = ARCH_NOARCH;
+  s->arch = pool->noarchid;
   s->evr = ID_EMPTY;
 
-  queue_init(&pool->vendormap);
-
-  pool->debugmask = SAT_DEBUG_RESULT;  /* FIXME */
+  pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
 #ifdef FEDORA
-  pool->obsoleteusescolors = 1;
-#endif
-#ifdef DEBIAN 
-  pool->allowselfconflicts = 1;
-# ifdef MULTI_SEMANTICS
-  pool->disttype = DISTTYPE_DEB;
-# endif
+  pool->implicitobsoleteusescolors = 1;
 #endif
 #ifdef RPM5
+  pool->noobsoletesmultiversion = 1;
+  pool->forbidselfconflicts = 1;
   pool->obsoleteusesprovides = 1;
   pool->implicitobsoleteusesprovides = 1;
+  pool->havedistepoch = 1;
 #endif
   return pool;
 }
@@ -86,20 +104,41 @@ pool_free(Pool *pool)
 
   pool_freewhatprovides(pool);
   pool_freeidhashes(pool);
-  repo_freeallrepos(pool, 1);
-  sat_free(pool->id2arch);
-  sat_free(pool->solvables);
+  pool_freeallrepos(pool, 1);
+  solv_free(pool->id2arch);
+  solv_free(pool->id2color);
+  solv_free(pool->solvables);
   stringpool_free(&pool->ss);
-  sat_free(pool->rels);
+  solv_free(pool->rels);
   pool_setvendorclasses(pool, 0);
   queue_free(&pool->vendormap);
+  queue_free(&pool->pooljobs);
+  queue_free(&pool->lazywhatprovidesq);
   for (i = 0; i < POOL_TMPSPACEBUF; i++)
-    sat_free(pool->tmpspace.buf[i]);
+    solv_free(pool->tmpspace.buf[i]);
   for (i = 0; i < pool->nlanguages; i++)
     free((char *)pool->languages[i]);
-  sat_free(pool->languages);
-  sat_free(pool->languagecache);
-  sat_free(pool);
+  solv_free((void *)pool->languages);
+  solv_free(pool->languagecache);
+  solv_free(pool->errstr);
+  solv_free(pool->rootdir);
+  solv_free(pool);
+}
+
+void
+pool_freeallrepos(Pool *pool, int reuseids)
+{
+  int i;
+
+  pool_freewhatprovides(pool);
+  for (i = 1; i < pool->nrepos; i++)
+    if (pool->repos[i])
+      repo_freedata(pool->repos[i]);
+  pool->repos = solv_free(pool->repos);
+  pool->nrepos = 0;
+  pool->urepos = 0;
+  /* the first two solvables don't belong to a repo */
+  pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
 }
 
 #ifdef MULTI_SEMANTICS
@@ -107,13 +146,96 @@ void
 pool_setdisttype(Pool *pool, int disttype)
 {
   pool->disttype = disttype;
+  if (disttype == DISTTYPE_RPM)
+    pool->noarchid = ARCH_NOARCH;
+  if (disttype == DISTTYPE_DEB)
+    pool->noarchid = ARCH_ALL;
+  if (disttype == DISTTYPE_ARCH)
+    pool->noarchid = ARCH_ANY;
+  if (disttype == DISTTYPE_HAIKU)
+    pool->noarchid = ARCH_ANY;
+  pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
 }
 #endif
 
+int
+pool_get_flag(Pool *pool, int flag)
+{
+  switch (flag)
+    {
+    case POOL_FLAG_PROMOTEEPOCH:
+      return pool->promoteepoch;
+    case POOL_FLAG_FORBIDSELFCONFLICTS:
+      return pool->forbidselfconflicts;
+    case POOL_FLAG_OBSOLETEUSESPROVIDES:
+      return pool->obsoleteusesprovides;
+    case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
+      return pool->implicitobsoleteusesprovides;
+    case POOL_FLAG_OBSOLETEUSESCOLORS:
+      return pool->obsoleteusescolors;
+    case POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS:
+      return pool->implicitobsoleteusescolors;
+    case POOL_FLAG_NOINSTALLEDOBSOLETES:
+      return pool->noinstalledobsoletes;
+    case POOL_FLAG_HAVEDISTEPOCH:
+      return pool->havedistepoch;
+    case POOL_FLAG_NOOBSOLETESMULTIVERSION:
+      return pool->noobsoletesmultiversion;
+    case POOL_FLAG_ADDFILEPROVIDESFILTERED:
+      return pool->addfileprovidesfiltered;
+    default:
+      break;
+    }
+  return -1;
+}
+
+int
+pool_set_flag(Pool *pool, int flag, int value)
+{
+  int old = pool_get_flag(pool, flag);
+  switch (flag)
+    {
+    case POOL_FLAG_PROMOTEEPOCH:
+      pool->promoteepoch = value;
+      break;
+    case POOL_FLAG_FORBIDSELFCONFLICTS:
+      pool->forbidselfconflicts = value;
+      break;
+    case POOL_FLAG_OBSOLETEUSESPROVIDES:
+      pool->obsoleteusesprovides = value;
+      break;
+    case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
+      pool->implicitobsoleteusesprovides = value;
+      break;
+    case POOL_FLAG_OBSOLETEUSESCOLORS:
+      pool->obsoleteusescolors = value;
+      break;
+    case POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS:
+      pool->implicitobsoleteusescolors = value;
+      break;
+    case POOL_FLAG_NOINSTALLEDOBSOLETES:
+      pool->noinstalledobsoletes = value;
+      break;
+    case POOL_FLAG_HAVEDISTEPOCH:
+      pool->havedistepoch = value;
+      break;
+    case POOL_FLAG_NOOBSOLETESMULTIVERSION:
+      pool->noobsoletesmultiversion = value;
+      break;
+    case POOL_FLAG_ADDFILEPROVIDESFILTERED:
+      pool->addfileprovidesfiltered = value;
+      break;
+    default:
+      break;
+    }
+  return old;
+}
+
+
 Id
 pool_add_solvable(Pool *pool)
 {
-  pool->solvables = sat_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
+  pool->solvables = solv_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
   memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable));
   return pool->nsolvables++;
 }
@@ -124,7 +246,7 @@ pool_add_solvable_block(Pool *pool, int count)
   Id nsolvables = pool->nsolvables;
   if (!count)
     return nsolvables;
-  pool->solvables = sat_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
+  pool->solvables = solv_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
   memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count);
   pool->nsolvables += count;
   return nsolvables;
@@ -164,10 +286,6 @@ pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
   ob = pool->whatprovides[*(Id *)bp];
   if (oa == ob)
     return *(Id *)ap - *(Id *)bp;
-  if (!oa)
-    return -1;
-  if (!ob)
-    return 1;
   da = pool->whatprovidesdata + oa;
   db = pool->whatprovidesdata + ob;
   while (*db)
@@ -187,7 +305,7 @@ pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
 static void
 pool_shrink_whatprovides(Pool *pool)
 {
-  Id i, id;
+  Id i, n, id;
   Id *sorted;
   Id lastid, *last, *dp, *lp;
   Offset o;
@@ -195,18 +313,18 @@ pool_shrink_whatprovides(Pool *pool)
 
   if (pool->ss.nstrings < 3)
     return;
-  sorted = sat_malloc2(pool->ss.nstrings, sizeof(Id));
-  for (id = 0; id < pool->ss.nstrings; id++)
-    sorted[id] = id;
-  sat_sort(sorted + 1, pool->ss.nstrings - 1, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
+  sorted = solv_malloc2(pool->ss.nstrings, sizeof(Id));
+  for (i = id = 0; id < pool->ss.nstrings; id++)
+    if (pool->whatprovides[id] >= 4)
+      sorted[i++] = id;
+  n = i;
+  solv_sort(sorted, n, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
   last = 0;
   lastid = 0;
-  for (i = 1; i < pool->ss.nstrings; i++)
+  for (i = 0; i < n; i++)
     {
       id = sorted[i];
       o = pool->whatprovides[id];
-      if (o == 0 || o == 1)
-       continue;
       dp = pool->whatprovidesdata + o;
       if (last)
        {
@@ -228,12 +346,12 @@ pool_shrink_whatprovides(Pool *pool)
       last = pool->whatprovidesdata + o;
       lastid = id;
     }
-  sat_free(sorted);
-  dp = pool->whatprovidesdata + 2;
+  solv_free(sorted);
+  dp = pool->whatprovidesdata + 4;
   for (id = 1; id < pool->ss.nstrings; id++)
     {
       o = pool->whatprovides[id];
-      if (o == 0 || o == 1)
+      if (!o)
        continue;
       if ((Id)o < 0)
        {
@@ -243,6 +361,8 @@ pool_shrink_whatprovides(Pool *pool)
          pool->whatprovides[id] = pool->whatprovides[i];
          continue;
        }
+      if (o < 4)
+       continue;
       lp = pool->whatprovidesdata + o;
       if (lp < dp)
        abort();
@@ -251,12 +371,12 @@ pool_shrink_whatprovides(Pool *pool)
        ;
     }
   o = dp - pool->whatprovidesdata;
-  POOL_DEBUG(SAT_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
   if (pool->whatprovidesdataoff == o)
     return;
   r = pool->whatprovidesdataoff - o;
   pool->whatprovidesdataoff = o;
-  pool->whatprovidesdata = sat_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
+  pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
   if (r > pool->whatprovidesdataleft)
     r = pool->whatprovidesdataleft;
   memset(pool->whatprovidesdata + o, 0, r * sizeof(Id));
@@ -265,9 +385,9 @@ pool_shrink_whatprovides(Pool *pool)
 
 /*
  * pool_createwhatprovides()
- * 
+ *
  * create hashes over pool of solvables to ease provide lookups
- * 
+ *
  */
 void
 pool_createwhatprovides(Pool *pool)
@@ -282,15 +402,18 @@ pool_createwhatprovides(Pool *pool)
   Repo *installed = pool->installed;
   unsigned int now;
 
-  now = sat_timems(0);
-  POOL_DEBUG(SAT_DEBUG_STATS, "number of solvables: %d\n", pool->nsolvables);
-  POOL_DEBUG(SAT_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
+  now = solv_timems(0);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "number of solvables: %d, memory used: %d K\n", pool->nsolvables, pool->nsolvables * (int)sizeof(Solvable) / 1024);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "string memory used: %d K array + %d K data,  rel memory used: %d K array\n", pool->ss.nstrings / (1024 / (int)sizeof(Id)), pool->ss.sstrings / 1024, pool->nrels * (int)sizeof(Reldep) / 1024);
+  if (pool->ss.stringhashmask || pool->relhashmask)
+    POOL_DEBUG(SOLV_DEBUG_STATS, "string hash memory: %d K, rel hash memory : %d K\n", (pool->ss.stringhashmask + 1) / (int)(1024/sizeof(Id)), (pool->relhashmask + 1) / (int)(1024/sizeof(Id)));
 
   pool_freeidhashes(pool);     /* XXX: should not be here! */
   pool_freewhatprovides(pool);
   num = pool->ss.nstrings;
-  pool->whatprovides = whatprovides = sat_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
-  pool->whatprovides_rel = sat_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
+  pool->whatprovides = whatprovides = solv_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
+  pool->whatprovides_rel = solv_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
 
   /* count providers for each name */
   for (i = pool->nsolvables - 1; i > 0; i--)
@@ -315,29 +438,33 @@ pool_createwhatprovides(Pool *pool)
        }
     }
 
-  off = 2;     /* first entry is undef, second is empty list */
+  off = 4;     /* first entry is undef, second is empty list, third is system solvable  */
   np = 0;                             /* number of names provided */
   for (i = 0, idp = whatprovides; i < num; i++, idp++)
     {
       n = *idp;
-      if (!n)                         /* no providers */
-       continue;
-      off += n;                               /* make space for all providers */
-      *idp = off++;                   /* now idp points to terminating zero */
-      np++;                           /* inc # of provider 'slots' for stats */
+      if (!n)                          /* no providers */
+       {
+         *idp = 1;                     /* offset for empty list */
+         continue;
+       }
+      off += n;                                /* make space for all providers */
+      *idp = off++;                    /* now idp points to terminating zero */
+      np++;                            /* inc # of provider 'slots' for stats */
     }
 
-  POOL_DEBUG(SAT_DEBUG_STATS, "provide ids: %d\n", np);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "provide ids: %d\n", np);
 
   /* reserve some space for relation data */
   extra = 2 * pool->nrels;
   if (extra < 256)
     extra = 256;
 
-  POOL_DEBUG(SAT_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
 
   /* alloc space for all providers + extra */
-  whatprovidesdata = sat_calloc(off + extra, sizeof(Id));
+  whatprovidesdata = solv_calloc(off + extra, sizeof(Id));
+  whatprovidesdata[2] = SYSTEMSOLVABLE;
 
   /* now fill data for all provides */
   for (i = pool->nsolvables - 1; i > 0; i--)
@@ -370,8 +497,30 @@ pool_createwhatprovides(Pool *pool)
   pool->whatprovidesdataoff = off;
   pool->whatprovidesdataleft = extra;
   pool_shrink_whatprovides(pool);
-  POOL_DEBUG(SAT_DEBUG_STATS, "whatprovides memory used: %d K id array, %d K data\n", (pool->ss.nstrings + pool->nrels + WHATPROVIDES_BLOCK) / (int)(1024/sizeof(Id)), (pool->whatprovidesdataoff + pool->whatprovidesdataleft) / (int)(1024/sizeof(Id)));
-  POOL_DEBUG(SAT_DEBUG_STATS, "createwhatprovides took %d ms\n", sat_timems(now));
+  POOL_DEBUG(SOLV_DEBUG_STATS, "whatprovides memory used: %d K id array, %d K data\n", (pool->ss.nstrings + pool->nrels + WHATPROVIDES_BLOCK) / (int)(1024/sizeof(Id)), (pool->whatprovidesdataoff + pool->whatprovidesdataleft) / (int)(1024/sizeof(Id)));
+
+  queue_empty(&pool->lazywhatprovidesq);
+  if ((!pool->addedfileprovides && pool->disttype == DISTTYPE_RPM) || pool->addedfileprovides == 1)
+    {
+      if (!pool->addedfileprovides)
+       POOL_DEBUG(SOLV_DEBUG_STATS, "WARNING: pool_addfileprovides was not called, this may result in slow operation\n");
+      /* lazyly add file provides */
+      for (i = 1; i < num; i++)
+       {
+         const char *str = pool->ss.stringspace + pool->ss.strings[i];
+         if (str[0] != '/')
+           continue;
+         if (pool->addedfileprovides == 1 && repodata_filelistfilter_matches(0, str))
+           continue;
+         /* setup lazy adding, but remember old value */
+         if (pool->whatprovides[i] > 1)
+           queue_push2(&pool->lazywhatprovidesq, i, pool->whatprovides[i]);
+         pool->whatprovides[i] = 0;
+       }
+      POOL_DEBUG(SOLV_DEBUG_STATS, "lazywhatprovidesq size: %d entries\n", pool->lazywhatprovidesq.count / 2);
+    }
+
+  POOL_DEBUG(SOLV_DEBUG_STATS, "createwhatprovides took %d ms\n", solv_timems(now));
 }
 
 /*
@@ -382,9 +531,9 @@ pool_createwhatprovides(Pool *pool)
 void
 pool_freewhatprovides(Pool *pool)
 {
-  pool->whatprovides = sat_free(pool->whatprovides);
-  pool->whatprovides_rel = sat_free(pool->whatprovides_rel);
-  pool->whatprovidesdata = sat_free(pool->whatprovidesdata);
+  pool->whatprovides = solv_free(pool->whatprovides);
+  pool->whatprovides_rel = solv_free(pool->whatprovides_rel);
+  pool->whatprovidesdata = solv_free(pool->whatprovidesdata);
   pool->whatprovidesdataoff = 0;
   pool->whatprovidesdataleft = 0;
 }
@@ -394,11 +543,10 @@ pool_freewhatprovides(Pool *pool)
 
 /*
  * pool_queuetowhatprovides  - add queue contents to whatprovidesdata
- * 
- * on-demand filling of provider information
- * move queue data into whatprovidesdata
- * q: queue of Ids
- * returns: Offset into whatprovides
+ *
+ * used for whatprovides, jobs, learnt rules, selections
+ * input: q: queue of Ids
+ * returns: Offset into whatprovidesdata
  *
  */
 Id
@@ -409,12 +557,14 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)
 
   if (count == 0)                     /* queue empty -> 1 */
     return 1;
+  if (count == 1 && q->elements[0] == SYSTEMSOLVABLE)
+    return 2;
 
-  /* extend whatprovidesdata if needed, +1 for ID_NULL-termination */
+  /* extend whatprovidesdata if needed, +1 for 0-termination */
   if (pool->whatprovidesdataleft < count + 1)
     {
-      POOL_DEBUG(SAT_DEBUG_STATS, "growing provides hash data...\n");
-      pool->whatprovidesdata = sat_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
+      POOL_DEBUG(SOLV_DEBUG_STATS, "growing provides hash data...\n");
+      pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
       pool->whatprovidesdataleft = count + 4096;
     }
 
@@ -422,9 +572,9 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)
   off = pool->whatprovidesdataoff;
   memcpy(pool->whatprovidesdata + pool->whatprovidesdataoff, q->elements, count * sizeof(Id));
 
-  /* adapt count and ID_NULL-terminate */
+  /* adapt count and 0-terminate */
   pool->whatprovidesdataoff += count;
-  pool->whatprovidesdata[pool->whatprovidesdataoff++] = ID_NULL;
+  pool->whatprovidesdata[pool->whatprovidesdataoff++] = 0;
   pool->whatprovidesdataleft -= count + 1;
 
   return (Id)off;
@@ -435,13 +585,14 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)
 
 #if defined(MULTI_SEMANTICS)
 # define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
-#elif defined(DEBIAN_SEMANTICS)
+#elif defined(DEBIAN)
 # define EVRCMP_DEPCMP EVRCMP_COMPARE
 #else
 # define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
 #endif
 
 /* check if a package's nevr matches a dependency */
+/* semi-private, called from public pool_match_nevr */
 
 int
 pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
@@ -457,7 +608,10 @@ pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
        {
        case REL_ARCH:
          if (s->arch != evr)
-           return 0;
+           {
+             if (evr != ARCH_SRC || s->arch != ARCH_NOSRC)
+               return 0;
+           }
          return pool_match_nevr(pool, s, name);
        case REL_OR:
          if (pool_match_nevr(pool, s, name))
@@ -468,6 +622,11 @@ pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
          if (!pool_match_nevr(pool, s, name))
            return 0;
          return pool_match_nevr(pool, s, evr);
+       case REL_MULTIARCH:
+         if (evr != ARCH_ANY)
+           return 0;
+         /* XXX : need to check for Multi-Arch: allowed! */
+         return pool_match_nevr(pool, s, name);
        default:
          return 0;
        }
@@ -475,18 +634,34 @@ pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
   if (!pool_match_nevr(pool, s, name))
     return 0;
   if (evr == s->evr)
-    return flags & 2 ? 1 : 0;
+    return (flags & REL_EQ) ? 1 : 0;
   if (!flags)
     return 0;
   if (flags == 7)
     return 1;
-  if (flags != 2 && flags != 5)
-    flags ^= 5;
-  if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP)))) != 0)
-    return 1;
+  switch (pool_evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP))
+    {
+    case -2:
+      return 1;
+    case -1:
+      return (flags & REL_LT) ? 1 : 0;
+    case 0:
+      return (flags & REL_EQ) ? 1 : 0;
+    case 1:
+      return (flags & REL_GT) ? 1 : 0;
+    case 2:
+      return (flags & REL_EQ) ? 1 : 0;
+    default:
+      break;
+    }
   return 0;
 }
 
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+/* forward declaration */
+static int pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr);
+#endif
+
 /* match (flags, evr) against provider (pflags, pevr) */
 static inline int
 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
@@ -495,22 +670,57 @@ pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
     return 0;
   if (flags == 7 || pflags == 7)
     return 1;          /* rel provides every version */
-  if ((pflags & flags & 5) != 0)
+  if ((pflags & flags & (REL_LT | REL_GT)) != 0)
     return 1;          /* both rels show in the same direction */
   if (pevr == evr)
+    return (flags & pflags & REL_EQ) ? 1 : 0;
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+  if (ISRELDEP(pevr))
     {
-      if ((pflags & flags & 2) != 0)
-       return 1;       /* both have '=', match */
+      Reldep *rd = GETRELDEP(pool, pevr);
+      if (rd->flags == REL_COMPAT)
+       return pool_match_flags_evr_rel_compat(pool, rd, flags, evr);
     }
-  else
+#endif
+  switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
     {
-      int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5);
-      if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_DEPCMP)))) != 0)
-       return 1;
+    case -2:
+      return (pflags & REL_EQ) ? 1 : 0;
+    case -1:
+      return (flags & REL_LT) || (pflags & REL_GT) ? 1 : 0;
+    case 0:
+      return (flags & pflags & REL_EQ) ? 1 : 0;
+    case 1:
+      return (flags & REL_GT) || (pflags & REL_LT) ? 1 : 0;
+    case 2:
+      return (flags & REL_EQ) ? 1 : 0;
+    default:
+      break;
     }
   return 0;
 }
 
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+static int
+pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr)
+{
+  /* range->name is the actual version, range->evr the backwards compatibility
+     version. If flags are '>=' or '>', we match the compatibility version
+     as well, otherwise only the actual version. */
+  if (!(flags & REL_GT) || (flags & REL_LT))
+    return pool_match_flags_evr(pool, REL_EQ, range->name, flags, evr);
+  return pool_match_flags_evr(pool, REL_LT | REL_EQ, range->name, flags, evr) &&
+         pool_match_flags_evr(pool, REL_GT | REL_EQ, range->evr, REL_EQ, evr);
+}
+#endif
+
+/* public (i.e. not inlined) version of pool_match_flags_evr */
+int
+pool_intersect_evrs(Pool *pool, int pflags, Id pevr, int flags, int evr)
+{
+  return pool_match_flags_evr(pool, pflags, pevr, flags, evr);
+}
+
 /* match two dependencies (d1 = provider) */
 
 int
@@ -537,30 +747,161 @@ pool_match_dep(Pool *pool, Id d1, Id d2)
   if (!pool_match_dep(pool, rd1->name, rd2->name))
     return 0;
   /* name matches, check flags and evr */
-  return pool_match_flags_evr(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
+  return pool_intersect_evrs(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
+}
+
+Id
+pool_searchlazywhatprovidesq(Pool *pool, Id d)
+{
+  int start = 0;
+  int end = pool->lazywhatprovidesq.count;
+  Id *elements;
+  if (!end)
+    return 0;
+  elements = pool->lazywhatprovidesq.elements;
+  while (end - start > 16)
+    {
+      int mid = (start + end) / 2 & ~1;
+      if (elements[mid] == d)
+       return elements[mid + 1];
+      if (elements[mid] < d)
+       start = mid + 2;
+      else
+       end = mid;
+    }
+  for (; start < end; start += 2)
+    if (elements[start] == d)
+      return elements[start + 1];
+  return 0;
+}
+
+/*
+ * addstdproviders
+ *
+ * lazy populating of the whatprovides array, non relation case
+ */
+static Id
+pool_addstdproviders(Pool *pool, Id d)
+{
+  const char *str;
+  Queue q;
+  Id qbuf[16];
+  Dataiterator di;
+  Id oldoffset;
+
+  if (pool->addedfileprovides == 2)
+    {
+      pool->whatprovides[d] = 1;
+      return 1;
+    }
+  str =  pool->ss.stringspace + pool->ss.strings[d];
+  if (*str != '/')
+    {
+      pool->whatprovides[d] = 1;
+      return 1;
+    }
+  queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
+  dataiterator_init(&di, pool, 0, 0, SOLVABLE_FILELIST, str, SEARCH_STRING|SEARCH_FILES|SEARCH_COMPLETE_FILELIST);
+  for (; dataiterator_step(&di); dataiterator_skip_solvable(&di))
+    {
+      Solvable *s = pool->solvables + di.solvid;
+      /* XXX: maybe should add a provides dependency to the solvables
+       * OTOH this is only needed for rel deps that filter the provides,
+       * and those should not use filelist entries */
+      if (s->repo->disabled)
+       continue;
+      if (s->repo != pool->installed && !pool_installable(pool, s))
+       continue;
+      queue_push(&q, di.solvid);
+    }
+  dataiterator_free(&di);
+  oldoffset = pool_searchlazywhatprovidesq(pool, d);
+  if (!q.count)
+    pool->whatprovides[d] = oldoffset ? oldoffset : 1;
+  else
+    {
+      if (oldoffset)
+       {
+         Id *oo = pool->whatprovidesdata + oldoffset;
+         int i;
+         /* unify both queues. easy, as we know both are sorted */
+         for (i = 0; i < q.count; i++)
+           {
+             if (*oo > q.elements[i])
+               continue;
+             if (*oo < q.elements[i])
+               queue_insert(&q, i, *oo);
+             oo++;
+             if (!*oo)
+               break;
+           }
+         while (*oo)
+           queue_push(&q, *oo++);
+         if (q.count == oo - (pool->whatprovidesdata + oldoffset))
+           {
+             /* end result has same size as oldoffset -> no new entries */
+             queue_free(&q);
+             pool->whatprovides[d] = oldoffset;
+             return oldoffset;
+           }
+       }
+      pool->whatprovides[d] = pool_queuetowhatprovides(pool, &q);
+    }
+  queue_free(&q);
+  return pool->whatprovides[d];
+}
+
+
+static inline int
+pool_is_kind(Pool *pool, Id name, Id kind)
+{
+  const char *n;
+  if (!kind)
+    return 1;
+  n = pool_id2str(pool, name);
+  if (kind != 1)
+    {
+      const char *kn = pool_id2str(pool, kind);
+      int knl = strlen(kn);
+      return !strncmp(n, kn, knl) && n[knl] == ':' ? 1 : 0;
+    }
+  else
+    {
+      if (*n == ':')
+       return 1;
+      while(*n >= 'a' && *n <= 'z')
+       n++;
+      return *n == ':' ? 0 : 1;
+    }
 }
 
 /*
  * addrelproviders
- * 
+ *
  * add packages fulfilling the relation to whatprovides array
- * no exact providers, do range match
- * 
+ *
+ * some words about REL_AND and REL_IF: we assume the best case
+ * here, so that you get a "potential" result if you ask for a match.
+ * E.g. if you ask for "whatrequires A" and package X contains
+ * "Requires: A & B", you'll get "X" as an answer.
  */
-
 Id
 pool_addrelproviders(Pool *pool, Id d)
 {
-  Reldep *rd = GETRELDEP(pool, d);
+  Reldep *rd;
   Reldep *prd;
   Queue plist;
   Id buf[16];
-  Id name = rd->name;
-  Id evr = rd->evr;
-  int flags = rd->flags;
+  Id name, evr, flags;
   Id pid, *pidp;
   Id p, *pp;
 
+  if (!ISRELDEP(d))
+    return pool_addstdproviders(pool, d);
+  rd = GETRELDEP(pool, d);
+  name = rd->name;
+  evr = rd->evr;
+  flags = rd->flags;
   d = GETRELID(d);
   queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
 
@@ -572,7 +913,6 @@ pool_addrelproviders(Pool *pool, Id d)
 
       switch (flags)
        {
-       case REL_AND:
        case REL_WITH:
          wp = pool_whatprovides(pool, name);
          pp2 = pool_whatprovides_ptr(pool, evr);
@@ -588,24 +928,43 @@ pool_addrelproviders(Pool *pool, Id d)
                wp = 0;
            }
          break;
+
+       case REL_AND:
        case REL_OR:
          wp = pool_whatprovides(pool, name);
-         pp = pool->whatprovidesdata + wp;
-         if (!*pp)
+         if (!pool->whatprovidesdata[wp])
            wp = pool_whatprovides(pool, evr);
          else
            {
-             int cnt;
-             while ((p = *pp++) != 0)
-               queue_push(&plist, p);
-             cnt = plist.count;
-             pp = pool_whatprovides_ptr(pool, evr);
-             while ((p = *pp++) != 0)
-               queue_pushunique(&plist, p);
-             if (plist.count != cnt)
+             /* sorted merge */
+             pp2 = pool_whatprovides_ptr(pool, evr);
+             pp = pool->whatprovidesdata + wp;
+             while (*pp && *pp2)
+               {
+                 if (*pp < *pp2)
+                   queue_push(&plist, *pp++);
+                 else
+                   {
+                     if (*pp == *pp2)
+                       pp++;
+                     queue_push(&plist, *pp2++);
+                   }
+               }
+             while (*pp)
+               queue_push(&plist, *pp++);
+             while (*pp2)
+               queue_push(&plist, *pp2++);
+             /* if the number of elements did not change, we can reuse wp */
+             if (pp - (pool->whatprovidesdata + wp) != plist.count)
                wp = 0;
            }
          break;
+
+       case REL_COND:
+         /* assume the condition is true */
+         wp = pool_whatprovides(pool, name);
+         break;
+
        case REL_NAMESPACE:
          if (name == NAMESPACE_OTHERPROVIDERS)
            {
@@ -631,14 +990,30 @@ pool_addrelproviders(Pool *pool, Id d)
           * we have to iterate over the solvables as src packages do not
           * provide anything, thus they are not indexed in our
           * whatprovides hash */
-         if (evr == ARCH_SRC)
+         if (evr == ARCH_SRC || evr == ARCH_NOSRC)
            {
              Solvable *s;
              for (p = 1, s = pool->solvables + p; p < pool->nsolvables; p++, s++)
                {
-                 if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+                 if (!s->repo)
+                   continue;
+                 if (s->arch != evr && s->arch != ARCH_NOSRC)
+                   continue;
+                 if (pool_disabled_solvable(pool, s))
                    continue;
-                 if (pool_match_nevr(pool, s, name))
+                 if (!name || pool_match_nevr(pool, s, name))
+                   queue_push(&plist, p);
+               }
+             break;
+           }
+         if (!name)
+           {
+             FOR_POOL_SOLVABLES(p)
+               {
+                 Solvable *s = pool->solvables + p;
+                 if (s->repo != pool->installed && !pool_installable(pool, s))
+                   continue;
+                 if (s->arch == evr)
                    queue_push(&plist, p);
                }
              break;
@@ -654,6 +1029,37 @@ pool_addrelproviders(Pool *pool, Id d)
                wp = 0;
            }
          break;
+       case REL_MULTIARCH:
+         if (evr != ARCH_ANY)
+           break;
+         /* XXX : need to check for Multi-Arch: allowed! */
+         wp = pool_whatprovides(pool, name);
+         break;
+       case REL_KIND:
+         /* package kind filtering */
+         if (!name)
+           {
+             FOR_POOL_SOLVABLES(p)
+               {
+                 Solvable *s = pool->solvables + p;
+                 if (s->repo != pool->installed && !pool_installable(pool, s))
+                   continue;
+                 if (pool_is_kind(pool, s->name, evr))
+                   queue_push(&plist, p);
+               }
+             break;
+           }
+         wp = pool_whatprovides(pool, name);
+         pp = pool->whatprovidesdata + wp;
+         while ((p = *pp++) != 0)
+           {
+             Solvable *s = pool->solvables + p;
+             if (pool_is_kind(pool, s->name, evr))
+               queue_push(&plist, p);
+             else
+               wp = 0;
+           }
+         break;
        case REL_FILECONFLICT:
          pp = pool_whatprovides_ptr(pool, name);
          while ((p = *pp++) != 0)
@@ -685,7 +1091,7 @@ pool_addrelproviders(Pool *pool, Id d)
     {
       /* simple version comparison relation */
 #if 0
-      POOL_DEBUG(SAT_DEBUG_STATS, "addrelproviders: what provides %s?\n", dep2str(pool, name));
+      POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: what provides %s?\n", pool_dep2str(pool, name));
 #endif
       pp = pool_whatprovides_ptr(pool, name);
       while (ISRELDEP(name))
@@ -707,22 +1113,14 @@ pool_addrelproviders(Pool *pool, Id d)
          pidp = s->repo->idarraydata + s->provides;
          while ((pid = *pidp++) != 0)
            {
-             if (pid == name)
+             if (!ISRELDEP(pid))
                {
-#if defined(MULTI_SEMANTICS)
+                 if (pid != name)
+                   continue;           /* wrong provides name */
                  if (pool->disttype == DISTTYPE_DEB)
-                   continue;
-                 else
-                   break;
-#elif defined(DEBIAN_SEMANTICS)
-                 continue;             /* unversioned provides can
-                                        * never match versioned deps */
-#else
-                 break;                /* yes, provides all versions */
-#endif
+                   continue;           /* unversioned provides can never match versioned deps */
+                 break;
                }
-             if (!ISRELDEP(pid))
-               continue;               /* wrong provides name */
              prd = GETRELDEP(pool, pid);
              if (prd->name != name)
                continue;               /* wrong provides name */
@@ -735,12 +1133,12 @@ pool_addrelproviders(Pool *pool, Id d)
          queue_push(&plist, p);
        }
       /* make our system solvable provide all unknown rpmlib() stuff */
-      if (plist.count == 0 && !strncmp(id2str(pool, name), "rpmlib(", 7))
+      if (plist.count == 0 && !strncmp(pool_id2str(pool, name), "rpmlib(", 7))
        queue_push(&plist, SYSTEMSOLVABLE);
     }
   /* add providers to whatprovides */
 #if 0
-  POOL_DEBUG(SAT_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
 #endif
   pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
   queue_free(&plist);
@@ -748,6 +1146,46 @@ pool_addrelproviders(Pool *pool, Id d)
   return pool->whatprovides_rel[d];
 }
 
+void
+pool_flush_namespaceproviders(Pool *pool, Id ns, Id evr)
+{
+  int nrels = pool->nrels;
+  Id d;
+  Reldep *rd;
+
+  if (!pool->whatprovides_rel)
+    return;
+  for (d = 1, rd = pool->rels + d; d < nrels; d++, rd++)
+    {
+      if (rd->flags != REL_NAMESPACE || rd->name == NAMESPACE_OTHERPROVIDERS)
+       continue;
+      if (ns && rd->name != ns)
+       continue;
+      if (evr && rd->evr != evr)
+       continue;
+      pool->whatprovides_rel[d] = 0;
+    }
+}
+
+/* intersect dependencies in keyname with dep, return list of matching packages */
+void
+pool_whatmatchesdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker)
+{
+  Id p;
+
+  queue_empty(q);
+  FOR_POOL_SOLVABLES(p)
+    {
+      Solvable *s = pool->solvables + p;
+      if (s->repo->disabled)
+       continue;
+      if (s->repo != pool->installed && !pool_installable(pool, s))
+       continue;
+      if (solvable_matchesdep(s, keyname, dep, marker))
+       queue_push(q, p);
+    }
+}
+
 /*************************************************************************/
 
 void
@@ -756,7 +1194,7 @@ pool_debug(Pool *pool, int type, const char *format, ...)
   va_list args;
   char buf[1024];
 
-  if ((type & (SAT_FATAL|SAT_ERROR)) == 0)
+  if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0)
     {
       if ((pool->debugmask & type) == 0)
        return;
@@ -764,40 +1202,100 @@ pool_debug(Pool *pool, int type, const char *format, ...)
   va_start(args, format);
   if (!pool->debugcallback)
     {
-      if ((type & (SAT_FATAL|SAT_ERROR)) == 0 && !(pool->debugmask & SAT_DEBUG_TO_STDERR))
+      if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0 && !(pool->debugmask & SOLV_DEBUG_TO_STDERR))
         vprintf(format, args);
       else
         vfprintf(stderr, format, args);
       return;
     }
   vsnprintf(buf, sizeof(buf), format, args);
+  va_end(args);
   pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
 }
 
+int
+pool_error(Pool *pool, int ret, const char *format, ...)
+{
+  va_list args;
+  int l;
+  va_start(args, format);
+  if (!pool->errstr)
+    {
+      pool->errstra = 1024;
+      pool->errstr = solv_malloc(pool->errstra);
+    }
+  if (!*format)
+    {
+      *pool->errstr = 0;
+      l = 0;
+    }
+  else
+    l = vsnprintf(pool->errstr, pool->errstra, format, args);
+  va_end(args);
+  if (l >= 0 && l + 1 > pool->errstra)
+    {
+      pool->errstra = l + 256;
+      pool->errstr = solv_realloc(pool->errstr, pool->errstra);
+      va_start(args, format);
+      l = vsnprintf(pool->errstr, pool->errstra, format, args);
+      va_end(args);
+    }
+  if (l < 0)
+    strcpy(pool->errstr, "unknown error");
+  if (pool->debugmask & SOLV_ERROR)
+    pool_debug(pool, SOLV_ERROR, "%s\n", pool->errstr);
+  return ret;
+}
+
+char *
+pool_errstr(Pool *pool)
+{
+  return pool->errstr ? pool->errstr : "no error";
+}
+
 void
 pool_setdebuglevel(Pool *pool, int level)
 {
-  int mask = SAT_DEBUG_RESULT;
+  int mask = SOLV_DEBUG_RESULT;
   if (level > 0)
-    mask |= SAT_DEBUG_STATS|SAT_DEBUG_ANALYZE|SAT_DEBUG_UNSOLVABLE|SAT_DEBUG_SOLVER|SAT_DEBUG_TRANSACTION;
+    mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION|SOLV_ERROR;
   if (level > 1)
-    mask |= SAT_DEBUG_JOB|SAT_DEBUG_SOLUTIONS|SAT_DEBUG_POLICY;
+    mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
   if (level > 2)
-    mask |= SAT_DEBUG_PROPAGATE;
+    mask |= SOLV_DEBUG_PROPAGATE;
   if (level > 3)
-    mask |= SAT_DEBUG_RULE_CREATION;
-  if (level > 4)
-    mask |= SAT_DEBUG_SCHUBI;
-  mask |= pool->debugmask & SAT_DEBUG_TO_STDERR;       /* keep bit */
+    mask |= SOLV_DEBUG_RULE_CREATION;
+  mask |= pool->debugmask & SOLV_DEBUG_TO_STDERR;      /* keep bit */
   pool->debugmask = mask;
 }
 
+void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
+{
+  pool->debugcallback = debugcallback;
+  pool->debugcallbackdata = debugcallbackdata;
+}
+
+void pool_setdebugmask(Pool *pool, int mask)
+{
+  pool->debugmask = mask;
+}
+
+void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
+{
+  pool->loadcallback = cb;
+  pool->loadcallbackdata = loadcbdata;
+}
+
+void pool_setnamespacecallback(Pool *pool, Id (*cb)(struct _Pool *, void *, Id, Id), void *nscbdata)
+{
+  pool->nscallback = cb;
+  pool->nscallbackdata = nscbdata;
+}
+
 /*************************************************************************/
 
 struct searchfiles {
   Id *ids;
-  char **dirs;
-  char **names;
   int nfiles;
   Map seen;
 };
@@ -808,7 +1306,7 @@ static void
 pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct searchfiles *isf)
 {
   Id dep, sid;
-  const char *s, *sr;
+  const char *s;
   struct searchfiles *csf;
 
   while ((dep = *ida++) != 0)
@@ -860,20 +1358,13 @@ pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct sea
       if (MAPTST(&csf->seen, dep))
        continue;
       MAPSET(&csf->seen, dep);
-      s = id2str(pool, dep);
+      s = pool_id2str(pool, dep);
       if (*s != '/')
        continue;
-      csf->ids = sat_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
-      csf->dirs = sat_extend(csf->dirs, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
-      csf->names = sat_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
-      csf->ids[csf->nfiles] = dep;
-      sr = strrchr(s, '/');
-      csf->names[csf->nfiles] = strdup(sr + 1);
-      csf->dirs[csf->nfiles] = sat_malloc(sr - s + 1);
-      if (sr != s)
-        strncpy(csf->dirs[csf->nfiles], s, sr - s);
-      csf->dirs[csf->nfiles][sr - s] = 0;
-      csf->nfiles++;
+      if (csf != isf && pool->addedfileprovides == 1 && !repodata_filelistfilter_matches(0, s))
+       continue;       /* skip non-standard locations csf == isf: installed case */
+      csf->ids = solv_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
+      csf->ids[csf->nfiles++] = dep;
     }
 }
 
@@ -899,6 +1390,19 @@ addfileprovides_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyV
   if (!cbd->useddirs.size)
     {
       map_init(&cbd->useddirs, data->dirpool.ndirs + 1);
+      if (!cbd->dirs)
+       {
+         cbd->dirs = solv_malloc2(cbd->nfiles, sizeof(char *));
+         cbd->names = solv_malloc2(cbd->nfiles, sizeof(char *));
+         for (i = 0; i < cbd->nfiles; i++)
+           {
+             char *s = solv_strdup(pool_id2str(data->repo->pool, cbd->ids[i]));
+             cbd->dirs[i] = s;
+             s = strrchr(s, '/');
+             *s = 0;
+             cbd->names[i] = s + 1;
+           }
+       }
       for (i = 0; i < cbd->nfiles; i++)
        {
          Id did;
@@ -912,19 +1416,13 @@ addfileprovides_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyV
          if (did)
            MAPSET(&cbd->useddirs, did);
        }
+      repodata_free_dircache(data);
     }
   if (value->id >= data->dirpool.ndirs || !MAPTST(&cbd->useddirs, value->id))
     return 0;
   for (i = 0; i < cbd->nfiles; i++)
-    {
-      if (cbd->dids[i] != value->id)
-       continue;
-      if (!strcmp(cbd->names[i], value->str))
-       break;
-    }
-  if (i == cbd->nfiles)
-    return 0;
-  s->provides = repo_addid_dep(s->repo, s->provides, cbd->ids[i], SOLVABLE_FILEMARKER);
+    if (cbd->dids[i] == value->id && !strcmp(cbd->names[i], value->str))
+      s->provides = repo_addid_dep(s->repo, s->provides, cbd->ids[i], SOLVABLE_FILEMARKER);
   return 0;
 }
 
@@ -940,24 +1438,24 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru
   Map donemap;
   int ndone, incomplete;
 
-  if (!pool->nrepos)
+  if (!pool->urepos)
     return;
 
   cbd->nfiles = sf->nfiles;
   cbd->ids = sf->ids;
-  cbd->dirs = sf->dirs;
-  cbd->names = sf->names;
-  cbd->dids = sat_realloc2(cbd->dids, sf->nfiles, sizeof(Id));
+  cbd->dirs = 0;
+  cbd->names = 0;
+  cbd->dids = solv_realloc2(cbd->dids, sf->nfiles, sizeof(Id));
   map_init(&cbd->providedids, pool->ss.nstrings);
 
-  repoid = 0;
-  repo = repoonly ? repoonly : pool->repos[0];
+  repoid = 1;
+  repo = repoonly ? repoonly : pool->repos[repoid];
   map_init(&donemap, pool->nsolvables);
   queue_init(&fileprovidesq);
   provstart = provend = 0;
   for (;;)
     {
-      if (repo->disabled)
+      if (!repo || repo->disabled)
        {
          if (repoonly || ++repoid == pool->nrepos)
            break;
@@ -965,7 +1463,7 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru
          continue;
        }
       ndone = 0;
-      for (data = repo->repodata, repodataid = 0; repodataid < repo->nrepodata; repodataid++, data++)
+      FOR_REPODATAS(repo, repodataid, data)
        {
          if (ndone >= repo->nsolvables)
            break;
@@ -1015,11 +1513,11 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru
                {
 #if 0
                  for (i = 0; i < cbd->nfiles; i++)
-                   if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, id2str(pool, cbd->ids[i])))
-                     printf("need complete filelist because of %s\n", id2str(pool, cbd->ids[i]));
+                   if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
+                     printf("need complete filelist because of %s\n", pool_id2str(pool, cbd->ids[i]));
 #endif
                  for (i = 0; i < cbd->nfiles; i++)
-                   if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, id2str(pool, cbd->ids[i])))
+                   if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
                      break;
                  if (i < cbd->nfiles)
                    incomplete = 1;
@@ -1050,24 +1548,37 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru
   map_free(&donemap);
   queue_free(&fileprovidesq);
   map_free(&cbd->providedids);
+  if (cbd->dirs)
+    {
+      for (i = 0; i < cbd->nfiles; i++)
+       solv_free(cbd->dirs[i]);
+      cbd->dirs = solv_free(cbd->dirs);
+      cbd->names = solv_free(cbd->names);
+    }
 }
 
 void
-pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
+pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst)
 {
   Solvable *s;
-  Repo *repo;
+  Repo *installed, *repo;
   struct searchfiles sf, isf, *isfp;
   struct addfileprovides_cbdata cbd;
   int i;
   unsigned int now;
 
-  now = sat_timems(0);
+  installed = pool->installed;
+  now = solv_timems(0);
   memset(&sf, 0, sizeof(sf));
   map_init(&sf.seen, pool->ss.nstrings + pool->nrels);
   memset(&isf, 0, sizeof(isf));
   map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
+  pool->addedfileprovides = pool->addfileprovidesfiltered ? 1 : 2;
 
+  if (idq)
+    queue_empty(idq);
+  if (idqinst)
+    queue_empty(idqinst);
   isfp = installed ? &isf : 0;
   for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
     {
@@ -1091,59 +1602,45 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
     }
   map_free(&sf.seen);
   map_free(&isf.seen);
-  POOL_DEBUG(SAT_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
+  POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
   cbd.dids = 0;
-  if (idp)
-    *idp = 0;
   if (sf.nfiles)
     {
 #if 0
       for (i = 0; i < sf.nfiles; i++)
-       POOL_DEBUG(SAT_DEBUG_STATS, "looking up %s in filelist\n", id2str(pool, sf.ids[i]));
+       POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i]));
 #endif
       pool_addfileprovides_search(pool, &cbd, &sf, 0);
-      if (idp)
-       {
-         sf.ids = sat_extend(sf.ids, sf.nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
-         sf.ids[sf.nfiles] = 0;
-         *idp = sf.ids;
-         sf.ids = 0;
-       }
-      sat_free(sf.ids);
-      for (i = 0; i < sf.nfiles; i++)
-       {
-         sat_free(sf.dirs[i]);
-         sat_free(sf.names[i]);
-       }
-      sat_free(sf.dirs);
-      sat_free(sf.names);
+      if (idq)
+        for (i = 0; i < sf.nfiles; i++)
+         queue_push(idq, sf.ids[i]);
+      if (idqinst)
+        for (i = 0; i < sf.nfiles; i++)
+         queue_push(idqinst, sf.ids[i]);
+      solv_free(sf.ids);
     }
   if (isf.nfiles)
     {
 #if 0
       for (i = 0; i < isf.nfiles; i++)
-       POOL_DEBUG(SAT_DEBUG_STATS, "looking up %s in installed filelist\n", id2str(pool, isf.ids[i]));
+       POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in installed filelist\n", pool_id2str(pool, isf.ids[i]));
 #endif
       if (installed)
         pool_addfileprovides_search(pool, &cbd, &isf, installed);
-      sat_free(isf.ids);
-      for (i = 0; i < isf.nfiles; i++)
-       {
-         sat_free(isf.dirs[i]);
-         sat_free(isf.names[i]);
-       }
-      sat_free(isf.dirs);
-      sat_free(isf.names);
+      if (installed && idqinst)
+        for (i = 0; i < isf.nfiles; i++)
+         queue_pushunique(idqinst, isf.ids[i]);
+      solv_free(isf.ids);
     }
-  sat_free(cbd.dids);
+  solv_free(cbd.dids);
   pool_freewhatprovides(pool); /* as we have added provides */
-  POOL_DEBUG(SAT_DEBUG_STATS, "addfileprovides took %d ms\n", sat_timems(now));
+  POOL_DEBUG(SOLV_DEBUG_STATS, "addfileprovides took %d ms\n", solv_timems(now));
 }
 
 void
 pool_addfileprovides(Pool *pool)
 {
-  pool_addfileprovides_ids(pool, pool->installed, 0);
+  pool_addfileprovides_queue(pool, 0, 0);
 }
 
 void
@@ -1173,20 +1670,17 @@ pool_set_languages(Pool *pool, const char **languages, int nlanguages)
 {
   int i;
 
-  pool->languagecache = sat_free(pool->languagecache);
+  pool->languagecache = solv_free(pool->languagecache);
   pool->languagecacheother = 0;
-  if (pool->nlanguages)
-    {
-      for (i = 0; i < pool->nlanguages; i++)
-       free((char *)pool->languages[i]);
-      free(pool->languages);
-    }
+  for (i = 0; i < pool->nlanguages; i++)
+    free((char *)pool->languages[i]);
+  pool->languages = solv_free((void *)pool->languages);
   pool->nlanguages = nlanguages;
   if (!nlanguages)
     return;
-  pool->languages = sat_calloc(nlanguages, sizeof(const char **));
+  pool->languages = solv_calloc(nlanguages, sizeof(const char **));
   for (i = 0; i < pool->nlanguages; i++)
-    pool->languages[i] = strdup(languages[i]);
+    pool->languages[i] = solv_strdup(languages[i]);
 }
 
 Id
@@ -1196,16 +1690,16 @@ pool_id2langid(Pool *pool, Id id, const char *lang, int create)
   char buf[256], *p;
   int l;
 
-  if (!lang)
+  if (!lang || !*lang)
     return id;
-  n = id2str(pool, id);
+  n = pool_id2str(pool, id);
   l = strlen(n) + strlen(lang) + 2;
   if (l > sizeof(buf))
-    p = sat_malloc(strlen(n) + strlen(lang) + 2);
+    p = solv_malloc(strlen(n) + strlen(lang) + 2);
   else
     p = buf;
   sprintf(p, "%s:%s", n, lang);
-  id = str2id(pool, p, create);
+  id = pool_str2id(pool, p, create);
   if (p != buf)
     free(p);
   return id;
@@ -1219,7 +1713,7 @@ pool_alloctmpspace(Pool *pool, int len)
     return 0;
   if (len > pool->tmpspace.len[n])
     {
-      pool->tmpspace.buf[n] = sat_realloc(pool->tmpspace.buf[n], len + 32);
+      pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
       pool->tmpspace.len[n] = len + 32;
     }
   pool->tmpspace.n = (n + 1) % POOL_TMPSPACEBUF;
@@ -1243,7 +1737,7 @@ pool_alloctmpspace_free(Pool *pool, const char *space, int len)
            continue;
          if (len > pool->tmpspace.len[n])
            {
-             pool->tmpspace.buf[n] = sat_realloc(pool->tmpspace.buf[n], len + 32);
+             pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
              pool->tmpspace.len[n] = len + 32;
            }
           return pool->tmpspace.buf[n];
@@ -1333,7 +1827,7 @@ pool_bin2hex(Pool *pool, const unsigned char *buf, int len)
   if (!len)
     return "";
   s = pool_alloctmpspace(pool, 2 * len + 1);
-  sat_bin2hex(buf, len, s);
+  solv_bin2hex(buf, len, s);
   return s;
 }
 
@@ -1373,9 +1867,9 @@ solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyVa
       struct mptree *mptree;
 
       /* create map from dir to mptree */
-      cbd->dirmap = sat_free(cbd->dirmap);
+      cbd->dirmap = solv_free(cbd->dirmap);
       cbd->nmap = 0;
-      dirmap = sat_calloc(data->dirpool.ndirs, sizeof(Id));
+      dirmap = solv_calloc(data->dirpool.ndirs, sizeof(Id));
       mptree = cbd->mptree;
       mp = 0;
       for (dn = 2, dirs = data->dirpool.dirs + dn; dn < data->dirpool.ndirs; dn++)
@@ -1400,7 +1894,7 @@ solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyVa
          if (data->localpool)
            compstr = stringpool_id2str(&data->spool, comp);
          else
-           compstr = id2str(data->repo->pool, comp);
+           compstr = pool_id2str(data->repo->pool, comp);
          compl = strlen(compstr);
          for (i = mptree[mp].child; i; i = mptree[i].sibling)
            if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
@@ -1428,7 +1922,7 @@ solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyVa
       cbd->mps[mp].kbytes += value->num;
       cbd->mps[mp].files += value->num2;
     }
-  else
+  else if (!(cbd->mps[mp].flags & DUCHANGES_ONLYADD))
     {
       cbd->mps[mp].kbytes -= value->num;
       cbd->mps[mp].files -= value->num2;
@@ -1450,29 +1944,16 @@ propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint)
 
 #define MPTREE_BLOCK 15
 
-void
-pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
+static struct mptree *
+create_mptree(DUChanges *mps, int nmps)
 {
-  char *p;
-  const char *path, *compstr;
-  struct mptree *mptree;
   int i, nmptree;
+  struct mptree *mptree;
   int pos, compl;
   int mp;
-  struct ducbdata cbd;
-  Solvable *s;
-  Id sp;
-  Map ignoredu;
-  Repo *oldinstalled = pool->installed;
-
-  memset(&ignoredu, 0, sizeof(ignoredu));
-  cbd.mps = mps;
-  cbd.addsub = 0;
-  cbd.dirmap = 0;
-  cbd.nmap = 0;
-  cbd.olddata = 0;
+  const char *p, *path, *compstr;
 
-  mptree = sat_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
+  mptree = solv_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
 
   /* our root node */
   mptree[0].sibling = 0;
@@ -1481,7 +1962,7 @@ pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
   mptree[0].compl = 0;
   mptree[0].mountpoint = -1;
   nmptree = 1;
-  
+
   /* create component tree */
   for (mp = 0; mp < nmps; mp++)
     {
@@ -1513,7 +1994,7 @@ pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
          if (!i)
            {
              /* create new node */
-             mptree = sat_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
+             mptree = solv_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
              i = nmptree++;
              mptree[i].sibling = mptree[pos].child;
              mptree[i].child = 0;
@@ -1540,6 +2021,30 @@ pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
     }
 #endif
 
+  return mptree;
+}
+
+void
+pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
+{
+  struct mptree *mptree;
+  struct ducbdata cbd;
+  Solvable *s;
+  int i, sp;
+  Map ignoredu;
+  Repo *oldinstalled = pool->installed;
+  int haveonlyadd = 0;
+
+  map_init(&ignoredu, 0);
+  mptree = create_mptree(mps, nmps);
+
+  for (i = 0; i < nmps; i++)
+    if ((mps[i].flags & DUCHANGES_ONLYADD) != 0)
+      haveonlyadd = 1;
+  cbd.mps = mps;
+  cbd.dirmap = 0;
+  cbd.nmap = 0;
+  cbd.olddata = 0;
   cbd.mptree = mptree;
   cbd.addsub = 1;
   for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
@@ -1553,21 +2058,55 @@ pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
       if (!cbd.hasdu && oldinstalled)
        {
          Id op, opp;
+         int didonlyadd = 0;
          /* no du data available, ignore data of all installed solvables we obsolete */
-         if (!ignoredu.map)
-           map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
+         if (!ignoredu.size)
+           map_grow(&ignoredu, oldinstalled->end - oldinstalled->start);
+         FOR_PROVIDES(op, opp, s->name)
+           {
+             Solvable *s2 = pool->solvables + op;
+             if (!pool->implicitobsoleteusesprovides && s->name != s2->name)
+               continue;
+             if (pool->implicitobsoleteusescolors && !pool_colormatch(pool, s, s2))
+               continue;
+             if (op >= oldinstalled->start && op < oldinstalled->end)
+               {
+                 MAPSET(&ignoredu, op - oldinstalled->start);
+                 if (haveonlyadd && pool->solvables[op].repo == oldinstalled && !didonlyadd)
+                   {
+                     repo_search(oldinstalled, op, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
+                     cbd.addsub = -1;
+                     repo_search(oldinstalled, op, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
+                     cbd.addsub = 1;
+                     didonlyadd = 1;
+                   }
+               }
+           }
          if (s->obsoletes)
            {
              Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
              while ((obs = *obsp++) != 0)
                FOR_PROVIDES(op, opp, obs)
-                 if (op >= oldinstalled->start && op < oldinstalled->end)
-                   MAPSET(&ignoredu, op - oldinstalled->start);
+                 {
+                   Solvable *s2 = pool->solvables + op;
+                   if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, s2, obs))
+                     continue;
+                   if (pool->obsoleteusescolors && !pool_colormatch(pool, s, s2))
+                     continue;
+                   if (op >= oldinstalled->start && op < oldinstalled->end)
+                     {
+                       MAPSET(&ignoredu, op - oldinstalled->start);
+                       if (haveonlyadd && pool->solvables[op].repo == oldinstalled && !didonlyadd)
+                         {
+                           repo_search(oldinstalled, op, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
+                           cbd.addsub = -1;
+                           repo_search(oldinstalled, op, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
+                           cbd.addsub = 1;
+                           didonlyadd = 1;
+                         }
+                     }
+                 }
            }
-         FOR_PROVIDES(op, opp, s->name)
-           if (pool->solvables[op].name == s->name)
-             if (op >= oldinstalled->start && op < oldinstalled->end)
-               MAPSET(&ignoredu, op - oldinstalled->start);
        }
     }
   cbd.addsub = -1;
@@ -1583,10 +2122,9 @@ pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
          repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
        }
     }
-  if (ignoredu.map)
-    map_free(&ignoredu);
-  sat_free(cbd.dirmap);
-  sat_free(mptree);
+  map_free(&ignoredu);
+  solv_free(cbd.dirmap);
+  solv_free(mptree);
 }
 
 int
@@ -1603,7 +2141,7 @@ pool_calc_installsizechange(Pool *pool, Map *installedmap)
        continue;
       if (!MAPTST(installedmap, sp))
        continue;
-      change += solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
+      change += solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
     }
   if (oldinstalled)
     {
@@ -1611,7 +2149,7 @@ pool_calc_installsizechange(Pool *pool, Map *installedmap)
        {
          if (MAPTST(installedmap, sp))
            continue;
-         change -= solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
+         change -= solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
        }
     }
   return change;
@@ -1623,25 +2161,25 @@ pool_calc_installsizechange(Pool *pool, Map *installedmap)
  *  8: interesting (only true if installed)
  * 16: undecided
  */
+
 static inline Id dep2name(Pool *pool, Id dep)
 {
   while (ISRELDEP(dep))
     {
-      Reldep *rd = rd = GETRELDEP(pool, dep);
+      Reldep *rd = GETRELDEP(pool, dep);
       dep = rd->name;
     }
   return dep;
 }
 
-static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con) 
+static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
 {
   Id p, pp;
-  Solvable *sn = pool->solvables + n; 
+  Solvable *sn = pool->solvables + n;
 
   FOR_PROVIDES(p, pp, sn->name)
-    {    
-      Solvable *s = pool->solvables + p; 
+    {
+      Solvable *s = pool->solvables + p;
       if (s->name != sn->name || s->arch != sn->arch)
         continue;
       if ((map[p] & 9) != 9)
@@ -1653,7 +2191,7 @@ static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n
   return 0;
 }
 
-static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
+static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *multiversionmap)
 {
   Id p, pp;
   int r = 0;
@@ -1663,7 +2201,7 @@ static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, in
         return 1;      /* always boring, as never constraining */
       if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
        continue;
-      if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
+      if (ispatch && multiversionmap && multiversionmap->size && MAPTST(multiversionmap, p) && ISRELDEP(dep))
        if (providedbyinstalled_multiversion(pool, map, p, dep))
          continue;
       if ((map[p] & 9) == 9)
@@ -1685,14 +2223,14 @@ static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, in
  */
 
 void
-pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
+pool_trivial_installable_multiversionmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *multiversionmap)
 {
   int i, r, m, did;
   Id p, *dp, con, *conp, req, *reqp;
   unsigned char *map;
   Solvable *s;
 
-  map = sat_calloc(pool->nsolvables, 1);
+  map = solv_calloc(pool->nsolvables, 1);
   for (p = 1; p < pool->nsolvables; p++)
     {
       if (!MAPTST(installedmap, p))
@@ -1738,9 +2276,12 @@ pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pk
                {
                  /* decided and miss */
                  map[p] = 2;
+                 did = 0;
                  break;
                }
-             m |= r;   /* 1 | 9 | 16 | 17 */
+             if (r == 16)
+               break;  /* undecided */
+             m |= r;   /* 1 | 9 | 17 */
            }
          if (req)
            continue;
@@ -1751,20 +2292,21 @@ pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pk
        {
          int ispatch = 0;      /* see solver.c patch handling */
 
-         if (!strncmp("patch:", id2str(pool, s->name), 6))
+         if (!strncmp("patch:", pool_id2str(pool, s->name), 6))
            ispatch = 1;
          conp = s->repo->idarraydata + s->conflicts;
          while ((con = *conp++) != 0)
            {
-             if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
+             if ((providedbyinstalled(pool, map, con, ispatch, multiversionmap) & 1) != 0)
                {
                  map[p] = 2;
+                 did = 0;
                  break;
                }
              if ((m == 1 || m == 17) && ISRELDEP(con))
                {
                  con = dep2name(pool, con);
-                 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
+                 if ((providedbyinstalled(pool, map, con, ispatch, multiversionmap) & 1) != 0)
                    m = 9;
                }
            }
@@ -1828,14 +2370,14 @@ pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pk
 void
 pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
 {
-  pool_trivial_installable_noobsoletesmap(pool, installedmap, pkgs, res, 0);
+  pool_trivial_installable_multiversionmap(pool, installedmap, pkgs, res, 0);
 }
 
 const char *
 pool_lookup_str(Pool *pool, Id entry, Id keyname)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    return repodata_lookup_str(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
+    return repo_lookup_str(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
   if (entry <= 0)
     return 0;
   return solvable_lookup_str(pool->solvables + entry, keyname);
@@ -1845,26 +2387,17 @@ Id
 pool_lookup_id(Pool *pool, Id entry, Id keyname)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    {
-      Repodata *data = pool->pos.repo->repodata + pool->pos.repodataid;
-      Id id = repodata_lookup_id(data, SOLVID_POS, keyname);
-      return data->localpool ? repodata_globalize_id(data, id, 1) : id;
-    }
+    return repo_lookup_id(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
   if (entry <= 0)
     return 0;
   return solvable_lookup_id(pool->solvables + entry, keyname);
 }
 
-unsigned int
-pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned int notfound)
+unsigned long long
+pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned long long notfound)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    {
-      unsigned int value;
-      if (repodata_lookup_num(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, &value))
-       return value;
-      return notfound;
-    }
+    return repo_lookup_num(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, notfound);
   if (entry <= 0)
     return notfound;
   return solvable_lookup_num(pool->solvables + entry, keyname, notfound);
@@ -1874,7 +2407,7 @@ int
 pool_lookup_void(Pool *pool, Id entry, Id keyname)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    return repodata_lookup_void(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
+    return repo_lookup_void(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
   if (entry <= 0)
     return 0;
   return solvable_lookup_void(pool->solvables + entry, keyname);
@@ -1884,7 +2417,7 @@ const unsigned char *
 pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    return repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
+    return repo_lookup_bin_checksum(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, typep);
   if (entry <= 0)
     return 0;
   return solvable_lookup_bin_checksum(pool->solvables + entry, keyname, typep);
@@ -1894,15 +2427,70 @@ const char *
 pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
 {
   if (entry == SOLVID_POS && pool->pos.repo)
-    {
-      const unsigned char *chk = repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
-      return chk ? repodata_chk2str(pool->pos.repo->repodata + pool->pos.repodataid, *typep, chk) : 0;
-    }
+    return repo_lookup_checksum(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, typep);
   if (entry <= 0)
     return 0;
   return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
 }
 
+int
+pool_lookup_idarray(Pool *pool, Id entry, Id keyname, Queue *q)
+{
+  if (entry == SOLVID_POS && pool->pos.repo)
+    return repo_lookup_idarray(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, q);
+  if (entry <= 0)
+    return 0;
+  return solvable_lookup_idarray(pool->solvables + entry, keyname, q);
+}
+
+const char *
+pool_lookup_deltalocation(Pool *pool, Id entry, unsigned int *medianrp)
+{
+  const char *loc;
+  if (medianrp)
+    *medianrp = 0;
+  if (entry != SOLVID_POS)
+    return 0;
+  loc = pool_lookup_str(pool, entry, DELTA_LOCATION_DIR);
+  loc = pool_tmpjoin(pool, loc, loc ? "/" : 0, pool_lookup_str(pool, entry, DELTA_LOCATION_NAME));
+  loc = pool_tmpappend(pool, loc, "-", pool_lookup_str(pool, entry, DELTA_LOCATION_EVR));
+  loc = pool_tmpappend(pool, loc, ".", pool_lookup_str(pool, entry, DELTA_LOCATION_SUFFIX));
+  return loc;
+}
+
+static void
+add_new_provider(Pool *pool, Id id, Id p)
+{
+  Queue q;
+  Id *pp;
+
+  while (ISRELDEP(id))
+    {
+      Reldep *rd = GETRELDEP(pool, id);
+      id = rd->name;
+    }
+
+  queue_init(&q);
+  for (pp = pool->whatprovidesdata + pool->whatprovides[id]; *pp; pp++)
+    {
+      if (*pp == p)
+       {
+         queue_free(&q);
+         return;
+       }
+      if (*pp > p)
+       {
+         queue_push(&q, p);
+         p = 0;
+       }
+      queue_push(&q, *pp);
+    }
+  if (p)
+    queue_push(&q, p);
+  pool->whatprovides[id] = pool_queuetowhatprovides(pool, &q);
+  queue_free(&q);
+}
+
 void
 pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
 {
@@ -1914,18 +2502,21 @@ pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
 
   if (!conflicts->count)
     return;
-  pool_freewhatprovides(pool);
-  for (i = 0; i < conflicts->count; i += 5)
+  for (i = 0; i < conflicts->count; i += 6)
     {
       fn = conflicts->elements[i];
       p = conflicts->elements[i + 1];
       md5 = conflicts->elements[i + 2];
-      q = conflicts->elements[i + 3];
-      id = rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
+      q = conflicts->elements[i + 4];
+      id = pool_rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
       s = pool->solvables + p;
       if (!s->repo)
        continue;
       s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
+      if (pool->whatprovides)
+       add_new_provider(pool, fn, p);
+      if (pool->whatprovides_rel)
+       pool->whatprovides_rel[GETRELID(id)] = 0;       /* clear cache */
       s = pool->solvables + q;
       if (!s->repo)
        continue;
@@ -1935,4 +2526,44 @@ pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
     pool_freeidhashes(pool);
 }
 
+char *
+pool_prepend_rootdir(Pool *pool, const char *path)
+{
+  if (!path)
+    return 0;
+  if (!pool->rootdir)
+    return solv_strdup(path);
+  return solv_dupjoin(pool->rootdir, "/", *path == '/' ? path + 1 : path);
+}
+
+const char *
+pool_prepend_rootdir_tmp(Pool *pool, const char *path)
+{
+  if (!path)
+    return 0;
+  if (!pool->rootdir)
+    return path;
+  return pool_tmpjoin(pool, pool->rootdir, "/", *path == '/' ? path + 1 : path);
+}
+
+void
+pool_set_rootdir(Pool *pool, const char *rootdir)
+{
+  solv_free(pool->rootdir);
+  pool->rootdir = solv_strdup(rootdir);
+}
+
+const char *
+pool_get_rootdir(Pool *pool)
+{
+  return pool->rootdir;
+}
+
+/* only used in libzypp */
+void
+pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *))
+{
+  pool->custom_vendorcheck = vendorcheck;
+}
+
 /* EOF */