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);
389 #if defined(SWIGPYTHON)
391 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
392 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
393 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
394 PyObject *result = PyEval_CallObject((PyObject *)d, args);
396 return 0; /* exception */
400 ecode = SWIG_AsVal_int(result, &vresult);
402 return SWIG_IsOK(ecode) ? vresult : 0;
405 void set_loadcallback(PyObject *callable) {
407 if ($self->loadcallback == loadcallback) {
408 Py_DECREF($self->loadcallbackdata);
409 pool_setloadcallback($self, 0, 0);
414 pool_setloadcallback($self, loadcallback, callable);
418 #if defined(SWIGPYTHON)
419 Pool_set_loadcallback($self, 0);
423 Id str2id(const char *str, int create=1) {
424 return str2id($self, str, create);
426 const char *id2str(Id id) {
427 return id2str($self, id);
429 const char *dep2str(Id id) {
430 return dep2str($self, id);
432 Id rel2id(Id name, Id evr, int flags, int create=1) {
433 return rel2id($self, name, evr, flags, create);
435 void setarch(const char *arch) {
436 pool_setarch($self, arch);
438 Repo *add_repo(const char *name) {
439 return repo_create($self, name);
441 const char *lookup_str(Id entry, Id keyname) {
442 return pool_lookup_str($self, entry, keyname);
444 Id lookup_id(Id entry, Id keyname) {
445 return pool_lookup_id($self, entry, keyname);
447 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
448 return pool_lookup_num($self, entry, keyname, notfound);
450 bool lookup_void(Id entry, Id keyname) {
451 return pool_lookup_void($self, entry, keyname);
453 SWIGCDATA lookup_bin_checksum(Id entry, Id keyname, Id *OUTPUT) {
455 const unsigned char *b;
457 b = pool_lookup_bin_checksum($self, entry, keyname, OUTPUT);
459 return cdata_void(0, 0);
460 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
462 const char *lookup_checksum(Id entry, Id keyname, Id *OUTPUT) {
465 const char *b = pool_lookup_checksum($self, entry, keyname, OUTPUT);
468 %newobject dataiterator_new;
469 Dataiterator *dataiterator_new(Id p, Id key, const char *match, int flags) {
470 return new_Dataiterator($self, 0, p, key, match, flags);
472 const char *solvid2str(Id solvid) {
473 return solvid2str($self, solvid);
475 void addfileprovides() {
476 pool_addfileprovides($self);
478 void createwhatprovides() {
479 pool_createwhatprovides($self);
481 %newobject solvables;
482 Pool_solvable_iterator * const solvables;
484 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
485 Pool_solvable_iterator *s;
486 s = sat_calloc(1, sizeof(*s));
493 Pool_repo_iterator * const repos;
495 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
496 Pool_repo_iterator *s;
497 s = sat_calloc(1, sizeof(*s));
505 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
506 pool_set_installed(pool, installed);
508 Repo *Pool_installed_get(Pool *pool) {
509 return pool->installed;
513 Queue providerids(Id dep) {
518 FOR_PROVIDES(p, pp, dep)
522 Queue allprovidingids() {
527 for (id = 1; id < pool->ss.nstrings; id++)
528 if (pool->whatprovides[id])
533 Queue jobsolvids(Job *job) {
538 how = job->how & SOLVER_SELECTMASK;
539 FOR_JOB_SELECT(p, pp, how, job->what)
543 Job *Job(Id how, Id what) {
544 return new_Job($self, how, what);
547 #if defined(SWIGPYTHON)
549 def jobsolvables (self, *args):
550 return [ self.solvables[id] for id in self.jobsolvids(*args) ]
551 def providers(self, *args):
552 return [ self.solvables[id] for id in self.providerids(*args) ]
556 Id towhatprovides(Queue q) {
557 return pool_queuetowhatprovides($self, &q);
559 bool isknownarch(Id id) {
561 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
563 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
568 %newobject create_solver;
569 Solver *create_solver() {
570 return solver_create($self);
575 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
576 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
577 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
578 static const int REPO_USE_LOADING = REPO_USE_LOADING;
579 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
580 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
581 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
583 void free(int reuseids = 0) {
584 repo_free($self, reuseids);
586 bool add_solv(const char *name, int flags = 0) {
587 FILE *fp = fopen(name, "r");
590 int r = repo_add_solv_flags($self, fp, flags);
594 bool add_solv(FILE *fp, int flags = 0) {
595 return repo_add_solv_flags($self, fp, flags) == 0;
597 bool add_products(const char *proddir, int flags = 0) {
598 repo_add_products($self, proddir, 0, flags);
601 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
602 repo_add_rpmmd($self, fp, language, flags);
605 bool add_rpmdb(Repo *ref, int flags = 0) {
606 repo_add_rpmdb($self, ref, 0, flags);
609 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
610 repo_add_susetags($self, fp, defvendor, language, flags);
613 bool add_repomdxml(FILE *fp, int flags = 0) {
614 repo_add_repomdxml($self, fp, flags);
617 bool add_content(FILE *fp, int flags = 0) {
618 repo_add_content($self, fp, flags);
621 bool add_updateinfoxml(FILE *fp, int flags = 0) {
622 repo_add_updateinfoxml($self, fp, flags);
625 bool add_deltainfoxml(FILE *fp, int flags = 0) {
626 repo_add_deltainfoxml($self, fp, flags);
630 repo_internalize($self);
632 const char *lookup_str(Id entry, Id keyname) {
633 return repo_lookup_str($self, entry, keyname);
635 Id lookup_id(Id entry, Id keyname) {
636 return repo_lookup_id($self, entry, keyname);
638 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
639 return repo_lookup_num($self, entry, keyname, notfound);
641 void write(FILE *fp) {
642 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
644 # HACK, remove if no longer needed!
645 bool write_first_repodata(FILE *fp, int flags = 0) {
646 int oldnrepodata = $self->nrepodata;
647 $self->nrepodata = 1;
648 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
649 $self->nrepodata = oldnrepodata;
652 %newobject dataiterator_new;
653 Dataiterator *dataiterator_new(Id p, Id key, const char *match, int flags) {
654 return new_Dataiterator($self->pool, $self, p, key, match, flags);
659 SWIGINTERN Id Repo_id_get(Repo *repo) {
663 Repo_solvable_iterator * const solvables;
665 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
666 Repo_solvable_iterator *s;
667 s = sat_calloc(1, sizeof(*s));
674 XRepodata *add_repodata(int flags = 0) {
675 Repodata *rd = repo_add_repodata($self, flags);
676 return new_XRepodata($self, rd - $self->repodata);
679 void create_stubs() {
681 if (!$self->nrepodata)
683 data = $self->repodata + ($self->nrepodata - 1);
684 if (data->state != REPODATA_STUB)
685 repodata_create_stubs(data);
687 #if defined(SWIGPYTHON)
690 SWIGINTERN void Repo_appdata_set(Repo *repo, PyObject *o) {
693 SWIGINTERN PyObject *Repo_appdata_get(Repo *repo) {
694 PyObject *o = repo->appdata;
702 %extend Dataiterator {
703 static const int SEARCH_STRING = SEARCH_STRING;
704 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
705 static const int SEARCH_GLOB = SEARCH_GLOB;
706 static const int SEARCH_REGEX = SEARCH_REGEX;
707 static const int SEARCH_NOCASE = SEARCH_NOCASE;
708 static const int SEARCH_FILES = SEARCH_FILES;
709 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
711 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
712 Dataiterator *di = sat_calloc(1, sizeof(*di));
713 dataiterator_init(di, pool, repo, p, key, match, flags);
717 dataiterator_free($self);
720 Dataiterator *__iter__() {
726 PyErr_SetString(PyExc_StopIteration,"no more matches");
731 Dataiterator *next() {
733 if (!dataiterator_step($self)) {
736 ndi = sat_calloc(1, sizeof(*ndi));
737 dataiterator_init_clone(ndi, $self);
740 void setpos_parent() {
741 dataiterator_setpos_parent($self);
743 void prepend_keyname(Id key) {
744 dataiterator_prepend_keyname($self, key);
746 void skip_solvable() {
747 dataiterator_skip_solvable($self);
751 XSolvable * const solvable;
753 SWIGINTERN XSolvable *Dataiterator_solvable_get(Dataiterator *di) {
754 return new_XSolvable(di->pool, di->solvid);
758 return $self->key->name;
760 const char *key_idstr() {
761 return id2str($self->pool, $self->key->name);
764 return $self->key->type;
766 const char *keytype_idstr() {
767 return id2str($self->pool, $self->key->type);
772 const char *match_idstr() {
773 return id2str($self->pool, $self->kv.id);
775 const char *match_str() {
776 return $self->kv.str;
779 return $self->kv.num;
782 return $self->kv.num2;
787 %extend Pool_solvable_iterator {
788 Pool_solvable_iterator *__iter__() {
794 PyErr_SetString(PyExc_StopIteration,"no more matches");
800 Pool *pool = $self->pool;
802 if ($self->id >= pool->nsolvables)
804 while (++$self->id < pool->nsolvables)
805 if (pool->solvables[$self->id].repo)
806 return new_XSolvable(pool, $self->id);
809 %newobject __getitem__;
810 XSolvable *__getitem__(Id key) {
811 Pool *pool = $self->pool;
812 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
813 return new_XSolvable(pool, key);
818 %extend Pool_repo_iterator {
819 Pool_repo_iterator *__iter__() {
825 PyErr_SetString(PyExc_StopIteration,"no more matches");
830 Pool *pool = $self->pool;
831 if ($self->id >= pool->nrepos + 1)
833 while (++$self->id < pool->nrepos + 1) {
834 Repo *r = pool_id2repo(pool, $self->id);
840 Repo *__getitem__(Id key) {
841 Pool *pool = $self->pool;
842 if (key > 0 && key < pool->nrepos + 1)
843 return pool_id2repo(pool, key);
848 %extend Repo_solvable_iterator {
849 Repo_solvable_iterator *__iter__() {
855 PyErr_SetString(PyExc_StopIteration,"no more matches");
861 Repo *repo = $self->repo;
862 Pool *pool = repo->pool;
864 if (repo->start > 0 && $self->id < repo->start)
865 $self->id = repo->start - 1;
866 if ($self->id >= repo->end)
868 while (++$self->id < repo->end)
869 if (pool->solvables[$self->id].repo == repo)
870 return new_XSolvable(pool, $self->id);
873 %newobject __getitem__;
874 XSolvable *__getitem__(Id key) {
875 Repo *repo = $self->repo;
876 Pool *pool = repo->pool;
877 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
878 return new_XSolvable(pool, key);
884 XSolvable(Pool *pool, Id id) {
887 XSolvable *s = sat_calloc(1, sizeof(*s));
893 return solvid2str($self->pool, $self->id);
895 const char *lookup_str(Id keyname) {
896 return pool_lookup_str($self->pool, $self->id, keyname);
898 Id lookup_id(Id keyname) {
899 return pool_lookup_id($self->pool, $self->id, keyname);
901 unsigned int lookup_num(Id keyname, unsigned int notfound = 0) {
902 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
904 bool lookup_void(Id keyname) {
905 return pool_lookup_void($self->pool, $self->id, keyname);
907 SWIGCDATA lookup_bin_checksum(Id keyname, Id *OUTPUT) {
909 const unsigned char *b;
911 b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, OUTPUT);
913 return cdata_void(0, 0);
914 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
916 const char *lookup_checksum(Id keyname, Id *OUTPUT) {
919 const char *b = pool_lookup_checksum($self->pool, $self->id, keyname, OUTPUT);
922 const char *lookup_location(int *OUTPUT) {
923 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
926 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
929 Pool *pool = $self->pool;
930 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
933 const char * const name;
935 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
936 Pool *pool = xs->pool;
937 return id2str(pool, pool->solvables[xs->id].name);
942 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
943 return xs->pool->solvables[xs->id].name;
946 const char * const evr;
948 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
949 Pool *pool = xs->pool;
950 return id2str(pool, pool->solvables[xs->id].evr);
955 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
956 return xs->pool->solvables[xs->id].evr;
959 const char * const arch;
961 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
962 Pool *pool = xs->pool;
963 return id2str(pool, pool->solvables[xs->id].arch);
968 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
969 return xs->pool->solvables[xs->id].arch;
974 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
975 return xs->pool->solvables[xs->id].repo;
981 Problem(Solver *solv, Id id) {
983 p = sat_calloc(1, sizeof(*p));
988 Id findproblemrule_helper() {
989 return solver_findproblemrule($self->solv, $self->id);
991 Queue findallproblemrules_helper(int unfiltered=0) {
992 Solver *solv = $self->solv;
997 solver_findallproblemrules(solv, $self->id, &q);
1000 for (i = j = 0; i < q.count; i++)
1002 probr = q.elements[i];
1003 if ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end))
1005 q.elements[j++] = probr;
1008 queue_truncate(&q, j);
1012 int solution_count() {
1013 return solver_solution_count($self->solv, $self->id);
1015 #if defined(SWIGPYTHON)
1017 def findproblemrule(self):
1018 return XRule(self.solv, self.findproblemrule_helper())
1019 def findallproblemrules(self, unfiltered=0):
1020 return [ XRule(self.solv, i) for i in self.findallproblemrules_helper(unfiltered) ]
1021 def solutions(self):
1022 return [ Solution(self, i) for i in range(1, self.solution_count() + 1) ];
1028 Solution(Problem *p, Id id) {
1030 s = sat_calloc(1, sizeof(*s));
1032 s->problemid = p->id;
1036 int element_count() {
1037 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1039 #if defined(SWIGPYTHON)
1042 return [ Solutionelement(self, i) for i in range(1, self.element_count() + 1) ];
1047 %extend Solutionelement {
1048 Solutionelement(Solution *s, Id id) {
1050 e = sat_calloc(1, sizeof(*e));
1052 e->problemid = s->problemid;
1053 e->solutionid = s->id;
1055 solver_next_solutionelement(e->solv, e->problemid, e->solutionid, e->id - 1, &e->p, &e->rp);
1057 e->type = e->rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_DEINSTALL;
1065 %newobject solvable;
1066 XSolvable * const solvable;
1067 %newobject replacement;
1068 XSolvable * const replacement;
1071 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
1072 return new_XSolvable(e->solv->pool, e->p);
1074 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
1075 return new_XSolvable(e->solv->pool, e->rp);
1077 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
1078 return (e->p - 1) / 2;
1084 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
1085 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
1086 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
1087 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
1088 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
1089 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
1090 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
1091 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
1092 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
1093 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
1094 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
1095 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
1096 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
1097 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
1098 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
1099 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
1100 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
1101 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
1102 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
1104 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
1105 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
1106 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
1107 static const int SOLVER_SOLUTION_DEINSTALL = SOLVER_SOLUTION_DEINSTALL;
1108 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
1113 #if defined(SWIGPYTHON)
1115 def solve(self, jobs):
1117 for job in jobs: j += [job.how, job.what]
1118 nprob = self.solve_helper(j)
1119 return [ Problem(self, pid) for pid in range(1, nprob + 1) ]
1122 int solve_helper(Queue jobs) {
1123 solver_solve($self, &jobs);
1124 return solver_problem_count($self);
1126 %newobject transaction;
1127 Transaction *transaction() {
1129 t = sat_calloc(1, sizeof(*t));
1130 transaction_init_clone(t, &$self->trans);
1135 %extend Transaction {
1136 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
1137 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
1138 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
1139 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
1140 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
1141 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
1142 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
1143 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
1144 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
1145 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
1146 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
1147 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
1148 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
1149 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
1150 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
1151 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
1152 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
1153 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
1154 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
1155 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
1156 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
1157 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
1158 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
1159 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
1160 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
1161 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
1162 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
1164 transaction_free($self);
1168 return $self->steps.count == 0;
1170 Queue classify_helper(int mode) {
1173 transaction_classify($self, mode, &q);
1176 Queue classify_pkgs_helper(int mode, Id cl, Id from, Id to) {
1179 transaction_classify_pkgs($self, mode, cl, from, to, &q);
1182 %newobject othersolvable;
1183 XSolvable *othersolvable(XSolvable *s) {
1184 Id op = transaction_obs_pkg($self, s->id);
1185 return new_XSolvable($self->pool, op);
1187 #if defined(SWIGPYTHON)
1189 def classify(self, mode = 0):
1191 cr = self.classify_helper(mode)
1192 for type, cnt, fromid, toid in zip(*([iter(cr)] * 4)):
1193 if type != self.SOLVER_TRANSACTION_IGNORE:
1194 r.append([ type, [ self.pool.solvables[j] for j in self.classify_pkgs_helper(mode, type, fromid, toid) ], fromid, toid ])
1198 Queue installedresult_helper(int *OUTPUT) {
1201 *OUTPUT = transaction_installedresult(self, &q);
1204 #if defined(SWIGPYTHON)
1206 def installedresult(self):
1207 r = self.installedresult_helper()
1209 rn = [ self.pool.solvables[r[i]] for i in range(0, newpkgs) ]
1210 rk = [ self.pool.solvables[r[i]] for i in range(newpkgs, len(r)) ]
1214 Queue steps_helper() {
1216 queue_init_clone(&q, &$self->steps);
1219 int steptype(XSolvable *s, int mode) {
1220 return transaction_type($self, s->id, mode);
1222 #if defined(SWIGPYTHON)
1225 return [ self.pool.solvables[i] for i in self.steps_helper() ]
1228 int calc_installsizechange() {
1229 return transaction_calc_installsizechange($self);
1234 XRule(Solver *solv, Id id) {
1237 XRule *xr = sat_calloc(1, sizeof(*xr));
1242 %apply Id *OUTPUT { Id *source, Id *target, Id *dep };
1243 int info_helper(Id *source, Id *target, Id *dep) {
1244 return solver_ruleinfo($self->solv, $self->id, source, target, dep);
1246 #if defined(SWIGPYTHON)
1249 type, source, target, dep = self.info_helper()
1251 source = self.solv.pool.solvables[source]
1253 target = self.solv.pool.solvables[target]
1254 return type, source, target, dep
1261 XRepodata(Repo *repo, Id id) {
1262 XRepodata *xr = sat_calloc(1, sizeof(*xr));
1268 return repodata_new_handle($self->repo->repodata + $self->id);
1270 void set_id(Id solvid, Id keyname, Id id) {
1271 repodata_set_id($self->repo->repodata + $self->id, solvid, keyname, id);
1273 void set_str(Id solvid, Id keyname, const char *str) {
1274 repodata_set_str($self->repo->repodata + $self->id, solvid, keyname, str);
1276 void set_poolstr(Id solvid, Id keyname, const char *str) {
1277 repodata_set_poolstr($self->repo->repodata + $self->id, solvid, keyname, str);
1279 void add_idarray(Id solvid, Id keyname, Id id) {
1280 repodata_add_idarray($self->repo->repodata + $self->id, solvid, keyname, id);
1282 void add_flexarray(Id solvid, Id keyname, Id handle) {
1283 repodata_add_flexarray($self->repo->repodata + $self->id, solvid, keyname, handle);
1285 void set_bin_checksum(Id solvid, Id keyname, Id chksumtype, const char *chksum) {
1286 repodata_set_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, chksumtype, (const unsigned char *)chksum);
1288 const char *lookup_str(Id solvid, Id keyname) {
1289 return repodata_lookup_str($self->repo->repodata + $self->id, solvid, keyname);
1291 SWIGCDATA lookup_bin_checksum(Id solvid, Id keyname, Id *OUTPUT) {
1292 const unsigned char *b;
1294 b = repodata_lookup_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, OUTPUT);
1295 return cdata_void((char *)b, sat_chksum_len(*OUTPUT));
1297 void internalize() {
1298 repodata_internalize($self->repo->repodata + $self->id);
1300 void create_stubs() {
1301 repodata_create_stubs($self->repo->repodata + $self->id);
1303 void write(FILE *fp) {
1304 repodata_write($self->repo->repodata + $self->id, fp, repo_write_stdkeyfilter, 0);