#ifdef SUSE
#include "repo_autopattern.h"
#endif
+#if defined(ENABLE_COMPLEX_DEPS) && (defined(ENABLE_SUSEREPO) || defined(ENABLE_RPMMD) || defined(ENABLE_RPMDB) || defined(ENABLE_RPMPKG))
+#include "pool_parserpmrichdep.h"
+#endif
#include "solv_xfopen.h"
#include "testcase.h"
%constant int REL_MULTIARCH;
%constant int REL_ELSE;
%constant int REL_ERROR;
+%constant int REL_WITHOUT;
+%constant int REL_UNLESS;
typedef struct {
Pool* const pool;
static const Id SELECTION_GLOB = SELECTION_GLOB;
static const Id SELECTION_FLAT = SELECTION_FLAT;
static const Id SELECTION_NOCASE = SELECTION_NOCASE;
+ static const Id SELECTION_SKIP_KIND = SELECTION_SKIP_KIND;
+ static const Id SELECTION_MATCH_DEPSTR = SELECTION_MATCH_DEPSTR;
static const Id SELECTION_SOURCE_ONLY = SELECTION_SOURCE_ONLY;
static const Id SELECTION_WITH_SOURCE = SELECTION_WITH_SOURCE;
+ static const Id SELECTION_WITH_DISABLED = SELECTION_WITH_DISABLED;
+ static const Id SELECTION_WITH_BADARCH = SELECTION_WITH_BADARCH;
+ static const Id SELECTION_WITH_ALL = SELECTION_WITH_ALL;
+ static const Id SELECTION_ADD = SELECTION_ADD;
+ static const Id SELECTION_SUBTRACT = SELECTION_SUBTRACT;
+ static const Id SELECTION_FILTER = SELECTION_FILTER;
+ static const Id SELECTION_FILTER_KEEP_IFEMPTY = SELECTION_FILTER_KEEP_IFEMPTY;
+ static const Id SELECTION_FILTER_SWAPPED = SELECTION_FILTER_SWAPPED;
Selection(Pool *pool) {
Selection *s;
bool isempty() {
return $self->q.count == 0;
}
+ %newobject clone;
+ Selection *clone(int flags = 0) {
+ Selection *s = new_Selection($self->pool);
+ queue_init_clone(&s->q, &$self->q);
+ s->flags = $self->flags;
+ return s;
+ }
void filter(Selection *lsel) {
if ($self->pool != lsel->pool)
queue_empty(&$self->q);
void add_raw(Id how, Id what) {
queue_push2(&$self->q, how, what);
}
+ void subtract(Selection *lsel) {
+ if ($self->pool == lsel->pool)
+ selection_subtract($self->pool, &$self->q, &lsel->q);
+ }
+
+ void select(const char *name, int flags) {
+ if ((flags & SELECTION_MODEBITS) == 0)
+ flags |= SELECTION_FILTER | SELECTION_WITH_ALL;
+ $self->flags = selection_make($self->pool, &$self->q, name, flags);
+ }
+ void matchdeps(const char *name, int flags, Id keyname, Id marker = -1) {
+ if ((flags & SELECTION_MODEBITS) == 0)
+ flags |= SELECTION_FILTER | SELECTION_WITH_ALL;
+ $self->flags = selection_make_matchdeps($self->pool, &$self->q, name, flags, keyname, marker);
+ }
+ void matchdepid(DepId dep, int flags, Id keyname, Id marker = -1) {
+ if ((flags & SELECTION_MODEBITS) == 0)
+ flags |= SELECTION_FILTER | SELECTION_WITH_ALL;
+ $self->flags = selection_make_matchdepid($self->pool, &$self->q, dep, flags, keyname, marker);
+ }
+
%typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
%newobject jobs;
Queue jobs(int flags) {
Id id = pool_str2id($self, str, create);
return new_Dep($self, id);
}
+#if defined(ENABLE_COMPLEX_DEPS) && (defined(ENABLE_SUSEREPO) || defined(ENABLE_RPMMD) || defined(ENABLE_RPMDB) || defined(ENABLE_RPMPKG))
+ %newobject Dep;
+ Dep *parserpmrichdep(const char *str) {
+ Id id = pool_parserpmrichdep($self, str);
+ return new_Dep($self, id);
+ }
+#endif
const char *id2str(Id id) {
return pool_id2str($self, id);
}
return pool_queuetowhatprovides($self, &q);
}
+ void set_namespaceproviders(DepId ns, DepId evr, bool value=1) {
+ Id dep = pool_rel2id($self, ns, evr, REL_NAMESPACE, 1);
+ pool_set_whatprovides($self, dep, value ? 2 : 1);
+ }
+
+ void flush_namespaceproviders(DepId ns, DepId evr) {
+ pool_flush_namespaceproviders($self, ns, evr);
+ }
+
+
%typemap(out) Queue whatmatchesdep Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
%newobject whatmatchesdep;
Queue whatmatchesdep(Id keyname, DepId dep, Id marker = -1) {
return 0;
if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
return 1;
- if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
+ if (pool->id2arch && pool_arch2score(pool, id) == 0)
return 0;
return 1;
}
return sel;
}
+ %newobject matchdeps;
+ Selection *matchdeps(const char *name, int flags, Id keyname, Id marker = -1) {
+ Selection *sel = new_Selection($self);
+ sel->flags = selection_make_matchdeps($self, &sel->q, name, flags, keyname, marker);
+ return sel;
+ }
+
+ %newobject matchdepid;
+ Selection *matchdepid(DepId dep, int flags, Id keyname, Id marker = -1) {
+ Selection *sel = new_Selection($self);
+ sel->flags = selection_make_matchdepid($self, &sel->q, dep, flags, keyname, marker);
+ return sel;
+ }
+
void setpooljobs_helper(Queue jobs) {
queue_free(&$self->pooljobs);
queue_init_clone(&$self->pooljobs, &jobs);
}
return q;
}
+
+ %typemap(out) Queue get_recommended Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
+ %newobject get_recommended;
+ Queue get_recommended(bool noselected=0) {
+ Queue q;
+ queue_init(&q);
+ solver_get_recommendations($self, &q, NULL, noselected);
+ return q;
+ }
+ %typemap(out) Queue get_suggested Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
+ %newobject get_suggested;
+ Queue get_suggested(bool noselected=0) {
+ Queue q;
+ queue_init(&q);
+ solver_get_recommendations($self, NULL, &q, noselected);
+ return q;
+ }
}
%extend Transaction {
bool write(FILE *fp) {
return repodata_write(repo_id2repodata($self->repo, $self->id), fp) == 0;
}
+ Id str2dir(const char *dir, bool create=1) {
+ Repodata *data = repo_id2repodata($self->repo, $self->id);
+ return repodata_str2dir(data, dir, create);
+ }
+ const char *dir2str(Id did, const char *suf = 0) {
+ Repodata *data = repo_id2repodata($self->repo, $self->id);
+ return repodata_dir2str(data, did, suf);
+ }
+ void add_dirstr(Id solvid, Id keyname, Id dir, const char *str) {
+ Repodata *data = repo_id2repodata($self->repo, $self->id);
+ repodata_add_dirstr(data, solvid, keyname, dir, str);
+ }
bool add_solv(FILE *fp, int flags = 0) {
Repodata *data = repo_id2repodata($self->repo, $self->id);
int r, oldstate = data->state;