Imported Upstream version 0.7.5
[platform/upstream/libsolv.git] / src / solvable.c
index dfe8ce1..d3d2d31 100644 (file)
 #include "pool.h"
 #include "repo.h"
 #include "util.h"
+#include "policy.h"
+#include "poolvendor.h"
+#include "chksum.h"
+#include "linkedpkg.h"
 
 const char *
-solvable2str(Pool *pool, Solvable *s)
+pool_solvable2str(Pool *pool, Solvable *s)
 {
   const char *n, *e, *a;
+  int nl, el, al;
   char *p;
-  n = id2str(pool, s->name);
-  e = id2str(pool, s->evr);
-  a = id2str(pool, s->arch);
-  p = pool_alloctmpspace(pool, strlen(n) + strlen(e) + strlen(a) + 3);
-  sprintf(p, "%s-%s.%s", n, e, a);
+  n = pool_id2str(pool, s->name);
+  e = s->evr ? pool_id2str(pool, s->evr) : "";
+  /* XXX: may want to skip the epoch here */
+  a = s->arch ? pool_id2str(pool, s->arch) : "";
+  nl = strlen(n);
+  el = strlen(e);
+  al = strlen(a);
+  if (pool->havedistepoch)
+    {
+      /* strip the distepoch from the evr */
+      const char *de = strrchr(e, '-');
+      if (de && (de = strchr(de, ':')) != 0)
+       el = de - e;
+    }
+  p = pool_alloctmpspace(pool, nl + el + al + 3);
+  strcpy(p, n);
+  if (el)
+    {
+      p[nl++] = '-';
+      strncpy(p + nl, e, el);
+      p[nl + el] = 0;
+    }
+  if (al)
+    {
+      p[nl + el] = pool->disttype == DISTTYPE_HAIKU ? '-' : '.';
+      strcpy(p + nl + el + 1, a);
+    }
+  if (pool->disttype == DISTTYPE_CONDA && solvable_lookup_type(s, SOLVABLE_BUILDFLAVOR))
+    {
+      Queue flavorq;
+      int i;
+      queue_init(&flavorq);
+      solvable_lookup_idarray(s, SOLVABLE_BUILDFLAVOR, &flavorq);
+      for (i = 0; i < flavorq.count; i++)
+       p = pool_tmpappend(pool, p, "-", pool_id2str(pool, flavorq.elements[i]));
+      queue_free(&flavorq);
+    }
   return p;
 }
 
 Id
