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);
154 SWIG_Error(SWIG_RuntimeError, "list must contain only integers");
160 %typemap(out) Queue {
162 VALUE o = rb_ary_new2($1.count);
163 for (i = 0; i < $1.count; i++)
164 rb_ary_store(o, i, SWIG_From_int($1.elements[i]));
168 %typemap(arginit) Queue {
171 %typemap(freearg) Queue {
174 %define Queue2Array(type, step, con) %{
176 int cnt = $1.count / step;
177 Id *idp = $1.elements;
178 VALUE o = rb_ary_new2(cnt);
179 for (i = 0; i < cnt; i++, idp += step)
182 #define result resultx
185 rb_ary_store(o, i, $result);
197 #if defined(SWIGPERL)
199 # work around a swig bug
203 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv,pPerl)
205 # ifndef MULTIPLICITY
206 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv)
208 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(PERL_GET_THX, cv)
214 %define perliter(class)
217 my $i = ${##class##::ITERATORS}{$_[0]};
219 $_[1] == $i->[0] - 1 ? $i->[1] : undef;
221 $_[0]->__getitem__($_[1]);
224 sub class##::FETCHSIZE {
225 my $i = ${##class##::ITERATORS}{$_[0]};
227 ($i->[1] = $_[0]->__next__()) ? ++$i->[0] : 0;
237 #define SWIG_PERL_ITERATOR 0x80
239 SWIGRUNTIMEINLINE SV *
240 SWIG_Perl_NewArrayObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
241 SV *result = sv_newmortal();
242 if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
247 sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
248 stash=SvSTASH(SvRV(obj));
249 if (flags & SWIG_POINTER_OWN) {
251 GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
253 gv_init(gv, stash, "OWNER", 5, FALSE);
255 hv_store_ent(hv, obj, newSViv(1), 0);
257 if (flags & SWIG_PERL_ITERATOR) {
259 GV *gv=*(GV**)hv_fetch(stash, "ITERATORS", 9, TRUE);
262 gv_init(gv, stash, "ITERATORS", 9, FALSE);
264 hv_store_ent(hv, obj, newRV_inc((SV *)av), 0);
266 sv_magic((SV *)array, (SV *)obj, 'P', Nullch, 0);
268 self=newRV_noinc((SV *)array);
269 sv_setsv(result, self);
270 SvREFCNT_dec((SV *)self);
271 sv_bless(result, stash);
273 sv_setref_pv(result, (char *) SWIG_Perl_TypeProxyName(t), ptr);
280 %typemap(out) Perlarray {
281 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow); argvi++;
283 %typemap(out) Perliterator {
284 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow | SWIG_PERL_ITERATOR); argvi++;
287 %typemap(out) Pool_solvable_iterator * = Perlarray;
288 %typemap(out) Pool_solvable_iterator * solvables_iter = Perliterator;
289 %typemap(out) Pool_repo_iterator * = Perlarray;
290 %typemap(out) Pool_repo_iterator * repos_iter = Perliterator;
291 %typemap(out) Repo_solvable_iterator * = Perlarray;
292 %typemap(out) Repo_solvable_iterator * solvables_iter = Perliterator;
293 %typemap(out) Dataiterator * = Perliterator;
299 #if defined(SWIGPYTHON)
300 typedef PyObject *AppObjectPtr;
301 %typemap(out) AppObjectPtr {
306 #if defined(SWIGPERL)
307 typedef SV *AppObjectPtr;
308 %typemap(in) AppObjectPtr {
309 $1 = SvROK($input) ? SvRV($input) : 0;
311 %typemap(out) AppObjectPtr {
312 $result = $1 ? newRV_inc($1) : newSV(0);
316 #if defined(SWIGRUBY)
317 typedef VALUE AppObjectPtr;
318 %typemap(in) AppObjectPtr {
321 %typemap(out) AppObjectPtr {
331 %include "typemaps.i"
335 #include <sys/stat.h>
336 #include <sys/types.h>
340 #include "poolarch.h"
343 #include "solverdebug.h"
344 #include "repo_solv.h"
348 #include "repo_rpmdb.h"
350 #include "repo_deb.h"
351 #include "repo_rpmmd.h"
352 #include "repo_write.h"
353 #include "repo_products.h"
354 #include "repo_susetags.h"
355 #include "repo_updateinfoxml.h"
356 #include "repo_deltainfoxml.h"
357 #include "repo_repomdxml.h"
358 #include "repo_content.h"
359 #include "solv_xfopen.h"
364 #define SOLVER_SOLUTION_ERASE -100
365 #define SOLVER_SOLUTION_REPLACE -101
366 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
367 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
368 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
370 typedef struct chksum Chksum;
372 typedef void *AppObjectPtr;
397 } Pool_solvable_iterator;
402 } Pool_repo_iterator;
407 } Repo_solvable_iterator;
447 Transaction *transaction;
455 typedef Dataiterator Datamatch;
460 %mixin Dataiterator "Enumerable";
461 %mixin Pool_solvable_iterator "Enumerable";
462 %mixin Pool_repo_iterator "Enumerable";
463 %mixin Repo_solvable_iterator "Enumerable";
471 %constant Id SOLVID_META;
472 %constant Id SOLVID_POS;
474 %constant int REL_EQ;
475 %constant int REL_GT;
476 %constant int REL_LT;
477 %constant int REL_ARCH;
505 # put before pool/repo so we can access the constructor
506 %nodefaultdtor Dataiterator;
507 typedef struct {} Dataiterator;
508 typedef struct {} Pool_solvable_iterator;
509 typedef struct {} Pool_repo_iterator;
510 typedef struct {} Repo_solvable_iterator;
512 %nodefaultctor Datamatch;
513 %nodefaultdtor Datamatch;
520 %nodefaultctor Datapos;
534 AppObjectPtr appdata;
539 typedef struct _Repo {
541 const char * const name;
544 int const nsolvables;
545 AppObjectPtr appdata;
548 %nodefaultctor Solver;
549 %nodefaultdtor Solver;
554 typedef struct chksum {
557 %rename(xfopen) solv_xfopen;
558 %rename(xfopen_fd) solv_xfopen_fd;
559 %rename(xfopen_dup) solv_xfopen_dup;
560 %rename(xfclose) solv_xfclose;
561 %rename(xfileno) solv_xfileno;
563 FILE *solv_xfopen(const char *fn, const char *mode = 0);
564 FILE *solv_xfopen_fd(const char *fn, int fd, const char *mode = 0);
565 FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode = 0);
566 int solv_xfclose(FILE *fp);
567 int solv_xfileno(FILE *fp);
570 SWIGINTERN int solv_xfclose(FILE *fp) {
573 SWIGINTERN int solv_xfileno(FILE *fp) {
576 SWIGINTERN FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode) {
578 return fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
601 %nodefaultctor Transaction;
602 %nodefaultdtor Transaction;
608 Transaction * const transaction;
617 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
618 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
619 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
620 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
621 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
622 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
623 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
624 static const Id SOLVER_NOOP = SOLVER_NOOP;
625 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
626 static const Id SOLVER_ERASE = SOLVER_ERASE;
627 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
628 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
629 static const Id SOLVER_NOOBSOLETES = SOLVER_NOOBSOLETES;
630 static const Id SOLVER_LOCK = SOLVER_LOCK;
631 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
632 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
633 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
634 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
635 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
636 static const Id SOLVER_WEAK = SOLVER_WEAK;
637 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
638 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
639 static const Id SOLVER_SETEV = SOLVER_SETEV;
640 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
641 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
642 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
643 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
644 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
645 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
647 Job(Pool *pool, int how, Id what) {
648 Job *job = solv_calloc(1, sizeof(*job));
655 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
656 %newobject solvables;
658 Pool *pool = $self->pool;
662 how = $self->how & SOLVER_SELECTMASK;
663 FOR_JOB_SELECT(p, pp, how, $self->what)
668 bool __eq__(Job *j) {
669 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
671 bool __ne__(Job *j) {
672 return !Job___eq__($self, j);
674 #if defined(SWIGPERL)
675 %rename("str") __str__;
677 const char *__str__() {
678 return pool_job2str($self->pool, $self->how, $self->what, 0);
680 const char *__repr__() {
681 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
682 return pool_tmpjoin($self->pool, "<Job ", str, ">");
688 return (Chksum *)solv_chksum_create(type);
690 Chksum(Id type, const char *hex) {
691 unsigned char buf[64];
692 int l = solv_chksum_len(type);
695 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
697 return (Chksum *)solv_chksum_create_from_bin(type, buf);
700 solv_chksum_free($self, 0);
704 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
705 return solv_chksum_get_type(chksum);
708 void add(const char *str) {
709 solv_chksum_add($self, str, strlen((char *)str));
711 void add_fp(FILE *fp) {
714 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
715 solv_chksum_add($self, buf, l);
716 rewind(fp); /* convenience */
718 void add_fd(int fd) {
721 while ((l = read(fd, buf, sizeof(buf))) > 0)
722 solv_chksum_add($self, buf, l);
723 lseek(fd, 0, 0); /* convenience */
725 void add_stat(const char *filename) {
727 if (stat(filename, &stb))
728 memset(&stb, 0, sizeof(stb));
729 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
730 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
731 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
732 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
736 const unsigned char *b;
737 b = solv_chksum_get($self, &l);
738 return cdata_void((void *)b, l);
743 const unsigned char *b;
746 b = solv_chksum_get($self, &l);
747 ret = solv_malloc(2 * l + 1);
748 solv_bin2hex(b, l, ret);
752 bool __eq__(Chksum *chk) {
754 const unsigned char *b, *bo;
757 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
759 b = solv_chksum_get($self, &l);
760 bo = solv_chksum_get(chk, 0);
761 return memcmp(b, bo, l) == 0;
763 bool __ne__(Chksum *chk) {
764 return !Chksum___eq__($self, chk);
766 #if defined(SWIGRUBY)
767 %rename("to_s") __str__;
768 %rename("inspect") __repr__;
770 #if defined(SWIGPERL)
771 %rename("str") __str__;
774 const char *__str__() {
777 if (solv_chksum_isfinished($self))
778 h = Chksum_hex($self);
779 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
780 solv_free((void *)h);
784 const char *__repr__() {
785 const char *h = Chksum___str__($self);
786 const char *str = solv_dupjoin("<Chksum ", h, ">");
787 solv_free((void *)h);
794 Pool *pool = pool_create();
799 void set_debuglevel(int level) {
800 pool_setdebuglevel($self, level);
802 #if defined(SWIGPYTHON)
804 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
805 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
806 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
807 PyObject *result = PyEval_CallObject((PyObject *)d, args);
812 return 0; /* exception */
813 ecode = SWIG_AsVal_int(result, &vresult);
815 return SWIG_IsOK(ecode) ? vresult : 0;
818 void set_loadcallback(PyObject *callable) {
819 if ($self->loadcallback == loadcallback) {
820 Py_DECREF($self->loadcallbackdata);
825 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
828 #if defined(SWIGPERL)
830 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
834 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
839 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
841 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
851 void set_loadcallback(SV *callable) {
852 if ($self->loadcallback == loadcallback)
853 SvREFCNT_dec($self->loadcallbackdata);
855 SvREFCNT_inc(callable);
856 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
860 #if defined(SWIGRUBY)
862 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
863 XRepodata *xd = new_XRepodata(data->repo, data - data->repo->repodata);
864 VALUE callable = (VALUE)d;
865 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
866 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
869 SWIGINTERN void mark_Pool(void *ptr) {
871 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
872 VALUE callable = (VALUE)pool->loadcallbackdata;
873 rb_gc_mark(callable);
877 %typemap(in, numinputs=0) VALUE callable {
878 $1 = rb_block_given_p() ? rb_block_proc() : 0;
880 void set_loadcallback(VALUE callable) {
881 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
886 Pool_set_loadcallback($self, 0);
889 Id str2id(const char *str, bool create=1) {
890 return pool_str2id($self, str, create);
892 Dep *Dep(const char *str, bool create=1) {
893 Id id = pool_str2id($self, str, create);
894 return new_Dep($self, id);
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, pool_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;
1097 return repo_add_solvable($self);
1100 bool add_products(const char *proddir, int flags = 0) {
1101 repo_add_products($self, proddir, 0, flags);
1104 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1105 repo_add_rpmmd($self, fp, language, flags);
1109 bool add_rpmdb(Repo *ref, int flags = 0) {
1110 repo_add_rpmdb($self, ref, 0, flags);
1113 Id add_rpm(const char *name, int flags = 0) {
1114 return repo_add_rpm($self, name, flags);
1117 bool add_debdb(int flags = 0) {
1118 repo_add_debdb($self, 0, flags);
1121 Id add_deb(const char *name, int flags = 0) {
1122 return repo_add_deb($self, name, flags);
1124 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1125 repo_add_susetags($self, fp, defvendor, language, flags);
1128 bool add_repomdxml(FILE *fp, int flags = 0) {
1129 repo_add_repomdxml($self, fp, flags);
1132 bool add_content(FILE *fp, int flags = 0) {
1133 repo_add_content($self, fp, flags);
1136 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1137 repo_add_updateinfoxml($self, fp, flags);
1140 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1141 repo_add_deltainfoxml($self, fp, flags);
1144 void internalize() {
1145 repo_internalize($self);
1147 const char *lookup_str(Id entry, Id keyname) {
1148 return repo_lookup_str($self, entry, keyname);
1150 Id lookup_id(Id entry, Id keyname) {
1151 return repo_lookup_id($self, entry, keyname);
1153 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
1154 return repo_lookup_num($self, entry, keyname, notfound);
1156 void write(FILE *fp) {
1157 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
1159 # HACK, remove if no longer needed!
1160 bool write_first_repodata(FILE *fp) {
1161 int oldnrepodata = $self->nrepodata;
1162 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1163 repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
1164 $self->nrepodata = oldnrepodata;
1168 %newobject Dataiterator;
1169 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1170 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1175 SWIGINTERN Id Repo_id_get(Repo *repo) {
1176 return repo->repoid;
1179 Repo_solvable_iterator * const solvables;
1181 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1182 return new_Repo_solvable_iterator(repo);
1185 %newobject solvables_iter;
1186 Repo_solvable_iterator *solvables_iter() {
1187 return new_Repo_solvable_iterator($self);
1190 XRepodata *add_repodata(int flags = 0) {
1191 Repodata *rd = repo_add_repodata($self, flags);
1192 return new_XRepodata($self, rd - $self->repodata);
1195 void create_stubs() {
1197 if (!$self->nrepodata)
1199 data = $self->repodata + ($self->nrepodata - 1);
1200 if (data->state != REPODATA_STUB)
1201 repodata_create_stubs(data);
1204 %rename("iscontiguous?") iscontiguous;
1206 bool iscontiguous() {
1208 for (i = $self->start; i < $self->end; i++)
1209 if ($self->pool->solvables[i].repo != $self)
1213 XRepodata *first_repodata() {
1215 if ($self->nrepodata < 2)
1217 /* make sure all repodatas but the first are extensions */
1218 if ($self->repodata[1].loadcallback)
1220 for (i = 2; i < $self->nrepodata; i++)
1221 if (!$self->repodata[i].loadcallback)
1222 return 0; /* oops, not an extension */
1223 return new_XRepodata($self, 1);
1226 bool __eq__(Repo *repo) {
1227 return $self == repo;
1229 bool __ne__(Repo *repo) {
1230 return $self != repo;
1232 #if defined(SWIGPERL)
1233 %rename("str") __str__;
1236 const char *__str__() {
1239 return solv_strdup($self->name);
1240 sprintf(buf, "Repo#%d", $self->repoid);
1241 return solv_strdup(buf);
1243 %newobject __repr__;
1244 const char *__repr__() {
1248 sprintf(buf, "<Repo #%d ", $self->repoid);
1249 return solv_dupjoin(buf, $self->name, ">");
1251 sprintf(buf, "<Repo #%d>", $self->repoid);
1252 return solv_strdup(buf);
1256 %extend Dataiterator {
1257 static const int SEARCH_STRING = SEARCH_STRING;
1258 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1259 static const int SEARCH_GLOB = SEARCH_GLOB;
1260 static const int SEARCH_REGEX = SEARCH_REGEX;
1261 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1262 static const int SEARCH_FILES = SEARCH_FILES;
1263 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1265 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1266 Dataiterator *di = solv_calloc(1, sizeof(*di));
1267 dataiterator_init(di, pool, repo, p, key, match, flags);
1271 dataiterator_free($self);
1274 #if defined(SWIGPYTHON)
1275 %newobject __iter__;
1276 Dataiterator *__iter__() {
1278 ndi = solv_calloc(1, sizeof(*ndi));
1279 dataiterator_init_clone(ndi, $self);
1282 %rename("next") __next__();
1283 %exception __next__ {
1286 PyErr_SetString(PyExc_StopIteration,"no more matches");
1293 perliter(solv::Dataiterator)
1296 %newobject __next__;
1297 Datamatch *__next__() {
1299 if (!dataiterator_step($self)) {
1302 ndi = solv_calloc(1, sizeof(*ndi));
1303 dataiterator_init_clone(ndi, $self);
1309 while ((d = Dataiterator___next__($self)) != 0) {
1310 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1314 void prepend_keyname(Id key) {
1315 dataiterator_prepend_keyname($self, key);
1317 void skip_solvable() {
1318 dataiterator_skip_solvable($self);
1324 dataiterator_free($self);
1327 %newobject solvable;
1328 XSolvable * const solvable;
1330 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1331 return new_XSolvable(di->pool, di->solvid);
1335 return $self->key->name;
1337 const char *key_idstr() {
1338 return pool_id2str($self->pool, $self->key->name);
1341 return $self->key->type;
1343 const char *type_idstr() {
1344 return pool_id2str($self->pool, $self->key->type);
1347 return $self->kv.id;
1349 const char *idstr() {
1350 return pool_id2str($self->pool, $self->kv.id);
1353 return $self->kv.str;
1356 return $self->kv.num;
1359 return $self->kv.num2;
1362 dataiterator_setpos($self);
1364 void setpos_parent() {
1365 dataiterator_setpos_parent($self);
1369 %extend Pool_solvable_iterator {
1370 Pool_solvable_iterator(Pool *pool) {
1371 Pool_solvable_iterator *s;
1372 s = solv_calloc(1, sizeof(*s));
1376 #if defined(SWIGPYTHON)
1377 %newobject __iter__;
1378 Pool_solvable_iterator *__iter__() {
1379 Pool_solvable_iterator *s;
1380 s = solv_calloc(1, sizeof(*s));
1384 %rename("next") __next__();
1385 %exception __next__ {
1388 PyErr_SetString(PyExc_StopIteration,"no more matches");
1395 perliter(solv::Pool_solvable_iterator)
1397 %newobject __next__;
1398 XSolvable *__next__() {
1399 Pool *pool = $self->pool;
1400 if ($self->id >= pool->nsolvables)
1402 while (++$self->id < pool->nsolvables)
1403 if (pool->solvables[$self->id].repo)
1404 return new_XSolvable(pool, $self->id);
1410 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1411 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1415 %newobject __getitem__;
1416 XSolvable *__getitem__(Id key) {
1417 Pool *pool = $self->pool;
1418 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1419 return new_XSolvable(pool, key);
1423 return $self->pool->nsolvables;
1427 %extend Pool_repo_iterator {
1428 Pool_repo_iterator(Pool *pool) {
1429 Pool_repo_iterator *s;
1430 s = solv_calloc(1, sizeof(*s));
1434 #if defined(SWIGPYTHON)
1435 %newobject __iter__;
1436 Pool_repo_iterator *__iter__() {
1437 Pool_repo_iterator *s;
1438 s = solv_calloc(1, sizeof(*s));
1442 %rename("next") __next__();
1443 %exception __next__ {
1446 PyErr_SetString(PyExc_StopIteration,"no more matches");
1451 %newobject __next__;
1453 Pool *pool = $self->pool;
1454 if ($self->id >= pool->nrepos)
1456 while (++$self->id < pool->nrepos) {
1457 Repo *r = pool_id2repo(pool, $self->id);
1466 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1467 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p__Repo, SWIG_POINTER_OWN | 0));
1471 Repo *__getitem__(Id key) {
1472 Pool *pool = $self->pool;
1473 if (key > 0 && key < pool->nrepos)
1474 return pool_id2repo(pool, key);
1478 return $self->pool->nrepos;
1482 %extend Repo_solvable_iterator {
1483 Repo_solvable_iterator(Repo *repo) {
1484 Repo_solvable_iterator *s;
1485 s = solv_calloc(1, sizeof(*s));
1489 #if defined(SWIGPYTHON)
1490 %newobject __iter__;
1491 Repo_solvable_iterator *__iter__() {
1492 Repo_solvable_iterator *s;
1493 s = solv_calloc(1, sizeof(*s));
1497 %rename("next") __next__();
1498 %exception __next__ {
1501 PyErr_SetString(PyExc_StopIteration,"no more matches");
1506 %newobject __next__;
1507 XSolvable *__next__() {
1508 Repo *repo = $self->repo;
1509 Pool *pool = repo->pool;
1510 if (repo->start > 0 && $self->id < repo->start)
1511 $self->id = repo->start - 1;
1512 if ($self->id >= repo->end)
1514 while (++$self->id < repo->end)
1515 if (pool->solvables[$self->id].repo == repo)
1516 return new_XSolvable(pool, $self->id);
1522 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1523 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1527 %newobject __getitem__;
1528 XSolvable *__getitem__(Id key) {
1529 Repo *repo = $self->repo;
1530 Pool *pool = repo->pool;
1531 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1532 return new_XSolvable(pool, key);
1536 return $self->repo->pool->nsolvables;
1541 Dep(Pool *pool, Id id) {
1545 s = solv_calloc(1, sizeof(*s));
1551 return pool_dep2str($self->pool, $self->id);
1553 bool __eq__(Dep *s) {
1554 return $self->pool == s->pool && $self->id == s->id;
1556 bool __ne__(Dep *s) {
1557 return !Dep___eq__($self, s);
1559 #if defined(SWIGPERL)
1560 %rename("str") __str__;
1562 const char *__str__() {
1563 return pool_dep2str($self->pool, $self->id);
1565 %newobject __repr__;
1566 const char *__repr__() {
1568 sprintf(buf, "<Id #%d ", $self->id);
1569 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
1574 XSolvable(Pool *pool, Id id) {
1576 if (!id || id >= pool->nsolvables)
1578 s = solv_calloc(1, sizeof(*s));
1584 return pool_solvid2str($self->pool, $self->id);
1586 const char *lookup_str(Id keyname) {
1587 return pool_lookup_str($self->pool, $self->id, keyname);
1589 Id lookup_id(Id keyname) {
1590 return pool_lookup_id($self->pool, $self->id, keyname);
1592 unsigned int lookup_num(Id keyname, unsigned int notfound = 0) {
1593 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
1595 bool lookup_void(Id keyname) {
1596 return pool_lookup_void($self->pool, $self->id, keyname);
1598 %newobject lookup_checksum;
1599 Chksum *lookup_checksum(Id keyname) {
1601 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
1602 return solv_chksum_create_from_bin(type, b);
1604 const char *lookup_location(unsigned int *OUTPUT) {
1605 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
1608 %rename("installable?") installable;
1610 bool installable() {
1611 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
1614 %rename("isinstalled?") isinstalled;
1616 bool isinstalled() {
1617 Pool *pool = $self->pool;
1618 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
1623 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
1624 Pool *pool = xs->pool;
1625 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
1627 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
1628 Pool *pool = xs->pool;
1629 return pool_id2str(pool, pool->solvables[xs->id].name);
1634 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
1635 xs->pool->solvables[xs->id].name = nameid;
1637 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
1638 return xs->pool->solvables[xs->id].name;
1643 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
1644 Pool *pool = xs->pool;
1645 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
1647 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
1648 Pool *pool = xs->pool;
1649 return pool_id2str(pool, pool->solvables[xs->id].evr);
1654 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
1655 xs->pool->solvables[xs->id].evr = evrid;
1657 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
1658 return xs->pool->solvables[xs->id].evr;
1663 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
1664 Pool *pool = xs->pool;
1665 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
1667 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
1668 Pool *pool = xs->pool;
1669 return pool_id2str(pool, pool->solvables[xs->id].arch);
1674 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
1675 xs->pool->solvables[xs->id].arch = archid;
1677 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
1678 return xs->pool->solvables[xs->id].arch;
1683 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
1684 Pool *pool = xs->pool;
1685 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
1687 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
1688 Pool *pool = xs->pool;
1689 return pool_id2str(pool, pool->solvables[xs->id].vendor);
1694 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
1695 xs->pool->solvables[xs->id].vendor = vendorid;
1697 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
1698 return xs->pool->solvables[xs->id].vendor;
1703 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
1704 return xs->pool->solvables[xs->id].repo;
1708 void add_provides(Dep *dep, Id marker = -SOLVABLE_FILEMARKER) {
1709 Solvable *s = $self->pool->solvables + $self->id;
1710 s->provides = repo_addid_dep(s->repo, s->provides, dep->id, marker);
1712 void add_providesid(Id id, Id marker = -SOLVABLE_FILEMARKER) {
1713 Solvable *s = $self->pool->solvables + $self->id;
1714 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
1716 void add_obsoletes(Dep *dep) {
1717 Solvable *s = $self->pool->solvables + $self->id;
1718 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, dep->id, 0);
1720 void add_obsoletesid(Id id) {
1721 Solvable *s = $self->pool->solvables + $self->id;
1722 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
1724 void add_conflicts(Dep *dep) {
1725 Solvable *s = $self->pool->solvables + $self->id;
1726 s->conflicts = repo_addid_dep(s->repo, s->conflicts, dep->id, 0);
1728 void add_conflictsid(Id id) {
1729 Solvable *s = $self->pool->solvables + $self->id;
1730 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
1732 void add_requires(Dep *dep, Id marker = -SOLVABLE_PREREQMARKER) {
1733 Solvable *s = $self->pool->solvables + $self->id;
1734 s->requires = repo_addid_dep(s->repo, s->requires, dep->id, marker);
1736 void add_requiresid(Id id, Id marker = -SOLVABLE_PREREQMARKER) {
1737 Solvable *s = $self->pool->solvables + $self->id;
1738 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
1740 void add_recommends(Dep *dep) {
1741 Solvable *s = $self->pool->solvables + $self->id;
1742 s->recommends = repo_addid_dep(s->repo, s->recommends, dep->id, 0);
1744 void add_recommendsid(Id id) {
1745 Solvable *s = $self->pool->solvables + $self->id;
1746 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
1748 void add_suggests(Dep *dep) {
1749 Solvable *s = $self->pool->solvables + $self->id;
1750 s->suggests = repo_addid_dep(s->repo, s->suggests, dep->id, 0);
1752 void add_suggestsid(Id id) {
1753 Solvable *s = $self->pool->solvables + $self->id;
1754 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
1756 void add_supplements(Dep *dep) {
1757 Solvable *s = $self->pool->solvables + $self->id;
1758 s->supplements = repo_addid_dep(s->repo, s->supplements, dep->id, 0);
1760 void add_supplementsid(Id id) {
1761 Solvable *s = $self->pool->solvables + $self->id;
1762 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
1764 void add_enhances(Dep *dep) {
1765 Solvable *s = $self->pool->solvables + $self->id;
1766 s->enhances = repo_addid_dep(s->repo, s->enhances, dep->id, 0);
1768 void add_enhancesid(Id id) {
1769 Solvable *s = $self->pool->solvables + $self->id;
1770 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
1773 bool __eq__(XSolvable *s) {
1774 return $self->pool == s->pool && $self->id == s->id;
1776 bool __ne__(XSolvable *s) {
1777 return !XSolvable___eq__($self, s);
1779 #if defined(SWIGPERL)
1780 %rename("str") __str__;
1782 const char *__str__() {
1783 return pool_solvid2str($self->pool, $self->id);
1785 %newobject __repr__;
1786 const char *__repr__() {
1788 sprintf(buf, "<Solvable #%d ", $self->id);
1789 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
1794 Problem(Solver *solv, Id id) {
1796 p = solv_calloc(1, sizeof(*p));
1801 %newobject findproblemrule;
1802 XRule *findproblemrule() {
1803 Id r = solver_findproblemrule($self->solv, $self->id);
1804 return new_XRule($self->solv, r);
1806 %newobject findallproblemrules;
1807 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
1808 Queue findallproblemrules(int unfiltered=0) {
1809 Solver *solv = $self->solv;
1814 solver_findallproblemrules(solv, $self->id, &q);
1817 for (i = j = 0; i < q.count; i++)
1819 SolverRuleinfo rclass;
1820 probr = q.elements[i];
1821 rclass = solver_ruleclass(solv, probr);
1822 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
1824 q.elements[j++] = probr;
1827 queue_truncate(&q, j);
1831 int solution_count() {
1832 return solver_solution_count($self->solv, $self->id);
1834 %newobject solutions;
1835 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
1840 cnt = solver_solution_count($self->solv, $self->id);
1841 for (i = 1; i <= cnt; i++)
1848 Solution(Problem *p, Id id) {
1850 s = solv_calloc(1, sizeof(*s));
1852 s->problemid = p->id;
1856 int element_count() {
1857 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1860 %newobject elements;
1861 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
1862 Queue elements(bool expandreplaces=0) {
1866 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
1867 for (i = 1; i <= cnt; i++)
1870 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
1872 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
1878 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
1879 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
1881 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
1882 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
1883 queue_push2(&q, p, rp);
1885 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
1886 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
1887 queue_push2(&q, p, rp);
1889 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
1890 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
1891 queue_push2(&q, p, rp);
1896 queue_push2(&q, i, type);
1897 queue_push2(&q, p, rp);
1903 %extend Solutionelement {
1904 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
1906 e = solv_calloc(1, sizeof(*e));
1908 e->problemid = problemid;
1919 if (p == SOLVER_SOLUTION_ERASE)
1924 else if (p == SOLVER_SOLUTION_REPLACE)
1929 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
1930 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);
1931 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
1932 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);
1933 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
1934 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);
1935 return solver_solutionelement2str($self->solv, p, rp);
1937 %newobject replaceelements;
1938 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
1939 Queue replaceelements() {
1944 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
1947 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
1948 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1949 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
1950 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1951 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
1952 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1953 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
1955 queue_push(&q, $self->type);
1958 int illegalreplace() {
1959 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
1961 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
1963 %newobject solvable;
1964 XSolvable * const solvable;
1965 %newobject replacement;
1966 XSolvable * const replacement;
1969 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
1970 return new_XSolvable(e->solv->pool, e->p);
1972 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
1973 return new_XSolvable(e->solv->pool, e->rp);
1975 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
1976 if (e->type != SOLVER_SOLUTION_JOB)
1978 return (e->p - 1) / 2;
1983 if ($self->type == SOLVER_SOLUTION_JOB)
1984 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
1985 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE)
1986 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE, $self->p);
1987 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
1988 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE, $self->rp);
1989 if ($self->type == SOLVER_SOLUTION_ERASE)
1990 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE, $self->p);
1996 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
1997 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
1998 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
1999 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2000 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2001 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2002 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2003 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2004 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2005 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2006 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2007 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2008 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2009 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2010 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2011 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2012 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2013 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2014 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2016 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2017 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2018 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2019 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2020 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2021 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2022 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2023 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2025 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2026 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2027 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2029 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2030 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2031 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2032 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2033 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2034 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2035 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2036 static const int SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED = SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED;
2037 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2043 int set_flag(int flag, int value) {
2044 return solver_set_flag($self, flag, value);
2046 int get_flag(int flag) {
2047 return solver_get_flag($self, flag);
2049 #if defined(SWIGPYTHON)
2051 def solve(self, jobs):
2053 for job in jobs: j += [job.how, job.what]
2054 return self.solve_helper(j)
2057 #if defined(SWIGPERL)
2059 sub solv::Solver::solve {
2060 my ($self, $jobs) = @_;
2061 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2062 return $self->solve_helper(\@j);
2066 #if defined(SWIGRUBY)
2069 "class Solv::Solver\n"
2070 " def solve(jobs)\n"
2072 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2073 " solve_helper(jl)\n"
2079 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2080 %newobject solve_helper;
2081 Queue solve_helper(Queue jobs) {
2085 solver_solve($self, &jobs);
2086 cnt = solver_problem_count($self);
2087 for (i = 1; i <= cnt; i++)
2091 %newobject transaction;
2092 Transaction *transaction() {
2093 return solver_create_transaction($self);
2097 %extend Transaction {
2098 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2099 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2100 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2101 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2102 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2103 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2104 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2105 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2106 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2107 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2108 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2109 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2110 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2111 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2112 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2113 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2114 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2115 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2116 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2117 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2118 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2119 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2120 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2121 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2122 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2123 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2124 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2126 transaction_free($self);
2129 %rename("isempty?") isempty;
2132 return $self->steps.count == 0;
2135 %newobject othersolvable;
2136 XSolvable *othersolvable(XSolvable *s) {
2137 Id op = transaction_obs_pkg($self, s->id);
2138 return new_XSolvable($self->pool, op);
2141 %newobject allothersolvables;
2142 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2143 Queue allothersolvables(XSolvable *s) {
2146 transaction_all_obs_pkgs($self, s->id, &q);
2150 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2151 %newobject classify;
2152 Queue classify(int mode = 0) {
2155 transaction_classify($self, mode, &q);
2159 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2160 %newobject newpackages;
2161 Queue newpackages() {
2165 cut = transaction_installedresult(self, &q);
2166 queue_truncate(&q, cut);
2170 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2171 %newobject keptpackages;
2172 Queue keptpackages() {
2176 cut = transaction_installedresult(self, &q);
2178 queue_deleten(&q, 0, cut);
2182 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2186 queue_init_clone(&q, &$self->steps);
2190 int steptype(XSolvable *s, int mode) {
2191 return transaction_type($self, s->id, mode);
2193 int calc_installsizechange() {
2194 return transaction_calc_installsizechange($self);
2196 void order(int flags) {
2197 transaction_order($self, flags);
2201 %extend TransactionClass {
2202 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2203 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2204 cl->transaction = trans;
2208 cl->fromid = fromid;
2212 %newobject solvables;
2213 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2217 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2223 XRule(Solver *solv, Id id) {
2226 XRule *xr = solv_calloc(1, sizeof(*xr));
2232 Id type, source, target, dep;
2233 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2234 return new_Ruleinfo($self, type, source, target, dep);
2236 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2237 %newobject allinfos;
2241 solver_allruleinfos($self->solv, $self->id, &q);
2245 bool __eq__(XRule *xr) {
2246 return $self->solv == xr->solv && $self->id == xr->id;
2248 bool __ne__(XRule *xr) {
2249 return !XRule___eq__($self, xr);
2251 %newobject __repr__;
2252 const char *__repr__() {
2254 sprintf(buf, "<Rule #%d>", $self->id);
2255 return solv_strdup(buf);
2260 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2261 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2265 ri->source = source;
2266 ri->target = target;
2270 XSolvable * const solvable;
2271 XSolvable * const othersolvable;
2273 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2274 return new_XSolvable(ri->solv->pool, ri->source);
2276 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2277 return new_XSolvable(ri->solv->pool, ri->target);
2280 const char *problemstr() {
2281 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2286 XRepodata(Repo *repo, Id id) {
2287 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2293 return repodata_new_handle($self->repo->repodata + $self->id);
2295 void set_id(Id solvid, Id keyname, Id id) {
2296 repodata_set_id($self->repo->repodata + $self->id, solvid, keyname, id);
2298 void set_str(Id solvid, Id keyname, const char *str) {
2299 repodata_set_str($self->repo->repodata + $self->id, solvid, keyname, str);
2301 void set_poolstr(Id solvid, Id keyname, const char *str) {
2302 repodata_set_poolstr($self->repo->repodata + $self->id, solvid, keyname, str);
2304 void add_idarray(Id solvid, Id keyname, Id id) {
2305 repodata_add_idarray($self->repo->repodata + $self->id, solvid, keyname, id);
2307 void add_flexarray(Id solvid, Id keyname, Id handle) {
2308 repodata_add_flexarray($self->repo->repodata + $self->id, solvid, keyname, handle);
2310 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2311 const unsigned char *buf = solv_chksum_get(chksum, 0);
2313 repodata_set_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, solv_chksum_get_type(chksum), buf);
2315 const char *lookup_str(Id solvid, Id keyname) {
2316 return repodata_lookup_str($self->repo->repodata + $self->id, solvid, keyname);
2318 Queue lookup_idarray(Id solvid, Id keyname) {
2321 repodata_lookup_idarray($self->repo->repodata + $self->id, solvid, keyname, &r);
2324 %newobject lookup_checksum;
2325 Chksum *lookup_checksum(Id solvid, Id keyname) {
2327 const unsigned char *b = repodata_lookup_bin_checksum($self->repo->repodata + $self->id, solvid, keyname, &type);
2328 return solv_chksum_create_from_bin(type, b);
2330 void internalize() {
2331 repodata_internalize($self->repo->repodata + $self->id);
2333 void create_stubs() {
2334 repodata_create_stubs($self->repo->repodata + $self->id);
2336 void write(FILE *fp) {
2337 repodata_write($self->repo->repodata + $self->id, fp, repo_write_stdkeyfilter, 0);
2339 bool add_solv(FILE *fp, int flags = 0) {
2340 Repodata *data = $self->repo->repodata + $self->id;
2341 int r, oldstate = data->state;
2342 data->state = REPODATA_LOADING;
2343 r = repo_add_solv_flags(data->repo, fp, flags | REPO_USE_LOADING);
2344 if (r || data->state == REPODATA_LOADING)
2345 data->state = oldstate;
2348 void extend_to_repo() {
2349 Repodata *data = $self->repo->repodata + $self->id;
2350 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2352 bool __eq__(XRepodata *xr) {
2353 return $self->repo == xr->repo && $self->id == xr->id;
2355 bool __ne__(XRepodata *xr) {
2356 return !XRepodata___eq__($self, xr);
2358 %newobject __repr__;
2359 const char *__repr__() {
2361 sprintf(buf, "<Repodata #%d>", $self->id);
2362 return solv_strdup(buf);