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;
693 pool_job2solvables($self->pool, &q, $self->how, $self->what);
697 bool __eq__(Job *j) {
698 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
700 bool __ne__(Job *j) {
701 return !Job___eq__($self, j);
703 #if defined(SWIGPERL)
704 %rename("str") __str__;
706 const char *__str__() {
707 return pool_job2str($self->pool, $self->how, $self->what, 0);
709 const char *__repr__() {
710 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
711 return pool_tmpjoin($self->pool, "<Job ", str, ">");
716 static const Id SELECTION_NAME = SELECTION_NAME;
717 static const Id SELECTION_PROVIDES = SELECTION_PROVIDES;
718 static const Id SELECTION_FILELIST = SELECTION_FILELIST;
719 static const Id SELECTION_GLOB = SELECTION_GLOB;
720 static const Id SELECTION_NOCASE = SELECTION_NOCASE;
721 static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
722 static const Id SELECTION_FLAT = SELECTION_FLAT;
724 Selection(Pool *pool) {
726 s = solv_calloc(1, sizeof(*s));
732 queue_free(&$self->q);
738 void make(const char *name, int flags) {
739 $self->flags = selection_make($self->pool, &$self->q, name, flags);
742 %rename("isempty?") isempty;
745 return $self->q.count == 0;
747 void limit(Selection *lsel) {
748 if ($self->pool != lsel->pool)
749 queue_empty(&$self->q);
751 selection_limit($self->pool, &$self->q, &lsel->q);
753 void add(Selection *lsel) {
754 if ($self->pool == lsel->pool)
756 selection_add($self->pool, &$self->q, &lsel->q);
757 $self->flags |= lsel->flags;
760 void addsimple(Id how, Id what) {
761 queue_push2(&$self->q, how, what);
763 %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
765 Queue jobs(int flags) {
768 queue_init_clone(&q, &$self->q);
769 for (i = 0; i < q.count; i += 2)
770 q.elements[i] |= flags;
774 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
775 %newobject solvables;
779 selection_solvables($self->pool, &q, &$self->q);
783 #if defined(SWIGPERL)
784 %rename("str") __str__;
786 const char *__str__() {
789 s = pool_tmpjoin($self->pool, 0, 0, 0);
790 for (i = 0; i < $self->q.count; i += 2)
791 s = pool_tmpappend($self->pool, s, " | ", solver_select2str($self->pool, $self->q.elements[i] & SOLVER_SELECTMASK, $self->q.elements[i + 1]));
792 return *s ? s + 3 : s;
798 return (Chksum *)solv_chksum_create(type);
800 Chksum(Id type, const char *hex) {
801 unsigned char buf[64];
802 int l = solv_chksum_len(type);
805 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
807 return (Chksum *)solv_chksum_create_from_bin(type, buf);
810 solv_chksum_free($self, 0);
814 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
815 return solv_chksum_get_type(chksum);
818 void add(const char *str) {
819 solv_chksum_add($self, str, strlen((char *)str));
821 void add_fp(FILE *fp) {
824 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
825 solv_chksum_add($self, buf, l);
826 rewind(fp); /* convenience */
828 void add_fd(int fd) {
831 while ((l = read(fd, buf, sizeof(buf))) > 0)
832 solv_chksum_add($self, buf, l);
833 lseek(fd, 0, 0); /* convenience */
835 void add_stat(const char *filename) {
837 if (stat(filename, &stb))
838 memset(&stb, 0, sizeof(stb));
839 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
840 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
841 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
842 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
846 const unsigned char *b;
847 b = solv_chksum_get($self, &l);
848 return cdata_void((void *)b, l);
853 const unsigned char *b;
856 b = solv_chksum_get($self, &l);
857 ret = solv_malloc(2 * l + 1);
858 solv_bin2hex(b, l, ret);
862 bool __eq__(Chksum *chk) {
864 const unsigned char *b, *bo;
867 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
869 b = solv_chksum_get($self, &l);
870 bo = solv_chksum_get(chk, 0);
871 return memcmp(b, bo, l) == 0;
873 bool __ne__(Chksum *chk) {
874 return !Chksum___eq__($self, chk);
876 #if defined(SWIGRUBY)
877 %rename("to_s") __str__;
878 %rename("inspect") __repr__;
880 #if defined(SWIGPERL)
881 %rename("str") __str__;
884 const char *__str__() {
887 if (solv_chksum_isfinished($self))
888 h = Chksum_hex($self);
889 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
890 solv_free((void *)h);
894 const char *__repr__() {
895 const char *h = Chksum___str__($self);
896 const char *str = solv_dupjoin("<Chksum ", h, ">");
897 solv_free((void *)h);
904 Pool *pool = pool_create();
909 void set_debuglevel(int level) {
910 pool_setdebuglevel($self, level);
912 int set_flag(int flag, int value) {
913 return pool_set_flag($self, flag, value);
915 int get_flag(int flag) {
916 return pool_get_flag($self, flag);
918 void set_rootdir(const char *rootdir) {
919 pool_set_rootdir($self, rootdir);
921 const char *get_rootdir(int flag) {
922 return pool_get_rootdir($self);
924 #if defined(SWIGPYTHON)
926 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
927 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
928 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
929 PyObject *result = PyEval_CallObject((PyObject *)d, args);
934 return 0; /* exception */
935 ecode = SWIG_AsVal_int(result, &vresult);
937 return SWIG_IsOK(ecode) ? vresult : 0;
940 void set_loadcallback(PyObject *callable) {
941 if ($self->loadcallback == loadcallback) {
942 PyObject *obj = $self->loadcallbackdata;
948 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
951 #if defined(SWIGPERL)
953 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
957 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
962 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
964 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
974 void set_loadcallback(SV *callable) {
975 if ($self->loadcallback == loadcallback)
976 SvREFCNT_dec($self->loadcallbackdata);
978 SvREFCNT_inc(callable);
979 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
983 #if defined(SWIGRUBY)
985 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
986 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
987 VALUE callable = (VALUE)d;
988 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
989 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
992 SWIGINTERN void mark_Pool(void *ptr) {
994 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
995 VALUE callable = (VALUE)pool->loadcallbackdata;
996 rb_gc_mark(callable);
1000 %typemap(in, numinputs=0) VALUE callable {
1001 $1 = rb_block_given_p() ? rb_block_proc() : 0;
1003 void set_loadcallback(VALUE callable) {
1004 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
1009 Pool_set_loadcallback($self, 0);
1012 Id str2id(const char *str, bool create=1) {
1013 return pool_str2id($self, str, create);
1015 Dep *Dep(const char *str, bool create=1) {
1016 Id id = pool_str2id($self, str, create);
1017 return new_Dep($self, id);
1019 const char *id2str(Id id) {
1020 return pool_id2str($self, id);
1022 const char *dep2str(Id id) {
1023 return pool_dep2str($self, id);
1025 Id rel2id(Id name, Id evr, int flags, bool create=1) {
1026 return pool_rel2id($self, name, evr, flags, create);
1028 Id id2langid(Id id, const char *lang, bool create=1) {
1029 return pool_id2langid($self, id, lang, create);
1031 void setarch(const char *arch) {
1032 pool_setarch($self, arch);
1034 Repo *add_repo(const char *name) {
1035 return repo_create($self, name);
1037 const char *lookup_str(Id entry, Id keyname) {
1038 return pool_lookup_str($self, entry, keyname);
1040 Id lookup_id(Id entry, Id keyname) {
1041 return pool_lookup_id($self, entry, keyname);
1043 unsigned int lookup_num(Id entry, Id keyname, unsigned int notfound = 0) {
1044 return pool_lookup_num($self, entry, keyname, notfound);
1046 bool lookup_void(Id entry, Id keyname) {
1047 return pool_lookup_void($self, entry, keyname);
1049 %newobject lookup_checksum;
1050 Chksum *lookup_checksum(Id entry, Id keyname) {
1052 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
1053 return solv_chksum_create_from_bin(type, b);
1056 %newobject Dataiterator;
1057 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1058 return new_Dataiterator($self, 0, p, key, match, flags);
1060 const char *solvid2str(Id solvid) {
1061 return pool_solvid2str($self, solvid);
1063 void addfileprovides() {
1064 pool_addfileprovides($self);
1066 Queue addfileprovides_queue() {
1069 pool_addfileprovides_queue($self, &r, 0);
1072 void createwhatprovides() {
1073 pool_createwhatprovides($self);
1076 XSolvable *id2solvable(Id id) {
1077 return new_XSolvable($self, id);
1079 %newobject solvables;
1080 Pool_solvable_iterator * const solvables;
1082 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
1083 return new_Pool_solvable_iterator(pool);
1086 %newobject solvables_iter;
1087 Pool_solvable_iterator * solvables_iter() {
1088 return new_Pool_solvable_iterator($self);
1091 Repo *id2repo(Id id) {
1092 if (id < 1 || id >= $self->nrepos)
1094 return pool_id2repo($self, id);
1097 Pool_repo_iterator * const repos;
1099 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
1100 return new_Pool_repo_iterator(pool);
1103 %newobject repos_iter;
1104 Pool_repo_iterator * repos_iter() {
1105 return new_Pool_repo_iterator($self);
1110 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
1111 pool_set_installed(pool, installed);
1113 Repo *Pool_installed_get(Pool *pool) {
1114 return pool->installed;
1118 Queue matchprovidingids(const char *match, int flags) {
1124 for (id = 1; id < pool->ss.nstrings; id++)
1125 if (pool->whatprovides[id])
1129 if (!datamatcher_init(&ma, match, flags)) {
1130 for (id = 1; id < pool->ss.nstrings; id++)
1131 if (pool->whatprovides[id] && datamatcher_match(&ma, pool_id2str(pool, id)))
1133 datamatcher_free(&ma);
1139 Job *Job(int how, Id what) {
1140 return new_Job($self, how, what);
1143 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1144 %newobject whatprovides;
1145 Queue whatprovides(Id dep) {
1150 FOR_PROVIDES(p, pp, dep)
1155 Id towhatprovides(Queue q) {
1156 return pool_queuetowhatprovides($self, &q);
1160 %rename("isknownarch?") isknownarch;
1162 bool isknownarch(Id id) {
1164 if (!id || id == ID_EMPTY)
1166 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1168 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1175 return solver_create($self);
1178 %newobject Selection;
1179 Selection *Selection() {
1180 return new_Selection($self);
1183 Selection *select(const char *name, int flags) {
1184 Selection *sel = new_Selection($self);
1185 sel->flags = selection_make($self, &sel->q, name, flags);
1191 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1192 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1193 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1194 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1195 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1196 static const int REPO_USE_ROOTDIR = REPO_USE_ROOTDIR;
1197 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1198 #ifdef ENABLE_SUSEREPO
1199 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1202 void free(bool reuseids = 0) {
1203 repo_free($self, reuseids);
1205 void empty(bool reuseids = 0) {
1206 repo_empty($self, reuseids);
1209 %rename("isempty?") isempty;
1212 return !$self->nsolvables;
1214 bool add_solv(const char *name, int flags = 0) {
1215 FILE *fp = fopen(name, "r");
1219 r = repo_add_solv($self, fp, flags);
1223 bool add_solv(FILE *fp, int flags = 0) {
1224 return repo_add_solv($self, fp, flags) == 0;
1227 XSolvable *add_solvable() {
1228 Id solvid = repo_add_solvable($self);
1229 return new_XSolvable($self->pool, solvid);
1233 bool add_rpmdb(Repo *ref, int flags = 0) {
1234 return repo_add_rpmdb($self, ref, flags);
1236 Id add_rpm(const char *name, int flags = 0) {
1237 return repo_add_rpm($self, name, flags);
1241 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1242 return repo_add_rpmmd($self, fp, language, flags);
1244 bool add_repomdxml(FILE *fp, int flags = 0) {
1245 return repo_add_repomdxml($self, fp, flags);
1247 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1248 return repo_add_updateinfoxml($self, fp, flags);
1250 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1251 return repo_add_deltainfoxml($self, fp, flags);
1254 #ifdef ENABLE_DEBIAN
1255 bool add_debdb(int flags = 0) {
1256 return repo_add_debdb($self, flags);
1258 Id add_deb(const char *name, int flags = 0) {
1259 return repo_add_deb($self, name, flags);
1262 #ifdef ENABLE_SUSEREPO
1263 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1264 return repo_add_susetags($self, fp, defvendor, language, flags);
1266 bool add_content(FILE *fp, int flags = 0) {
1267 return repo_add_content($self, fp, flags);
1269 bool add_products(const char *proddir, int flags = 0) {
1270 return repo_add_products($self, proddir, flags);
1273 #ifdef ENABLE_MDKREPO
1274 bool add_mdk(FILE *fp, int flags = 0) {
1275 return repo_add_mdk($self, fp, flags);
1277 bool add_mdk_info(FILE *fp, int flags = 0) {
1278 return repo_add_mdk($self, fp, flags);
1281 #ifdef ENABLE_ARCHREPO
1282 bool add_arch_repo(FILE *fp, int flags = 0) {
1283 return repo_add_arch_repo($self, fp, flags);
1285 Id add_arch_pkg(const char *name, int flags = 0) {
1286 return repo_add_arch_pkg($self, name, flags);
1289 void internalize() {
1290 repo_internalize($self);
1292 const char *lookup_str(Id entry, Id keyname) {
1293 return repo_lookup_str($self, entry, keyname);
1295 Id lookup_id(Id entry, Id keyname) {
1296 return repo_lookup_id($self, entry, keyname);
1298 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1299 return repo_lookup_num($self, entry, keyname, notfound);
1301 void write(FILE *fp) {
1302 repo_write($self, fp);
1304 # HACK, remove if no longer needed!
1305 bool write_first_repodata(FILE *fp) {
1306 int oldnrepodata = $self->nrepodata;
1307 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1308 repo_write($self, fp);
1309 $self->nrepodata = oldnrepodata;
1313 %newobject Dataiterator;
1314 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1315 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1320 SWIGINTERN Id Repo_id_get(Repo *repo) {
1321 return repo->repoid;
1324 Repo_solvable_iterator * const solvables;
1326 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1327 return new_Repo_solvable_iterator(repo);
1330 %newobject solvables_iter;
1331 Repo_solvable_iterator *solvables_iter() {
1332 return new_Repo_solvable_iterator($self);
1335 XRepodata *add_repodata(int flags = 0) {
1336 Repodata *rd = repo_add_repodata($self, flags);
1337 return new_XRepodata($self, rd->repodataid);
1340 void create_stubs() {
1342 if (!$self->nrepodata)
1344 data = repo_id2repodata($self, $self->nrepodata - 1);
1345 if (data->state != REPODATA_STUB)
1346 repodata_create_stubs(data);
1349 %rename("iscontiguous?") iscontiguous;
1351 bool iscontiguous() {
1353 for (i = $self->start; i < $self->end; i++)
1354 if ($self->pool->solvables[i].repo != $self)
1358 XRepodata *first_repodata() {
1361 if ($self->nrepodata < 2)
1363 /* make sure all repodatas but the first are extensions */
1364 data = repo_id2repodata($self, 1);
1365 if (data->loadcallback)
1367 for (i = 2; i < $self->nrepodata; i++)
1369 data = repo_id2repodata($self, i);
1370 if (!data->loadcallback)
1371 return 0; /* oops, not an extension */
1373 return new_XRepodata($self, 1);
1376 bool __eq__(Repo *repo) {
1377 return $self == repo;
1379 bool __ne__(Repo *repo) {
1380 return $self != repo;
1382 #if defined(SWIGPERL)
1383 %rename("str") __str__;
1386 const char *__str__() {
1389 return solv_strdup($self->name);
1390 sprintf(buf, "Repo#%d", $self->repoid);
1391 return solv_strdup(buf);
1393 %newobject __repr__;
1394 const char *__repr__() {
1398 sprintf(buf, "<Repo #%d ", $self->repoid);
1399 return solv_dupjoin(buf, $self->name, ">");
1401 sprintf(buf, "<Repo #%d>", $self->repoid);
1402 return solv_strdup(buf);
1406 %extend Dataiterator {
1407 static const int SEARCH_STRING = SEARCH_STRING;
1408 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1409 static const int SEARCH_GLOB = SEARCH_GLOB;
1410 static const int SEARCH_REGEX = SEARCH_REGEX;
1411 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1412 static const int SEARCH_FILES = SEARCH_FILES;
1413 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1415 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1416 Dataiterator *di = solv_calloc(1, sizeof(*di));
1417 dataiterator_init(di, pool, repo, p, key, match, flags);
1421 dataiterator_free($self);
1424 #if defined(SWIGPYTHON)
1425 %newobject __iter__;
1426 Dataiterator *__iter__() {
1428 ndi = solv_calloc(1, sizeof(*ndi));
1429 dataiterator_init_clone(ndi, $self);
1432 %rename("next") __next__();
1433 %exception __next__ {
1436 PyErr_SetString(PyExc_StopIteration,"no more matches");
1443 perliter(solv::Dataiterator)
1446 %newobject __next__;
1447 Datamatch *__next__() {
1449 if (!dataiterator_step($self)) {
1452 ndi = solv_calloc(1, sizeof(*ndi));
1453 dataiterator_init_clone(ndi, $self);
1459 while ((d = Dataiterator___next__($self)) != 0) {
1460 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1464 void prepend_keyname(Id key) {
1465 dataiterator_prepend_keyname($self, key);
1467 void skip_solvable() {
1468 dataiterator_skip_solvable($self);
1473 Id lookup_id(Id keyname) {
1474 Pool *pool = $self->repo->pool;
1475 Datapos oldpos = pool->pos;
1478 r = pool_lookup_id(pool, SOLVID_POS, keyname);
1482 const char *lookup_str(Id keyname) {
1483 Pool *pool = $self->repo->pool;
1484 Datapos oldpos = pool->pos;
1487 r = pool_lookup_str(pool, SOLVID_POS, keyname);
1491 %newobject lookup_checksum;
1492 Chksum *lookup_checksum(Id keyname) {
1493 Pool *pool = $self->repo->pool;
1494 Datapos oldpos = pool->pos;
1496 const unsigned char *b;
1498 b = pool_lookup_bin_checksum(pool, SOLVID_POS, keyname, &type);
1500 return solv_chksum_create_from_bin(type, b);
1506 dataiterator_free($self);
1509 %newobject solvable;
1510 XSolvable * const solvable;
1512 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1513 return new_XSolvable(di->pool, di->solvid);
1517 return $self->key->name;
1519 const char *key_idstr() {
1520 return pool_id2str($self->pool, $self->key->name);
1523 return $self->key->type;
1525 const char *type_idstr() {
1526 return pool_id2str($self->pool, $self->key->type);
1529 return $self->kv.id;
1531 const char *idstr() {
1532 return pool_id2str($self->pool, $self->kv.id);
1535 return $self->kv.str;
1538 return $self->kv.num;
1541 return $self->kv.num2;
1545 Pool *pool = $self->pool;
1546 Datapos *pos, oldpos = pool->pos;
1547 dataiterator_setpos($self);
1548 pos = solv_calloc(1, sizeof(*pos));
1553 %newobject parentpos;
1554 Datapos *parentpos() {
1555 Pool *pool = $self->pool;
1556 Datapos *pos, oldpos = pool->pos;
1557 dataiterator_setpos_parent($self);
1558 pos = solv_calloc(1, sizeof(*pos));
1564 dataiterator_setpos($self);
1566 void setpos_parent() {
1567 dataiterator_setpos_parent($self);
1571 %extend Pool_solvable_iterator {
1572 Pool_solvable_iterator(Pool *pool) {
1573 Pool_solvable_iterator *s;
1574 s = solv_calloc(1, sizeof(*s));
1578 #if defined(SWIGPYTHON)
1579 %newobject __iter__;
1580 Pool_solvable_iterator *__iter__() {
1581 Pool_solvable_iterator *s;
1582 s = solv_calloc(1, sizeof(*s));
1586 %rename("next") __next__();
1587 %exception __next__ {
1590 PyErr_SetString(PyExc_StopIteration,"no more matches");
1597 perliter(solv::Pool_solvable_iterator)
1599 %newobject __next__;
1600 XSolvable *__next__() {
1601 Pool *pool = $self->pool;
1602 if ($self->id >= pool->nsolvables)
1604 while (++$self->id < pool->nsolvables)
1605 if (pool->solvables[$self->id].repo)
1606 return new_XSolvable(pool, $self->id);
1612 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1613 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1617 %newobject __getitem__;
1618 XSolvable *__getitem__(Id key) {
1619 Pool *pool = $self->pool;
1620 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1621 return new_XSolvable(pool, key);
1625 return $self->pool->nsolvables;
1629 %extend Pool_repo_iterator {
1630 Pool_repo_iterator(Pool *pool) {
1631 Pool_repo_iterator *s;
1632 s = solv_calloc(1, sizeof(*s));
1636 #if defined(SWIGPYTHON)
1637 %newobject __iter__;
1638 Pool_repo_iterator *__iter__() {
1639 Pool_repo_iterator *s;
1640 s = solv_calloc(1, sizeof(*s));
1644 %rename("next") __next__();
1645 %exception __next__ {
1648 PyErr_SetString(PyExc_StopIteration,"no more matches");
1653 %newobject __next__;
1655 Pool *pool = $self->pool;
1656 if ($self->id >= pool->nrepos)
1658 while (++$self->id < pool->nrepos) {
1659 Repo *r = pool_id2repo(pool, $self->id);
1668 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1669 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
1673 Repo *__getitem__(Id key) {
1674 Pool *pool = $self->pool;
1675 if (key > 0 && key < pool->nrepos)
1676 return pool_id2repo(pool, key);
1680 return $self->pool->nrepos;
1684 %extend Repo_solvable_iterator {
1685 Repo_solvable_iterator(Repo *repo) {
1686 Repo_solvable_iterator *s;
1687 s = solv_calloc(1, sizeof(*s));
1691 #if defined(SWIGPYTHON)
1692 %newobject __iter__;
1693 Repo_solvable_iterator *__iter__() {
1694 Repo_solvable_iterator *s;
1695 s = solv_calloc(1, sizeof(*s));
1699 %rename("next") __next__();
1700 %exception __next__ {
1703 PyErr_SetString(PyExc_StopIteration,"no more matches");
1708 %newobject __next__;
1709 XSolvable *__next__() {
1710 Repo *repo = $self->repo;
1711 Pool *pool = repo->pool;
1712 if (repo->start > 0 && $self->id < repo->start)
1713 $self->id = repo->start - 1;
1714 if ($self->id >= repo->end)
1716 while (++$self->id < repo->end)
1717 if (pool->solvables[$self->id].repo == repo)
1718 return new_XSolvable(pool, $self->id);
1724 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1725 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1729 %newobject __getitem__;
1730 XSolvable *__getitem__(Id key) {
1731 Repo *repo = $self->repo;
1732 Pool *pool = repo->pool;
1733 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1734 return new_XSolvable(pool, key);
1738 return $self->repo->pool->nsolvables;
1743 Dep(Pool *pool, Id id) {
1747 s = solv_calloc(1, sizeof(*s));
1753 return pool_dep2str($self->pool, $self->id);
1755 bool __eq__(Dep *s) {
1756 return $self->pool == s->pool && $self->id == s->id;
1758 bool __ne__(Dep *s) {
1759 return !Dep___eq__($self, s);
1761 #if defined(SWIGPERL)
1762 %rename("str") __str__;
1764 const char *__str__() {
1765 return pool_dep2str($self->pool, $self->id);
1767 %newobject __repr__;
1768 const char *__repr__() {
1770 sprintf(buf, "<Id #%d ", $self->id);
1771 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
1776 XSolvable(Pool *pool, Id id) {
1778 if (!id || id >= pool->nsolvables)
1780 s = solv_calloc(1, sizeof(*s));
1786 return pool_solvid2str($self->pool, $self->id);
1788 const char *lookup_str(Id keyname) {
1789 return pool_lookup_str($self->pool, $self->id, keyname);
1791 Id lookup_id(Id keyname) {
1792 return pool_lookup_id($self->pool, $self->id, keyname);
1794 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
1795 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
1797 bool lookup_void(Id keyname) {
1798 return pool_lookup_void($self->pool, $self->id, keyname);
1800 %newobject lookup_checksum;
1801 Chksum *lookup_checksum(Id keyname) {
1803 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
1804 return solv_chksum_create_from_bin(type, b);
1806 Queue lookup_idarray(Id keyname, Id marker = 1) {
1807 Solvable *s = $self->pool->solvables + $self->id;
1811 if (keyname == SOLVABLE_PROVIDES)
1812 marker = -SOLVABLE_FILEMARKER;
1813 else if (keyname == SOLVABLE_REQUIRES)
1814 marker = -SOLVABLE_PREREQMARKER;
1818 solvable_lookup_deparray(s, keyname, &r, marker);
1821 %typemap(out) Queue lookup_deparray Queue2Array(Dep *, 1, new_Dep(arg1->pool, id));
1822 %newobject lookup_deparray;
1823 Queue lookup_deparray(Id keyname, Id marker = 1) {
1824 Solvable *s = $self->pool->solvables + $self->id;
1828 if (keyname == SOLVABLE_PROVIDES)
1829 marker = -SOLVABLE_FILEMARKER;
1830 else if (keyname == SOLVABLE_REQUIRES)
1831 marker = -SOLVABLE_PREREQMARKER;
1835 solvable_lookup_deparray(s, keyname, &r, marker);
1838 const char *lookup_location(unsigned int *OUTPUT) {
1839 return solvable_get_location($self->pool->solvables + $self->id, OUTPUT);
1842 %rename("installable?") installable;
1844 bool installable() {
1845 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
1848 %rename("isinstalled?") isinstalled;
1850 bool isinstalled() {
1851 Pool *pool = $self->pool;
1852 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
1857 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
1858 Pool *pool = xs->pool;
1859 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
1861 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
1862 Pool *pool = xs->pool;
1863 return pool_id2str(pool, pool->solvables[xs->id].name);
1868 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
1869 xs->pool->solvables[xs->id].name = nameid;
1871 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
1872 return xs->pool->solvables[xs->id].name;
1877 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
1878 Pool *pool = xs->pool;
1879 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
1881 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
1882 Pool *pool = xs->pool;
1883 return pool_id2str(pool, pool->solvables[xs->id].evr);
1888 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
1889 xs->pool->solvables[xs->id].evr = evrid;
1891 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
1892 return xs->pool->solvables[xs->id].evr;
1897 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
1898 Pool *pool = xs->pool;
1899 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
1901 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
1902 Pool *pool = xs->pool;
1903 return pool_id2str(pool, pool->solvables[xs->id].arch);
1908 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
1909 xs->pool->solvables[xs->id].arch = archid;
1911 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
1912 return xs->pool->solvables[xs->id].arch;
1917 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
1918 Pool *pool = xs->pool;
1919 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
1921 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
1922 Pool *pool = xs->pool;
1923 return pool_id2str(pool, pool->solvables[xs->id].vendor);
1928 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
1929 xs->pool->solvables[xs->id].vendor = vendorid;
1931 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
1932 return xs->pool->solvables[xs->id].vendor;
1937 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
1938 return xs->pool->solvables[xs->id].repo;
1942 void add_provides(Dep *dep, Id marker = -SOLVABLE_FILEMARKER) {
1943 Solvable *s = $self->pool->solvables + $self->id;
1944 s->provides = repo_addid_dep(s->repo, s->provides, dep->id, marker);
1946 void add_providesid(Id id, Id marker = -SOLVABLE_FILEMARKER) {
1947 Solvable *s = $self->pool->solvables + $self->id;
1948 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
1950 void add_obsoletes(Dep *dep) {
1951 Solvable *s = $self->pool->solvables + $self->id;
1952 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, dep->id, 0);
1954 void add_obsoletesid(Id id) {
1955 Solvable *s = $self->pool->solvables + $self->id;
1956 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
1958 void add_conflicts(Dep *dep) {
1959 Solvable *s = $self->pool->solvables + $self->id;
1960 s->conflicts = repo_addid_dep(s->repo, s->conflicts, dep->id, 0);
1962 void add_conflictsid(Id id) {
1963 Solvable *s = $self->pool->solvables + $self->id;
1964 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
1966 void add_requires(Dep *dep, Id marker = -SOLVABLE_PREREQMARKER) {
1967 Solvable *s = $self->pool->solvables + $self->id;
1968 s->requires = repo_addid_dep(s->repo, s->requires, dep->id, marker);
1970 void add_requiresid(Id id, Id marker = -SOLVABLE_PREREQMARKER) {
1971 Solvable *s = $self->pool->solvables + $self->id;
1972 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
1974 void add_recommends(Dep *dep) {
1975 Solvable *s = $self->pool->solvables + $self->id;
1976 s->recommends = repo_addid_dep(s->repo, s->recommends, dep->id, 0);
1978 void add_recommendsid(Id id) {
1979 Solvable *s = $self->pool->solvables + $self->id;
1980 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
1982 void add_suggests(Dep *dep) {
1983 Solvable *s = $self->pool->solvables + $self->id;
1984 s->suggests = repo_addid_dep(s->repo, s->suggests, dep->id, 0);
1986 void add_suggestsid(Id id) {
1987 Solvable *s = $self->pool->solvables + $self->id;
1988 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
1990 void add_supplements(Dep *dep) {
1991 Solvable *s = $self->pool->solvables + $self->id;
1992 s->supplements = repo_addid_dep(s->repo, s->supplements, dep->id, 0);
1994 void add_supplementsid(Id id) {
1995 Solvable *s = $self->pool->solvables + $self->id;
1996 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
1998 void add_enhances(Dep *dep) {
1999 Solvable *s = $self->pool->solvables + $self->id;
2000 s->enhances = repo_addid_dep(s->repo, s->enhances, dep->id, 0);
2002 void add_enhancesid(Id id) {
2003 Solvable *s = $self->pool->solvables + $self->id;
2004 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
2007 bool __eq__(XSolvable *s) {
2008 return $self->pool == s->pool && $self->id == s->id;
2010 bool __ne__(XSolvable *s) {
2011 return !XSolvable___eq__($self, s);
2013 #if defined(SWIGPERL)
2014 %rename("str") __str__;
2016 const char *__str__() {
2017 return pool_solvid2str($self->pool, $self->id);
2019 %newobject __repr__;
2020 const char *__repr__() {
2022 sprintf(buf, "<Solvable #%d ", $self->id);
2023 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
2028 Problem(Solver *solv, Id id) {
2030 p = solv_calloc(1, sizeof(*p));
2035 %newobject findproblemrule;
2036 XRule *findproblemrule() {
2037 Id r = solver_findproblemrule($self->solv, $self->id);
2038 return new_XRule($self->solv, r);
2040 %newobject findallproblemrules;
2041 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
2042 Queue findallproblemrules(int unfiltered=0) {
2043 Solver *solv = $self->solv;
2048 solver_findallproblemrules(solv, $self->id, &q);
2051 for (i = j = 0; i < q.count; i++)
2053 SolverRuleinfo rclass;
2054 probr = q.elements[i];
2055 rclass = solver_ruleclass(solv, probr);
2056 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
2058 q.elements[j++] = probr;
2061 queue_truncate(&q, j);
2065 int solution_count() {
2066 return solver_solution_count($self->solv, $self->id);
2068 %newobject solutions;
2069 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
2074 cnt = solver_solution_count($self->solv, $self->id);
2075 for (i = 1; i <= cnt; i++)
2082 Solution(Problem *p, Id id) {
2084 s = solv_calloc(1, sizeof(*s));
2086 s->problemid = p->id;
2090 int element_count() {
2091 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2094 %newobject elements;
2095 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
2096 Queue elements(bool expandreplaces=0) {
2100 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2101 for (i = 1; i <= cnt; i++)
2104 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
2106 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
2112 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
2113 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
2115 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
2116 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2117 queue_push2(&q, p, rp);
2119 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
2120 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2121 queue_push2(&q, p, rp);
2123 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
2124 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2125 queue_push2(&q, p, rp);
2130 queue_push2(&q, i, type);
2131 queue_push2(&q, p, rp);
2137 %extend Solutionelement {
2138 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
2140 e = solv_calloc(1, sizeof(*e));
2142 e->problemid = problemid;
2153 if (p == SOLVER_SOLUTION_ERASE)
2158 else if (p == SOLVER_SOLUTION_REPLACE)
2163 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
2164 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);
2165 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
2166 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);
2167 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2168 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);
2169 return solver_solutionelement2str($self->solv, p, rp);
2171 %newobject replaceelements;
2172 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
2173 Queue replaceelements() {
2178 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2181 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2182 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
2183 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2184 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
2185 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2186 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
2187 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2189 queue_push(&q, $self->type);
2192 int illegalreplace() {
2193 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2195 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2197 %newobject solvable;
2198 XSolvable * const solvable;
2199 %newobject replacement;
2200 XSolvable * const replacement;
2203 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
2204 return new_XSolvable(e->solv->pool, e->p);
2206 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
2207 return new_XSolvable(e->solv->pool, e->rp);
2209 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
2210 if (e->type != SOLVER_SOLUTION_JOB)
2212 return (e->p - 1) / 2;
2217 Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
2218 if ($self->type == SOLVER_SOLUTION_JOB)
2219 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
2220 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE)
2221 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->p);
2222 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2223 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->rp);
2224 if ($self->type == SOLVER_SOLUTION_ERASE)
2225 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE|extraflags, $self->p);
2231 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
2232 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
2233 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
2234 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2235 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2236 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2237 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2238 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2239 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2240 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2241 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2242 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2243 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2244 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2245 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2246 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2247 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2248 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2249 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2251 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2252 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2253 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2254 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2255 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2256 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2257 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2258 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2260 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2261 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2262 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2264 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2265 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2266 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2267 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2268 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2269 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2270 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2271 static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
2272 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2278 int set_flag(int flag, int value) {
2279 return solver_set_flag($self, flag, value);
2281 int get_flag(int flag) {
2282 return solver_get_flag($self, flag);
2284 #if defined(SWIGPYTHON)
2286 def solve(self, jobs):
2288 for job in jobs: j += [job.how, job.what]
2289 return self.solve_helper(j)
2292 #if defined(SWIGPERL)
2294 sub solv::Solver::solve {
2295 my ($self, $jobs) = @_;
2296 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2297 return $self->solve_helper(\@j);
2301 #if defined(SWIGRUBY)
2304 "class Solv::Solver\n"
2305 " def solve(jobs)\n"
2307 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2308 " solve_helper(jl)\n"
2314 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2315 %newobject solve_helper;
2316 Queue solve_helper(Queue jobs) {
2320 solver_solve($self, &jobs);
2321 cnt = solver_problem_count($self);
2322 for (i = 1; i <= cnt; i++)
2326 %newobject transaction;
2327 Transaction *transaction() {
2328 return solver_create_transaction($self);
2332 %extend Transaction {
2333 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2334 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2335 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2336 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2337 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2338 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2339 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2340 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2341 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2342 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2343 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2344 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2345 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2346 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2347 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2348 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2349 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2350 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2351 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2352 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2353 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2354 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2355 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2356 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2357 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2358 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2359 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2361 transaction_free($self);
2364 %rename("isempty?") isempty;
2367 return $self->steps.count == 0;
2370 %newobject othersolvable;
2371 XSolvable *othersolvable(XSolvable *s) {
2372 Id op = transaction_obs_pkg($self, s->id);
2373 return new_XSolvable($self->pool, op);
2376 %newobject allothersolvables;
2377 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2378 Queue allothersolvables(XSolvable *s) {
2381 transaction_all_obs_pkgs($self, s->id, &q);
2385 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2386 %newobject classify;
2387 Queue classify(int mode = 0) {
2390 transaction_classify($self, mode, &q);
2394 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2395 %newobject newpackages;
2396 Queue newpackages() {
2400 cut = transaction_installedresult(self, &q);
2401 queue_truncate(&q, cut);
2405 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2406 %newobject keptpackages;
2407 Queue keptpackages() {
2411 cut = transaction_installedresult(self, &q);
2413 queue_deleten(&q, 0, cut);
2417 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2421 queue_init_clone(&q, &$self->steps);
2425 int steptype(XSolvable *s, int mode) {
2426 return transaction_type($self, s->id, mode);
2428 int calc_installsizechange() {
2429 return transaction_calc_installsizechange($self);
2431 void order(int flags) {
2432 transaction_order($self, flags);
2436 %extend TransactionClass {
2437 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2438 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2439 cl->transaction = trans;
2443 cl->fromid = fromid;
2447 %newobject solvables;
2448 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2452 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2458 XRule(Solver *solv, Id id) {
2461 XRule *xr = solv_calloc(1, sizeof(*xr));
2467 Id type, source, target, dep;
2468 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2469 return new_Ruleinfo($self, type, source, target, dep);
2471 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2472 %newobject allinfos;
2476 solver_allruleinfos($self->solv, $self->id, &q);
2480 bool __eq__(XRule *xr) {
2481 return $self->solv == xr->solv && $self->id == xr->id;
2483 bool __ne__(XRule *xr) {
2484 return !XRule___eq__($self, xr);
2486 %newobject __repr__;
2487 const char *__repr__() {
2489 sprintf(buf, "<Rule #%d>", $self->id);
2490 return solv_strdup(buf);
2495 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2496 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2500 ri->source = source;
2501 ri->target = target;
2505 XSolvable * const solvable;
2506 XSolvable * const othersolvable;
2508 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2509 return new_XSolvable(ri->solv->pool, ri->source);
2511 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2512 return new_XSolvable(ri->solv->pool, ri->target);
2515 const char *problemstr() {
2516 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2521 XRepodata(Repo *repo, Id id) {
2522 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2528 return repodata_new_handle(repo_id2repodata($self->repo, $self->id));
2530 void set_id(Id solvid, Id keyname, Id id) {
2531 repodata_set_id(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2533 void set_str(Id solvid, Id keyname, const char *str) {
2534 repodata_set_str(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2536 void set_poolstr(Id solvid, Id keyname, const char *str) {
2537 repodata_set_poolstr(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2539 void add_idarray(Id solvid, Id keyname, Id id) {
2540 repodata_add_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2542 void add_flexarray(Id solvid, Id keyname, Id handle) {
2543 repodata_add_flexarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, handle);
2545 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2546 const unsigned char *buf = solv_chksum_get(chksum, 0);
2548 repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
2550 const char *lookup_str(Id solvid, Id keyname) {
2551 return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
2553 Queue lookup_idarray(Id solvid, Id keyname) {
2556 repodata_lookup_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, &r);
2559 %newobject lookup_checksum;
2560 Chksum *lookup_checksum(Id solvid, Id keyname) {
2562 const unsigned char *b = repodata_lookup_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, &type);
2563 return solv_chksum_create_from_bin(type, b);
2565 void internalize() {
2566 repodata_internalize(repo_id2repodata($self->repo, $self->id));
2568 void create_stubs() {
2569 repodata_create_stubs(repo_id2repodata($self->repo, $self->id));
2571 void write(FILE *fp) {
2572 repodata_write(repo_id2repodata($self->repo, $self->id), fp);
2574 bool add_solv(FILE *fp, int flags = 0) {
2575 Repodata *data = repo_id2repodata($self->repo, $self->id);
2576 int r, oldstate = data->state;
2577 data->state = REPODATA_LOADING;
2578 r = repo_add_solv(data->repo, fp, flags | REPO_USE_LOADING);
2579 if (r || data->state == REPODATA_LOADING)
2580 data->state = oldstate;
2583 void extend_to_repo() {
2584 Repodata *data = repo_id2repodata($self->repo, $self->id);
2585 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2587 bool __eq__(XRepodata *xr) {
2588 return $self->repo == xr->repo && $self->id == xr->id;
2590 bool __ne__(XRepodata *xr) {
2591 return !XRepodata___eq__($self, xr);
2593 %newobject __repr__;
2594 const char *__repr__() {
2596 sprintf(buf, "<Repodata #%d>", $self->id);
2597 return solv_strdup(buf);