+solvable_lookup_type(Solvable *s, Id keyname)
+{
+  if (!s->repo)
+    return 0;
+  return repo_lookup_type(s->repo, s - s->repo->pool->solvables, keyname);
+}
+
+Id
 solvable_lookup_id(Solvable *s, Id keyname)
 {
   if (!s->repo)
@@ -45,32 +90,118 @@ solvable_lookup_id(Solvable *s, Id keyname)
 int
 solvable_lookup_idarray(Solvable *s, Id keyname, Queue *q)
 {
-  Dataiterator di;
-  int found = 0;
+  if (!s->repo)
+    {
+      queue_empty(q);
+      return 0;
+    }
+  return repo_lookup_idarray(s->repo, s - s->repo->pool->solvables, keyname, q);
+}
 
-  queue_empty(q);
+int
+solvable_lookup_deparray(Solvable *s, Id keyname, Queue *q, Id marker)
+{
   if (!s->repo)
-    return 0;
-  dataiterator_init(&di, s->repo->pool, s->repo, s - s->repo->pool->solvables, keyname, 0, SEARCH_ARRAYSENTINEL);
-  while (dataiterator_step(&di))
     {
-      if (di.key->type != REPOKEY_TYPE_IDARRAY && di.key->type != REPOKEY_TYPE_REL_IDARRAY)
-       continue;
-      found = 1;
-      if (di.kv.eof)
-       break;
-      queue_push(q, di.kv.id);
+      queue_empty(q);
+      return 0;
+    }
+  return repo_lookup_deparray(s->repo, s - s->repo->pool->solvables, keyname, q, marker);
+}
+
+static const char *
+solvable_lookup_str_joinarray(Solvable *s, Id keyname, const char *joinstr)
+{
+  Queue q;
+  Id qbuf[10];
+  char *str = 0;
+
+  queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
+  if (solvable_lookup_idarray(s, keyname, &q) && q.count)
+    {
+      Pool *pool = s->repo->pool;
+      if (q.count == 1)
+       str = (char *)pool_id2str(pool, q.elements[0]);
+      else
+       {
+         int i;
+         str = pool_tmpjoin(pool, pool_id2str(pool, q.elements[0]), 0, 0);
+         for (i = 1; i < q.count; i++)
+           str = pool_tmpappend(pool, str, joinstr, pool_id2str(pool, q.elements[i]));
+       }
     }
-  dataiterator_free(&di);
-  return found;
+  queue_free(&q);
+  return str;
 }
 
 const char *
 solvable_lookup_str(Solvable *s, Id keyname)
 {
+  const char *str;
   if (!s->repo)
     return 0;
-  return repo_lookup_str(s->repo, s - s->repo->pool->solvables, keyname);
+  str = repo_lookup_str(s->repo, s - s->repo->pool->solvables, keyname);
+  if (!str && (keyname == SOLVABLE_LICENSE || keyname == SOLVABLE_GROUP || keyname == SOLVABLE_BUILDFLAVOR))
+    str = solvable_lookup_str_joinarray(s, keyname, ", ");
+  return str;
+}
+
+static const char *
+solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname, int usebase)
+{
+  Pool *pool;
+  const char *str, *basestr;
+  Id p, pp, name;
+  Solvable *s2;
+  int pass;
+
+  if (!s->repo)
+    return 0;
+  pool = s->repo->pool;
+  str = solvable_lookup_str(s, keyname);
+  if (str || keyname == basekeyname)
+    return str;
+  basestr = solvable_lookup_str(s, basekeyname);
+  if (!basestr)
+    return 0;
+  /* search for a solvable with same name and same base that has the
+   * translation */
+  if (!pool->whatprovides)
+    return usebase ? basestr : 0;
+  name = s->name;
+  /* we do this in two passes, first same vendor, then all other vendors */
+  for (pass = 0; pass < 2; pass++)
+    {
+      FOR_PROVIDES(p, pp, name)
+       {
+         s2 = pool->solvables + p;
+         if (s2->name != name)
+           continue;
+         if ((s->vendor == s2->vendor) != (pass == 0))
+           continue;
+         str = solvable_lookup_str(s2, basekeyname);
+         if (!str || strcmp(str, basestr))
+           continue;
+         str = solvable_lookup_str(s2, keyname);
+         if (str)
+           return str;
+       }
+#ifdef ENABLE_LINKED_PKGS
+      /* autopattern/product translation magic */
+      if (pass)
+       {
+         const char *n = pool_id2str(pool, name);
+         if (*n == 'p')
+           {
+             if (!strncmp("pattern:", n, 8) && (name = find_autopattern_name(pool, s)) != 0)
+               pass = -1;
+             if (!strncmp("product:", n, 8) && (name = find_autoproduct_name(pool, s)) != 0)
+               pass = -1;
+           }
+       }
+#endif
+    }
+  return usebase ? basestr : 0;
 }
 
 const char *
@@ -89,7 +220,7 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname)
   cols = pool->nlanguages + 1;
   if (!pool->languagecache)
     {
-      pool->languagecache = sat_calloc(cols * ID_NUM_INTERNAL, sizeof(Id));
+      pool->languagecache = solv_calloc(cols * ID_NUM_INTERNAL, sizeof(Id));
       pool->languagecacheother = 0;
     }
   if (keyname >= ID_NUM_INTERNAL)
@@ -100,9 +231,9 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname)
          break;
       if (i >= pool->languagecacheother)
        {
-         pool->languagecache = sat_realloc2(pool->languagecache, pool->languagecacheother + 1, cols * sizeof(Id));
-         pool->languagecacheother++;
+         pool->languagecache = solv_realloc2(pool->languagecache, pool->languagecacheother + 1, cols * sizeof(Id));
          row = pool->languagecache + cols * (ID_NUM_INTERNAL + pool->languagecacheother++);
+         *row = keyname;
        }
     }
   else
@@ -111,17 +242,8 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname)
   for (i = 0; i < pool->nlanguages; i++, row++)
     {
       if (!*row)
-       {
-         char *p;
-         const char *kn;
-
-         kn = id2str(pool, keyname);
-          p = sat_malloc(strlen(kn) + strlen(pool->languages[i]) + 2);
-         sprintf(p, "%s:%s", kn, pool->languages[i]);
-         *row = str2id(pool, p, 1);
-          sat_free(p);
-       }
-      str = solvable_lookup_str(s, *row);
+        *row = pool_id2langid(pool, keyname, pool->languages[i], 1);
+      str = solvable_lookup_str_base(s, *row, keyname, 0);
       if (str)
        return str;
     }
