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/types.h>
340 /* argh, swig undefs bool for perl */
346 #include "poolarch.h"
349 #include "solverdebug.h"
350 #include "repo_solv.h"
352 #include "selection.h"
354 #include "repo_write.h"
356 #include "repo_rpmdb.h"
359 #include "repo_deb.h"
362 #include "repo_rpmmd.h"
363 #include "repo_updateinfoxml.h"
364 #include "repo_deltainfoxml.h"
365 #include "repo_repomdxml.h"
367 #ifdef ENABLE_SUSEREPO
368 #include "repo_products.h"
369 #include "repo_susetags.h"
370 #include "repo_content.h"
372 #ifdef ENABLE_MDKREPO
373 #include "repo_mdk.h"
375 #ifdef ENABLE_ARCHREPO
376 #include "repo_arch.h"
378 #include "solv_xfopen.h"
380 /* for old ruby versions */
382 #define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
385 #define RARRAY_LEN(ary) (RARRAY(ary)->len)
388 #define SOLVER_SOLUTION_ERASE -100
389 #define SOLVER_SOLUTION_REPLACE -101
390 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
391 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
392 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
394 typedef struct chksum Chksum;
395 typedef void *AppObjectPtr;
420 } Pool_solvable_iterator;
425 } Pool_repo_iterator;
430 } Repo_solvable_iterator;
470 Transaction *transaction;
484 typedef Dataiterator Datamatch;
489 %mixin Dataiterator "Enumerable";
490 %mixin Pool_solvable_iterator "Enumerable";
491 %mixin Pool_repo_iterator "Enumerable";
492 %mixin Repo_solvable_iterator "Enumerable";
500 %constant Id SOLVID_META;
501 %constant Id SOLVID_POS;
503 %constant int REL_EQ;
504 %constant int REL_GT;
505 %constant int REL_LT;
506 %constant int REL_ARCH;
538 # put before pool/repo so we can access the constructor
539 %nodefaultdtor Dataiterator;
540 typedef struct {} Dataiterator;
541 typedef struct {} Pool_solvable_iterator;
542 typedef struct {} Pool_repo_iterator;
543 typedef struct {} Repo_solvable_iterator;
545 %nodefaultctor Datamatch;
546 %nodefaultdtor Datamatch;
553 %nodefaultctor Datapos;
567 AppObjectPtr appdata;
574 const char * const name;
577 int const nsolvables;
578 AppObjectPtr appdata;
581 %nodefaultctor Solver;
582 %nodefaultdtor Solver;
590 %rename(xfopen) solv_xfopen;
591 %rename(xfopen_fd) solv_xfopen_fd;
592 %rename(xfopen_dup) solv_xfopen_dup;
593 %rename(xfclose) solv_xfclose;
594 %rename(xfileno) solv_xfileno;
596 FILE *solv_xfopen(const char *fn, const char *mode = 0);
597 FILE *solv_xfopen_fd(const char *fn, int fd, const char *mode = 0);
598 FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode = 0);
599 int solv_xfclose(FILE *fp);
600 int solv_xfileno(FILE *fp);
603 SWIGINTERN int solv_xfclose(FILE *fp) {
606 SWIGINTERN int solv_xfileno(FILE *fp) {
609 SWIGINTERN FILE *solv_xfopen_dup(const char *fn, int fd, const char *mode) {
611 return fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
634 %nodefaultctor Transaction;
635 %nodefaultdtor Transaction;
641 Transaction * const transaction;
650 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
651 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
652 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
653 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
654 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
655 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
656 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
657 static const Id SOLVER_NOOP = SOLVER_NOOP;
658 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
659 static const Id SOLVER_ERASE = SOLVER_ERASE;
660 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
661 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
662 static const Id SOLVER_NOOBSOLETES = SOLVER_NOOBSOLETES;
663 static const Id SOLVER_LOCK = SOLVER_LOCK;
664 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
665 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
666 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
667 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
668 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
669 static const Id SOLVER_WEAK = SOLVER_WEAK;
670 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
671 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
672 static const Id SOLVER_SETEV = SOLVER_SETEV;
673 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
674 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
675 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
676 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
677 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
678 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
680 Job(Pool *pool, int how, Id what) {
681 Job *job = solv_calloc(1, sizeof(*job));
688 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
689 %newobject solvables;
691 Pool *pool = $self->pool;
695 how = $self->how & SOLVER_SELECTMASK;
696 if (how == SOLVER_SOLVABLE_ALL)
698 for (p = 2; p < pool->nsolvables; p++)
699 if (pool->solvables[p].repo)
702 else if (how == SOLVER_SOLVABLE_REPO)
704 Repo *repo = pool_id2repo(pool, $self->what);
707 FOR_REPO_SOLVABLES(repo, p, s)
712 FOR_JOB_SELECT(p, pp, how, $self->what)
718 bool __eq__(Job *j) {
719 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
721 bool __ne__(Job *j) {
722 return !Job___eq__($self, j);
724 #if defined(SWIGPERL)
725 %rename("str") __str__;
727 const char *__str__() {
728 return pool_job2str($self->pool, $self->how, $self->what, 0);
730 const char *__repr__() {
731 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
732 return pool_tmpjoin($self->pool, "<Job ", str, ">");
737 static const Id SELECTION_NAME = SELECTION_NAME;
738 static const Id SELECTION_PROVIDES = SELECTION_PROVIDES;
739 static const Id SELECTION_FILELIST = SELECTION_FILELIST;
740 static const Id SELECTION_GLOB = SELECTION_GLOB;
741 static const Id SELECTION_NOCASE = SELECTION_NOCASE;
742 static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
743 static const Id SELECTION_FLAT = SELECTION_FLAT;
745 Selection(Pool *pool) {
747 s = solv_calloc(1, sizeof(*s));
753 queue_free(&$self->q);
759 void make(const char *name, int flags) {
760 $self->flags = selection_make($self->pool, &$self->q, name, flags);
763 %rename("isempty?") isempty;
766 return $self->q.count == 0;
768 void limit(Selection *lsel) {
769 if ($self->pool != lsel->pool)
770 queue_empty(&$self->q);
772 selection_limit($self->pool, &$self->q, &lsel->q);
774 void add(Selection *lsel) {
775 if ($self->pool == lsel->pool)
777 selection_add($self->pool, &$self->q, &lsel->q);
778 $self->flags |= lsel->flags;
781 void addsimple(Id how, Id what) {
782 queue_push2(&$self->q, how, what);
784 %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
786 Queue jobs(int flags) {
789 queue_init_clone(&q, &$self->q);
790 for (i = 0; i < q.count; i += 2)
791 q.elements[i] |= flags;
795 #if defined(SWIGPERL)
796 %rename("str") __str__;
798 const char *__str__() {
801 s = pool_tmpjoin($self->pool, 0, 0, 0);
802 for (i = 0; i < $self->q.count; i += 2)
803 s = pool_tmpappend($self->pool, s, " | ", solver_select2str($self->pool, $self->q.elements[i] & SOLVER_SELECTMASK, $self->q.elements[i + 1]));
804 return *s ? s + 3 : s;
810 return (Chksum *)solv_chksum_create(type);
812 Chksum(Id type, const char *hex) {
813 unsigned char buf[64];
814 int l = solv_chksum_len(type);
817 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
819 return (Chksum *)solv_chksum_create_from_bin(type, buf);
822 solv_chksum_free($self, 0);
826 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
827 return solv_chksum_get_type(chksum);
830 void add(const char *str) {
831 solv_chksum_add($self, str, strlen((char *)str));
833 void add_fp(FILE *fp) {
836 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
837 solv_chksum_add($self, buf, l);
838 rewind(fp); /* convenience */
840 void add_fd(int fd) {
843 while ((l = read(fd, buf, sizeof(buf))) > 0)
844 solv_chksum_add($self, buf, l);
845 lseek(fd, 0, 0); /* convenience */
847 void add_stat(const char *filename) {
849 if (stat(filename, &stb))
850 memset(&stb, 0, sizeof(stb));
851 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
852 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
853 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
854 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
858 const unsigned char *b;
859 b = solv_chksum_get($self, &l);
860 return cdata_void((void *)b, l);
865 const unsigned char *b;
868 b = solv_chksum_get($self, &l);
869 ret = solv_malloc(2 * l + 1);
870 solv_bin2hex(b, l, ret);
874 bool __eq__(Chksum *chk) {
876 const unsigned char *b, *bo;
879 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
881 b = solv_chksum_get($self, &l);
882 bo = solv_chksum_get(chk, 0);
883 return memcmp(b, bo, l) == 0;
885 bool __ne__(Chksum *chk) {
886 return !Chksum___eq__($self, chk);
888 #if defined(SWIGRUBY)
889 %rename("to_s") __str__;
890 %rename("inspect") __repr__;
892 #if defined(SWIGPERL)
893 %rename("str") __str__;
896 const char *__str__() {
899 if (solv_chksum_isfinished($self))
900 h = Chksum_hex($self);
901 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
902 solv_free((void *)h);
906 const char *__repr__() {
907 const char *h = Chksum___str__($self);
908 const char *str = solv_dupjoin("<Chksum ", h, ">");
909 solv_free((void *)h);
916 Pool *pool = pool_create();
921 void set_debuglevel(int level) {
922 pool_setdebuglevel($self, level);
924 int set_flag(int flag, int value) {
925 return pool_set_flag($self, flag, value);
927 int get_flag(int flag) {
928 return pool_get_flag($self, flag);
930 void set_rootdir(const char *rootdir) {
931 pool_set_rootdir($self, rootdir);
933 const char *get_rootdir(int flag) {
934 return pool_get_rootdir($self);
936 #if defined(SWIGPYTHON)
938 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
939 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
940 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
941 PyObject *result = PyEval_CallObject((PyObject *)d, args);
946 return 0; /* exception */
947 ecode = SWIG_AsVal_int(result, &vresult);
949 return SWIG_IsOK(ecode) ? vresult : 0;
952 void set_loadcallback(PyObject *callable) {
953 if ($self->loadcallback == loadcallback) {
954 PyObject *obj = $self->loadcallbackdata;
960 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
963 #if defined(SWIGPERL)
965 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
969 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
974 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
976 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
986 void set_loadcallback(SV *callable) {
987 if ($self->loadcallback == loadcallback)
988 SvREFCNT_dec($self->loadcallbackdata);
990 SvREFCNT_inc(callable);
991 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
995 #if defined(SWIGRUBY)
997 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
998 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
999 VALUE callable = (VALUE)d;
1000 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
1001 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
1002 return res == Qtrue;
1004 SWIGINTERN void mark_Pool(void *ptr) {
1006 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
1007 VALUE callable = (VALUE)pool->loadcallbackdata;
1008 rb_gc_mark(callable);
1012 %typemap(in, numinputs=0) VALUE callable {
1013 $1 = rb_block_given_p() ? rb_block_proc() : 0;
1015 void set_loadcallback(VALUE callable) {
1016 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
1021 Pool_set_loadcallback($self, 0);
1024 Id str2id(const char *str, bool create=1) {
1025 return pool_str2id($self, str, create);
1027 Dep *Dep(const char *str, bool create=1) {
1028 Id id = pool_str2id($self, str, create);
1029 return new_Dep($self, id);
1031 const char *id2str(Id id) {
1032 return pool_id2str($self, id);
1034 const char *dep2str(Id id) {
1035 return pool_dep2str($self, id);
1037 Id rel2id(Id name, Id evr, int flags, bool create=1) {
1038 return pool_rel2id($self, name, evr, flags, create);
1040 Id id2langid(Id id, const char *lang, bool create=1) {
1041 return pool_id2langid($self, id, lang, create);
1043 void setarch(const char *arch) {
1044 pool_setarch($self, arch);
1046 Repo *add_repo(const char *name) {
1047 return repo_create($self, name);
1049 const char *lookup_str(Id entry, Id keyname) {
1050 return pool_lookup_str($self, entry, keyname);
1052 Id lookup_id(Id entry, Id keyname) {
1053 return pool_lookup_id($self, entry, keyname);
1055 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
1056 return pool_lookup_num($self, entry, keyname, notfound);
1058 bool lookup_void(Id entry, Id keyname) {
1059 return pool_lookup_void($self, entry, keyname);
1061 %newobject lookup_checksum;
1062 Chksum *lookup_checksum(Id entry, Id keyname) {
1064 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
1065 return solv_chksum_create_from_bin(type, b);
1068 %newobject Dataiterator;
1069 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1070 return new_Dataiterator($self, 0, p, key, match, flags);
1072 const char *solvid2str(Id solvid) {
1073 return pool_solvid2str($self, solvid);
1075 void addfileprovides() {
1076 pool_addfileprovides($self);
1078 Queue addfileprovides_queue() {
1081 pool_addfileprovides_queue($self, &r, 0);
1084 void createwhatprovides() {
1085 pool_createwhatprovides($self);
1088 XSolvable *id2solvable(Id id) {
1089 return new_XSolvable($self, id);
1091 %newobject solvables;
1092 Pool_solvable_iterator * const solvables;
1094 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
1095 return new_Pool_solvable_iterator(pool);
1098 %newobject solvables_iter;
1099 Pool_solvable_iterator * solvables_iter() {
1100 return new_Pool_solvable_iterator($self);
1103 Repo *id2repo(Id id) {
1104 if (id < 1 || id >= $self->nrepos)
1106 return pool_id2repo($self, id);
1109 Pool_repo_iterator * const repos;
1111 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
1112 return new_Pool_repo_iterator(pool);
1115 %newobject repos_iter;
1116 Pool_repo_iterator * repos_iter() {
1117 return new_Pool_repo_iterator($self);
1122 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
1123 pool_set_installed(pool, installed);
1125 Repo *Pool_installed_get(Pool *pool) {
1126 return pool->installed;
1130 Queue matchprovidingids(const char *match, int flags) {
1136 for (id = 1; id < pool->ss.nstrings; id++)
1137 if (pool->whatprovides[id])
1141 if (!datamatcher_init(&ma, match, flags)) {
1142 for (id = 1; id < pool->ss.nstrings; id++)
1143 if (pool->whatprovides[id] && datamatcher_match(&ma, pool_id2str(pool, id)))
1145 datamatcher_free(&ma);
1151 Job *Job(int how, Id what) {
1152 return new_Job($self, how, what);
1155 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1156 %newobject whatprovides;
1157 Queue whatprovides(Id dep) {
1162 FOR_PROVIDES(p, pp, dep)
1167 Id towhatprovides(Queue q) {
1168 return pool_queuetowhatprovides($self, &q);
1172 %rename("isknownarch?") isknownarch;
1174 bool isknownarch(Id id) {
1176 if (!id || id == ID_EMPTY)
1178 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1180 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1187 return solver_create($self);
1190 %newobject Selection;
1191 Selection *Selection() {
1192 return new_Selection($self);
1195 Selection *select(const char *name, int flags) {
1196 Selection *sel = new_Selection($self);
1197 sel->flags = selection_make($self, &sel->q, name, flags);
1203 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1204 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1205 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1206 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1207 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1208 static const int REPO_USE_ROOTDIR = REPO_USE_ROOTDIR;
1209 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1210 #ifdef ENABLE_SUSEREPO
1211 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1214 void free(bool reuseids = 0) {
1215 repo_free($self, reuseids);
1217 void empty(bool reuseids = 0) {
1218 repo_empty($self, reuseids);
1221 %rename("isempty?") isempty;
1224 return !$self->nsolvables;
1226 bool add_solv(const char *name, int flags = 0) {
1227 FILE *fp = fopen(name, "r");
1231 r = repo_add_solv($self, fp, flags);
1235 bool add_solv(FILE *fp, int flags = 0) {
1236 return repo_add_solv($self, fp, flags) == 0;
1239 XSolvable *add_solvable() {
1240 Id solvid = repo_add_solvable($self);
1241 return new_XSolvable($self->pool, solvid);
1245 bool add_rpmdb(Repo *ref, int flags = 0) {
1246 return repo_add_rpmdb($self, ref, flags);
1248 Id add_rpm(const char *name, int flags = 0) {
1249 return repo_add_rpm($self, name, flags);
1253 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1254 return repo_add_rpmmd($self, fp, language, flags);
1256 bool add_repomdxml(FILE *fp, int flags = 0) {
1257 return repo_add_repomdxml($self, fp, flags);
1259 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1260 return repo_add_updateinfoxml($self, fp, flags);
1262 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1263 return repo_add_deltainfoxml($self, fp, flags);
1266 #ifdef ENABLE_DEBIAN
1267 bool add_debdb(int flags = 0) {
1268 return repo_add_debdb($self, flags);
1270 Id add_deb(const char *name, int flags = 0) {
1271 return repo_add_deb($self, name, flags);
1274 #ifdef ENABLE_SUSEREPO
1275 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1276 return repo_add_susetags($self, fp, defvendor, language, flags);
1278 bool add_content(FILE *fp, int flags = 0) {
1279 return repo_add_content($self, fp, flags);
1281 bool add_products(const char *proddir, int flags = 0) {
1282 return repo_add_products($self, proddir, flags);
1285 #ifdef ENABLE_MDKREPO
1286 bool add_mdk(FILE *fp, int flags = 0) {
1287 return repo_add_mdk($self, fp, flags);
1289 bool add_mdk_info(FILE *fp, int flags = 0) {
1290 return repo_add_mdk($self, fp, flags);
1293 #ifdef ENABLE_ARCHREPO
1294 bool add_arch_repo(FILE *fp, int flags = 0) {
1295 return repo_add_arch_repo($self, fp, flags);
1297 Id add_arch_pkg(const char *name, int flags = 0) {
1298 return repo_add_arch_pkg($self, name, flags);
1301 void internalize() {
1302 repo_internalize($self);
1304 const char *lookup_str(Id entry, Id keyname) {
1305 return repo_lookup_str($self, entry, keyname);
1307 Id lookup_id(Id entry, Id keyname) {
1308 return repo_lookup_id($self, entry, keyname);
1310 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1311 return repo_lookup_num($self, entry, keyname, notfound);
1313 void write(FILE *fp) {
1314 repo_write($self, fp);
1316 # HACK, remove if no longer needed!
1317 bool write_first_repodata(FILE *fp) {
1318 int oldnrepodata = $self->nrepodata;
1319 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1320 repo_write($self, fp);
1321 $self->nrepodata = oldnrepodata;
1325 %newobject Dataiterator;
1326 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1327 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1332 SWIGINTERN Id Repo_id_get(Repo *repo) {
1333 return repo->repoid;
1336 Repo_solvable_iterator * const solvables;
1338 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1339 return new_Repo_solvable_iterator(repo);
1342 %newobject solvables_iter;
1343 Repo_solvable_iterator *solvables_iter() {
1344 return new_Repo_solvable_iterator($self);
1347 XRepodata *add_repodata(int flags = 0) {
1348 Repodata *rd = repo_add_repodata($self, flags);
1349 return new_XRepodata($self, rd->repodataid);
1352 void create_stubs() {
1354 if (!$self->nrepodata)
1356 data = repo_id2repodata($self, $self->nrepodata - 1);
1357 if (data->state != REPODATA_STUB)
1358 repodata_create_stubs(data);
1361 %rename("iscontiguous?") iscontiguous;
1363 bool iscontiguous() {
1365 for (i = $self->start; i < $self->end; i++)
1366 if ($self->pool->solvables[i].repo != $self)
1370 XRepodata *first_repodata() {
1373 if ($self->nrepodata < 2)
1375 /* make sure all repodatas but the first are extensions */
1376 data = repo_id2repodata($self, 1);
1377 if (data->loadcallback)
1379 for (i = 2; i < $self->nrepodata; i++)
1381 data = repo_id2repodata($self, i);
1382 if (!data->loadcallback)
1383 return 0; /* oops, not an extension */
1385 return new_XRepodata($self, 1);
1388 bool __eq__(Repo *repo) {
1389 return $self == repo;
1391 bool __ne__(Repo *repo) {
1392 return $self != repo;
1394 #if defined(SWIGPERL)
1395 %rename("str") __str__;
1398 const char *__str__() {
1401 return solv_strdup($self->name);
1402 sprintf(buf, "Repo#%d", $self->repoid);
1403 return solv_strdup(buf);
1405 %newobject __repr__;
1406 const char *__repr__() {
1410 sprintf(buf, "<Repo #%d ", $self->repoid);
1411 return solv_dupjoin(buf, $self->name, ">");
1413 sprintf(buf, "<Repo #%d>", $self->repoid);
1414 return solv_strdup(buf);
1418 %extend Dataiterator {
1419 static const int SEARCH_STRING = SEARCH_STRING;
1420 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1421 static const int SEARCH_GLOB = SEARCH_GLOB;
1422 static const int SEARCH_REGEX = SEARCH_REGEX;
1423 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1424 static const int SEARCH_FILES = SEARCH_FILES;
1425 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1427 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1428 Dataiterator *di = solv_calloc(1, sizeof(*di));
1429 dataiterator_init(di, pool, repo, p, key, match, flags);
1433 dataiterator_free($self);
1436 #if defined(SWIGPYTHON)
1437 %newobject __iter__;
1438 Dataiterator *__iter__() {
1440 ndi = solv_calloc(1, sizeof(*ndi));
1441 dataiterator_init_clone(ndi, $self);
1444 %rename("next") __next__();
1445 %exception __next__ {
1448 PyErr_SetString(PyExc_StopIteration,"no more matches");
1455 perliter(solv::Dataiterator)
1458 %newobject __next__;
1459 Datamatch *__next__() {
1461 if (!dataiterator_step($self)) {
1464 ndi = solv_calloc(1, sizeof(*ndi));
1465 dataiterator_init_clone(ndi, $self);
1471 while ((d = Dataiterator___next__($self)) != 0) {
1472 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1476 void prepend_keyname(Id key) {
1477 dataiterator_prepend_keyname($self, key);
1479 void skip_solvable() {
1480 dataiterator_skip_solvable($self);
1485 Id lookup_id(Id keyname) {
1486 Pool *pool = $self->repo->pool;
1487 Datapos oldpos = pool->pos;
1490 r = pool_lookup_id(pool, SOLVID_POS, keyname);
1494 const char *lookup_str(Id keyname) {
1495 Pool *pool = $self->repo->pool;
1496 Datapos oldpos = pool->pos;
1499 r = pool_lookup_str(pool, SOLVID_POS, keyname);
1503 %newobject lookup_checksum;
1504 Chksum *lookup_checksum(Id keyname) {
1505 Pool *pool = $self->repo->pool;
1506 Datapos oldpos = pool->pos;
1508 const unsigned char *b;
1510 b = pool_lookup_bin_checksum(pool, SOLVID_POS, keyname, &type);
1512 return solv_chksum_create_from_bin(type, b);
1518 dataiterator_free($self);
1521 %newobject solvable;
1522 XSolvable * const solvable;
1524 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1525 return new_XSolvable(di->pool, di->solvid);
1529 return $self->key->name;
1531 const char *key_idstr() {
1532 return pool_id2str($self->pool, $self->key->name);
1535 return $self->key->type;
1537 const char *type_idstr() {
1538 return pool_id2str($self->pool, $self->key->type);
1541 return $self->kv.id;
1543 const char *idstr() {
1544 return pool_id2str($self->pool, $self->kv.id);
1547 return $self->kv.str;
1550 return $self->kv.num;
1553 return $self->kv.num2;
1557 Pool *pool = $self->pool;
1558 Datapos *pos, oldpos = pool->pos;
1559 dataiterator_setpos($self);
1560 pos = solv_calloc(1, sizeof(*pos));
1565 %newobject parentpos;
1566 Datapos *parentpos() {
1567 Pool *pool = $self->pool;
1568 Datapos *pos, oldpos = pool->pos;
1569 dataiterator_setpos_parent($self);
1570 pos = solv_calloc(1, sizeof(*pos));
1576 dataiterator_setpos($self);
1578 void setpos_parent() {
1579 dataiterator_setpos_parent($self);
1583 %extend Pool_solvable_iterator {
1584 Pool_solvable_iterator(Pool *pool) {
1585 Pool_solvable_iterator *s;
1586 s = solv_calloc(1, sizeof(*s));
1590 #if defined(SWIGPYTHON)
1591 %newobject __iter__;
1592 Pool_solvable_iterator *__iter__() {
1593 Pool_solvable_iterator *s;
1594 s = solv_calloc(1, sizeof(*s));
1598 %rename("next") __next__();
1599 %exception __next__ {
1602 PyErr_SetString(PyExc_StopIteration,"no more matches");
1609 perliter(solv::Pool_solvable_iterator)
1611 %newobject __next__;
1612 XSolvable *__next__() {
1613 Pool *pool = $self->pool;
1614 if ($self->id >= pool->nsolvables)
1616 while (++$self->id < pool->nsolvables)
1617 if (pool->solvables[$self->id].repo)
1618 return new_XSolvable(pool, $self->id);
1624 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1625 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1629 %newobject __getitem__;
1630 XSolvable *__getitem__(Id key) {
1631 Pool *pool = $self->pool;
1632 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1633 return new_XSolvable(pool, key);
1637 return $self->pool->nsolvables;
1641 %extend Pool_repo_iterator {
1642 Pool_repo_iterator(Pool *pool) {
1643 Pool_repo_iterator *s;
1644 s = solv_calloc(1, sizeof(*s));
1648 #if defined(SWIGPYTHON)
1649 %newobject __iter__;
1650 Pool_repo_iterator *__iter__() {
1651 Pool_repo_iterator *s;
1652 s = solv_calloc(1, sizeof(*s));
1656 %rename("next") __next__();
1657 %exception __next__ {
1660 PyErr_SetString(PyExc_StopIteration,"no more matches");
1665 %newobject __next__;
1667 Pool *pool = $self->pool;
1668 if ($self->id >= pool->nrepos)
1670 while (++$self->id < pool->nrepos) {
1671 Repo *r = pool_id2repo(pool, $self->id);
1680 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1681 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
1685 Repo *__getitem__(Id key) {
1686 Pool *pool = $self->pool;
1687 if (key > 0 && key < pool->nrepos)
1688 return pool_id2repo(pool, key);
1692 return $self->pool->nrepos;
1696 %extend Repo_solvable_iterator {
1697 Repo_solvable_iterator(Repo *repo) {
1698 Repo_solvable_iterator *s;
1699 s = solv_calloc(1, sizeof(*s));
1703 #if defined(SWIGPYTHON)
1704 %newobject __iter__;
1705 Repo_solvable_iterator *__iter__() {
1706 Repo_solvable_iterator *s;
1707 s = solv_calloc(1, sizeof(*s));
1711 %rename("next") __next__();
1712 %exception __next__ {
1715 PyErr_SetString(PyExc_StopIteration,"no more matches");
1720 %newobject __next__;
1721 XSolvable *__next__() {
1722 Repo *repo = $self->repo;
1723 Pool *pool = repo->pool;
1724 if (repo->start > 0 && $self->id < repo->start)
1725 $self->id = repo->start - 1;
1726 if ($self->id >= repo->end)
1728 while (++$self->id < repo->end)
1729 if (pool->solvables[$self->id].repo == repo)
1730 return new_XSolvable(pool, $self->id);
1736 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1737 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1741 %newobject __getitem__;
1742 XSolvable *__getitem__(Id key) {
1743 Repo *repo = $self->repo;
1744 Pool *pool = repo->pool;
1745 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1746 return new_XSolvable(pool, key);
1750 return $self->repo->pool->nsolvables;
1755 Dep(Pool *pool, Id id) {
1759 s = solv_calloc(1, sizeof(*s));
1765 return pool_dep2str($self->pool, $self->id);
1767 bool __eq__(Dep *s) {
1768 return $self->pool == s->pool && $self->id == s->id;
1770 bool __ne__(Dep *s) {
1771 return !Dep___eq__($self, s);
1773 #if defined(SWIGPERL)
1774 %rename("str") __str__;
1776 const char *__str__() {
1777 return pool_dep2str($self->pool, $self->id);
1779 %newobject __repr__;
1780 const char *__repr__() {
1782 sprintf(buf, "<Id #%d ", $self->id);
1783 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
1788 XSolvable(Pool *pool, Id id) {
1790 if (!id || id >= pool->nsolvables)
1792 s = solv_calloc(1, sizeof(*s));
1798 return pool_solvid2str($self->pool, $self->id);
1800 const char *lookup_str(Id keyname) {
1801 return pool_lookup_str($self->pool, $self->id, keyname);
1803 Id lookup_id(Id keyname) {
1804 return pool_lookup_id($self->pool, $self->id, keyname);
1806 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
1807 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
1809 bool lookup_void(Id keyname) {
1810 return pool_lookup_void($self->pool, $self->id, keyname);
1812 %newobject lookup_checksum;
1813 Chksum *lookup_checksum(Id keyname) {
1815 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
1816 return solv_chksum_create_from_bin(type, b);
1818 Queue lookup_idarray(Id keyname, Id marker = 1) {
1819 Solvable *s = $self->pool->solvables + $self->id;
1823 if (keyname == SOLVABLE_PROVIDES)
1824 marker = -SOLVABLE_FILEMARKER;
1825 else if (keyname == SOLVABLE_REQUIRES)
1826 marker = -SOLVABLE_PREREQMARKER;
1830 solvable_lookup_deparray(s, keyname, &r, marker);
1833 %typemap(out) Queue lookup_deparray Queue2Array(Dep *, 1, new_Dep(arg1->pool, id));
1834 %newobject lookup_deparray;
1835 Queue lookup_deparray(Id keyname, Id marker = 1) {
1836 Solvable *s = $self->pool->solvables + $self->id;
1840 if (keyname == SOLVABLE_PROVIDES)
1841 marker = -SOLVABLE_FILEMARKER;
1842 else if (keyname == SOLVABLE_REQUIRES)
1843 marker = -SOLVABLE_PREREQMARKER;
1847 solvable_lookup_deparray(s, keyname, &r, marker);
1850 const char *lookup_location(unsigned int *OUTPUT) {
1851 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
1854 %rename("installable?") installable;
1856 bool installable() {
1857 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
1860 %rename("isinstalled?") isinstalled;
1862 bool isinstalled() {
1863 Pool *pool = $self->pool;
1864 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
1869 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
1870 Pool *pool = xs->pool;
1871 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
1873 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
1874 Pool *pool = xs->pool;
1875 return pool_id2str(pool, pool->solvables[xs->id].name);
1880 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
1881 xs->pool->solvables[xs->id].name = nameid;
1883 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
1884 return xs->pool->solvables[xs->id].name;
1889 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
1890 Pool *pool = xs->pool;
1891 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
1893 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
1894 Pool *pool = xs->pool;
1895 return pool_id2str(pool, pool->solvables[xs->id].evr);
1900 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
1901 xs->pool->solvables[xs->id].evr = evrid;
1903 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
1904 return xs->pool->solvables[xs->id].evr;
1909 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
1910 Pool *pool = xs->pool;
1911 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
1913 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
1914 Pool *pool = xs->pool;
1915 return pool_id2str(pool, pool->solvables[xs->id].arch);
1920 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
1921 xs->pool->solvables[xs->id].arch = archid;
1923 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
1924 return xs->pool->solvables[xs->id].arch;
1929 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
1930 Pool *pool = xs->pool;
1931 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
1933 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
1934 Pool *pool = xs->pool;
1935 return pool_id2str(pool, pool->solvables[xs->id].vendor);
1940 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
1941 xs->pool->solvables[xs->id].vendor = vendorid;
1943 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
1944 return xs->pool->solvables[xs->id].vendor;
1949 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
1950 return xs->pool->solvables[xs->id].repo;
1954 void add_provides(Dep *dep, Id marker = -SOLVABLE_FILEMARKER) {
1955 Solvable *s = $self->pool->solvables + $self->id;
1956 s->provides = repo_addid_dep(s->repo, s->provides, dep->id, marker);
1958 void add_providesid(Id id, Id marker = -SOLVABLE_FILEMARKER) {
1959 Solvable *s = $self->pool->solvables + $self->id;
1960 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
1962 void add_obsoletes(Dep *dep) {
1963 Solvable *s = $self->pool->solvables + $self->id;
1964 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, dep->id, 0);
1966 void add_obsoletesid(Id id) {
1967 Solvable *s = $self->pool->solvables + $self->id;
1968 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
1970 void add_conflicts(Dep *dep) {
1971 Solvable *s = $self->pool->solvables + $self->id;
1972 s->conflicts = repo_addid_dep(s->repo, s->conflicts, dep->id, 0);
1974 void add_conflictsid(Id id) {
1975 Solvable *s = $self->pool->solvables + $self->id;
1976 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
1978 void add_requires(Dep *dep, Id marker = -SOLVABLE_PREREQMARKER) {
1979 Solvable *s = $self->pool->solvables + $self->id;
1980 s->requires = repo_addid_dep(s->repo, s->requires, dep->id, marker);
1982 void add_requiresid(Id id, Id marker = -SOLVABLE_PREREQMARKER) {
1983 Solvable *s = $self->pool->solvables + $self->id;
1984 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
1986 void add_recommends(Dep *dep) {
1987 Solvable *s = $self->pool->solvables + $self->id;
1988 s->recommends = repo_addid_dep(s->repo, s->recommends, dep->id, 0);
1990 void add_recommendsid(Id id) {
1991 Solvable *s = $self->pool->solvables + $self->id;
1992 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
1994 void add_suggests(Dep *dep) {
1995 Solvable *s = $self->pool->solvables + $self->id;
1996 s->suggests = repo_addid_dep(s->repo, s->suggests, dep->id, 0);
1998 void add_suggestsid(Id id) {
1999 Solvable *s = $self->pool->solvables + $self->id;
2000 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
2002 void add_supplements(Dep *dep) {
2003 Solvable *s = $self->pool->solvables + $self->id;
2004 s->supplements = repo_addid_dep(s->repo, s->supplements, dep->id, 0);
2006 void add_supplementsid(Id id) {
2007 Solvable *s = $self->pool->solvables + $self->id;
2008 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
2010 void add_enhances(Dep *dep) {
2011 Solvable *s = $self->pool->solvables + $self->id;
2012 s->enhances = repo_addid_dep(s->repo, s->enhances, dep->id, 0);
2014 void add_enhancesid(Id id) {
2015 Solvable *s = $self->pool->solvables + $self->id;
2016 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
2019 bool __eq__(XSolvable *s) {
2020 return $self->pool == s->pool && $self->id == s->id;
2022 bool __ne__(XSolvable *s) {
2023 return !XSolvable___eq__($self, s);
2025 #if defined(SWIGPERL)
2026 %rename("str") __str__;
2028 const char *__str__() {
2029 return pool_solvid2str($self->pool, $self->id);
2031 %newobject __repr__;
2032 const char *__repr__() {
2034 sprintf(buf, "<Solvable #%d ", $self->id);
2035 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
2040 Problem(Solver *solv, Id id) {
2042 p = solv_calloc(1, sizeof(*p));
2047 %newobject findproblemrule;
2048 XRule *findproblemrule() {
2049 Id r = solver_findproblemrule($self->solv, $self->id);
2050 return new_XRule($self->solv, r);
2052 %newobject findallproblemrules;
2053 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
2054 Queue findallproblemrules(int unfiltered=0) {
2055 Solver *solv = $self->solv;
2060 solver_findallproblemrules(solv, $self->id, &q);
2063 for (i = j = 0; i < q.count; i++)
2065 SolverRuleinfo rclass;
2066 probr = q.elements[i];
2067 rclass = solver_ruleclass(solv, probr);
2068 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
2070 q.elements[j++] = probr;
2073 queue_truncate(&q, j);
2077 int solution_count() {
2078 return solver_solution_count($self->solv, $self->id);
2080 %newobject solutions;
2081 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
2086 cnt = solver_solution_count($self->solv, $self->id);
2087 for (i = 1; i <= cnt; i++)
2094 Solution(Problem *p, Id id) {
2096 s = solv_calloc(1, sizeof(*s));
2098 s->problemid = p->id;
2102 int element_count() {
2103 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2106 %newobject elements;
2107 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
2108 Queue elements(bool expandreplaces=0) {
2112 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2113 for (i = 1; i <= cnt; i++)
2116 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
2118 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
2124 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
2125 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
2127 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
2128 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2129 queue_push2(&q, p, rp);
2131 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
2132 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2133 queue_push2(&q, p, rp);
2135 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
2136 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2137 queue_push2(&q, p, rp);
2142 queue_push2(&q, i, type);
2143 queue_push2(&q, p, rp);
2149 %extend Solutionelement {
2150 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
2152 e = solv_calloc(1, sizeof(*e));
2154 e->problemid = problemid;
2165 if (p == SOLVER_SOLUTION_ERASE)
2170 else if (p == SOLVER_SOLUTION_REPLACE)
2175 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
2176 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);
2177 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
2178 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);
2179 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2180 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);
2181 return solver_solutionelement2str($self->solv, p, rp);
2183 %newobject replaceelements;
2184 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
2185 Queue replaceelements() {
2190 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2193 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2194 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
2195 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2196 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
2197 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2198 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
2199 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2201 queue_push(&q, $self->type);
2204 int illegalreplace() {
2205 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2207 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2209 %newobject solvable;
2210 XSolvable * const solvable;
2211 %newobject replacement;
2212 XSolvable * const replacement;
2215 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
2216 return new_XSolvable(e->solv->pool, e->p);
2218 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
2219 return new_XSolvable(e->solv->pool, e->rp);
2221 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
2222 if (e->type != SOLVER_SOLUTION_JOB)
2224 return (e->p - 1) / 2;
2229 Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
2230 if ($self->type == SOLVER_SOLUTION_JOB)
2231 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
2232 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE)
2233 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->p);
2234 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2235 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->rp);
2236 if ($self->type == SOLVER_SOLUTION_ERASE)
2237 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE|extraflags, $self->p);
2243 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
2244 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
2245 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
2246 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2247 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2248 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2249 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2250 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2251 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2252 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2253 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2254 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2255 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2256 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2257 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2258 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2259 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2260 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2261 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2263 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2264 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2265 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2266 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2267 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2268 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2269 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2270 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2272 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2273 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2274 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2276 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2277 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2278 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2279 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2280 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2281 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2282 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2283 static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
2284 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2290 int set_flag(int flag, int value) {
2291 return solver_set_flag($self, flag, value);
2293 int get_flag(int flag) {
2294 return solver_get_flag($self, flag);
2296 #if defined(SWIGPYTHON)
2298 def solve(self, jobs):
2300 for job in jobs: j += [job.how, job.what]
2301 return self.solve_helper(j)
2304 #if defined(SWIGPERL)
2306 sub solv::Solver::solve {
2307 my ($self, $jobs) = @_;
2308 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2309 return $self->solve_helper(\@j);
2313 #if defined(SWIGRUBY)
2316 "class Solv::Solver\n"
2317 " def solve(jobs)\n"
2319 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2320 " solve_helper(jl)\n"
2326 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2327 %newobject solve_helper;
2328 Queue solve_helper(Queue jobs) {
2332 solver_solve($self, &jobs);
2333 cnt = solver_problem_count($self);
2334 for (i = 1; i <= cnt; i++)
2338 %newobject transaction;
2339 Transaction *transaction() {
2340 return solver_create_transaction($self);
2344 %extend Transaction {
2345 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2346 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2347 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2348 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2349 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2350 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2351 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2352 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2353 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2354 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2355 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2356 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2357 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2358 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2359 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2360 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2361 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2362 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2363 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2364 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2365 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2366 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2367 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2368 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2369 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2370 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2371 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2373 transaction_free($self);
2376 %rename("isempty?") isempty;
2379 return $self->steps.count == 0;
2382 %newobject othersolvable;
2383 XSolvable *othersolvable(XSolvable *s) {
2384 Id op = transaction_obs_pkg($self, s->id);
2385 return new_XSolvable($self->pool, op);
2388 %newobject allothersolvables;
2389 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2390 Queue allothersolvables(XSolvable *s) {
2393 transaction_all_obs_pkgs($self, s->id, &q);
2397 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2398 %newobject classify;
2399 Queue classify(int mode = 0) {
2402 transaction_classify($self, mode, &q);
2406 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2407 %newobject newpackages;
2408 Queue newpackages() {
2412 cut = transaction_installedresult(self, &q);
2413 queue_truncate(&q, cut);
2417 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2418 %newobject keptpackages;
2419 Queue keptpackages() {
2423 cut = transaction_installedresult(self, &q);
2425 queue_deleten(&q, 0, cut);
2429 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2433 queue_init_clone(&q, &$self->steps);
2437 int steptype(XSolvable *s, int mode) {
2438 return transaction_type($self, s->id, mode);
2440 int calc_installsizechange() {
2441 return transaction_calc_installsizechange($self);
2443 void order(int flags) {
2444 transaction_order($self, flags);
2448 %extend TransactionClass {
2449 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2450 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2451 cl->transaction = trans;
2455 cl->fromid = fromid;
2459 %newobject solvables;
2460 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2464 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2470 XRule(Solver *solv, Id id) {
2473 XRule *xr = solv_calloc(1, sizeof(*xr));
2479 Id type, source, target, dep;
2480 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2481 return new_Ruleinfo($self, type, source, target, dep);
2483 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2484 %newobject allinfos;
2488 solver_allruleinfos($self->solv, $self->id, &q);
2492 bool __eq__(XRule *xr) {
2493 return $self->solv == xr->solv && $self->id == xr->id;
2495 bool __ne__(XRule *xr) {
2496 return !XRule___eq__($self, xr);
2498 %newobject __repr__;
2499 const char *__repr__() {
2501 sprintf(buf, "<Rule #%d>", $self->id);
2502 return solv_strdup(buf);
2507 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2508 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2512 ri->source = source;
2513 ri->target = target;
2517 XSolvable * const solvable;
2518 XSolvable * const othersolvable;
2520 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2521 return new_XSolvable(ri->solv->pool, ri->source);
2523 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2524 return new_XSolvable(ri->solv->pool, ri->target);
2527 const char *problemstr() {
2528 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2533 XRepodata(Repo *repo, Id id) {
2534 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2540 return repodata_new_handle(repo_id2repodata($self->repo, $self->id));
2542 void set_id(Id solvid, Id keyname, Id id) {
2543 repodata_set_id(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2545 void set_str(Id solvid, Id keyname, const char *str) {
2546 repodata_set_str(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2548 void set_poolstr(Id solvid, Id keyname, const char *str) {
2549 repodata_set_poolstr(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2551 void add_idarray(Id solvid, Id keyname, Id id) {
2552 repodata_add_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2554 void add_flexarray(Id solvid, Id keyname, Id handle) {
2555 repodata_add_flexarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, handle);
2557 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2558 const unsigned char *buf = solv_chksum_get(chksum, 0);
2560 repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
2562 const char *lookup_str(Id solvid, Id keyname) {
2563 return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
2565 Queue lookup_idarray(Id solvid, Id keyname) {
2568 repodata_lookup_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, &r);
2571 %newobject lookup_checksum;
2572 Chksum *lookup_checksum(Id solvid, Id keyname) {
2574 const unsigned char *b = repodata_lookup_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, &type);
2575 return solv_chksum_create_from_bin(type, b);
2577 void internalize() {
2578 repodata_internalize(repo_id2repodata($self->repo, $self->id));
2580 void create_stubs() {
2581 repodata_create_stubs(repo_id2repodata($self->repo, $self->id));
2583 void write(FILE *fp) {
2584 repodata_write(repo_id2repodata($self->repo, $self->id), fp);
2586 bool add_solv(FILE *fp, int flags = 0) {
2587 Repodata *data = repo_id2repodata($self->repo, $self->id);
2588 int r, oldstate = data->state;
2589 data->state = REPODATA_LOADING;
2590 r = repo_add_solv(data->repo, fp, flags | REPO_USE_LOADING);
2591 if (r || data->state == REPODATA_LOADING)
2592 data->state = oldstate;
2595 void extend_to_repo() {
2596 Repodata *data = repo_id2repodata($self->repo, $self->id);
2597 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2599 bool __eq__(XRepodata *xr) {
2600 return $self->repo == xr->repo && $self->id == xr->id;
2602 bool __ne__(XRepodata *xr) {
2603 return !XRepodata___eq__($self, xr);
2605 %newobject __repr__;
2606 const char *__repr__() {
2608 sprintf(buf, "<Repodata #%d>", $self->id);
2609 return solv_strdup(buf);