Imported Upstream version 0.7.12
[platform/upstream/libsolv.git] / src / repo.h
index 2d2d7fc..b503431 100644 (file)
@@ -7,7 +7,7 @@
 
 /*
  * repo.h
- * 
+ *
  */
 
 #ifndef LIBSOLV_REPO_H
 
 #include "pooltypes.h"
 #include "pool.h"
+#include "poolarch.h"
 #include "repodata.h"
 #include "dataiterator.h"
 #include "hash.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-
-typedef struct _Repo {
+typedef struct s_Repo {
   const char *name;            /* name pointer */
   Id repoid;                   /* our id */
   void *appdata;               /* application private pointer */
@@ -39,7 +42,7 @@ typedef struct _Repo {
   Id *idarraydata;             /* array of metadata Ids, solvable dependencies are offsets into this array */
   int idarraysize;
 
-  unsigned nrepodata;          /* number of our stores..  */
+  int nrepodata;               /* number of our stores..  */
 
   Id *rpmdbid;                 /* solvable side data: rpm database id */
 
@@ -48,7 +51,7 @@ typedef struct _Repo {
   Offset lastoff;              /* start of last array in idarraydata */
 
   Hashtable lastidhash;                /* hash to speed up repo_addid_dep */
-  Hashmask lastidhash_mask;
+  Hashval lastidhash_mask;
   int lastidhash_idarraysize;
   int lastmarker;
   Offset lastmarkerpos;
@@ -65,12 +68,11 @@ extern void repo_free_solvable(Repo *repo, Id p, int reuseids);
 extern void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids);
 extern void *repo_sidedata_create(Repo *repo, size_t size);
 extern void *repo_sidedata_extend(Repo *repo, void *b, size_t size, Id p, int count);
+extern Id repo_add_solvable_block_before(Repo *repo, int count, Repo *beforerepo);
 
 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker);
 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
-extern Offset repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset freshens);
-extern Offset repo_fix_conflicts(Repo *repo, Offset conflicts);
 
 static inline const char *repo_name(const Repo *repo)
 {
@@ -84,16 +86,36 @@ static inline Repo *pool_id2repo(Pool *pool, Id repoid)
   return repoid < pool->nrepos ? pool->repos[repoid] : 0;
 }
 
+static inline int pool_disabled_solvable(const Pool *pool, Solvable *s)
+{
+  if (s->repo && s->repo->disabled)
+    return 1;
+  if (pool->considered)
+    {
+      Id id = s - pool->solvables;
+      if (!MAPTST(pool->considered, id))
+       return 1;
+    }
+  return 0;
+}
+
+static inline int pool_badarch_solvable(const Pool *pool, Solvable *s)
+{
+  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 && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))
+  if (pool->id2arch && (!s->arch || pool_arch2score(pool, s->arch) == 0))
     return 0;
   if (pool->considered)
-    { 
+    {
       Id id = s - pool->solvables;
       if (!MAPTST(pool->considered, id))
        return 0;
@@ -101,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
@@ -113,6 +163,8 @@ static inline int pool_installable(const Pool *pool, Solvable *s)
 #define REPO_LOCALPOOL                 (1 << 2)
 #define REPO_USE_LOADING               (1 << 3)
 #define REPO_EXTEND_SOLVABLES          (1 << 4)
+#define REPO_USE_ROOTDIR               (1 << 5)
+#define REPO_NO_LOCATION               (1 << 6)
 
 Repodata *repo_add_repodata(Repo *repo, int flags);
 Repodata *repo_id2repodata(Repo *repo, Id id);
@@ -120,6 +172,11 @@ Repodata *repo_last_repodata(Repo *repo);
 
 void repo_search(Repo *repo, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata);
 
+/* returns the last repodata that contains the key */
+Repodata *repo_lookup_repodata(Repo *repo, Id entry, Id keyname);
+Repodata *repo_lookup_repodata_opt(Repo *repo, Id entry, Id keyname);
+Repodata *repo_lookup_filelist_repodata(Repo *repo, Id entry, Datamatcher *matcher);
+
 /* returns the string value of the attribute, or NULL if not found */
 Id repo_lookup_type(Repo *repo, Id entry, Id keyname);
 const char *repo_lookup_str(Repo *repo, Id entry, Id keyname);
@@ -131,6 +188,9 @@ int repo_lookup_deparray(Repo *repo, Id entry, Id keyname, Queue *q, Id marker);
 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);
 void repo_set_num(Repo *repo, Id p, Id keyname, unsigned long long num);
@@ -141,14 +201,19 @@ void repo_add_idarray(Repo *repo, Id p, Id keyname, Id id);
 void repo_add_deparray(Repo *repo, Id p, Id keyname, Id dep, Id marker);
 void repo_set_idarray(Repo *repo, Id p, Id keyname, Queue *q);
 void repo_set_deparray(Repo *repo, Id p, Id keyname, Queue *q, Id marker);
+void repo_unset(Repo *repo, Id p, Id keyname);
+
 void repo_internalize(Repo *repo);
 void repo_disable_paging(Repo *repo);
+Id *repo_create_keyskip(Repo *repo, Id entry, Id **oldkeyskip);
+
 
 /* iterator macros */
 #define FOR_REPO_SOLVABLES(r, p, s)                                            \
   for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p)  \
-    if (s->repo == (r))
+    if (s->repo != (r))                                                                \
+      continue;                                                                        \
+    else
 
 #ifdef LIBSOLV_INTERNAL
 #define FOR_REPODATAS(repo, rdid, data)        \
@@ -158,4 +223,13 @@ void repo_disable_paging(Repo *repo);
        for (rdid = 1; rdid < repo->nrepodata && (data = repo_id2repodata(repo, rdid)); rdid++)
 #endif
 
+/* weird suse stuff, do not use */
+extern Offset repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset freshens);
+extern Offset repo_fix_conflicts(Repo *repo, Offset conflicts);
+extern void repo_rewrite_suse_deps(Solvable *s, Offset freshens);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* LIBSOLV_REPO_H */