@@ -129,26 +251,37 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname)
 }
 
 const char *
-solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang)
+solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang, int usebase)
 {
-  if (s->repo)
-    {
-      const char *str;
-      Id id = pool_id2langid(s->repo->pool, keyname, lang, 0);
-      if (id && (str = solvable_lookup_str(s, id)) != 0)
-        return str;
-    }
+  Id id;
+  if (!s->repo)
+    return 0;
+  id = pool_id2langid(s->repo->pool, keyname, lang, 0);
+  if (id)
+    return solvable_lookup_str_base(s, id, keyname, usebase);
+  if (!usebase)
+    return 0;
   return solvable_lookup_str(s, keyname);
 }
 
-unsigned int
-solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound)
+unsigned long long
+solvable_lookup_num(Solvable *s, Id keyname, unsigned long long notfound)
 {
   if (!s->repo)
-    return 0;
+    return notfound;
   return repo_lookup_num(s->repo, s - s->repo->pool->solvables, keyname, notfound);
 }
 
+unsigned long long
+solvable_lookup_sizek(Solvable *s, Id keyname, unsigned long long notfound)
+{
+  unsigned long long size;
+  if (!s->repo)
+    return notfound;
+  size = solvable_lookup_num(s, keyname, (unsigned long long)-1);
+  return size == (unsigned long long)-1 ? notfound : ((size + 1023) >> 10);
+}
+
 int
 solvable_lookup_void(Solvable *s, Id keyname)
 {
@@ -160,86 +293,64 @@ solvable_lookup_void(Solvable *s, Id keyname)
 int
 solvable_lookup_bool(Solvable *s, Id keyname)
 {
-  Repo *repo = s->repo;
-  Pool *pool;
-  Repodata *data;
-  int i, j, n;
-
-  if (!repo)
+  Id type;
+  if (!s->repo)
     return 0;
-  pool = repo->pool;
-  n = s - pool->solvables;
-  for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
-    {
-      if (n < data->start || n >= data->end)
-        continue;
-      /* there are two ways of storing a bool, as num == 1 or void */
-      for (j = 1; j < data->nkeys; j++)
-        {
-          if (data->keys[j].name == keyname
-              && (data->keys[j].type == REPOKEY_TYPE_U32
-                  || data->keys[j].type == REPOKEY_TYPE_NUM
-                  || data->keys[j].type == REPOKEY_TYPE_CONSTANT
-                  || data->keys[j].type == REPOKEY_TYPE_VOID))
-            {
-              unsigned int value;
-              if (repodata_lookup_num(data, n, keyname, &value))
-                return value == 1;
-              if (repodata_lookup_void(data, n, keyname))
-                return 1;
-            }
-        }
-    }
+  /* historic nonsense: there are two ways of storing a bool, as num == 1 or void. test both. */
+  type = repo_lookup_type(s->repo, s - s->repo->pool->solvables, keyname);
+  if (type == REPOKEY_TYPE_VOID)
+    return 1;
+  if (type == REPOKEY_TYPE_NUM || type == REPOKEY_TYPE_CONSTANT)
+    return repo_lookup_num(s->repo, s - s->repo->pool->solvables, keyname, 0) == 1;
   return 0;
 }
 
 const unsigned char *
 solvable_lookup_bin_checksum(Solvable *s, Id keyname, Id *typep)
 {
-  Repo *repo = s->repo;
-
-  if (!repo)
+  if (!s->repo)
     {
       *typep = 0;
       return 0;
     }
-  return repo_lookup_bin_checksum(repo, s - repo->pool->solvables, keyname, typep);
+  return repo_lookup_bin_checksum(s->repo, s - s->repo->pool->solvables, keyname, typep);
 }
 
 const char *
 solvable_lookup_checksum(Solvable *s, Id keyname, Id *typep)
 {
   const unsigned char *chk = solvable_lookup_bin_checksum(s, keyname, typep);
-  /* we need the repodata just as a reference for a pool */
-  return chk ? repodata_chk2str(s->repo->repodata, *typep, chk) : 0;
+  return chk ? pool_bin2hex(s->repo->pool, chk, solv_chksum_len(*typep)) : 0;
 }
 
 static inline const char *
 evrid2vrstr(Pool *pool, Id evrid)
 {
-  const char *p, *evr = id2str(pool, evrid);
+  const char *p, *evr = pool_id2str(pool, evrid);
   if (!evr)
     return evr;
   for (p = evr; *p >= '0' && *p <= '9'; p++)
     ;
-  return p != evr && *p == ':' ? p + 1 : evr;
+  return p != evr && *p == ':' && p[1] ? p + 1 : evr;
 }
 
-char *
-solvable_get_location(Solvable *s, unsigned int *medianrp)
+const char *
+solvable_lookup_location(Solvable *s, unsigned int *medianrp)
 {
   Pool *pool;
   int l = 0;
   char *loc;
   const char *mediadir, *mediafile;
 
-  *medianrp = 0;
+  if (medianrp)
+    *medianrp = 0;
   if (!s->repo)
     return 0;
   pool = s->repo->pool;
-  *medianrp = solvable_lookup_num(s, SOLVABLE_MEDIANR, 1);
+  if (medianrp)
+    *medianrp = solvable_lookup_num(s, SOLVABLE_MEDIANR, 0);
   if (solvable_lookup_void(s, SOLVABLE_MEDIADIR))
-    mediadir = id2str(pool, s->arch);
+    mediadir = pool_id2str(pool, s->arch);
   else
     mediadir = solvable_lookup_str(s, SOLVABLE_MEDIADIR);
   if (mediadir)
@@ -247,9 +358,9 @@ solvable_get_location(Solvable *s, unsigned int *medianrp)
   if (solvable_lookup_void(s, SOLVABLE_MEDIAFILE))
     {
       const char *name, *evr, *arch;
-      name = id2str(pool, s->name);
+      name = pool_id2str(pool, s->name);
       evr = evrid2vrstr(pool, s->evr);
-      arch = id2str(pool, s->arch);
+      arch = pool_id2str(pool, s->arch);
       /* name-vr.arch.rpm */
       loc = pool_alloctmpspace(pool, l + strlen(name) + strlen(evr) + strlen(arch) + 7);
       if (mediadir)
@@ -271,182 +382,45 @@ solvable_get_location(Solvable *s, unsigned int *medianrp)
   return loc;
 }
 
-/*****************************************************************************/
-
-static inline Id dep2name(Pool *pool, Id dep)
-{
-  while (ISRELDEP(dep))
-    {
-      Reldep *rd = rd = GETRELDEP(pool, dep);
-      dep = rd->name;
-    }
-  return dep;
-}
-
-static inline int providedbyinstalled(Pool *pool, Map *installed, Id dep)
+const char *
+solvable_get_location(Solvable *s, unsigned int *medianrp)
 {
-  Id p, pp;
-  FOR_PROVIDES(p, pp, dep)
-    {
-      if (p == SYSTEMSOLVABLE)
-       return -1;
-      if (MAPTST(installed, p))
-       return 1;
-    }
-  return 0;
+  const char *loc = solvable_lookup_location(s, medianrp);
+  if (medianrp && *medianrp == 0)
+    *medianrp = 1;     /* compat, to be removed */
+  return loc;
 }
 
-/*
- * solvable_trivial_installable_map - anwers is a solvable is installable
- * without any other installs/deinstalls.
- * The packages considered to be installed are provided via the
- * installedmap bitmap. A additional "conflictsmap" bitmap providing
- * information about the conflicts of the installed packages can be
- * used for extra speed up. Provide a NULL pointer if you do not
- * have this information.
- * Both maps can be created with pool_create_state_maps() or
- * solver_create_state_maps().
- *
- * returns:
- * 1:  solvable is installable without any other package changes
- * 0:  solvable is not installable
- * -1: solvable is installable, but doesn't constrain any installed packages
- */
-int
-solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap)
+const char *
+solvable_lookup_sourcepkg(Solvable *s)
 {
-  Pool *pool = s->repo->pool;
-  Solvable *s2;
-  Id p, pp, *dp;
-  Id *reqp, req;
-  Id *conp, con;
-  Id *obsp, obs;
-  int r, interesting = 0;
+  Pool *pool;
+  const char *evr, *name;
+  Id archid;
 
-  if (conflictsmap && MAPTST(conflictsmap, s - pool->solvables))
+  if (!s->repo)
     return 0;
-  if (s->requires)
-    {
-      reqp = s->repo->idarraydata + s->requires;
-      while ((req = *reqp++) != 0)
-       {
-         if (req == SOLVABLE_PREREQMARKER)
-           continue;
-          r = providedbyinstalled(pool, installedmap, req);
-         if (!r)
-           return 0;
-         if (r > 0)
-           interesting = 1;
-       }
-    }
-  if (s->conflicts)
-    {
-      conp = s->repo->idarraydata + s->conflicts;
-      while ((con = *conp++) != 0)
-       {
-         if (providedbyinstalled(pool, installedmap, con))
-           return 0;
-         if (!interesting && ISRELDEP(con))
-           {
-              con = dep2name(pool, con);
-             if (providedbyinstalled(pool, installedmap, con))
-               interesting = 1;
-           }
-       }
-    }
-  if (s->repo)
-    {
-      Repo *installed = 0;
-      if (s->obsoletes && s->repo != installed)
-       {
-         obsp = s->repo->idarraydata + s->obsoletes;
-         while ((obs = *obsp++) != 0)
-           {
-             if (providedbyinstalled(pool, installedmap, obs))
-               return 0;
-           }
-       }
-      if (s->repo != installed)
-       {
-         FOR_PROVIDES(p, pp, s->name)
-           {
-             s2 = pool->solvables + p;
-             if (s2->repo == installed && s2->name == s->name)
-               return 0;
-           }
-       }
-    }
-  if (!conflictsmap)
-    {
-      int i;
-
-      p = s - pool->solvables;
-      for (i = 1; i < pool->nsolvables; i++)
-       {
-         if (!MAPTST(installedmap, i))
-           continue;
-         s2 = pool->solvables + i;
-         if (!s2->conflicts)
-           continue;
-         conp = s2->repo->idarraydata + s2->conflicts;
-         while ((con = *conp++) != 0)
-           {
-             dp = pool_whatprovides_ptr(pool, con);
-             for (; *dp; dp++)
-               if (*dp == p)
-                 return 0;
-           }
-       }
-     }
-  return interesting ? 1 : -1;
-}
-
-/*
- * different interface for solvable_trivial_installable_map, where
- * the information about the installed packages is provided
- * by a queue.
- */
-int
-solvable_trivial_installable_queue(Solvable *s, Queue *installed)
-{
-  Pool *pool = s->repo->pool;
-  int i;
-  Id p;
-  Map installedmap;
-  int r;
-
-  map_init(&installedmap, pool->nsolvables);
-  for (i = 0; i < installed->count; i++)
+  pool = s->repo->pool;
+  if (solvable_lookup_void(s, SOLVABLE_SOURCENAME))
+    name = pool_id2str(pool, s->name);
+  else
+    name = solvable_lookup_str(s, SOLVABLE_SOURCENAME);
+  if (!name)
+    return 0;
+  archid = solvable_lookup_id(s, SOLVABLE_SOURCEARCH);
+  if (solvable_lookup_void(s, SOLVABLE_SOURCEEVR))
+    evr = evrid2vrstr(pool, s->evr);
+  else
+    evr = solvable_lookup_str(s, SOLVABLE_SOURCEEVR);
+  if (archid == ARCH_SRC || archid == ARCH_NOSRC)
     {
-      p = installed->elements[i];
-      if (p > 0)               /* makes it work with decisionq */
-       MAPSET(&installedmap, p);
+      char *str;
+      str = pool_tmpjoin(pool, name, evr ? "-" : 0, evr);
+      str = pool_tmpappend(pool, str, ".", pool_id2str(pool, archid));
+      return pool_tmpappend(pool, str, ".rpm", 0);
     }
-  r = solvable_trivial_installable_map(s, &installedmap, 0);
-  map_free(&installedmap);
-  return r;
-}
-
-/*
- * different interface for solvable_trivial_installable_map, where
- * the information about the installed packages is provided
- * by a repo containing the installed solvables.
- */
-int
-solvable_trivial_installable_repo(Solvable *s, Repo *installed)
-{
-  Pool *pool = s->repo->pool;
-  Id p;
-  Solvable *s2;
-  Map installedmap;
-  int r;
-
-  map_init(&installedmap, pool->nsolvables);
-  FOR_REPO_SOLVABLES(installed, p, s2)
-    MAPSET(&installedmap, p);
-  r = solvable_trivial_installable_map(s, &installedmap, 0);
-  map_free(&installedmap);
-  return r;
+  else
+    return name;       /* FIXME */
 }
 
 
@@ -455,9 +429,9 @@ solvable_trivial_installable_repo(Solvable *s, Repo *installed)
 /*
  * Create maps containing the state of each solvable. Input is a "installed" queue,
  * it contains all solvable ids that are considered to be installed.
- * 
- * The created maps can be used for solvable_trivial_installable_map(),
- * pool_calc_duchanges(), pool_calc_installsizechange().
+ *
+ * The created maps can be used for * pool_calc_duchanges() and
+ * pool_calc_installsizechange().
  *
  */
 void
@@ -493,24 +467,30 @@ pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *con
 }
 
 /* Tests if two solvables have identical content. Currently
- * both solvables need to come from the same pool */
+ * both solvables need to come from the same pool
+ */
 
 int
 solvable_identical(Solvable *s1, Solvable *s2)
 {
-  unsigned int bt1, bt2;
+  unsigned long long bt1, bt2;
   Id rq1, rq2;
   Id *reqp;
-
   if (s1->name != s2->name)
     return 0;
   if (s1->arch != s2->arch)
     return 0;
   if (s1->evr != s2->evr)
     return 0;
-  /* map missing vendor to empty string */
+
+  /* check vendor, map missing vendor to empty string */
   if ((s1->vendor ? s1->vendor : 1) != (s2->vendor ? s2->vendor : 1))
-    return 0;
+    {
+      /* workaround for bug 881493 */
+      if (s1->repo && !strncmp(pool_id2str(s1->repo->pool, s1->name), "product:", 8))
+       return 1;
+      return 0;
+    }
 
   /* looking good, try some fancier stuff */
   /* might also look up the package checksum here */
@@ -523,17 +503,37 @@ solvable_identical(Solvable *s1, Solvable *s2)
     }
   else
     {
+      if (s1->repo)
+       {
+          /* workaround for bugs 881493 and 885830*/
+         const char *n = pool_id2str(s1->repo->pool, s1->name);
+         if (!strncmp(n, "product:", 8) || !strncmp(n, "application:", 12))
+           return 1;
+       }
       /* look at requires in a last attempt to find recompiled packages */
       rq1 = rq2 = 0;
       if (s1->requires)
        for (reqp = s1->repo->idarraydata + s1->requires; *reqp; reqp++)
-         rq1 ^= *reqp++;
+         rq1 ^= *reqp;
       if (s2->requires)
        for (reqp = s2->repo->idarraydata + s2->requires; *reqp; reqp++)
-         rq2 ^= *reqp++;
+         rq2 ^= *reqp;
       if (rq1 != rq2)
         return 0;
     }
