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_LEN($input);
148 o = RARRAY_PTR($input);
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 {
302 $result = $1 ? $1 : Py_None;
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"
336 #include <sys/stat.h>
337 #include <sys/utsname.h>
338 #include <sys/types.h>
341 /* argh, swig undefs bool for perl */
347 #include "poolarch.h"
350 #include "solverdebug.h"
351 #include "repo_solv.h"
353 #include "selection.h"
355 #include "repo_write.h"
357 #include "repo_rpmdb.h"
360 #include "repo_deb.h"
363 #include "repo_rpmmd.h"
364 #include "repo_updateinfoxml.h"
365 #include "repo_deltainfoxml.h"
366 #include "repo_repomdxml.h"
368 #ifdef ENABLE_SUSEREPO
369 #include "repo_products.h"
370 #include "repo_susetags.h"
371 #include "repo_content.h"
373 #ifdef ENABLE_MDKREPO
374 #include "repo_mdk.h"
376 #ifdef ENABLE_ARCHREPO
377 #include "repo_arch.h"
379 #include "solv_xfopen.h"
381 /* for old ruby versions */
383 #define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
386 #define RARRAY_LEN(ary) (RARRAY(ary)->len)
389 #define SOLVER_SOLUTION_ERASE -100
390 #define SOLVER_SOLUTION_REPLACE -101
391 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
392 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
393 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
395 typedef struct chksum Chksum;
396 typedef void *AppObjectPtr;
421 } Pool_solvable_iterator;
426 } Pool_repo_iterator;
431 } Repo_solvable_iterator;
471 Transaction *transaction;
485 typedef Dataiterator Datamatch;
490 %mixin Dataiterator "Enumerable";
491 %mixin Pool_solvable_iterator "Enumerable";
492 %mixin Pool_repo_iterator "Enumerable";
493 %mixin Repo_solvable_iterator "Enumerable";
501 %constant Id SOLVID_META;
502 %constant Id SOLVID_POS;
504 %constant int REL_EQ;
505 %constant int REL_GT;
506 %constant int REL_LT;
507 %constant int REL_ARCH;
539 # put before pool/repo so we can access the constructor
540 %nodefaultdtor Dataiterator;
541 typedef struct {} Dataiterator;
542 typedef struct {} Pool_solvable_iterator;
543 typedef struct {} Pool_repo_iterator;
544 typedef struct {} Repo_solvable_iterator;
546 %nodefaultctor Datamatch;
547 %nodefaultdtor Datamatch;
554 %nodefaultctor Datapos;
568 AppObjectPtr appdata;
575 const char * const name;
578 int const nsolvables;
579 AppObjectPtr appdata;
582 %nodefaultctor Solver;
583 %nodefaultdtor Solver;
591 %rename(xfopen) solv_xfopen;
592 %rename(xfopen_fd) solv_xfopen_fd;
593 %rename(xfopen_dup) solv_xfopen_dup;
594 %rename(xfclose) solv_xfclose;
595 %rename(xfileno) solv_xfileno;
597 FILE *solv_xfopen(const char *fn, const char *mode = 0);
598 FILE *solv_xfopen_fd(const char *fn, int fd, const char *mode = 0);
599 FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode = 0);
600 int solv_xfclose(FILE *fp);
601 int solv_xfileno(FILE *fp);
604 SWIGINTERN int solv_xfclose(FILE *fp) {
607 SWIGINTERN int solv_xfileno(FILE *fp) {
610 SWIGINTERN FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode) {
612 return fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
635 %nodefaultctor Transaction;
636 %nodefaultdtor Transaction;
642 Transaction * const transaction;
651 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
652 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
653 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
654 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
655 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
656 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
657 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
658 static const Id SOLVER_NOOP = SOLVER_NOOP;
659 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
660 static const Id SOLVER_ERASE = SOLVER_ERASE;
661 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
662 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
663 static const Id SOLVER_NOOBSOLETES = SOLVER_NOOBSOLETES;
664 static const Id SOLVER_LOCK = SOLVER_LOCK;
665 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
666 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
667 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
668 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
669 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
670 static const Id SOLVER_WEAK = SOLVER_WEAK;
671 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
672 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
673 static const Id SOLVER_SETEV = SOLVER_SETEV;
674 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
675 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
676 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
677 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
678 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
679 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
681 Job(Pool *pool, int how, Id what) {
682 Job *job = solv_calloc(1, sizeof(*job));
689 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
690 %newobject solvables;
694 pool_job2solvables($self->pool, &q, $self->how, $self->what);
698 bool __eq__(Job *j) {
699 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
701 bool __ne__(Job *j) {
702 return !Job___eq__($self, j);
704 #if defined(SWIGPERL)
705 %rename("str") __str__;
707 const char *__str__() {
708 return pool_job2str($self->pool, $self->how, $self->what, 0);
710 const char *__repr__() {
711 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
712 return pool_tmpjoin($self->pool, "<Job ", str, ">");
717 static const Id SELECTION_NAME = SELECTION_NAME;
718 static const Id SELECTION_PROVIDES = SELECTION_PROVIDES;
719 static const Id SELECTION_FILELIST = SELECTION_FILELIST;
720 static const Id SELECTION_GLOB = SELECTION_GLOB;
721 static const Id SELECTION_NOCASE = SELECTION_NOCASE;
722 static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
723 static const Id SELECTION_FLAT = SELECTION_FLAT;
724 static const Id SELECTION_SOURCE_ONLY = SELECTION_SOURCE_ONLY;
725 static const Id SELECTION_WITH_SOURCE = SELECTION_WITH_SOURCE;
727 Selection(Pool *pool) {
729 s = solv_calloc(1, sizeof(*s));
735 queue_free(&$self->q);
741 void make(const char *name, int flags) {
742 $self->flags = selection_make($self->pool, &$self->q, name, flags);
745 %rename("isempty?") isempty;
748 return $self->q.count == 0;
750 void limit(Selection *lsel) {
751 if ($self->pool != lsel->pool)
752 queue_empty(&$self->q);
754 selection_limit($self->pool, &$self->q, &lsel->q);
756 void add(Selection *lsel) {
757 if ($self->pool == lsel->pool)
759 selection_add($self->pool, &$self->q, &lsel->q);
760 $self->flags |= lsel->flags;
763 void addsimple(Id how, Id what) {
764 queue_push2(&$self->q, how, what);
766 %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
768 Queue jobs(int flags) {
771 queue_init_clone(&q, &$self->q);
772 for (i = 0; i < q.count; i += 2)
773 q.elements[i] |= flags;
777 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
778 %newobject solvables;
782 selection_solvables($self->pool, &$self->q, &q);
786 #if defined(SWIGPERL)
787 %rename("str") __str__;
789 const char *__str__() {
790 return pool_selection2str($self->pool, &$self->q, 0);
792 const char *__repr__() {
793 const char *str = pool_selection2str($self->pool, &$self->q, ~0);
794 return pool_tmpjoin($self->pool, "<Selection ", str, ">");
800 return (Chksum *)solv_chksum_create(type);
802 Chksum(Id type, const char *hex) {
803 unsigned char buf[64];
804 int l = solv_chksum_len(type);
807 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
809 return (Chksum *)solv_chksum_create_from_bin(type, buf);
812 solv_chksum_free($self, 0);
816 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
817 return solv_chksum_get_type(chksum);
820 void add(const char *str) {
821 solv_chksum_add($self, str, strlen((char *)str));
823 void add_fp(FILE *fp) {
826 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
827 solv_chksum_add($self, buf, l);
828 rewind(fp); /* convenience */
830 void add_fd(int fd) {
833 while ((l = read(fd, buf, sizeof(buf))) > 0)
834 solv_chksum_add($self, buf, l);
835 lseek(fd, 0, 0); /* convenience */
837 void add_stat(const char *filename) {
839 if (stat(filename, &stb))
840 memset(&stb, 0, sizeof(stb));
841 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
842 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
843 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
844 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
846 void add_fstat(int fd) {
849 memset(&stb, 0, sizeof(stb));
850 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
851 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
852 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
853 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
857 const unsigned char *b;
858 b = solv_chksum_get($self, &l);
859 return cdata_void((void *)b, l);
864 const unsigned char *b;
867 b = solv_chksum_get($self, &l);
868 ret = solv_malloc(2 * l + 1);
869 solv_bin2hex(b, l, ret);
873 bool __eq__(Chksum *chk) {
875 const unsigned char *b, *bo;
878 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
880 b = solv_chksum_get($self, &l);
881 bo = solv_chksum_get(chk, 0);
882 return memcmp(b, bo, l) == 0;
884 bool __ne__(Chksum *chk) {
885 return !Chksum___eq__($self, chk);
887 #if defined(SWIGRUBY)
888 %rename("to_s") __str__;
889 %rename("inspect") __repr__;
891 #if defined(SWIGPERL)
892 %rename("str") __str__;
895 const char *__str__() {
898 if (solv_chksum_isfinished($self))
899 h = Chksum_hex($self);
900 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
901 solv_free((void *)h);
905 const char *__repr__() {
906 const char *h = Chksum___str__($self);
907 const char *str = solv_dupjoin("<Chksum ", h, ">");
908 solv_free((void *)h);
915 Pool *pool = pool_create();
920 void set_debuglevel(int level) {
921 pool_setdebuglevel($self, level);
923 int set_flag(int flag, int value) {
924 return pool_set_flag($self, flag, value);
926 int get_flag(int flag) {
927 return pool_get_flag($self, flag);
929 void set_rootdir(const char *rootdir) {
930 pool_set_rootdir($self, rootdir);
932 const char *get_rootdir(int flag) {
933 return pool_get_rootdir($self);
935 #if defined(SWIGPYTHON)
937 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
938 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
939 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
940 PyObject *result = PyEval_CallObject((PyObject *)d, args);
945 return 0; /* exception */
946 ecode = SWIG_AsVal_int(result, &vresult);
948 return SWIG_IsOK(ecode) ? vresult : 0;
951 void set_loadcallback(PyObject *callable) {
952 if ($self->loadcallback == loadcallback) {
953 PyObject *obj = $self->loadcallbackdata;
959 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
962 #if defined(SWIGPERL)
964 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
968 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
973 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
975 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
985 void set_loadcallback(SV *callable) {
986 if ($self->loadcallback == loadcallback)
987 SvREFCNT_dec($self->loadcallbackdata);
989 SvREFCNT_inc(callable);
990 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
994 #if defined(SWIGRUBY)
996 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
997 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
998 VALUE callable = (VALUE)d;
999 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
1000 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
1001 return res == Qtrue;
1003 SWIGINTERN void mark_Pool(void *ptr) {
1005 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
1006 VALUE callable = (VALUE)pool->loadcallbackdata;
1007 rb_gc_mark(callable);
1011 %typemap(in, numinputs=0) VALUE callable {
1012 $1 = rb_block_given_p() ? rb_block_proc() : 0;
1014 void set_loadcallback(VALUE callable) {
1015 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
1020 Pool_set_loadcallback($self, 0);
1023 Id str2id(const char *str, bool create=1) {
1024 return pool_str2id($self, str, create);
1026 Dep *Dep(const char *str, bool create=1) {
1027 Id id = pool_str2id($self, str, create);
1028 return new_Dep($self, id);
1030 const char *id2str(Id id) {
1031 return pool_id2str($self, id);
1033 const char *dep2str(Id id) {
1034 return pool_dep2str($self, id);
1036 Id rel2id(Id name, Id evr, int flags, bool create=1) {
1037 return pool_rel2id($self, name, evr, flags, create);
1039 Id id2langid(Id id, const char *lang, bool create=1) {
1040 return pool_id2langid($self, id, lang, create);
1042 void setarch(const char *arch = 0) {
1051 pool_setarch($self, arch);
1053 Repo *add_repo(const char *name) {
1054 return repo_create($self, name);
1056 const char *lookup_str(Id entry, Id keyname) {
1057 return pool_lookup_str($self, entry, keyname);
1059 Id lookup_id(Id entry, Id keyname) {
1060 return pool_lookup_id($self, entry, keyname);
1062 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
1063 return pool_lookup_num($self, entry, keyname, notfound);
1065 bool lookup_void(Id entry, Id keyname) {
1066 return pool_lookup_void($self, entry, keyname);
1068 %newobject lookup_checksum;
1069 Chksum *lookup_checksum(Id entry, Id keyname) {
1071 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
1072 return solv_chksum_create_from_bin(type, b);
1075 %newobject Dataiterator;
1076 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1077 return new_Dataiterator($self, 0, p, key, match, flags);
1079 const char *solvid2str(Id solvid) {
1080 return pool_solvid2str($self, solvid);
1082 void addfileprovides() {
1083 pool_addfileprovides($self);
1085 Queue addfileprovides_queue() {
1088 pool_addfileprovides_queue($self, &r, 0);
1091 void createwhatprovides() {
1092 pool_createwhatprovides($self);
1095 XSolvable *id2solvable(Id id) {
1096 return new_XSolvable($self, id);
1098 %newobject solvables;
1099 Pool_solvable_iterator * const solvables;
1101 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
1102 return new_Pool_solvable_iterator(pool);
1105 %newobject solvables_iter;
1106 Pool_solvable_iterator * solvables_iter() {
1107 return new_Pool_solvable_iterator($self);
1110 Repo *id2repo(Id id) {
1111 if (id < 1 || id >= $self->nrepos)
1113 return pool_id2repo($self, id);
1116 Pool_repo_iterator * const repos;
1118 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
1119 return new_Pool_repo_iterator(pool);
1122 %newobject repos_iter;
1123 Pool_repo_iterator * repos_iter() {
1124 return new_Pool_repo_iterator($self);
1129 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
1130 pool_set_installed(pool, installed);
1132 Repo *Pool_installed_get(Pool *pool) {
1133 return pool->installed;
1137 Queue matchprovidingids(const char *match, int flags) {
1143 for (id = 1; id < pool->ss.nstrings; id++)
1144 if (pool->whatprovides[id])
1148 if (!datamatcher_init(&ma, match, flags)) {
1149 for (id = 1; id < pool->ss.nstrings; id++)
1150 if (pool->whatprovides[id] && datamatcher_match(&ma, pool_id2str(pool, id)))
1152 datamatcher_free(&ma);
1158 Job *Job(int how, Id what) {
1159 return new_Job($self, how, what);
1162 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1163 %newobject whatprovides;
1164 Queue whatprovides(Id dep) {
1169 FOR_PROVIDES(p, pp, dep)
1174 Id towhatprovides(Queue q) {
1175 return pool_queuetowhatprovides($self, &q);
1179 %rename("isknownarch?") isknownarch;
1181 bool isknownarch(Id id) {
1183 if (!id || id == ID_EMPTY)
1185 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1187 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1194 return solver_create($self);
1197 %newobject Selection;
1198 Selection *Selection() {
1199 return new_Selection($self);
1202 Selection *select(const char *name, int flags) {
1203 Selection *sel = new_Selection($self);
1204 sel->flags = selection_make($self, &sel->q, name, flags);
1210 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1211 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1212 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1213 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1214 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1215 static const int REPO_USE_ROOTDIR = REPO_USE_ROOTDIR;
1216 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1217 #ifdef ENABLE_SUSEREPO
1218 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1221 void free(bool reuseids = 0) {
1222 repo_free($self, reuseids);
1224 void empty(bool reuseids = 0) {
1225 repo_empty($self, reuseids);
1228 %rename("isempty?") isempty;
1231 return !$self->nsolvables;
1233 bool add_solv(const char *name, int flags = 0) {
1234 FILE *fp = fopen(name, "r");
1238 r = repo_add_solv($self, fp, flags);
1242 bool add_solv(FILE *fp, int flags = 0) {
1243 return repo_add_solv($self, fp, flags) == 0;
1246 XSolvable *add_solvable() {
1247 Id solvid = repo_add_solvable($self);
1248 return new_XSolvable($self->pool, solvid);
1252 bool add_rpmdb(Repo *ref, int flags = 0) {
1253 return repo_add_rpmdb($self, ref, flags);
1255 Id add_rpm(const char *name, int flags = 0) {
1256 return repo_add_rpm($self, name, flags);
1260 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1261 return repo_add_rpmmd($self, fp, language, flags);
1263 bool add_repomdxml(FILE *fp, int flags = 0) {
1264 return repo_add_repomdxml($self, fp, flags);
1266 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1267 return repo_add_updateinfoxml($self, fp, flags);
1269 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1270 return repo_add_deltainfoxml($self, fp, flags);
1273 #ifdef ENABLE_DEBIAN
1274 bool add_debdb(int flags = 0) {
1275 return repo_add_debdb($self, flags);
1277 Id add_deb(const char *name, int flags = 0) {
1278 return repo_add_deb($self, name, flags);
1281 #ifdef ENABLE_SUSEREPO
1282 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1283 return repo_add_susetags($self, fp, defvendor, language, flags);
1285 bool add_content(FILE *fp, int flags = 0) {
1286 return repo_add_content($self, fp, flags);
1288 bool add_products(const char *proddir, int flags = 0) {
1289 return repo_add_products($self, proddir, flags);
1292 #ifdef ENABLE_MDKREPO
1293 bool add_mdk(FILE *fp, int flags = 0) {
1294 return repo_add_mdk($self, fp, flags);
1296 bool add_mdk_info(FILE *fp, int flags = 0) {
1297 return repo_add_mdk($self, fp, flags);
1300 #ifdef ENABLE_ARCHREPO
1301 bool add_arch_repo(FILE *fp, int flags = 0) {
1302 return repo_add_arch_repo($self, fp, flags);
1304 Id add_arch_pkg(const char *name, int flags = 0) {
1305 return repo_add_arch_pkg($self, name, flags);
1308 void internalize() {
1309 repo_internalize($self);
1311 const char *lookup_str(Id entry, Id keyname) {
1312 return repo_lookup_str($self, entry, keyname);
1314 Id lookup_id(Id entry, Id keyname) {
1315 return repo_lookup_id($self, entry, keyname);
1317 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1318 return repo_lookup_num($self, entry, keyname, notfound);
1320 void write(FILE *fp) {
1321 repo_write($self, fp);
1323 # HACK, remove if no longer needed!
1324 bool write_first_repodata(FILE *fp) {
1325 int oldnrepodata = $self->nrepodata;
1326 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1327 repo_write($self, fp);
1328 $self->nrepodata = oldnrepodata;
1332 %newobject Dataiterator;
1333 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1334 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1339 SWIGINTERN Id Repo_id_get(Repo *repo) {
1340 return repo->repoid;
1343 Repo_solvable_iterator * const solvables;
1345 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1346 return new_Repo_solvable_iterator(repo);
1349 %newobject solvables_iter;
1350 Repo_solvable_iterator *solvables_iter() {
1351 return new_Repo_solvable_iterator($self);
1354 XRepodata *add_repodata(int flags = 0) {
1355 Repodata *rd = repo_add_repodata($self, flags);
1356 return new_XRepodata($self, rd->repodataid);
1359 void create_stubs() {
1361 if (!$self->nrepodata)
1363 data = repo_id2repodata($self, $self->nrepodata - 1);
1364 if (data->state != REPODATA_STUB)
1365 repodata_create_stubs(data);
1368 %rename("iscontiguous?") iscontiguous;
1370 bool iscontiguous() {
1372 for (i = $self->start; i < $self->end; i++)
1373 if ($self->pool->solvables[i].repo != $self)
1377 XRepodata *first_repodata() {
1380 if ($self->nrepodata < 2)
1382 /* make sure all repodatas but the first are extensions */
1383 data = repo_id2repodata($self, 1);
1384 if (data->loadcallback)
1386 for (i = 2; i < $self->nrepodata; i++)
1388 data = repo_id2repodata($self, i);
1389 if (!data->loadcallback)
1390 return 0; /* oops, not an extension */
1392 return new_XRepodata($self, 1);
1395 bool __eq__(Repo *repo) {
1396 return $self == repo;
1398 bool __ne__(Repo *repo) {
1399 return $self != repo;
1401 #if defined(SWIGPERL)
1402 %rename("str") __str__;
1405 const char *__str__() {
1408 return solv_strdup($self->name);
1409 sprintf(buf, "Repo#%d", $self->repoid);
1410 return solv_strdup(buf);
1412 %newobject __repr__;
1413 const char *__repr__() {
1417 sprintf(buf, "<Repo #%d ", $self->repoid);
1418 return solv_dupjoin(buf, $self->name, ">");
1420 sprintf(buf, "<Repo #%d>", $self->repoid);
1421 return solv_strdup(buf);
1425 %extend Dataiterator {
1426 static const int SEARCH_STRING = SEARCH_STRING;
1427 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1428 static const int SEARCH_GLOB = SEARCH_GLOB;
1429 static const int SEARCH_REGEX = SEARCH_REGEX;
1430 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1431 static const int SEARCH_FILES = SEARCH_FILES;
1432 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1434 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1435 Dataiterator *di = solv_calloc(1, sizeof(*di));
1436 dataiterator_init(di, pool, repo, p, key, match, flags);
1440 dataiterator_free($self);
1443 #if defined(SWIGPYTHON)
1444 %newobject __iter__;
1445 Dataiterator *__iter__() {
1447 ndi = solv_calloc(1, sizeof(*ndi));
1448 dataiterator_init_clone(ndi, $self);
1451 %rename("next") __next__();
1452 %exception __next__ {
1455 PyErr_SetString(PyExc_StopIteration,"no more matches");
1462 perliter(solv::Dataiterator)
1465 %newobject __next__;
1466 Datamatch *__next__() {
1468 if (!dataiterator_step($self)) {
1471 ndi = solv_calloc(1, sizeof(*ndi));
1472 dataiterator_init_clone(ndi, $self);
1478 while ((d = Dataiterator___next__($self)) != 0) {
1479 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1483 void prepend_keyname(Id key) {
1484 dataiterator_prepend_keyname($self, key);
1486 void skip_solvable() {
1487 dataiterator_skip_solvable($self);
1492 Id lookup_id(Id keyname) {
1493 Pool *pool = $self->repo->pool;
1494 Datapos oldpos = pool->pos;
1497 r = pool_lookup_id(pool, SOLVID_POS, keyname);
1501 const char *lookup_str(Id keyname) {
1502 Pool *pool = $self->repo->pool;
1503 Datapos oldpos = pool->pos;
1506 r = pool_lookup_str(pool, SOLVID_POS, keyname);
1510 %newobject lookup_checksum;
1511 Chksum *lookup_checksum(Id keyname) {
1512 Pool *pool = $self->repo->pool;
1513 Datapos oldpos = pool->pos;
1515 const unsigned char *b;
1517 b = pool_lookup_bin_checksum(pool, SOLVID_POS, keyname, &type);
1519 return solv_chksum_create_from_bin(type, b);
1521 const char *lookup_deltaseq() {
1522 Pool *pool = $self->repo->pool;
1523 Datapos oldpos = pool->pos;
1526 seq = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NAME);
1528 seq = pool_tmpjoin(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_EVR));
1529 seq = pool_tmpappend(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM));
1534 const char *lookup_deltalocation() {
1535 Pool *pool = $self->repo->pool;
1536 Datapos oldpos = pool->pos;
1539 loc = pool_lookup_deltalocation(pool, SOLVID_POS);
1547 dataiterator_free($self);
1550 %newobject solvable;
1551 XSolvable * const solvable;
1553 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1554 return new_XSolvable(di->pool, di->solvid);
1558 return $self->key->name;
1560 const char *key_idstr() {
1561 return pool_id2str($self->pool, $self->key->name);
1564 return $self->key->type;
1566 const char *type_idstr() {
1567 return pool_id2str($self->pool, $self->key->type);
1570 return $self->kv.id;
1572 const char *idstr() {
1573 return pool_id2str($self->pool, $self->kv.id);
1576 return $self->kv.str;
1579 return $self->kv.num;
1582 return $self->kv.num2;
1586 Pool *pool = $self->pool;
1587 Datapos *pos, oldpos = pool->pos;
1588 dataiterator_setpos($self);
1589 pos = solv_calloc(1, sizeof(*pos));
1594 %newobject parentpos;
1595 Datapos *parentpos() {
1596 Pool *pool = $self->pool;
1597 Datapos *pos, oldpos = pool->pos;
1598 dataiterator_setpos_parent($self);
1599 pos = solv_calloc(1, sizeof(*pos));
1605 dataiterator_setpos($self);
1607 void setpos_parent() {
1608 dataiterator_setpos_parent($self);
1612 %extend Pool_solvable_iterator {
1613 Pool_solvable_iterator(Pool *pool) {
1614 Pool_solvable_iterator *s;
1615 s = solv_calloc(1, sizeof(*s));
1619 #if defined(SWIGPYTHON)
1620 %newobject __iter__;
1621 Pool_solvable_iterator *__iter__() {
1622 Pool_solvable_iterator *s;
1623 s = solv_calloc(1, sizeof(*s));
1627 %rename("next") __next__();
1628 %exception __next__ {
1631 PyErr_SetString(PyExc_StopIteration,"no more matches");
1638 perliter(solv::Pool_solvable_iterator)
1640 %newobject __next__;
1641 XSolvable *__next__() {
1642 Pool *pool = $self->pool;
1643 if ($self->id >= pool->nsolvables)
1645 while (++$self->id < pool->nsolvables)
1646 if (pool->solvables[$self->id].repo)
1647 return new_XSolvable(pool, $self->id);
1653 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1654 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1658 %newobject __getitem__;
1659 XSolvable *__getitem__(Id key) {
1660 Pool *pool = $self->pool;
1661 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1662 return new_XSolvable(pool, key);
1666 return $self->pool->nsolvables;
1670 %extend Pool_repo_iterator {
1671 Pool_repo_iterator(Pool *pool) {
1672 Pool_repo_iterator *s;
1673 s = solv_calloc(1, sizeof(*s));
1677 #if defined(SWIGPYTHON)
1678 %newobject __iter__;
1679 Pool_repo_iterator *__iter__() {
1680 Pool_repo_iterator *s;
1681 s = solv_calloc(1, sizeof(*s));
1685 %rename("next") __next__();
1686 %exception __next__ {
1689 PyErr_SetString(PyExc_StopIteration,"no more matches");
1694 %newobject __next__;
1696 Pool *pool = $self->pool;
1697 if ($self->id >= pool->nrepos)
1699 while (++$self->id < pool->nrepos) {
1700 Repo *r = pool_id2repo(pool, $self->id);
1709 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1710 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
1714 Repo *__getitem__(Id key) {
1715 Pool *pool = $self->pool;
1716 if (key > 0 && key < pool->nrepos)
1717 return pool_id2repo(pool, key);
1721 return $self->pool->nrepos;
1725 %extend Repo_solvable_iterator {
1726 Repo_solvable_iterator(Repo *repo) {
1727 Repo_solvable_iterator *s;
1728 s = solv_calloc(1, sizeof(*s));
1732 #if defined(SWIGPYTHON)
1733 %newobject __iter__;
1734 Repo_solvable_iterator *__iter__() {
1735 Repo_solvable_iterator *s;
1736 s = solv_calloc(1, sizeof(*s));
1740 %rename("next") __next__();
1741 %exception __next__ {
1744 PyErr_SetString(PyExc_StopIteration,"no more matches");
1749 %newobject __next__;
1750 XSolvable *__next__() {
1751 Repo *repo = $self->repo;
1752 Pool *pool = repo->pool;
1753 if (repo->start > 0 && $self->id < repo->start)
1754 $self->id = repo->start - 1;
1755 if ($self->id >= repo->end)
1757 while (++$self->id < repo->end)
1758 if (pool->solvables[$self->id].repo == repo)
1759 return new_XSolvable(pool, $self->id);
1765 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1766 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1770 %newobject __getitem__;
1771 XSolvable *__getitem__(Id key) {
1772 Repo *repo = $self->repo;
1773 Pool *pool = repo->pool;
1774 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1775 return new_XSolvable(pool, key);
1779 return $self->repo->pool->nsolvables;
1784 Dep(Pool *pool, Id id) {
1788 s = solv_calloc(1, sizeof(*s));
1794 return pool_dep2str($self->pool, $self->id);
1796 bool __eq__(Dep *s) {
1797 return $self->pool == s->pool && $self->id == s->id;
1799 bool __ne__(Dep *s) {
1800 return !Dep___eq__($self, s);
1802 #if defined(SWIGPERL)
1803 %rename("str") __str__;
1805 const char *__str__() {
1806 return pool_dep2str($self->pool, $self->id);
1808 %newobject __repr__;
1809 const char *__repr__() {
1811 sprintf(buf, "<Id #%d ", $self->id);
1812 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
1817 XSolvable(Pool *pool, Id id) {
1819 if (!id || id >= pool->nsolvables)
1821 s = solv_calloc(1, sizeof(*s));
1827 return pool_solvid2str($self->pool, $self->id);
1829 const char *lookup_str(Id keyname) {
1830 return pool_lookup_str($self->pool, $self->id, keyname);
1832 Id lookup_id(Id keyname) {
1833 return pool_lookup_id($self->pool, $self->id, keyname);
1835 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
1836 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
1838 bool lookup_void(Id keyname) {
1839 return pool_lookup_void($self->pool, $self->id, keyname);
1841 %newobject lookup_checksum;
1842 Chksum *lookup_checksum(Id keyname) {
1844 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
1845 return solv_chksum_create_from_bin(type, b);
1847 Queue lookup_idarray(Id keyname, Id marker = -1) {
1848 Solvable *s = $self->pool->solvables + $self->id;
1851 if (marker == -1 || marker == 1) {
1852 if (keyname == SOLVABLE_PROVIDES)
1853 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
1854 else if (keyname == SOLVABLE_REQUIRES)
1855 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
1859 solvable_lookup_deparray(s, keyname, &r, marker);
1862 %typemap(out) Queue lookup_deparray Queue2Array(Dep *, 1, new_Dep(arg1->pool, id));
1863 %newobject lookup_deparray;
1864 Queue lookup_deparray(Id keyname, Id marker = -1) {
1865 Solvable *s = $self->pool->solvables + $self->id;
1868 if (marker == -1 || marker == 1) {
1869 if (keyname == SOLVABLE_PROVIDES)
1870 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
1871 else if (keyname == SOLVABLE_REQUIRES)
1872 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
1876 solvable_lookup_deparray(s, keyname, &r, marker);
1879 const char *lookup_location(unsigned int *OUTPUT) {
1880 return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT);
1883 %rename("installable?") installable;
1885 bool installable() {
1886 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
1889 %rename("isinstalled?") isinstalled;
1891 bool isinstalled() {
1892 Pool *pool = $self->pool;
1893 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
1898 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
1899 Pool *pool = xs->pool;
1900 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
1902 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
1903 Pool *pool = xs->pool;
1904 return pool_id2str(pool, pool->solvables[xs->id].name);
1909 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
1910 xs->pool->solvables[xs->id].name = nameid;
1912 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
1913 return xs->pool->solvables[xs->id].name;
1918 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
1919 Pool *pool = xs->pool;
1920 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
1922 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
1923 Pool *pool = xs->pool;
1924 return pool_id2str(pool, pool->solvables[xs->id].evr);
1929 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
1930 xs->pool->solvables[xs->id].evr = evrid;
1932 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
1933 return xs->pool->solvables[xs->id].evr;
1938 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
1939 Pool *pool = xs->pool;
1940 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
1942 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
1943 Pool *pool = xs->pool;
1944 return pool_id2str(pool, pool->solvables[xs->id].arch);
1949 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
1950 xs->pool->solvables[xs->id].arch = archid;
1952 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
1953 return xs->pool->solvables[xs->id].arch;
1958 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
1959 Pool *pool = xs->pool;
1960 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
1962 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
1963 Pool *pool = xs->pool;
1964 return pool_id2str(pool, pool->solvables[xs->id].vendor);
1969 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
1970 xs->pool->solvables[xs->id].vendor = vendorid;
1972 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
1973 return xs->pool->solvables[xs->id].vendor;
1978 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
1979 return xs->pool->solvables[xs->id].repo;
1983 void add_provides(Dep *dep, Id marker = -1) {
1984 Solvable *s = $self->pool->solvables + $self->id;
1985 if (marker == -1 || marker == 1)
1986 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
1987 s->provides = repo_addid_dep(s->repo, s->provides, dep->id, marker);
1989 void add_providesid(Id id, Id marker = -1) {
1990 Solvable *s = $self->pool->solvables + $self->id;
1991 if (marker == -1 || marker == 1)
1992 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
1993 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
1995 void add_obsoletes(Dep *dep) {
1996 Solvable *s = $self->pool->solvables + $self->id;
1997 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, dep->id, 0);
1999 void add_obsoletesid(Id id) {
2000 Solvable *s = $self->pool->solvables + $self->id;
2001 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
2003 void add_conflicts(Dep *dep) {
2004 Solvable *s = $self->pool->solvables + $self->id;
2005 s->conflicts = repo_addid_dep(s->repo, s->conflicts, dep->id, 0);
2007 void add_conflictsid(Id id) {
2008 Solvable *s = $self->pool->solvables + $self->id;
2009 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2011 void add_requires(Dep *dep, Id marker = -1) {
2012 Solvable *s = $self->pool->solvables + $self->id;
2013 if (marker == -1 || marker == 1)
2014 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2015 s->requires = repo_addid_dep(s->repo, s->requires, dep->id, marker);
2017 void add_requiresid(Id id, Id marker = -1) {
2018 Solvable *s = $self->pool->solvables + $self->id;
2019 if (marker == -1 || marker == 1)
2020 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2021 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
2023 void add_recommends(Dep *dep) {
2024 Solvable *s = $self->pool->solvables + $self->id;
2025 s->recommends = repo_addid_dep(s->repo, s->recommends, dep->id, 0);
2027 void add_recommendsid(Id id) {
2028 Solvable *s = $self->pool->solvables + $self->id;
2029 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
2031 void add_suggests(Dep *dep) {
2032 Solvable *s = $self->pool->solvables + $self->id;
2033 s->suggests = repo_addid_dep(s->repo, s->suggests, dep->id, 0);
2035 void add_suggestsid(Id id) {
2036 Solvable *s = $self->pool->solvables + $self->id;
2037 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
2039 void add_supplements(Dep *dep) {
2040 Solvable *s = $self->pool->solvables + $self->id;
2041 s->supplements = repo_addid_dep(s->repo, s->supplements, dep->id, 0);
2043 void add_supplementsid(Id id) {
2044 Solvable *s = $self->pool->solvables + $self->id;
2045 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
2047 void add_enhances(Dep *dep) {
2048 Solvable *s = $self->pool->solvables + $self->id;
2049 s->enhances = repo_addid_dep(s->repo, s->enhances, dep->id, 0);
2051 void add_enhancesid(Id id) {
2052 Solvable *s = $self->pool->solvables + $self->id;
2053 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
2056 bool __eq__(XSolvable *s) {
2057 return $self->pool == s->pool && $self->id == s->id;
2059 bool __ne__(XSolvable *s) {
2060 return !XSolvable___eq__($self, s);
2062 #if defined(SWIGPERL)
2063 %rename("str") __str__;
2065 const char *__str__() {
2066 return pool_solvid2str($self->pool, $self->id);
2068 %newobject __repr__;
2069 const char *__repr__() {
2071 sprintf(buf, "<Solvable #%d ", $self->id);
2072 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
2077 Problem(Solver *solv, Id id) {
2079 p = solv_calloc(1, sizeof(*p));
2084 %newobject findproblemrule;
2085 XRule *findproblemrule() {
2086 Id r = solver_findproblemrule($self->solv, $self->id);
2087 return new_XRule($self->solv, r);
2089 %newobject findallproblemrules;
2090 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
2091 Queue findallproblemrules(int unfiltered=0) {
2092 Solver *solv = $self->solv;
2097 solver_findallproblemrules(solv, $self->id, &q);
2100 for (i = j = 0; i < q.count; i++)
2102 SolverRuleinfo rclass;
2103 probr = q.elements[i];
2104 rclass = solver_ruleclass(solv, probr);
2105 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
2107 q.elements[j++] = probr;
2110 queue_truncate(&q, j);
2114 int solution_count() {
2115 return solver_solution_count($self->solv, $self->id);
2117 %newobject solutions;
2118 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
2123 cnt = solver_solution_count($self->solv, $self->id);
2124 for (i = 1; i <= cnt; i++)
2131 Solution(Problem *p, Id id) {
2133 s = solv_calloc(1, sizeof(*s));
2135 s->problemid = p->id;
2139 int element_count() {
2140 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2143 %newobject elements;
2144 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
2145 Queue elements(bool expandreplaces=0) {
2149 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2150 for (i = 1; i <= cnt; i++)
2153 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
2155 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
2161 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
2162 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
2164 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
2165 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2166 queue_push2(&q, p, rp);
2168 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
2169 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2170 queue_push2(&q, p, rp);
2172 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
2173 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2174 queue_push2(&q, p, rp);
2179 queue_push2(&q, i, type);
2180 queue_push2(&q, p, rp);
2186 %extend Solutionelement {
2187 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
2189 e = solv_calloc(1, sizeof(*e));
2191 e->problemid = problemid;
2202 if (p == SOLVER_SOLUTION_ERASE)
2207 else if (p == SOLVER_SOLUTION_REPLACE)
2212 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
2213 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);
2214 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
2215 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);
2216 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2217 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);
2218 return solver_solutionelement2str($self->solv, p, rp);
2220 %newobject replaceelements;
2221 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
2222 Queue replaceelements() {
2227 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2230 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2231 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
2232 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2233 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
2234 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2235 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
2236 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2238 queue_push(&q, $self->type);
2241 int illegalreplace() {
2242 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2244 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2246 %newobject solvable;
2247 XSolvable * const solvable;
2248 %newobject replacement;
2249 XSolvable * const replacement;
2252 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
2253 return new_XSolvable(e->solv->pool, e->p);
2255 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
2256 return new_XSolvable(e->solv->pool, e->rp);
2258 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
2259 if (e->type != SOLVER_SOLUTION_JOB)
2261 return (e->p - 1) / 2;
2266 Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
2267 if ($self->type == SOLVER_SOLUTION_JOB)
2268 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
2269 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE)
2270 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->p);
2271 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2272 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->rp);
2273 if ($self->type == SOLVER_SOLUTION_ERASE)
2274 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE|extraflags, $self->p);
2280 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
2281 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
2282 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
2283 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2284 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2285 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2286 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2287 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2288 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2289 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2290 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2291 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2292 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2293 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2294 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2295 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2296 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2297 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2298 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2300 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2301 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2302 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2303 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2304 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2305 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2306 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2307 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2309 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2310 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2311 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2313 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2314 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2315 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2316 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2317 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2318 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2319 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2320 static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
2321 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2327 int set_flag(int flag, int value) {
2328 return solver_set_flag($self, flag, value);
2330 int get_flag(int flag) {
2331 return solver_get_flag($self, flag);
2333 #if defined(SWIGPYTHON)
2335 def solve(self, jobs):
2337 for job in jobs: j += [job.how, job.what]
2338 return self.solve_helper(j)
2341 #if defined(SWIGPERL)
2343 sub solv::Solver::solve {
2344 my ($self, $jobs) = @_;
2345 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2346 return $self->solve_helper(\@j);
2350 #if defined(SWIGRUBY)
2353 "class Solv::Solver\n"
2354 " def solve(jobs)\n"
2356 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2357 " solve_helper(jl)\n"
2363 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2364 %newobject solve_helper;
2365 Queue solve_helper(Queue jobs) {
2369 solver_solve($self, &jobs);
2370 cnt = solver_problem_count($self);
2371 for (i = 1; i <= cnt; i++)
2375 %newobject transaction;
2376 Transaction *transaction() {
2377 return solver_create_transaction($self);
2381 %extend Transaction {
2382 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2383 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2384 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2385 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2386 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2387 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2388 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2389 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2390 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2391 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2392 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2393 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2394 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2395 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2396 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2397 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2398 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2399 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2400 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2401 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2402 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2403 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2404 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2405 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2406 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2407 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2408 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2410 transaction_free($self);
2413 %rename("isempty?") isempty;
2416 return $self->steps.count == 0;
2419 %newobject othersolvable;
2420 XSolvable *othersolvable(XSolvable *s) {
2421 Id op = transaction_obs_pkg($self, s->id);
2422 return new_XSolvable($self->pool, op);
2425 %newobject allothersolvables;
2426 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2427 Queue allothersolvables(XSolvable *s) {
2430 transaction_all_obs_pkgs($self, s->id, &q);
2434 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2435 %newobject classify;
2436 Queue classify(int mode = 0) {
2439 transaction_classify($self, mode, &q);
2443 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2444 %newobject newpackages;
2445 Queue newpackages() {
2449 cut = transaction_installedresult(self, &q);
2450 queue_truncate(&q, cut);
2454 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2455 %newobject keptpackages;
2456 Queue keptpackages() {
2460 cut = transaction_installedresult(self, &q);
2462 queue_deleten(&q, 0, cut);
2466 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2470 queue_init_clone(&q, &$self->steps);
2474 int steptype(XSolvable *s, int mode) {
2475 return transaction_type($self, s->id, mode);
2477 int calc_installsizechange() {
2478 return transaction_calc_installsizechange($self);
2480 void order(int flags) {
2481 transaction_order($self, flags);
2485 %extend TransactionClass {
2486 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2487 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2488 cl->transaction = trans;
2492 cl->fromid = fromid;
2496 %newobject solvables;
2497 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2501 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2507 XRule(Solver *solv, Id id) {
2510 XRule *xr = solv_calloc(1, sizeof(*xr));
2516 Id type, source, target, dep;
2517 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2518 return new_Ruleinfo($self, type, source, target, dep);
2520 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2521 %newobject allinfos;
2525 solver_allruleinfos($self->solv, $self->id, &q);
2529 bool __eq__(XRule *xr) {
2530 return $self->solv == xr->solv && $self->id == xr->id;
2532 bool __ne__(XRule *xr) {
2533 return !XRule___eq__($self, xr);
2535 %newobject __repr__;
2536 const char *__repr__() {
2538 sprintf(buf, "<Rule #%d>", $self->id);
2539 return solv_strdup(buf);
2544 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2545 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2549 ri->source = source;
2550 ri->target = target;
2554 XSolvable * const solvable;
2555 XSolvable * const othersolvable;
2557 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2558 return new_XSolvable(ri->solv->pool, ri->source);
2560 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2561 return new_XSolvable(ri->solv->pool, ri->target);
2564 const char *problemstr() {
2565 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2570 XRepodata(Repo *repo, Id id) {
2571 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2577 return repodata_new_handle(repo_id2repodata($self->repo, $self->id));
2579 void set_id(Id solvid, Id keyname, Id id) {
2580 repodata_set_id(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2582 void set_str(Id solvid, Id keyname, const char *str) {
2583 repodata_set_str(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2585 void set_poolstr(Id solvid, Id keyname, const char *str) {
2586 repodata_set_poolstr(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2588 void add_idarray(Id solvid, Id keyname, Id id) {
2589 repodata_add_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2591 void add_flexarray(Id solvid, Id keyname, Id handle) {
2592 repodata_add_flexarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, handle);
2594 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2595 const unsigned char *buf = solv_chksum_get(chksum, 0);
2597 repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
2599 const char *lookup_str(Id solvid, Id keyname) {
2600 return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
2602 Queue lookup_idarray(Id solvid, Id keyname) {
2605 repodata_lookup_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, &r);
2608 %newobject lookup_checksum;
2609 Chksum *lookup_checksum(Id solvid, Id keyname) {
2611 const unsigned char *b = repodata_lookup_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, &type);
2612 return solv_chksum_create_from_bin(type, b);
2614 void internalize() {
2615 repodata_internalize(repo_id2repodata($self->repo, $self->id));
2617 void create_stubs() {
2618 repodata_create_stubs(repo_id2repodata($self->repo, $self->id));
2620 void write(FILE *fp) {
2621 repodata_write(repo_id2repodata($self->repo, $self->id), fp);
2623 bool add_solv(FILE *fp, int flags = 0) {
2624 Repodata *data = repo_id2repodata($self->repo, $self->id);
2625 int r, oldstate = data->state;
2626 data->state = REPODATA_LOADING;
2627 r = repo_add_solv(data->repo, fp, flags | REPO_USE_LOADING);
2628 if (r || data->state == REPODATA_LOADING)
2629 data->state = oldstate;
2632 void extend_to_repo() {
2633 Repodata *data = repo_id2repodata($self->repo, $self->id);
2634 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2636 bool __eq__(XRepodata *xr) {
2637 return $self->repo == xr->repo && $self->id == xr->id;
2639 bool __ne__(XRepodata *xr) {
2640 return !XRepodata___eq__($self, xr);
2642 %newobject __repr__;
2643 const char *__repr__() {
2645 sprintf(buf, "<Repodata #%d>", $self->id);
2646 return solv_strdup(buf);