Imported Upstream version 0.7.12
[platform/upstream/libsolv.git] / src / repo.h
index 4abfb0f..b503431 100644 (file)
@@ -101,20 +101,18 @@ static inline int pool_disabled_solvable(const Pool *pool, Solvable *s)
 
 static inline int pool_badarch_solvable(const Pool *pool, Solvable *s)
 {
-  if (!s->arch)
-    return 1;
-  if (pool->id2arch && pool_arch2score(pool, s->arch) == 0)
+  if (pool->id2arch && (!s->arch || pool_arch2score(pool, s->arch) == 0))
     return 1;
   return 0;
 }
 
 static inline int pool_installable(const Pool *pool, Solvable *s)
 {
-  if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
+  if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
     return 0;
   if (s->repo && s->repo->disabled)
     return 0;
-  if (pool->id2arch && pool_arch2score(pool, s->arch) == 0)
+  if (pool->id2arch && (!s->arch || pool_arch2score(pool, s->arch) == 0))
     return 0;
   if (pool->considered)
     {
@@ -125,6 +123,34 @@ static inline int pool_installable(const Pool *pool, Solvable *s)
   return 1;
 }
 
+#ifdef LIBSOLV_INTERNAL
+static inline int pool_installable_whatprovides(const Pool *pool, Solvable *s)
+{
+  /* we always need the installed solvable in the whatprovides data,
+     otherwise obsoletes/conflicts on them won't work */
+  if (s->repo != pool->installed)
+    {
+      if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC || pool_badarch_solvable(pool, s))
+       return 0;
+      if (pool->considered && !pool->whatprovideswithdisabled)
+       {
+         Id id = s - pool->solvables;
+         if (!MAPTST(pool->considered, id))
+           return 0;
+       }
+    }
+  return 1;
+}
+#endif
+
+/* not in solvable.h because we need the repo definition */
+static inline Solvable *solvable_free(Solvable *s, int reuseids)
+{
+  if (s && s->repo)
+    repo_free_solvable(s->repo, s - s->repo->pool->solvables, reuseids);
+  return 0;
+}
+
 /* search callback values */
 #define SEARCH_NEXT_KEY         1
 #define SEARCH_NEXT_SOLVABLE    2
@@ -163,6 +189,7 @@ int repo_lookup_void(Repo *repo, Id entry, Id keyname);
 const char *repo_lookup_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
 const unsigned char *repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
 const void *repo_lookup_binary(Repo *repo, Id entry, Id keyname, int *lenp);
+unsigned int repo_lookup_count(Repo *repo, Id entry, Id keyname);      /* internal */
 Id solv_depmarker(Id keyname, Id marker);
 
 void repo_set_id(Repo *repo, Id p, Id keyname, Id id);