+  if (s1->repo && s1->repo->pool->disttype == DISTTYPE_CONDA)
+    {
+      /* check buildflavor and buildversion */
+      const char *str1, *str2;
+      str1 = solvable_lookup_str(s1, SOLVABLE_BUILDFLAVOR);
+      str2 = solvable_lookup_str(s2, SOLVABLE_BUILDFLAVOR);
+      if (str1 != str2 && (!str1 || !str2 || strcmp(str1, str2) != 0))
+       return 0;
+      str1 = solvable_lookup_str(s1, SOLVABLE_BUILDVERSION);
+      str2 = solvable_lookup_str(s2, SOLVABLE_BUILDVERSION);
+      if (str1 != str2 && (!str1 || !str2 || strcmp(str1, str2) != 0))
+       return 0;
+    }
   return 1;
 }
 
@@ -560,5 +560,150 @@ solvable_selfprovidedep(Solvable *s)
            return prov;
        }
     }
-  return rel2id(pool, s->name, s->evr, REL_EQ, 1);
+  return pool_rel2id(pool, s->name, s->evr, REL_EQ, 1);
+}
+
+/* setter functions, simply call the repo variants */
+void
+solvable_set_id(Solvable *s, Id keyname, Id id)
+{
+  repo_set_id(s->repo, s - s->repo->pool->solvables, keyname, id);
+}
+
+void
+solvable_set_num(Solvable *s, Id keyname, unsigned long long num)
+{
+  repo_set_num(s->repo, s - s->repo->pool->solvables, keyname, num);
+}
+
+void
+solvable_set_str(Solvable *s, Id keyname, const char *str)
+{
+  repo_set_str(s->repo, s - s->repo->pool->solvables, keyname, str);
+}
+
+void
+solvable_set_poolstr(Solvable *s, Id keyname, const char *str)
+{
+  repo_set_poolstr(s->repo, s - s->repo->pool->solvables, keyname, str);
+}
+
+void
+solvable_add_poolstr_array(Solvable *s, Id keyname, const char *str)
+{
+  repo_add_poolstr_array(s->repo, s - s->repo->pool->solvables, keyname, str);
+}
+
+void
+solvable_add_idarray(Solvable *s, Id keyname, Id id)
+{
+  repo_add_idarray(s->repo, s - s->repo->pool->solvables, keyname, id);
+}
+
+void
+solvable_add_deparray(Solvable *s, Id keyname, Id dep, Id marker)
+{
+  repo_add_deparray(s->repo, s - s->repo->pool->solvables, keyname, dep, marker);
+}
+
+void
+solvable_set_idarray(Solvable *s, Id keyname, Queue *q)
+{
+  repo_set_idarray(s->repo, s - s->repo->pool->solvables, keyname, q);
+}
+
+void
+solvable_set_deparray(Solvable *s, Id keyname, Queue *q, Id marker)
+{
+  repo_set_deparray(s->repo, s - s->repo->pool->solvables, keyname, q, marker);
+}
+
+void
+solvable_unset(Solvable *s, Id keyname)
+{
+  repo_unset(s->repo, s - s->repo->pool->solvables, keyname);
+}
+
+/* return true if a dependency intersects dep in the keyname array */
+int
+solvable_matchesdep(Solvable *s, Id keyname, Id dep, int marker)
+{
+  int i;
+  Pool *pool = s->repo->pool;
+  Queue q;
+
+  if (keyname == SOLVABLE_NAME)
+    return pool_match_nevr(pool, s, dep) ? 1 : 0;      /* nevr match hack */
+  queue_init(&q);
+  solvable_lookup_deparray(s, keyname, &q, marker);
+  for (i = 0; i < q.count; i++)
+    if (pool_match_dep(pool, q.elements[i], dep))
+      break;
+  i = i == q.count ? 0 : 1;
+  queue_free(&q);
+  return i;
+}
+
+int
+solvable_matchessolvable_int(Solvable *s, Id keyname, int marker, Id solvid, Map *solvidmap, Queue *depq, Map *missc, int reloff)
+{
+  Pool *pool = s->repo->pool;
+  int i, boff;
+  Id *wp;
+
+  if (depq->count)
+    queue_empty(depq);
+  solvable_lookup_deparray(s, keyname, depq, marker);
+  for (i = 0; i < depq->count; i++)
+    {
+      Id dep = depq->elements[i];
+      boff = ISRELDEP(dep) ? reloff + GETRELID(dep) : dep;
+      if (MAPTST(missc, boff))
+       continue;
+      if (ISRELDEP(dep))
+       {
+         Reldep *rd = GETRELDEP(pool, dep);
+         if (!ISRELDEP(rd->name) && rd->flags < 8)
+           {
+             /* do pre-filtering on the base */
+             if (MAPTST(missc, rd->name))
+               continue;
+             wp = pool_whatprovides_ptr(pool, rd->name);
+             if (solvidmap)
+               {
+                 for (; *wp; wp++)
+                   if (MAPTST(solvidmap, *wp))
+                     break;
+               }
+             else
+               {
+                 for (; *wp; wp++)
+                   if (*wp == solvid)
+                     break;
+               }
+             if (!*wp)
+               {
+                 /* the base does not include solvid, no need to check the complete dep */
+                 MAPSET(missc, rd->name);
+                 MAPSET(missc, boff);
+                 continue;
+               }
+           }
+       }
+      wp = pool_whatprovides_ptr(pool, dep);
+      if (solvidmap)
+       {
+         for (; *wp; wp++)
+           if (MAPTST(solvidmap, *wp))
+             return 1;
+       }
+      else
+       {
+         for (; *wp; wp++)
+           if (*wp == solvid)
+             return 1;
+       }
+      MAPSET(missc, boff);
+    }
+  return 0;
 }