2 # WARNING: for perl iterator/array support you need to run
3 # sed -i -e 's/SvTYPE(tsv) == SVt_PVHV/SvTYPE(tsv) == SVt_PVHV || SvTYPE(tsv) == SVt_PVAV/'
4 # on the generated c code
9 # %rename("to_s") string();
11 ##if defined(SWIGPYTHON)
12 # %rename("__str__") string();
19 %markfunc Pool "mark_Pool";
22 #if defined(SWIGPYTHON)
24 /* Check if is a list */
26 if (PyList_Check($input)) {
27 int size = PyList_Size($input);
29 for (i = 0; i < size; i++) {
30 PyObject *o = PyList_GetItem($input,i);
32 int e = SWIG_AsVal_int(o, &v);
34 SWIG_exception_fail(SWIG_ArgError(e), "list must contain only integers");
41 PyErr_SetString(PyExc_TypeError,"not a list");
48 PyObject *o = PyList_New($1.count);
49 for (i = 0; i < $1.count; i++)
50 PyList_SetItem(o, i, SWIG_From_int($1.elements[i]));
55 %define Queue2Array(type, step, con) %{
57 int cnt = $1.count / step;
58 Id *idp = $1.elements;
59 PyObject *o = PyList_New(cnt);
60 for (i = 0; i < cnt; i++, idp += step)
63 #define result resultx
66 PyList_SetItem(o, i, $result);
83 if (!SvROK($input) || SvTYPE(SvRV($input)) != SVt_PVAV)
84 SWIG_croak("Argument $argnum is not an array reference.");
85 av = (AV*)SvRV($input);
87 for (i = 0; i <= size; i++) {
88 SV **sv = av_fetch(av, i, 0);
90 int e = SWIG_AsVal_int(*sv, &v);
92 SWIG_croak("list must contain only integers");
98 # av_push(o, SvREFCNT_inc(SWIG_From_int($1.elements[i])));
99 # $result = newRV_noinc((SV*)o); argvi++;
101 %typemap(out) Queue {
103 if (argvi + $1.count + 1>= items) {
104 EXTEND(sp, items - (argvi + $1.count + 1) + 1);
106 for (i = 0; i < $1.count; i++)
107 ST(argvi++) = SvREFCNT_inc(SWIG_From_int($1.elements[i]));
111 %define Queue2Array(type, step, con) %{
113 int cnt = $1.count / step;
114 Id *idp = $1.elements;
115 if (argvi + cnt + 1 >= items) {
116 EXTEND(sp, items - (argvi + cnt + 1) + 1);
118 for (i = 0; i < cnt; i++, idp += step)
121 #define result resultx
124 SvREFCNT_inc(ST(argvi - 1));
134 %typemap(arginit) Queue {
137 %typemap(freearg) Queue {
141 #if defined(SWIGRUBY)
146 size = RARRAY($input)->len;
148 o = RARRAY($input)->ptr;
149 for (i = 0; i < size; i++, o++) {
151 int e = SWIG_AsVal_int(*o, &v);
153 SWIG_croak("list must contain only integers");
157 %typemap(out) Queue {
159 VALUE o = rb_ary_new2($1.count);
160 for (i = 0; i < $1.count; i++)
161 rb_ary_store(o, i, SWIG_From_int($1.elements[i]));
165 %typemap(arginit) Queue {
168 %typemap(freearg) Queue {
171 %define Queue2Array(type, step, con) %{
173 int cnt = $1.count / step;
174 Id *idp = $1.elements;
175 VALUE o = rb_ary_new2(cnt);
176 for (i = 0; i < cnt; i++, idp += step)
179 #define result resultx
182 rb_ary_store(o, i, $result);
194 #if defined(SWIGPERL)
196 # work around a swig bug
200 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv,pPerl)
202 # ifndef MULTIPLICITY
203 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv)
205 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(PERL_GET_THX, cv)
211 %define perliter(class)
214 my $i = ${##class##::ITERATORS}{$_[0]};
216 $_[1] == $i->[0] - 1 ? $i->[1] : undef;
218 $_[0]->__getitem__($_[1]);
221 sub class##::FETCHSIZE {
222 my $i = ${##class##::ITERATORS}{$_[0]};
224 ($i->[1] = $_[0]->__next__()) ? ++$i->[0] : 0;
234 #define SWIG_PERL_ITERATOR 0x80
236 SWIGRUNTIMEINLINE SV *
237 SWIG_Perl_NewArrayObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
238 SV *result = sv_newmortal();
239 if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
244 sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
245 stash=SvSTASH(SvRV(obj));
246 if (flags & SWIG_POINTER_OWN) {
248 GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
250 gv_init(gv, stash, "OWNER", 5, FALSE);
252 hv_store_ent(hv, obj, newSViv(1), 0);
254 if (flags & SWIG_PERL_ITERATOR) {
256 GV *gv=*(GV**)hv_fetch(stash, "ITERATORS", 9, TRUE);
259 gv_init(gv, stash, "ITERATORS", 9, FALSE);
261 hv_store_ent(hv, obj, newRV_inc((SV *)av), 0);
263 sv_magic((SV *)array, (SV *)obj, 'P', Nullch, 0);
265 self=newRV_noinc((SV *)array);
266 sv_setsv(result, self);
267 SvREFCNT_dec((SV *)self);
268 sv_bless(result, stash);
270 sv_setref_pv(result, (char *) SWIG_Perl_TypeProxyName(t), ptr);
277 %typemap(out) Perlarray {
278 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow); argvi++;
280 %typemap(out) Perliterator {
281 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow | SWIG_PERL_ITERATOR); argvi++;
284 %typemap(out) Pool_solvable_iterator * = Perlarray;
285 %typemap(out) Pool_solvable_iterator * solvables_iter = Perliterator;
286 %typemap(out) Pool_repo_iterator * = Perlarray;
287 %typemap(out) Pool_repo_iterator * repos_iter = Perliterator;
288 %typemap(out) Repo_solvable_iterator * = Perlarray;
289 %typemap(out) Repo_solvable_iterator * solvables_iter = Perliterator;
290 %typemap(out) Dataiterator * = Perliterator;
296 #if defined(SWIGPYTHON)
297 typedef PyObject *AppObjectPtr;
298 %typemap(out) AppObjectPtr {
303 #if defined(SWIGPERL)
304 typedef SV *AppObjectPtr;
305 %typemap(in) AppObjectPtr {
306 $1 = SvROK($input) ? SvRV($input) : 0;
308 %typemap(out) AppObjectPtr {
309 $result = $1 ? newRV_inc($1) : newSV(0);
313 #if defined(SWIGRUBY)
314 typedef VALUE AppObjectPtr;
315 %typemap(in) AppObjectPtr {
318 %typemap(out) AppObjectPtr {
328 %include "typemaps.i"
332 #include "sys/stat.h"
337 #include "solverdebug.h"
338 #include "repo_solv.h"
342 #include "repo_rpmdb.h"
344 #include "repo_deb.h"
345 #include "repo_rpmmd.h"
346 #include "repo_write.h"
347 #include "repo_products.h"
348 #include "repo_susetags.h"
349 #include "repo_updateinfoxml.h"
350 #include "repo_deltainfoxml.h"
351 #include "repo_repomdxml.h"
352 #include "repo_content.h"
353 #include "solv_xfopen.h"
358 #define SOLVER_SOLUTION_ERASE -100
359 #define SOLVER_SOLUTION_REPLACE -101
360 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
361 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
362 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
364 typedef struct chksum Chksum;
366 typedef void *AppObjectPtr;
391 } Pool_solvable_iterator;
396 } Pool_repo_iterator;
401 } Repo_solvable_iterator;
441 Transaction *transaction;
449 typedef Dataiterator Datamatch;
454 %mixin Dataiterator "Enumerable";
455 %mixin Pool_solvable_iterator "Enumerable";
456 %mixin Pool_repo_iterator "Enumerable";
457 %mixin Repo_solvable_iterator "Enumerable";
465 %constant Id SOLVID_META;
466 %constant Id SOLVID_POS;
468 %constant int REL_EQ;
469 %constant int REL_GT;
470 %constant int REL_LT;
471 %constant int REL_ARCH;
499 # put before pool/repo so we can access the constructor
500 %nodefaultdtor Dataiterator;
501 typedef struct {} Dataiterator;
502 typedef struct {} Pool_solvable_iterator;
503 typedef struct {} Pool_repo_iterator;
504 typedef struct {} Repo_solvable_iterator;
506 %nodefaultctor Datamatch;
507 %nodefaultdtor Datamatch;
514 %nodefaultctor Datapos;
528 AppObjectPtr appdata;
533 typedef struct _Repo {
535 const char * const name;
538 int const nsolvables;
539 AppObjectPtr appdata;
542 %nodefaultctor Solver;
543 %nodefaultdtor Solver;
548 bool allowarchchange;
549 bool allowvendorchange;
552 bool noupdateprovide;
553 bool dosplitprovides;
554 bool dontinstallrecommended;
555 bool ignorealreadyrecommended;
556 bool dontshowinstalledrecommended;
558 bool distupgrade_removeunsupported;
562 typedef struct chksum {
565 %rename(xfopen) solv_xfopen;
566 %rename(xfopen_fd) solv_xfopen_fd;
567 %rename(xfopen_dup) solv_xfopen_dup;
568 %rename(xfclose) solv_xfclose;
569 %rename(xfileno) solv_xfileno;
571 FILE *solv_xfopen(const char *fn, const char *mode = 0);
572 FILE *solv_xfopen_fd(const char *fn, int fd, const char *mode = 0);
573 FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode = 0);
574 int solv_xfclose(FILE *fp);
575 int solv_xfileno(FILE *fp);
578 SWIGINTERN int solv_xfclose(FILE *fp) {
581 SWIGINTERN int solv_xfileno(FILE *fp) {
584 SWIGINTERN FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode) {
586 return fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
609 %nodefaultctor Transaction;
610 %nodefaultdtor Transaction;
616 Transaction * const transaction;
625 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
626 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
627 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
628 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
629 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
630 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
631 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
632 static const Id SOLVER_NOOP = SOLVER_NOOP;
633 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
634 static const Id SOLVER_ERASE = SOLVER_ERASE;
635 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
636 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
637 static const Id SOLVER_NOOBSOLETES = SOLVER_NOOBSOLETES;
638 static const Id SOLVER_LOCK = SOLVER_LOCK;
639 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
640 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
641 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
642 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
643 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
644 static const Id SOLVER_WEAK = SOLVER_WEAK;
645 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
646 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
647 static const Id SOLVER_SETEV = SOLVER_SETEV;
648 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
649 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
650 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
651 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
652 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
653 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
655 Job(Pool *pool, int how, Id what) {
656 Job *job = solv_calloc(1, sizeof(*job));
663 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
664 %newobject solvables;
666 Pool *pool = $self->pool;
670 how = $self->how & SOLVER_SELECTMASK;
671 FOR_JOB_SELECT(p, pp, how, $self->what)
677 return pool_job2str($self->pool, $self->how, $self->what, 0);
680 bool __eq__(Job *j) {
681 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
683 bool __ne__(Job *j) {
684 return !Job___eq__($self, j);
686 const char *__str__() {
687 return pool_job2str($self->pool, $self->how, $self->what, 0);
689 const char *__repr__() {
690 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
691 return pool_tmpjoin($self->pool, "<Job ", str, ">");
697 return (Chksum *)solv_chksum_create(type);
699 Chksum(Id type, const char *hex) {
700 unsigned char buf[64];
701 int l = solv_chksum_len(type);
704 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
706 return (Chksum *)solv_chksum_create_from_bin(type, buf);
709 solv_chksum_free($self, 0);
713 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
714 return solv_chksum_get_type(chksum);
717 void add(const char *str) {
718 solv_chksum_add($self, str, strlen((char *)str));
720 void add_fp(FILE *fp) {
723 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
724 solv_chksum_add($self, buf, l);
725 rewind(fp); /* convenience */
727 void add_fd(int fd) {
730 while ((l = read(fd, buf, sizeof(buf))) > 0)
731 solv_chksum_add($self, buf, l);
732 lseek(fd, 0, 0); /* convenience */
734 void add_stat(const char *filename) {
736 if (stat(filename, &stb))
737 memset(&stb, 0, sizeof(stb));
738 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
739 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
740 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
741 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
745 const unsigned char *b;
746 b = solv_chksum_get($self, &l);
747 return cdata_void((void *)b, l);
752 const unsigned char *b;
755 b = solv_chksum_get($self, &l);
756 ret = solv_malloc(2 * l + 1);
757 solv_bin2hex(b, l, ret);
761 bool __eq__(Chksum *chk) {
763 const unsigned char *b, *bo;
766 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
768 b = solv_chksum_get($self, &l);
769 bo = solv_chksum_get(chk, 0);
770 return memcmp(b, bo, l) == 0;
772 bool __ne__(Chksum *chk) {
773 return !Chksum___eq__($self, chk);
775 #if defined(SWIGRUBY)
776 %rename("to_s") __str__;
777 %rename("inspect") __repr__;
780 const char *__str__() {
783 if (solv_chksum_isfinished($self))
784 h = Chksum_hex($self);
785 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
786 solv_free((void *)h);
790 const char *__repr__() {
791 const char *h = Chksum___str__($self);
792 const char *str = solv_dupjoin("<Chksum ", h, ">");
793 solv_free((void *)h);
800 Pool *pool = pool_create();
805 void set_debuglevel(int level) {
806 pool_setdebuglevel($self, level);
808 #if defined(SWIGPYTHON)
810 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
811 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
812 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
813 PyObject *result = PyEval_CallObject((PyObject *)d, args);
818 return 0; /* exception */
819 ecode = SWIG_AsVal_int(result, &vresult);
821 return SWIG_IsOK(ecode) ? vresult : 0;
824 void set_loadcallback(PyObject *callable) {
825 if ($self->loadcallback == loadcallback)
826 Py_DECREF($self->loadcallbackdata);
829 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
832 #if defined(SWIGPERL)
834 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
838 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
843 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
845 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
855 void set_loadcallback(SV *callable) {
856 if ($self->loadcallback == loadcallback)
857 SvREFCNT_dec($self->loadcallbackdata);
859 SvREFCNT_inc(callable);
860 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
864 #if defined(SWIGRUBY)
866 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
867 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
868 VALUE callable = (VALUE)d;
869 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
870 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
873 SWIGINTERN void mark_Pool(void *ptr) {
875 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
876 VALUE callable = (VALUE)pool->loadcallbackdata;
877 rb_gc_mark(callable);
881 %typemap(in, numinputs=0) VALUE callable {
882 $1 = rb_block_given_p() ? rb_block_proc() : 0;
884 void set_loadcallback(VALUE callable) {
885 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
890 Pool_set_loadcallback($self, 0);
893 Id str2id(const char *str, bool create=1) {
894 return pool_str2id($self, str, create);
896 const char *id2str(Id id) {
897 return pool_id2str($self, id);
899 const char *dep2str(Id id) {
900 return pool_dep2str($self, id);
902 Id rel2id(Id name, Id evr, int flags, bool create=1) {
903 return pool_rel2id($self, name, evr, flags, create);
905 Id id2langid(Id id, const char *lang, bool create=1) {
906 return pool_id2langid($self, id, lang, create);
908 void setarch(const char *arch) {
909 pool_setarch($self, arch);
911 Repo *add_repo(const char *name) {
912 return repo_create($self, name);
914 const char *lookup_str(Id entry, Id keyname) {
915 return pool_lookup_str($self, entry, keyname);
917 Id lookup_id(Id entry, Id keyname) {
918 return pool_lookup_id($self, entry, keyname);
920 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
921 return pool_lookup_num($self, entry, keyname, notfound);
923 bool lookup_void(Id entry, Id keyname) {
924 return pool_lookup_void($self, entry, keyname);
926 %newobject lookup_checksum;
927 Chksum *lookup_checksum(Id entry, Id keyname) {
929 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
930 return solv_chksum_create_from_bin(type, b);
933 %newobject Dataiterator;
934 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
935 return new_Dataiterator($self, 0, p, key, match, flags);
937 const char *solvid2str(Id solvid) {
938 return pool_solvid2str($self, solvid);
940 void addfileprovides() {
941 pool_addfileprovides($self);
943 Queue addfileprovides_ids() {
945 Id *addedfileprovides = 0;
947 pool_addfileprovides_ids($self, $self->installed, &addedfileprovides);
948 if (addedfileprovides) {
949 for (; *addedfileprovides; addedfileprovides++)
950 queue_push(&r, *addedfileprovides);
954 void createwhatprovides() {
955 pool_createwhatprovides($self);
958 XSolvable *id2solvable(Id id) {
959 return new_XSolvable($self, id);
961 %newobject solvables;
962 Pool_solvable_iterator * const solvables;
964 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
965 return new_Pool_solvable_iterator(pool);
968 %newobject solvables_iter;
969 Pool_solvable_iterator * solvables_iter() {
970 return new_Pool_solvable_iterator($self);
973 Repo *id2repo(Id id) {
974 if (id < 1 || id > $self->nrepos)
976 return pool_id2repo($self, id);
979 Pool_repo_iterator * const repos;
981 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
982 return new_Pool_repo_iterator(pool);
985 %newobject repos_iter;
986 Pool_repo_iterator * repos_iter() {
987 return new_Pool_repo_iterator($self);
992 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
993 pool_set_installed(pool, installed);
995 Repo *Pool_installed_get(Pool *pool) {
996 return pool->installed;
1000 Queue matchprovidingids(const char *match, int flags) {
1006 for (id = 1; id < pool->ss.nstrings; id++)
1007 if (pool->whatprovides[id])
1011 if (!datamatcher_init(&ma, match, flags)) {
1012 for (id = 1; id < pool->ss.nstrings; id++)
1013 if (pool->whatprovides[id] && datamatcher_match(&ma, id2str(pool, id)))
1015 datamatcher_free(&ma);
1021 Job *Job(int how, Id what) {
1022 return new_Job($self, how, what);
1025 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1026 %newobject whatprovides;
1027 Queue whatprovides(Id dep) {
1032 FOR_PROVIDES(p, pp, dep)
1037 Id towhatprovides(Queue q) {
1038 return pool_queuetowhatprovides($self, &q);
1042 %rename("isknownarch?") isknownarch;
1044 bool isknownarch(Id id) {
1046 if (!id || id == ID_EMPTY)
1048 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1050 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1057 return solver_create($self);
1062 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1063 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1064 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1065 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1066 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1067 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1068 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1069 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS ; /* repo_solv */
1071 void free(bool reuseids = 0) {
1072 repo_free($self, reuseids);
1074 void empty(bool reuseids = 0) {
1075 repo_empty($self, reuseids);
1078 %rename("isempty?") isempty;
1081 return !$self->nsolvables;
1083 bool add_solv(const char *name, int flags = 0) {
1084 FILE *fp = fopen(name, "r");
1088 r = repo_add_solv_flags($self, fp, flags);
1092 bool add_solv(FILE *fp, int flags = 0) {
1093 return repo_add_solv_flags($self, fp, flags) == 0;
1095 bool add_products(const char *proddir, int flags = 0) {
1096 repo_add_products($self, proddir, 0, flags);
1099 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1100 repo_add_rpmmd($self, fp, language, flags);
1104 bool add_rpmdb(Repo *ref, int flags = 0) {
1105 repo_add_rpmdb($self, ref, 0, flags);
1108 Id add_rpm(const char *name, int flags = 0) {
1109 return repo_add_rpm($self, name, flags);
1112 bool add_debdb(int flags = 0) {
1113 repo_add_debdb($self, 0, flags);
1116 Id add_deb(const char *name, int flags = 0) {
1117 return repo_add_deb($self, name, flags);
1119 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1120 repo_add_susetags($self, fp, defvendor, language, flags);
1123 bool add_repomdxml(FILE *fp, int flags = 0) {
1124 repo_add_repomdxml($self, fp, flags);
1127 bool add_content(FILE *fp, int flags = 0) {
1128 repo_add_content($self, fp, flags);
1131 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1132 repo_add_updateinfoxml($self, fp, flags);
1135 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1136 repo_add_deltainfoxml($self, fp, flags);
1139 void internalize() {
1140 repo_internalize($self);
1142 const char *lookup_str(Id entry, Id keyname) {
1143 return repo_lookup_str($self, entry, keyname);
1145 Id lookup_id(Id entry, Id keyname) {
1146 return repo_lookup_id($self, entry, keyname);
1148 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
1149 return repo_lookup_num($self, entry, keyname, notfound);
1151 void write(FILE *fp) {
1152 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
1154 # HACK, remove if no longer needed!
1155 bool write_first_repodata(FILE *fp) {
1156 int oldnrepodata = $self->nrepodata;
1157 $self->nrepodata = 1;
1158 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
1159 $self->nrepodata = oldnrepodata;
1163 %newobject Dataiterator;
1164 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1165 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1170 SWIGINTERN Id Repo_id_get(Repo *repo) {
1171 return repo->repoid;
1174 Repo_solvable_iterator * const solvables;
1176 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1177 return new_Repo_solvable_iterator(repo);
1180 %newobject solvables_iter;
1181 Repo_solvable_iterator *solvables_iter() {
1182 return new_Repo_solvable_iterator($self);
1185 XRepodata *add_repodata(int flags = 0) {
1186 Repodata *rd = repo_add_repodata($self, flags);
1187 return new_XRepodata($self, rd - $self->repodata);
1190 void create_stubs() {
1192 if (!$self->nrepodata)
1194 data = $self->repodata + ($self->nrepodata - 1);
1195 if (data->state != REPODATA_STUB)
1196 repodata_create_stubs(data);
1199 %rename("iscontiguous?") iscontiguous;
1201 bool iscontiguous() {
1203 for (i = $self->start; i < $self->end; i++)
1204 if ($self->pool->solvables[i].repo != $self)
1208 XRepodata *first_repodata() {
1210 if (!$self->nrepodata)
1212 /* make sure all repodatas but the first are extensions */
1213 if ($self->repodata[0].loadcallback)
1215 for (i = 1; i < $self->nrepodata; i++)
1216 if (!$self->repodata[i].loadcallback)
1217 return 0; /* oops, not an extension */
1218 return new_XRepodata($self, 0);
1221 bool __eq__(Repo *repo) {
1222 return $self == repo;
1224 bool __ne__(Repo *repo) {
1225 return $self != repo;
1228 const char *__str__() {
1231 return strdup($self->name);
1232 sprintf(buf, "Repo#%d", $self->repoid);
1235 %newobject __repr__;
1236 const char *__repr__() {
1240 sprintf(buf, "<Repo #%d ", $self->repoid);
1241 return solv_dupjoin(buf, $self->name, ">");
1243 sprintf(buf, "<Repo #%d>", $self->repoid);
1248 %extend Dataiterator {
1249 static const int SEARCH_STRING = SEARCH_STRING;
1250 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1251 static const int SEARCH_GLOB = SEARCH_GLOB;
1252 static const int SEARCH_REGEX = SEARCH_REGEX;
1253 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1254 static const int SEARCH_FILES = SEARCH_FILES;
1255 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1257 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1258 Dataiterator *di = solv_calloc(1, sizeof(*di));
1259 dataiterator_init(di, pool, repo, p, key, match, flags);
1263 dataiterator_free($self);
1266 #if defined(SWIGPYTHON)
1267 %newobject __iter__;
1268 Dataiterator *__iter__() {
1270 ndi = solv_calloc(1, sizeof(*ndi));
1271 dataiterator_init_clone(ndi, $self);
1274 %rename("next") __next__();
1275 %exception __next__ {
1278 PyErr_SetString(PyExc_StopIteration,"no more matches");
1285 perliter(solv::Dataiterator)
1288 %newobject __next__;
1289 Datamatch *__next__() {
1291 if (!dataiterator_step($self)) {
1294 ndi = solv_calloc(1, sizeof(*ndi));
1295 dataiterator_init_clone(ndi, $self);
1301 while ((d = Dataiterator___next__($self)) != 0) {
1302 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1306 void prepend_keyname(Id key) {
1307 dataiterator_prepend_keyname($self, key);
1309 void skip_solvable() {
1310 dataiterator_skip_solvable($self);
1316 dataiterator_free($self);
1319 %newobject solvable;
1320 XSolvable * const solvable;
1322 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1323 return new_XSolvable(di->pool, di->solvid);
1327 return $self->key->name;
1329 const char *key_idstr() {
1330 return id2str($self->pool, $self->key->name);
1333 return $self->key->type;
1335 const char *type_idstr() {
1336 return id2str($self->pool, $self->key->type);
1339 return $self->kv.id;
1341 const char *idstr() {
1342 return id2str($self->pool, $self->kv.id);
1345 return $self->kv.str;
1348 return $self->kv.num;
1351 return $self->kv.num2;
1354 dataiterator_setpos($self);
1356 void setpos_parent() {
1357 dataiterator_setpos_parent($self);
1361 %extend Pool_solvable_iterator {
1362 Pool_solvable_iterator(Pool *pool) {
1363 Pool_solvable_iterator *s;
1364 s = solv_calloc(1, sizeof(*s));
1368 #if defined(SWIGPYTHON)
1369 %newobject __iter__;
1370 Pool_solvable_iterator *__iter__() {
1371 Pool_solvable_iterator *s;
1372 s = solv_calloc(1, sizeof(*s));
1376 %rename("next") __next__();
1377 %exception __next__ {
1380 PyErr_SetString(PyExc_StopIteration,"no more matches");
1387 perliter(solv::Pool_solvable_iterator)
1389 %newobject __next__;
1390 XSolvable *__next__() {
1391 Pool *pool = $self->pool;
1393 if ($self->id >= pool->nsolvables)
1395 while (++$self->id < pool->nsolvables)
1396 if (pool->solvables[$self->id].repo)
1397 return new_XSolvable(pool, $self->id);
1403 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1404 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1408 %newobject __getitem__;
1409 XSolvable *__getitem__(Id key) {
1410 Pool *pool = $self->pool;
1411 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1412 return new_XSolvable(pool, key);
1416 return $self->pool->nsolvables;
1420 %extend Pool_repo_iterator {
1421 Pool_repo_iterator(Pool *pool) {
1422 Pool_repo_iterator *s;
1423 s = solv_calloc(1, sizeof(*s));
1427 #if defined(SWIGPYTHON)
1428 %newobject __iter__;
1429 Pool_repo_iterator *__iter__() {
1430 Pool_repo_iterator *s;
1431 s = solv_calloc(1, sizeof(*s));
1435 %rename("next") __next__();
1436 %exception __next__ {
1439 PyErr_SetString(PyExc_StopIteration,"no more matches");
1444 %newobject __next__;
1446 Pool *pool = $self->pool;
1447 if ($self->id >= pool->nrepos + 1)
1449 while (++$self->id < pool->nrepos + 1) {
1450 Repo *r = pool_id2repo(pool, $self->id);
1459 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1460 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p__Repo, SWIG_POINTER_OWN | 0));
1464 Repo *__getitem__(Id key) {
1465 Pool *pool = $self->pool;
1466 if (key > 0 && key < pool->nrepos + 1)
1467 return pool_id2repo(pool, key);
1471 return $self->pool->nrepos + 1;
1475 %extend Repo_solvable_iterator {
1476 Repo_solvable_iterator(Repo *repo) {
1477 Repo_solvable_iterator *s;
1478 s = solv_calloc(1, sizeof(*s));
1482 #if defined(SWIGPYTHON)
1483 %newobject __iter__;
1484 Repo_solvable_iterator *__iter__() {
1485 Repo_solvable_iterator *s;
1486 s = solv_calloc(1, sizeof(*s));
1490 %rename("next") __next__();
1491 %exception __next__ {
1494 PyErr_SetString(PyExc_StopIteration,"no more matches");
1499 %newobject __next__;
1500 XSolvable *__next__() {
1501 Repo *repo = $self->repo;
1502 Pool *pool = repo->pool;
1504 if (repo->start > 0 && $self->id < repo->start)
1505 $self->id = repo->start - 1;
1506 if ($self->id >= repo->end)
1508 while (++$self->id < repo->end)
1509 if (pool->solvables[$self->id].repo == repo)
1510 return new_XSolvable(pool, $self->id);
1516 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1517 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1521 %newobject __getitem__;
1522 XSolvable *__getitem__(Id key) {
1523 Repo *repo = $self->repo;
1524 Pool *pool = repo->pool;
1525 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1526 return new_XSolvable(pool, key);
1530 return $self->repo->pool->nsolvables;
1535 Dep(Pool *pool, Id id) {
1539 s = solv_calloc(1, sizeof(*s));
1545 return pool_dep2str($self->pool, $self->id);
1547 bool __eq__(Dep *s) {
1548 return $self->pool == s->pool && $self->id == s->id;
1550 bool __ne__(Dep *s) {
1551 return !Dep___eq__($self, s);
1553 const char *__str__() {
1554 return pool_dep2str($self->pool, $self->id);
1556 %newobject __repr__;
1557 const char *__repr__() {
1559 sprintf(buf, "<Id #%d ", $self->id);
1560 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
1565 XSolvable(Pool *pool, Id id) {
1567 if (!id || id >= pool->nsolvables)
1569 s = solv_calloc(1, sizeof(*s));
1575 return pool_solvid2str($self->pool, $self->id);
1577 const char *lookup_str(Id keyname) {
1578 return pool_lookup_str($self->pool, $self->id, keyname);
1580 Id lookup_id(Id keyname) {
1581 return pool_lookup_id($self->pool, $self->id, keyname);
1583 unsigned int lookup_num(Id keyname, unsigned int notfound = 0) {
1584 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
1586 bool lookup_void(Id keyname) {
1587 return pool_lookup_void($self->pool, $self->id, keyname);
1589 %newobject lookup_checksum;
1590 Chksum *lookup_checksum(Id keyname) {
1592 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
1593 return solv_chksum_create_from_bin(type, b);
1595 const char *lookup_location(int *OUTPUT) {
1596 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
1599 %rename("installable?") installable;
1601 bool installable() {
1602 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
1605 %rename("isinstalled?") isinstalled;
1607 bool isinstalled() {
1608 Pool *pool = $self->pool;
1609 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
1612 const char * const name;
1614 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
1615 Pool *pool = xs->pool;
1616 return id2str(pool, pool->solvables[xs->id].name);
1621 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
1622 return xs->pool->solvables[xs->id].name;
1625 const char * const evr;
1627 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
1628 Pool *pool = xs->pool;
1629 return id2str(pool, pool->solvables[xs->id].evr);
1634 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
1635 return xs->pool->solvables[xs->id].evr;
1638 const char * const arch;
1640 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
1641 Pool *pool = xs->pool;
1642 return id2str(pool, pool->solvables[xs->id].arch);
1647 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
1648 return xs->pool->solvables[xs->id].arch;
1651 const char * const vendor;
1653 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
1654 Pool *pool = xs->pool;
1655 return id2str(pool, pool->solvables[xs->id].vendor);
1660 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
1661 return xs->pool->solvables[xs->id].vendor;
1666 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
1667 return xs->pool->solvables[xs->id].repo;
1671 bool __eq__(XSolvable *s) {
1672 return $self->pool == s->pool && $self->id == s->id;
1674 bool __ne__(XSolvable *s) {
1675 return !XSolvable___eq__($self, s);
1677 const char *__str__() {
1678 return pool_solvid2str($self->pool, $self->id);
1680 %newobject __repr__;
1681 const char *__repr__() {
1683 sprintf(buf, "<Solvable #%d ", $self->id);
1684 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
1689 Problem(Solver *solv, Id id) {
1691 p = solv_calloc(1, sizeof(*p));
1696 %newobject findproblemrule;
1697 XRule *findproblemrule() {
1698 Id r = solver_findproblemrule($self->solv, $self->id);
1699 return new_XRule($self->solv, r);
1701 %newobject findallproblemrules;
1702 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
1703 Queue findallproblemrules(int unfiltered=0) {
1704 Solver *solv = $self->solv;
1709 solver_findallproblemrules(solv, $self->id, &q);
1712 for (i = j = 0; i < q.count; i++)
1714 probr = q.elements[i];
1715 if ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end))
1717 q.elements[j++] = probr;
1720 queue_truncate(&q, j);
1724 int solution_count() {
1725 return solver_solution_count($self->solv, $self->id);
1727 %newobject solutions;
1728 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
1733 cnt = solver_solution_count($self->solv, $self->id);
1734 for (i = 1; i <= cnt; i++)
1741 Solution(Problem *p, Id id) {
1743 s = solv_calloc(1, sizeof(*s));
1745 s->problemid = p->id;
1749 int element_count() {
1750 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1753 %newobject elements;
1754 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
1755 Queue elements(bool expandreplaces=0) {
1759 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1760 for (i = 1; i <= cnt; i++)
1763 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
1765 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
1771 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
1772 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
1774 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
1775 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
1776 queue_push2(&q, p, rp);
1778 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
1779 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
1780 queue_push2(&q, p, rp);
1782 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
1783 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
1784 queue_push2(&q, p, rp);
1789 queue_push2(&q, i, type);
1790 queue_push2(&q, p, rp);
1796 %extend Solutionelement {
1797 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
1799 e = solv_calloc(1, sizeof(*e));
1801 e->problemid = problemid;
1812 if (p == SOLVER_SOLUTION_ERASE)
1817 else if (p == SOLVER_SOLUTION_REPLACE)
1822 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
1823 return pool_tmpjoin($self->solv->pool, "allow ", policy_illegal2str($self->solv, POLICY_ILLEGAL_DOWNGRADE, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp), 0);
1824 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
1825 return pool_tmpjoin($self->solv->pool, "allow ", policy_illegal2str($self->solv, POLICY_ILLEGAL_ARCHCHANGE, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp), 0);
1826 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
1827 return pool_tmpjoin($self->solv->pool, "allow ", policy_illegal2str($self->solv, POLICY_ILLEGAL_VENDORCHANGE, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp), 0);
1828 return solver_solutionelement2str($self->solv, p, rp);
1830 %newobject replaceelements;
1831 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
1832 Queue replaceelements() {
1837 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
1840 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
1841 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1842 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
1843 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1844 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
1845 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1846 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
1848 queue_push(&q, $self->type);
1851 int illegalreplace() {
1852 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
1854 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
1856 %newobject solvable;
1857 XSolvable * const solvable;
1858 %newobject replacement;
1859 XSolvable * const replacement;
1862 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
1863 return new_XSolvable(e->solv->pool, e->p);
1865 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
1866 return new_XSolvable(e->solv->pool, e->rp);
1868 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
1869 return (e->p - 1) / 2;
1874 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE)
1875 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE, $self->p);
1876 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
1877 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE, $self->rp);
1878 if ($self->type == SOLVER_SOLUTION_ERASE)
1879 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE, $self->p);
1885 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
1886 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
1887 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
1888 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
1889 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
1890 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
1891 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
1892 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
1893 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
1894 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
1895 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
1896 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
1897 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
1898 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
1899 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
1900 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
1901 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
1902 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
1903 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
1905 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
1906 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
1907 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
1908 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
1909 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
1910 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
1911 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
1912 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
1914 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
1915 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
1916 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
1921 #if defined(SWIGPYTHON)
1923 def solve(self, jobs):
1925 for job in jobs: j += [job.how, job.what]
1926 return self.solve_helper(j)
1929 #if defined(SWIGPERL)
1931 sub solv::Solver::solve {
1932 my ($self, $jobs) = @_;
1933 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
1934 return $self->solve_helper(\@j);
1938 #if defined(SWIGRUBY)
1941 "class Solv::Solver\n"
1942 " def solve(jobs)\n"
1944 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
1945 " solve_helper(jl)\n"
1951 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
1952 %newobject solve_helper;
1953 Queue solve_helper(Queue jobs) {
1957 solver_solve($self, &jobs);
1958 cnt = solver_problem_count($self);
1959 for (i = 1; i <= cnt; i++)
1963 %newobject transaction;
1964 Transaction *transaction() {
1965 return solver_create_transaction($self);
1969 %extend Transaction {
1970 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
1971 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
1972 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
1973 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
1974 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
1975 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
1976 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
1977 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
1978 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
1979 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
1980 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
1981 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
1982 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
1983 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
1984 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
1985 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
1986 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
1987 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
1988 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
1989 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
1990 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
1991 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
1992 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
1993 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
1994 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
1995 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
1996 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
1998 transaction_free($self);
2001 %rename("isempty?") isempty;
2004 return $self->steps.count == 0;
2007 %newobject othersolvable;
2008 XSolvable *othersolvable(XSolvable *s) {
2009 Id op = transaction_obs_pkg($self, s->id);
2010 return new_XSolvable($self->pool, op);
2013 %newobject allothersolvables;
2014 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2015 Queue allothersolvables(XSolvable *s) {
2018 transaction_all_obs_pkgs($self, s->id, &q);
2022 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2023 %newobject classify;
2024 Queue classify(int mode = 0) {
2027 transaction_classify($self, mode, &q);
2031 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2032 %newobject newpackages;
2033 Queue newpackages() {
2037 cut = transaction_installedresult(self, &q);
2038 queue_truncate(&q, cut);
2042 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2043 %newobject keptpackages;
2044 Queue keptpackages() {
2048 cut = transaction_installedresult(self, &q);
2050 queue_deleten(&q, 0, cut);
2054 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2058 queue_init_clone(&q, &$self->steps);
2062 int steptype(XSolvable *s, int mode) {
2063 return transaction_type($self, s->id, mode);
2065 int calc_installsizechange() {
2066 return transaction_calc_installsizechange($self);
2068 void order(int flags) {
2069 transaction_order($self, flags);
2073 %extend TransactionClass {
2074 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2075 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2076 cl->transaction = trans;
2080 cl->fromid = fromid;
2084 %newobject solvables;
2085 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2089 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2095 XRule(Solver *solv, Id id) {
2098 XRule *xr = solv_calloc(1, sizeof(*xr));
2104 Id type, source, target, dep;
2105 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2106 return new_Ruleinfo($self, type, source, target, dep);
2108 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2109 %newobject allinfos;
2113 solver_allruleinfos($self->solv, $self->id, &q);
2117 bool __eq__(XRule *xr) {
2118 return $self->solv == xr->solv && $self->id == xr->id;
2120 bool __ne__(XRule *xr) {
2121 return !XRule___eq__($self, xr);
2123 %newobject __repr__;
2124 const char *__repr__() {
2126 sprintf(buf, "<Rule #%d>", $self->id);
2132 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2133 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2137 ri->source = source;
2138 ri->target = target;
2142 XSolvable * const solvable;
2143 XSolvable * const othersolvable;
2145 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2146 return new_XSolvable(ri->solv->pool, ri->source);
2148 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2149 return new_XSolvable(ri->solv->pool, ri->target);
2152 const char *problemstr() {
2153 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2158 XRepodata(Repo *repo, Id id) {
2159 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2165 return repodata_new_handle($self->repo->repodata + $self->id);
2167 void set_id(Id solvid, Id keyname, Id id) {
2168 repodata_set_id($self->repo->repodata + $self->id, solvid, keyname, id);
2170 void set_str(Id solvid, Id keyname, const char *str) {
2171 repodata_set_str($self->repo->repodata + $self->id, solvid, keyname, str);
2173 void set_poolstr(Id solvid, Id keyname, const char *str) {
2174 repodata_set_poolstr($self->repo->repodata + $self->id, solvid, keyname, str);
2176 void add_idarray(Id solvid, Id keyname, Id id) {
2177 repodata_add_idarray($self->repo->repodata + $self->id, solvid, keyname, id);
2179 void add_flexarray(Id solvid, Id keyname, Id handle) {
2180 repodata_add_flexarray($self->repo->repodata + $self->id, solvid, keyname, handle);
2182 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2183 const unsigned char *buf = solv_chksum_get(chksum, 0);
2185 repodata_set_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, solv_chksum_get_type(chksum), buf);
2187 const char *lookup_str(Id solvid, Id keyname) {
2188 return repodata_lookup_str($self->repo->repodata + $self->id, solvid, keyname);
2190 Queue lookup_idarray(Id solvid, Id keyname) {
2193 repodata_lookup_idarray($self->repo->repodata + $self->id, solvid, keyname, &r);
2196 %newobject lookup_checksum;
2197 Chksum *lookup_checksum(Id solvid, Id keyname) {
2199 const unsigned char *b = repodata_lookup_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, &type);
2200 return solv_chksum_create_from_bin(type, b);
2202 void internalize() {
2203 repodata_internalize($self->repo->repodata + $self->id);
2205 void create_stubs() {
2206 repodata_create_stubs($self->repo->repodata + $self->id);
2208 void write(FILE *fp) {
2209 repodata_write($self->repo->repodata + $self->id, fp, repo_write_stdkeyfilter, 0);
2211 bool add_solv(FILE *fp, int flags = 0) {
2212 Repodata *data = $self->repo->repodata + $self->id;
2213 int r, oldstate = data->state;
2214 data->state = REPODATA_LOADING;
2215 r = repo_add_solv_flags(data->repo, fp, flags | REPO_USE_LOADING);
2216 if (r || data->state == REPODATA_LOADING)
2217 data->state = oldstate;
2220 void extend_to_repo() {
2221 Repodata *data = $self->repo->repodata + $self->id;
2222 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2224 bool __eq__(XRepodata *xr) {
2225 return $self->repo == xr->repo && $self->id == xr->id;
2227 bool __ne__(XRepodata *xr) {
2228 return !XRepodata___eq__($self, xr);
2230 %newobject __repr__;
2231 const char *__repr__() {
2233 sprintf(buf, "<Repodata #%d>", $self->id);