#if defined(SWIGPERL)
-/* work around a swig bug */
+/* work around a swig bug for swig versions < 2.0.5 */
+#if SWIG_VERSION < 0x020005
%{
#undef SWIG_CALLXS
#ifdef PERL_OBJECT
# endif
#endif
%}
+#endif
%define perliter(class)
#include "selection.h"
#include "repo_write.h"
-#ifdef ENABLE_RPMDB
+#if defined(ENABLE_RPMDB) || defined(ENABLE_RPMPKG)
#include "repo_rpmdb.h"
#endif
#ifdef ENABLE_PUBKEY
%constant int REL_EQ;
%constant int REL_GT;
%constant int REL_LT;
-%constant int REL_ARCH;
%constant int REL_AND;
%constant int REL_OR;
%constant int REL_WITH;
+%constant int REL_NAMESPACE;
+%constant int REL_ARCH;
+%constant int REL_FILECONFLICT;
%constant int REL_COND;
+%constant int REL_COMPAT;
+%constant int REL_KIND;
+%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(Selection *from, int flags = 0) {
+ Selection *s;
+ s = solv_calloc(1, sizeof(*s));
+ s->pool = from->pool;
+ s->flags = from->flags;
+ queue_init_clone(&s->q, &from->q);
+ 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) {
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 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);
bool add_rpmdb_reffp(FILE *reffp, int flags = 0) {
return repo_add_rpmdb_reffp($self, reffp, flags) == 0;
}
+#endif
+#ifdef ENABLE_RPMPKG
%newobject add_rpm;
XSolvable *add_rpm(const char *name, int flags = 0) {
return new_XSolvable($self->pool, repo_add_rpm($self, name, flags));
}
#endif
+ Repo *createshadow(const char *name) {
+ Repo *repo = repo_create($self->pool, name);
+ if ($self->idarraysize) {
+ repo_reserve_ids(repo, 0, $self->idarraysize);
+ memcpy(repo->idarraydata, $self->idarraydata, sizeof(Id) * $self->idarraysize);
+ repo->idarraysize = $self->idarraysize;
+ }
+ repo->start = $self->start;
+ repo->end = $self->end;
+ repo->nsolvables = $self->nsolvables;
+ return repo;
+ }
+
+ void moveshadow(Queue q) {
+ Pool *pool = $self->pool;
+ int i;
+ for (i = 0; i < q.count; i++) {
+ Solvable *s;
+ Id p = q.elements[i];
+ if (p < $self->start || p >= $self->end)
+ continue;
+ s = pool->solvables + p;
+ if ($self->idarraysize != s->repo->idarraysize)
+ continue;
+ s->repo = $self;
+ }
+ }
+
#if defined(SWIGTCL)
%rename("==") __eq__;
#endif
#ifdef SWIGPERL
perliter(solv::Pool_repo_iterator)
#endif
- %newobject __next__;
Repo *__next__() {
Pool *pool = $self->pool;
if ($self->id >= pool->nrepos)
void each() {
Repo *n;
while ((n = Pool_repo_iterator___next__($self)) != 0) {
- rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
+ rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, 0 | 0));
}
}
#endif
const char *lookup_location(unsigned int *OUTPUT) {
return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT);
}
+ const char *lookup_sourcepkg() {
+ return solvable_lookup_sourcepkg($self->pool->solvables + $self->id);
+ }
%newobject Dataiterator;
Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) {
return new_Dataiterator($self->pool, 0, $self->id, key, match, flags);
int evrcmp(XSolvable *s2) {
return pool_evrcmp($self->pool, $self->pool->solvables[$self->id].evr, s2->pool->solvables[s2->id].evr, EVRCMP_COMPARE);
}
+#ifdef SWIGRUBY
+ %rename("matchesdep?") matchesdep;
+#endif
+ bool matchesdep(Id keyname, DepId id, Id marker = -1) {
+ return solvable_matchesdep($self->pool->solvables + $self->id, keyname, id, marker);
+ }
#if defined(SWIGTCL)
%rename("==") __eq__;
static const int SOLVER_FLAG_FOCUS_INSTALLED = SOLVER_FLAG_FOCUS_INSTALLED;
static const int SOLVER_FLAG_YUM_OBSOLETES = SOLVER_FLAG_YUM_OBSOLETES;
static const int SOLVER_FLAG_NEED_UPDATEPROVIDE = SOLVER_FLAG_NEED_UPDATEPROVIDE;
+ static const int SOLVER_FLAG_FOCUS_BEST = SOLVER_FLAG_FOCUS_BEST;
+ static const int SOLVER_FLAG_STRONG_RECOMMENDS = SOLVER_FLAG_STRONG_RECOMMENDS;
+ static const int SOLVER_FLAG_INSTALL_ALSO_UPDATES = SOLVER_FLAG_INSTALL_ALSO_UPDATES;
static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;
bool write_testcase(const char *dir) {
return testcase_write($self, dir, TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS, 0, 0);
}
+
+ Queue raw_decisions(int filter=0) {
+ Queue q;
+ queue_init(&q);
+ solver_get_decisionqueue($self, &q);
+ if (filter) {
+ int i, j;
+ for (i = j = 0; i < q.count; i++)
+ if ((filter > 0 && q.elements[i] > 1) ||
+ (filter < 0 && q.elements[i] < 0))
+ q.elements[j++] = q.elements[i];
+ queue_truncate(&q, j);
+ }
+ 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 {
if (buf)
repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
}
+ void set_sourcepkg(Id solvid, const char *sourcepkg) {
+ repodata_set_sourcepkg(repo_id2repodata($self->repo, $self->id), solvid, sourcepkg);
+ }
const char *lookup_str(Id solvid, Id keyname) {
return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
}