3 # %rename("to_s") string();
5 ##if defined(SWIGPYTHON)
6 # %rename("__str__") string();
12 %typemap(in) (Id *idarray, int idarraylen) {
13 /* Check if is a list */
14 if (PyList_Check($input)) {
15 int size = PyList_Size($input);
17 $1 = (Id *)sat_malloc2(size, sizeof(Id));
18 for (i = 0; i < size; i++) {
19 PyObject *o = PyList_GetItem($input,i);
21 int e = SWIG_AsVal_int(o, &v);
23 SWIG_exception_fail(SWIG_ArgError(e), "list must contain integers");
31 PyErr_SetString(PyExc_TypeError,"not a list");
35 %typemap(freearg) (Id *idarray, int idarraylen) {
40 /* Check if is a list */
42 if (PyList_Check($input)) {
43 int size = PyList_Size($input);
45 for (i = 0; i < size; i++) {
46 PyObject *o = PyList_GetItem($input,i);
48 int e = SWIG_AsVal_int(o, &v);
50 SWIG_exception_fail(SWIG_ArgError(e), "list must contain only integers");
57 PyErr_SetString(PyExc_TypeError,"not a list");
63 PyObject *o = PyList_New($1.count);
64 for (i = 0; i < $1.count; i++)
65 PyList_SetItem(o, i, SWIG_From_int($1.elements[i]));
69 %typemap(arginit) Queue {
72 %typemap(freearg) Queue {
85 #include "repo_solv.h"
88 #include "repo_rpmdb.h"
89 #include "repo_rpmmd.h"
90 #include "repo_write.h"
91 #include "repo_products.h"
92 #include "repo_susetags.h"
93 #include "repo_updateinfoxml.h"
94 #include "repo_deltainfoxml.h"
95 #include "repo_repomdxml.h"
96 #include "repo_content.h"
97 #include "sat_xfopen.h"
102 #define SOLVER_SOLUTION_DEINSTALL -100
103 #define SOLVER_SOLUTION_REPLACE -101
104 typedef struct chksum Chksum;
125 } Pool_solvable_iterator;
130 } Pool_repo_iterator;
135 } Repo_solvable_iterator;
172 %constant Id SOLVID_META;
173 %constant Id SOLVID_POS;
175 %constant int REL_EQ;
176 %constant int REL_GT;
177 %constant int REL_LT;
178 %constant int REL_ARCH;
196 # put before pool/repo so we can access the constructor
197 %nodefaultctor Dataiterator;
198 %nodefaultdtor Dataiterator;
199 typedef struct _Dataiterator {
218 typedef struct _Repo {
219 const char * const name;
222 int const nsolvables;
223 #if defined(SWIGRUBY)
226 #if defined(SWIGPERL)
231 %nodefaultctor Pool_solvable_iterator;
232 typedef struct {} Pool_solvable_iterator;
234 %nodefaultctor Pool_repo_iterator;
235 typedef struct {} Pool_repo_iterator;
237 %nodefaultctor Repo_solvable_iterator;
238 typedef struct {} Repo_solvable_iterator;
240 %nodefaultctor Solver;
241 %nodefaultdtor Solver;
244 bool ignorealreadyrecommended;
245 bool dosplitprovides;
250 bool allowarchchange;
251 bool allowvendorchange;
254 typedef struct chksum {} Chksum;
256 %rename(xfopen) sat_xfopen;
257 %rename(xfopen_fd) sat_xfopen_fd;
258 %rename(xfclose) sat_xfclose;
259 %rename(xfileno) sat_xfileno;
261 FILE *sat_xfopen(const char *fn);
262 FILE *sat_xfopen_fd(const char *fn, int fd);
264 int sat_xfclose(FILE *fp) {
267 int sat_xfileno(FILE *fp) {
291 %nodefaultctor Transaction;
292 %nodefaultdtor Transaction;
300 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
301 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
302 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
303 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
304 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
305 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
306 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
307 static const Id SOLVER_NOOP = SOLVER_NOOP;
308 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
309 static const Id SOLVER_ERASE = SOLVER_ERASE;
310 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
311 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
312 static const Id SOLVER_NOOBSOLETES = SOLVER_NOOBSOLETES;
313 static const Id SOLVER_LOCK = SOLVER_LOCK;
314 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
315 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
316 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
317 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
318 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
319 static const Id SOLVER_WEAK = SOLVER_WEAK;
320 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
321 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
322 static const Id SOLVER_SETEV = SOLVER_SETEV;
323 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
324 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
325 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
326 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
327 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
328 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
330 Job(Pool *pool, Id how, Id what) {
331 Job *job = sat_calloc(1, sizeof(*job));
341 return (Chksum *)sat_chksum_create(type);
344 sat_chksum_free($self, 0);
346 void add(const char *str) {
347 sat_chksum_add($self, str, strlen((char *)str));
349 void addfp(FILE *fp) {
352 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
353 sat_chksum_add($self, buf, l);
354 rewind(fp); /* convenience */
359 while ((l = read(fd, buf, sizeof(buf))) > 0)
360 sat_chksum_add($self, buf, l);
361 lseek(fd, 0, 0); /* convenience */
363 bool matches(char *othersum) {
366 b = sat_chksum_get($self, &l);
367 return memcmp(b, (void *)othersum, l) == 0;
372 b = sat_chksum_get($self, &l);
373 return cdata_void((void *)b, l);
381 Pool *pool = pool_create();
386 void set_debuglevel(int level) {
387 pool_setdebuglevel($self, level);
390 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
391 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
392 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
393 PyObject *result = PyEval_CallObject((PyObject *)d, args);
395 return 0; /* exception */
399 ecode = SWIG_AsVal_int(result, &vresult);
401 return SWIG_IsOK(ecode) ? vresult : 0;
404 void set_loadcallback(PyObject *callable) {
406 if ($self->loadcallback == loadcallback) {
407 Py_DECREF($self->loadcallbackdata);
408 pool_setloadcallback($self, 0, 0);
413 pool_setloadcallback($self, loadcallback, callable);
415 Id str2id(const char *str, int create=1) {
416 return str2id($self, str, create);
418 const char *id2str(Id id) {
419 return id2str($self, id);
421 const char *dep2str(Id id) {
422 return dep2str($self, id);
424 Id rel2id(Id name, Id evr, int flags, int create=1) {
425 return rel2id($self, name, evr, flags, create);
427 void setarch(const char *arch) {
428 pool_setarch($self, arch);
430 Repo *add_repo(const char *name) {
431 return repo_create($self, name);
433 const char *lookup_str(Id entry, Id keyname) {
434 return pool_lookup_str($self, entry, keyname);
436 Id lookup_id(Id entry, Id keyname) {
437 return pool_lookup_id($self, entry, keyname);
439 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
440 return pool_lookup_num($self, entry, keyname, notfound);
442 bool lookup_void(Id entry, Id keyname) {
443 return pool_lookup_void($self, entry, keyname);
445 SWIGCDATA lookup_bin_checksum(Id entry, Id keyname, Id *OUTPUT) {
447 const unsigned char *b;
449 b = pool_lookup_bin_checksum($self, entry, keyname, OUTPUT);
451 return cdata_void(0, 0);
452 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
454 const char *lookup_checksum(Id entry, Id keyname, Id *OUTPUT) {
457 const char *b = pool_lookup_checksum($self, entry, keyname, OUTPUT);
460 %newobject dataiterator_new;
461 Dataiterator *dataiterator_new(Id p, Id key, const char *match, int flags) {
462 return new_Dataiterator($self, 0, p, key, match, flags);
464 const char *solvid2str(Id solvid) {
465 return solvid2str($self, solvid);
467 void addfileprovides() {
468 pool_addfileprovides($self);
470 void createwhatprovides() {
471 pool_createwhatprovides($self);
473 Pool_solvable_iterator * const solvables;
475 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
476 Pool_solvable_iterator *s;
477 s = sat_calloc(1, sizeof(*s));
483 Pool_repo_iterator * const repos;
485 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
486 Pool_repo_iterator *s;
487 s = sat_calloc(1, sizeof(*s));
495 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
496 pool_set_installed(pool, installed);
498 Repo *Pool_installed_get(Pool *pool) {
499 return pool->installed;
503 Queue providerids(Id dep) {
508 FOR_PROVIDES(p, pp, dep)
512 Queue allprovidingids() {
517 for (id = 1; id < pool->ss.nstrings; id++)
518 if (pool->whatprovides[id])
523 Queue jobsolvids(Job *job) {
528 how = job->how & SOLVER_SELECTMASK;
529 FOR_JOB_SELECT(p, pp, how, job->what)
533 Job *Job(Id how, Id what) {
534 return new_Job($self, how, what);
537 #if defined(SWIGPYTHON)
539 def jobsolvables (self, *args):
540 return [ self.solvables[id] for id in self.jobsolvids(*args) ]
541 def providers(self, *args):
542 return [ self.solvables[id] for id in self.providerids(*args) ]
546 Id towhatprovides(Queue q) {
547 return pool_queuetowhatprovides($self, &q);
549 bool isknownarch(Id id) {
551 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
553 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
558 %newobject create_solver;
559 Solver *create_solver() {
560 return solver_create($self);
565 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
566 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
567 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
568 static const int REPO_USE_LOADING = REPO_USE_LOADING;
569 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
570 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
571 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
573 void free(int reuseids = 0) {
574 repo_free($self, reuseids);
576 bool add_solv(const char *name, int flags = 0) {
577 FILE *fp = fopen(name, "r");
580 int r = repo_add_solv_flags($self, fp, flags);
584 bool add_solv(FILE *fp, int flags = 0) {
585 return repo_add_solv_flags($self, fp, flags) == 0;
587 bool add_products(const char *proddir, int flags = 0) {
588 repo_add_products($self, proddir, 0, flags);
591 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
592 repo_add_rpmmd($self, fp, language, flags);
595 bool add_rpmdb(Repo *ref, int flags = 0) {
596 repo_add_rpmdb($self, ref, 0, flags);
599 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
600 repo_add_susetags($self, fp, defvendor, language, flags);
603 bool add_repomdxml(FILE *fp, int flags = 0) {
604 repo_add_repomdxml($self, fp, flags);
607 bool add_content(FILE *fp, int flags = 0) {
608 repo_add_content($self, fp, flags);
611 bool add_updateinfoxml(FILE *fp, int flags = 0) {
612 repo_add_updateinfoxml($self, fp, flags);
615 bool add_deltainfoxml(FILE *fp, int flags = 0) {
616 repo_add_deltainfoxml($self, fp, flags);
620 repo_internalize($self);
622 const char *lookup_str(Id entry, Id keyname) {
623 return repo_lookup_str($self, entry, keyname);
625 Id lookup_id(Id entry, Id keyname) {
626 return repo_lookup_id($self, entry, keyname);
628 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
629 return repo_lookup_num($self, entry, keyname, notfound);
631 void write(FILE *fp) {
632 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
634 # HACK, remove if no longer needed!
635 bool write_first_repodata(FILE *fp, int flags = 0) {
636 int oldnrepodata = $self->nrepodata;
637 $self->nrepodata = 1;
638 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
639 $self->nrepodata = oldnrepodata;
642 %newobject dataiterator_new;
643 Dataiterator *dataiterator_new(Id p, Id key, const char *match, int flags) {
644 return new_Dataiterator($self->pool, $self, p, key, match, flags);
649 SWIGINTERN Id Repo_id_get(Repo *repo) {
653 Repo_solvable_iterator * const solvables;
655 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
656 Repo_solvable_iterator *s;
657 s = sat_calloc(1, sizeof(*s));
664 XRepodata *add_repodata(int flags = 0) {
665 Repodata *rd = repo_add_repodata($self, flags);
666 return new_XRepodata($self, rd - $self->repodata);
669 void create_stubs() {
671 if (!$self->nrepodata)
673 data = $self->repodata + ($self->nrepodata - 1);
674 if (data->state != REPODATA_STUB)
675 repodata_create_stubs(data);
677 #if defined(SWIGPYTHON)
680 SWIGINTERN void Repo_appdata_set(Repo *repo, PyObject *o) {
683 SWIGINTERN PyObject *Repo_appdata_get(Repo *repo) {
684 PyObject *o = repo->appdata;
692 %extend Dataiterator {
693 static const int SEARCH_STRING = SEARCH_STRING;
694 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
695 static const int SEARCH_GLOB = SEARCH_GLOB;
696 static const int SEARCH_REGEX = SEARCH_REGEX;
697 static const int SEARCH_NOCASE = SEARCH_NOCASE;
698 static const int SEARCH_FILES = SEARCH_FILES;
699 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
701 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
702 Dataiterator *di = sat_calloc(1, sizeof(*di));
703 dataiterator_init(di, pool, repo, p, key, match, flags);
707 dataiterator_free($self);
709 Dataiterator *__iter__() {
715 PyErr_SetString(PyExc_StopIteration,"no more matches");
720 Dataiterator *next() {
722 if (!dataiterator_step($self)) {
725 ndi = sat_calloc(1, sizeof(*ndi));
726 dataiterator_init_clone(ndi, $self);
729 void setpos_parent() {
730 dataiterator_setpos_parent($self);
732 void prepend_keyname(Id key) {
733 dataiterator_prepend_keyname($self, key);
735 void skip_solvable() {
736 dataiterator_skip_solvable($self);
740 XSolvable * const solvable;
742 SWIGINTERN XSolvable *Dataiterator_solvable_get(Dataiterator *di) {
743 return new_XSolvable(di->pool, di->solvid);
747 return $self->key->name;
749 const char *key_idstr() {
750 return id2str($self->pool, $self->key->name);
753 return $self->key->type;
755 const char *keytype_idstr() {
756 return id2str($self->pool, $self->key->type);
761 const char *match_idstr() {
762 return id2str($self->pool, $self->kv.id);
764 const char *match_str() {
765 return $self->kv.str;
768 return $self->kv.num;
771 return $self->kv.num2;
776 %extend Pool_solvable_iterator {
777 Pool_solvable_iterator *__iter__() {
783 PyErr_SetString(PyExc_StopIteration,"no more matches");
789 Pool *pool = $self->pool;
791 if ($self->id >= pool->nsolvables)
793 while (++$self->id < pool->nsolvables)
794 if (pool->solvables[$self->id].repo)
795 return new_XSolvable(pool, $self->id);
798 %newobject __getitem__;
799 XSolvable *__getitem__(Id key) {
800 Pool *pool = $self->pool;
801 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
802 return new_XSolvable(pool, key);
807 %extend Pool_repo_iterator {
808 Pool_repo_iterator *__iter__() {
814 PyErr_SetString(PyExc_StopIteration,"no more matches");
819 Pool *pool = $self->pool;
820 if ($self->id >= pool->nrepos + 1)
822 while (++$self->id < pool->nrepos + 1) {
823 Repo *r = pool_id2repo(pool, $self->id);
829 Repo *__getitem__(Id key) {
830 Pool *pool = $self->pool;
831 if (key > 0 && key < pool->nrepos + 1)
832 return pool_id2repo(pool, key);
837 %extend Repo_solvable_iterator {
838 Repo_solvable_iterator *__iter__() {
844 PyErr_SetString(PyExc_StopIteration,"no more matches");
850 Repo *repo = $self->repo;
851 Pool *pool = repo->pool;
853 if (repo->start > 0 && $self->id < repo->start)
854 $self->id = repo->start - 1;
855 if ($self->id >= repo->end)
857 while (++$self->id < repo->end)
858 if (pool->solvables[$self->id].repo == repo)
859 return new_XSolvable(pool, $self->id);
862 %newobject __getitem__;
863 XSolvable *__getitem__(Id key) {
864 Repo *repo = $self->repo;
865 Pool *pool = repo->pool;
866 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
867 return new_XSolvable(pool, key);
873 XSolvable(Pool *pool, Id id) {
876 XSolvable *s = sat_calloc(1, sizeof(*s));
882 return solvid2str($self->pool, $self->id);
884 const char *lookup_str(Id keyname) {
885 return pool_lookup_str($self->pool, $self->id, keyname);
887 Id lookup_id(Id keyname) {
888 return pool_lookup_id($self->pool, $self->id, keyname);
890 unsigned int lookup_num(Id keyname, unsigned int notfound = 0) {
891 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
893 bool lookup_void(Id keyname) {
894 return pool_lookup_void($self->pool, $self->id, keyname);
896 SWIGCDATA lookup_bin_checksum(Id keyname, Id *OUTPUT) {
898 const unsigned char *b;
900 b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, OUTPUT);
902 return cdata_void(0, 0);
903 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
905 const char *lookup_checksum(Id keyname, Id *OUTPUT) {
908 const char *b = pool_lookup_checksum($self->pool, $self->id, keyname, OUTPUT);
911 const char *lookup_location(int *OUTPUT) {
912 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
915 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
918 Pool *pool = $self->pool;
919 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
922 const char * const name;
924 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
925 Pool *pool = xs->pool;
926 return id2str(pool, pool->solvables[xs->id].name);
931 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
932 return xs->pool->solvables[xs->id].name;
935 const char * const evr;
937 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
938 Pool *pool = xs->pool;
939 return id2str(pool, pool->solvables[xs->id].evr);
944 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
945 return xs->pool->solvables[xs->id].evr;
948 const char * const arch;
950 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
951 Pool *pool = xs->pool;
952 return id2str(pool, pool->solvables[xs->id].arch);
957 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
958 return xs->pool->solvables[xs->id].arch;
963 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
964 return xs->pool->solvables[xs->id].repo;
970 Problem(Solver *solv, Id id) {
972 p = sat_calloc(1, sizeof(*p));
977 Id findproblemrule_helper() {
978 return solver_findproblemrule($self->solv, $self->id);
980 Queue findallproblemrules_helper(int unfiltered=0) {
981 Solver *solv = $self->solv;
986 solver_findallproblemrules(solv, $self->id, &q);
989 for (i = j = 0; i < q.count; i++)
991 probr = q.elements[i];
992 if ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end))
994 q.elements[j++] = probr;
997 queue_truncate(&q, j);
1001 int solution_count() {
1002 return solver_solution_count($self->solv, $self->id);
1004 #if defined(SWIGPYTHON)
1006 def findproblemrule(self):
1007 return XRule(self.solv, self.findproblemrule_helper())
1008 def findallproblemrules(self, unfiltered=0):
1009 return [ XRule(self.solv, i) for i in self.findallproblemrules_helper(unfiltered) ]
1010 def solutions(self):
1011 return [ Solution(self, i) for i in range(1, self.solution_count() + 1) ];
1017 Solution(Problem *p, Id id) {
1019 s = sat_calloc(1, sizeof(*s));
1021 s->problemid = p->id;
1025 int element_count() {
1026 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1028 #if defined(SWIGPYTHON)
1031 return [ Solutionelement(self, i) for i in range(1, self.element_count() + 1) ];
1036 %extend Solutionelement {
1037 Solutionelement(Solution *s, Id id) {
1039 e = sat_calloc(1, sizeof(*e));
1041 e->problemid = s->problemid;
1042 e->solutionid = s->id;
1044 solver_next_solutionelement(e->solv, e->problemid, e->solutionid, e->id - 1, &e->p, &e->rp);
1046 e->type = e->rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_DEINSTALL;
1054 %newobject solvable;
1055 XSolvable * const solvable;
1056 %newobject replacement;
1057 XSolvable * const replacement;
1060 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
1061 return new_XSolvable(e->solv->pool, e->p);
1063 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
1064 return new_XSolvable(e->solv->pool, e->rp);
1066 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
1067 return (e->p - 1) / 2;
1073 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
1074 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
1075 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
1076 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
1077 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
1078 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
1079 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
1080 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
1081 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
1082 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
1083 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
1084 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
1085 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
1086 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
1087 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
1088 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
1089 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
1090 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
1091 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
1093 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
1094 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
1095 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
1096 static const int SOLVER_SOLUTION_DEINSTALL = SOLVER_SOLUTION_DEINSTALL;
1097 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
1102 #if defined(SWIGPYTHON)
1104 def solve(self, jobs):
1106 for job in jobs: j += [job.how, job.what]
1107 nprob = self.solve_helper(j)
1108 return [ Problem(self, pid) for pid in range(1, nprob + 1) ]
1111 int solve_helper(Queue jobs) {
1112 solver_solve($self, &jobs);
1113 return solver_problem_count($self);
1115 %newobject transaction;
1116 Transaction *transaction() {
1118 t = sat_calloc(1, sizeof(*t));
1119 transaction_init_clone(t, &$self->trans);
1124 %extend Transaction {
1125 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
1126 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
1127 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
1128 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
1129 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
1130 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
1131 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
1132 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
1133 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
1134 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
1135 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
1136 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
1137 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
1138 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
1139 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
1140 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
1141 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
1142 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
1143 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
1144 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
1145 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
1146 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
1147 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
1148 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
1149 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
1150 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
1151 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
1153 transaction_free($self);
1157 return $self->steps.count == 0;
1159 Queue classify_helper(int mode) {
1162 transaction_classify($self, mode, &q);
1165 Queue classify_pkgs_helper(int mode, Id cl, Id from, Id to) {
1168 transaction_classify_pkgs($self, mode, cl, from, to, &q);
1171 %newobject othersolvable;
1172 XSolvable *othersolvable(XSolvable *s) {
1173 Id op = transaction_obs_pkg($self, s->id);
1174 return new_XSolvable($self->pool, op);
1176 #if defined(SWIGPYTHON)
1178 def classify(self, mode = 0):
1180 cr = self.classify_helper(mode)
1181 for type, cnt, fromid, toid in zip(*([iter(cr)] * 4)):
1182 if type != self.SOLVER_TRANSACTION_IGNORE:
1183 r.append([ type, [ self.pool.solvables[j] for j in self.classify_pkgs_helper(mode, type, fromid, toid) ], fromid, toid ])
1187 Queue installedresult_helper(int *OUTPUT) {
1190 *OUTPUT = transaction_installedresult(self, &q);
1193 #if defined(SWIGPYTHON)
1195 def installedresult(self):
1196 r = self.installedresult_helper()
1198 rn = [ self.pool.solvables[r[i]] for i in range(0, newpkgs) ]
1199 rk = [ self.pool.solvables[r[i]] for i in range(newpkgs, len(r)) ]
1203 Queue steps_helper() {
1205 queue_init_clone(&q, &$self->steps);
1208 int steptype(XSolvable *s, int mode) {
1209 return transaction_type($self, s->id, mode);
1211 #if defined(SWIGPYTHON)
1214 return [ self.pool.solvables[i] for i in self.steps_helper() ]
1217 int calc_installsizechange() {
1218 return transaction_calc_installsizechange($self);
1223 XRule(Solver *solv, Id id) {
1226 XRule *xr = sat_calloc(1, sizeof(*xr));
1231 %apply Id *OUTPUT { Id *source, Id *target, Id *dep };
1232 int info_helper(Id *source, Id *target, Id *dep) {
1233 return solver_ruleinfo($self->solv, $self->id, source, target, dep);
1235 #if defined(SWIGPYTHON)
1238 type, source, target, dep = self.info_helper()
1240 source = self.solv.pool.solvables[source]
1242 target = self.solv.pool.solvables[target]
1243 return type, source, target, dep
1250 XRepodata(Repo *repo, Id id) {
1251 XRepodata *xr = sat_calloc(1, sizeof(*xr));
1257 return repodata_new_handle($self->repo->repodata + $self->id);
1259 void set_id(Id solvid, Id keyname, Id id) {
1260 repodata_set_id($self->repo->repodata + $self->id, solvid, keyname, id);
1262 void set_str(Id solvid, Id keyname, const char *str) {
1263 repodata_set_str($self->repo->repodata + $self->id, solvid, keyname, str);
1265 void set_poolstr(Id solvid, Id keyname, const char *str) {
1266 repodata_set_poolstr($self->repo->repodata + $self->id, solvid, keyname, str);
1268 void add_idarray(Id solvid, Id keyname, Id id) {
1269 repodata_add_idarray($self->repo->repodata + $self->id, solvid, keyname, id);
1271 void add_flexarray(Id solvid, Id keyname, Id handle) {
1272 repodata_add_flexarray($self->repo->repodata + $self->id, solvid, keyname, handle);
1274 void set_bin_checksum(Id solvid, Id keyname, Id chksumtype, const char *chksum) {
1275 repodata_set_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, chksumtype, (const unsigned char *)chksum);
1277 const char *lookup_str(Id solvid, Id keyname) {
1278 return repodata_lookup_str($self->repo->repodata + $self->id, solvid, keyname);
1280 SWIGCDATA lookup_bin_checksum(Id solvid, Id keyname, Id *OUTPUT) {
1281 const unsigned char *b;
1283 b = repodata_lookup_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, OUTPUT);
1284 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
1286 void internalize() {
1287 repodata_internalize($self->repo->repodata + $self->id);
1289 void create_stubs() {
1290 repodata_create_stubs($self->repo->repodata + $self->id);
1292 void write(FILE *fp) {
1293 repodata_write($self->repo->repodata + $self->id, fp, repo_write_stdkeyfilter, 0);