# on the generated c code
#
-#
-##if defined(SWIGRUBY)
-# %rename("to_s") string();
-##endif
-##if defined(SWIGPYTHON)
-# %rename("__str__") string();
-##endif
-#
-
%module solv
#ifdef SWIGRUBY
%include "typemaps.i"
+%typemap(in,numinputs=0,noblock=1) XRule **OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ) {
+ $1 = &temp;
+}
+%typemap(argout,noblock=1) XRule **OUTPUT {
+ %append_output(SWIG_NewPointerObj((void*)(*$1), SWIGTYPE_p_XRule, SWIG_POINTER_OWN | %newpointer_flags));
+}
+
%typemaps_asval(%checkcode(POINTER), SWIG_AsValSolvFpPtr, "SWIG_AsValSolvFpPtr", FILE*);
%typemaps_asval(%checkcode(INT32), SWIG_AsValDepId, "SWIG_AsValDepId", DepId);
#ifdef ENABLE_RPMDB
#include "repo_rpmdb.h"
#endif
-#ifdef ENABLE_RPMDB_PUBKEYS
-#include "repo_rpmdb_pubkey.h"
+#ifdef ENABLE_PUBKEY
+#include "repo_pubkey.h"
#endif
#ifdef ENABLE_DEBIAN
#include "repo_deb.h"
Id type;
Id source;
Id target;
- Id dep;
+ Id dep_id;
} Ruleinfo;
typedef struct {
typedef struct {
Solver* const solv;
Id const type;
- Id const dep;
+ Id const dep_id;
} Ruleinfo;
typedef struct {
int flags() {
return $self->flags;
}
- void make(const char *name, int flags) {
- $self->flags = selection_make($self->pool, &$self->q, name, flags);
- }
#ifdef SWIGRUBY
%rename("isempty?") isempty;
#endif
}
#if defined(SWIGRUBY)
%rename("to_s") __str__;
- %rename("inspect") __repr__;
#endif
#if defined(SWIGPERL)
%rename("str") __str__;
}
%extend Pool {
+ static const int POOL_FLAG_PROMOTEEPOCH = POOL_FLAG_PROMOTEEPOCH;
+ static const int POOL_FLAG_FORBIDSELFCONFLICTS = POOL_FLAG_FORBIDSELFCONFLICTS;
+ static const int POOL_FLAG_OBSOLETEUSESPROVIDES = POOL_FLAG_OBSOLETEUSESPROVIDES;
+ static const int POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES = POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES;
+ static const int POOL_FLAG_OBSOLETEUSESCOLORS = POOL_FLAG_OBSOLETEUSESCOLORS;
+ static const int POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS = POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS;
+ static const int POOL_FLAG_NOINSTALLEDOBSOLETES = POOL_FLAG_NOINSTALLEDOBSOLETES;
+ static const int POOL_FLAG_HAVEDISTEPOCH = POOL_FLAG_HAVEDISTEPOCH;
+ static const int POOL_FLAG_NOOBSOLETESMULTIVERSION = POOL_FLAG_NOOBSOLETESMULTIVERSION;
+
Pool() {
Pool *pool = pool_create();
return pool;
Id str2id(const char *str, bool create=1) {
return pool_str2id($self, str, create);
}
+ %newobject Dep;
Dep *Dep(const char *str, bool create=1) {
Id id = pool_str2id($self, str, create);
return new_Dep($self, id);
pool_createwhatprovides($self);
}
+ %newobject id2solvable;
XSolvable *id2solvable(Id id) {
return new_XSolvable($self, id);
}
}
Repo *installed;
+ const char * const errstr;
%{
SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
pool_set_installed(pool, installed);
Repo *Pool_installed_get(Pool *pool) {
return pool->installed;
}
+ const char *Pool_errstr_get(Pool *pool) {
+ return pool_errstr(pool);
+ }
%}
Queue matchprovidingids(const char *match, int flags) {
return q;
}
+ %newobject Job;
Job *Job(int how, Id what) {
return new_Job($self, how, what);
}
return repo_add_solv($self, fp, flags) == 0;
}
+ %newobject add_solvable;
XSolvable *add_solvable() {
Id solvid = repo_add_solvable($self);
return new_XSolvable($self->pool, solvid);
bool add_rpmdb_reffp(FILE *reffp, int flags = 0) {
return repo_add_rpmdb_reffp($self, reffp, flags) == 0;
}
- Id add_rpm(const char *name, int flags = 0) {
- return repo_add_rpm($self, name, flags);
+ %newobject add_rpm;
+ XSolvable *add_rpm(const char *name, int flags = 0) {
+ return new_XSolvable($self->pool, repo_add_rpm($self, name, flags));
}
#endif
-#ifdef ENABLE_RPMDB_PUBKEYS
+#ifdef ENABLE_PUBKEY
+#ifdef ENABLE_RPMDB
bool add_rpmdb_pubkeys(int flags = 0) {
return repo_add_rpmdb_pubkeys($self, flags) == 0;
}
- Id add_pubkey(const char *key, int flags = 0) {
- return repo_add_pubkey($self, key, flags);
+#endif
+ %newobject add_pubkey;
+ XSolvable *add_pubkey(const char *key, int flags = 0) {
+ return new_XSolvable($self->pool, repo_add_pubkey($self, key, flags));
}
#endif
#ifdef ENABLE_RPMMD
bool add_debpackages(FILE *fp, int flags = 0) {
return repo_add_debpackages($self, fp, flags) == 0;
}
- Id add_deb(const char *name, int flags = 0) {
- return repo_add_deb($self, name, flags);
+ %newobject add_deb;
+ XSolvable *add_deb(const char *name, int flags = 0) {
+ return new_XSolvable($self->pool, repo_add_deb($self, name, flags));
}
#endif
#ifdef ENABLE_SUSEREPO
bool add_arch_local(const char *dir, int flags = 0) {
return repo_add_arch_local($self, dir, flags) == 0;
}
- Id add_arch_pkg(const char *name, int flags = 0) {
- return repo_add_arch_pkg($self, name, flags);
+ %newobject add_arch_pkg;
+ XSolvable *add_arch_pkg(const char *name, int flags = 0) {
+ return new_XSolvable($self->pool, repo_add_arch_pkg($self, name, flags));
}
#endif
void internalize() {
return new_Repo_solvable_iterator($self);
}
+ %newobject add_repodata;
XRepodata *add_repodata(int flags = 0) {
Repodata *rd = repo_add_repodata($self, flags);
return new_XRepodata($self, rd->repodataid);
return;
data = repo_id2repodata($self, $self->nrepodata - 1);
if (data->state != REPODATA_STUB)
- repodata_create_stubs(data);
+ (void)repodata_create_stubs(data);
}
#ifdef SWIGRUBY
%rename("iscontiguous?") iscontiguous;
return 0;
return 1;
}
+ %newobject first_repodata;
XRepodata *first_repodata() {
Repodata *data;
int i;
static const int SEARCH_NOCASE = SEARCH_NOCASE;
static const int SEARCH_FILES = SEARCH_FILES;
static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
+ static const int SEARCH_CHECKSUMS = SEARCH_CHECKSUMS;
Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
Dataiterator *di = solv_calloc(1, sizeof(*di));
pool->pos = oldpos;
return r;
}
+ %newobject Dataiterator;
+ Dataiterator *Dataiterator(Id key, const char *match, int flags) {
+ Pool *pool = $self->repo->pool;
+ Datapos oldpos = pool->pos;
+ Dataiterator *di;
+ pool->pos = *$self;
+ di = new_Dataiterator(pool, 0, SOLVID_POS, key, match, flags);
+ pool->pos = oldpos;
+ return di;
+ }
}
%extend Datamatch {
const char *str() {
return $self->kv.str;
}
- int num() {
+ unsigned long long num() {
+ if ($self->key->type == REPOKEY_TYPE_NUM)
+ return SOLV_KV_NUM64(&$self->kv);
return $self->kv.num;
}
int num2() {
pool->pos = oldpos;
return pos;
}
- void setpos() {
- dataiterator_setpos($self);
- }
- void setpos_parent() {
- dataiterator_setpos_parent($self);
- }
#if defined(SWIGPERL)
%rename("str") __str__;
#endif
s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
}
+ void unset(Id keyname) {
+ Solvable *s = $self->pool->solvables + $self->id;
+ repo_unset(s->repo, $self->id, keyname);
+ }
+
void add_deparray(Id keyname, DepId id, Id marker = -1) {
Solvable *s = $self->pool->solvables + $self->id;
if (marker == -1 || marker == 1) {
int solution_count() {
return solver_solution_count($self->solv, $self->id);
}
- %newobject solutions;
%typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
+ %newobject solutions;
Queue solutions() {
Queue q;
int i, cnt;
return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
}
- %newobject elements;
%typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
+ %newobject elements;
Queue elements(bool expandreplaces=0) {
Queue q;
int i, cnt;
return pool_tmpjoin($self->solv->pool, "allow ", policy_illegal2str($self->solv, illegal, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp), 0);
return solver_solutionelement2str($self->solv, p, rp);
}
- %newobject replaceelements;
%typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
+ %newobject replaceelements;
Queue replaceelements() {
Queue q;
int illegal;
return new_XSolvable(e->solv->pool, e->rp);
}
SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
- if (e->type != SOLVER_SOLUTION_JOB)
+ if (e->type != SOLVER_SOLUTION_JOB && e->type != SOLVER_SOLUTION_POOLJOB)
return -1;
return (e->p - 1) / 2;
}
%newobject Job;
Job *Job() {
Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
- if ($self->type == SOLVER_SOLUTION_JOB)
+ if ($self->type == SOLVER_SOLUTION_JOB || SOLVER_SOLUTION_POOLJOB)
return new_Job($self->solv->pool, SOLVER_NOOP, 0);
if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE || $self->type == SOLVER_SOLUTION_BEST)
return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->p);
static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
static const int SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM = SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM;
+ static const int SOLVER_RULE_JOB_UNKNOWN_PACKAGE = SOLVER_RULE_JOB_UNKNOWN_PACKAGE;
+ static const int SOLVER_RULE_JOB_UNSUPPORTED = SOLVER_RULE_JOB_UNSUPPORTED;
static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
+ static const int SOLVER_FLAG_BEST_OBEY_POLICY = SOLVER_FLAG_BEST_OBEY_POLICY;
+ static const int SOLVER_FLAG_NO_AUTOTARGET = SOLVER_FLAG_NO_AUTOTARGET;
+
+ static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
+ static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;
+ static const int SOLVER_REASON_KEEP_INSTALLED = SOLVER_REASON_KEEP_INSTALLED;
+ static const int SOLVER_REASON_RESOLVE_JOB = SOLVER_REASON_RESOLVE_JOB;
+ static const int SOLVER_REASON_UPDATE_INSTALLED = SOLVER_REASON_UPDATE_INSTALLED;
+ static const int SOLVER_REASON_CLEANDEPS_ERASE = SOLVER_REASON_CLEANDEPS_ERASE;
+ static const int SOLVER_REASON_RESOLVE = SOLVER_REASON_RESOLVE;
+ static const int SOLVER_REASON_WEAKDEP = SOLVER_REASON_WEAKDEP;
+ static const int SOLVER_REASON_RESOLVE_ORPHAN = SOLVER_REASON_RESOLVE_ORPHAN;
+ static const int SOLVER_REASON_RECOMMENDED = SOLVER_REASON_RECOMMENDED;
+ static const int SOLVER_REASON_SUPPLEMENTED = SOLVER_REASON_SUPPLEMENTED;
~Solver() {
solver_free($self);
Transaction *transaction() {
return solver_create_transaction($self);
}
+
+ int describe_decision(XSolvable *s, XRule **OUTPUT) {
+ int ruleid;
+ int reason = solver_describe_decision($self, s->id, &ruleid);
+ *OUTPUT = new_XRule($self, ruleid);
+ return reason;
+ }
}
%extend Transaction {
return new_XSolvable($self->pool, op);
}
- %newobject allothersolvables;
%typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
+ %newobject allothersolvables;
Queue allothersolvables(XSolvable *s) {
Queue q;
queue_init(&q);
return q;
}
+ # deprecated, use newsolvables instead
%typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
%newobject newpackages;
Queue newpackages() {
return q;
}
+ # deprecated, use keptsolvables instead
%typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
%newobject keptpackages;
Queue keptpackages() {
return q;
}
+ %typemap(out) Queue newsolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
+ %newobject newsolvables;
+ Queue newsolvables() {
+ Queue q;
+ int cut;
+ queue_init(&q);
+ cut = transaction_installedresult(self, &q);
+ queue_truncate(&q, cut);
+ return q;
+ }
+
+ %typemap(out) Queue keptsolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
+ %newobject keptsolvables;
+ Queue keptsolvables() {
+ Queue q;
+ int cut;
+ queue_init(&q);
+ cut = transaction_installedresult(self, &q);
+ if (cut)
+ queue_deleten(&q, 0, cut);
+ return q;
+ }
+
%typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
- %newobject steps ;
+ %newobject steps;
Queue steps() {
Queue q;
queue_init_clone(&q, &$self->steps);
int calc_installsizechange() {
return transaction_calc_installsizechange($self);
}
- void order(int flags) {
+ void order(int flags=0) {
transaction_order($self, flags);
}
}
cl->toid = toid;
return cl;
}
- %newobject solvables;
%typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
+ %newobject solvables;
Queue solvables() {
Queue q;
queue_init(&q);
transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
return q;
}
- %newobject fromdep;
- Dep *fromdep() {
- return new_Dep($self->transaction->pool, $self->fromid);
- }
- %newobject todep;
- Dep *todep() {
- return new_Dep($self->transaction->pool, $self->toid);
- }
+ const char * const fromstr;
+ const char * const tostr;
+ %{
+ SWIGINTERN const char *TransactionClass_fromstr_get(TransactionClass *cl) {
+ return pool_id2str(cl->transaction->pool, cl->fromid);
+ }
+ SWIGINTERN const char *TransactionClass_tostr_get(TransactionClass *cl) {
+ return pool_id2str(cl->transaction->pool, cl->toid);
+ }
+ %}
}
%extend XRule {
xr->id = id;
return xr;
}
+ int const type;
+ %{
+ SWIGINTERN int XRule_type_get(XRule *xr) {
+ return solver_ruleclass(xr->solv, xr->id);
+ }
+ %}
+ %newobject info;
Ruleinfo *info() {
Id type, source, target, dep;
- type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
+ type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
return new_Ruleinfo($self, type, source, target, dep);
}
%typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
}
%extend Ruleinfo {
- Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
+ Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep_id) {
Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
ri->solv = r->solv;
ri->rid = r->id;
ri->type = type;
ri->source = source;
ri->target = target;
- ri->dep = dep;
+ ri->dep_id = dep_id;
return ri;
}
+ %newobject solvable;
XSolvable * const solvable;
+ %newobject othersolvable;
XSolvable * const othersolvable;
+ %newobject dep;
+ Dep * const dep;
%{
SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
return new_XSolvable(ri->solv->pool, ri->source);
SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
return new_XSolvable(ri->solv->pool, ri->target);
}
+ SWIGINTERN Dep *Ruleinfo_dep_get(Ruleinfo *ri) {
+ return new_Dep(ri->solv->pool, ri->dep_id);
+ }
%}
const char *problemstr() {
- return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
+ return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep_id);
}
}
repodata_internalize(repo_id2repodata($self->repo, $self->id));
}
void create_stubs() {
- repodata_create_stubs(repo_id2repodata($self->repo, $self->id));
+ Repodata *data = repo_id2repodata($self->repo, $self->id);
+ data = repodata_create_stubs(data);
+ $self->id = data->repodataid;
}
bool write(FILE *fp) {
return repodata_write(repo_id2repodata($self->repo, $self->id), fp) == 0;