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, (argvi + $1.count + 1) - items + 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, (argvi + cnt + 1) - items + 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;
298 #if defined(SWIGPYTHON)
299 typedef PyObject *AppObjectPtr;
300 %typemap(out) AppObjectPtr {
301 $result = $1 ? $1 : Py_None;
305 #if defined(SWIGPERL)
306 typedef SV *AppObjectPtr;
307 %typemap(in) AppObjectPtr {
308 $1 = SvROK($input) ? SvRV($input) : 0;
310 %typemap(out) AppObjectPtr {
311 $result = $1 ? newRV_inc($1) : newSV(0);
315 #if defined(SWIGRUBY)
316 typedef VALUE AppObjectPtr;
317 %typemap(in) AppObjectPtr {
320 %typemap(out) AppObjectPtr {
330 %fragment("SWIG_AsValFilePtr","header") {}
334 %fragment("SWIG_AsValSolvFpPtr","header", fragment="SWIG_AsValFilePtr") {
338 SWIG_AsValSolvFpPtr(VALUE obj, FILE **val) {
340 SWIG_AsValSolvFpPtr(void *obj, FILE **val) {
342 static swig_type_info* desc = 0;
346 if (!desc) desc = SWIG_TypeQuery("SolvFp *");
347 if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
349 *val = vptr ? ((SolvFp *)vptr)->fp : 0;
353 ecode = SWIG_AsValFilePtr(obj, val);
354 if (ecode == SWIG_OK)
357 return SWIG_TypeError;
363 %fragment("SWIG_AsValDepId","header") {
367 SWIG_AsValDepId(VALUE obj, int *val) {
369 SWIG_AsValDepId(void *obj, int *val) {
371 static swig_type_info* desc = 0;
374 if (!desc) desc = SWIG_TypeQuery("Dep *");
375 ecode = SWIG_AsVal_int(obj, val);
376 if (SWIG_IsOK(ecode))
378 if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
380 *val = vptr ? ((Dep *)vptr)->id : 0;
383 return SWIG_TypeError;
390 %include "typemaps.i"
392 %typemaps_asval(%checkcode(POINTER), SWIG_AsValSolvFpPtr, "SWIG_AsValSolvFpPtr", FILE*);
393 %typemaps_asval(%checkcode(INT32), SWIG_AsValDepId, "SWIG_AsValDepId", DepId);
399 #include <sys/stat.h>
400 #include <sys/utsname.h>
401 #include <sys/types.h>
404 /* argh, swig undefs bool for perl */
410 #include "poolarch.h"
413 #include "solverdebug.h"
414 #include "repo_solv.h"
416 #include "selection.h"
418 #include "repo_write.h"
420 #include "repo_rpmdb.h"
422 #ifdef ENABLE_RPMDB_PUBKEYS
423 #include "repo_rpmdb_pubkey.h"
426 #include "repo_deb.h"
429 #include "repo_rpmmd.h"
430 #include "repo_updateinfoxml.h"
431 #include "repo_deltainfoxml.h"
432 #include "repo_repomdxml.h"
434 #ifdef ENABLE_SUSEREPO
435 #include "repo_products.h"
436 #include "repo_susetags.h"
437 #include "repo_content.h"
439 #ifdef ENABLE_MDKREPO
440 #include "repo_mdk.h"
442 #ifdef ENABLE_ARCHREPO
443 #include "repo_arch.h"
445 #include "solv_xfopen.h"
447 /* for old ruby versions */
449 #define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
452 #define RARRAY_LEN(ary) (RARRAY(ary)->len)
455 #define SOLVER_SOLUTION_ERASE -100
456 #define SOLVER_SOLUTION_REPLACE -101
457 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
458 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
459 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
460 #define SOLVER_SOLUTION_REPLACE_NAMECHANGE -105
462 typedef struct chksum Chksum;
463 typedef void *AppObjectPtr;
489 } Pool_solvable_iterator;
494 } Pool_repo_iterator;
499 } Repo_solvable_iterator;
539 Transaction *transaction;
557 typedef Dataiterator Datamatch;
562 %mixin Dataiterator "Enumerable";
563 %mixin Pool_solvable_iterator "Enumerable";
564 %mixin Pool_repo_iterator "Enumerable";
565 %mixin Repo_solvable_iterator "Enumerable";
573 %constant Id SOLVID_META;
574 %constant Id SOLVID_POS;
576 %constant int REL_EQ;
577 %constant int REL_GT;
578 %constant int REL_LT;
579 %constant int REL_ARCH;
590 # put before pool/repo so we can access the constructor
591 %nodefaultdtor Dataiterator;
592 typedef struct {} Dataiterator;
615 typedef struct {} Pool_solvable_iterator;
616 typedef struct {} Pool_repo_iterator;
617 typedef struct {} Repo_solvable_iterator;
619 %nodefaultctor Datamatch;
620 %nodefaultdtor Datamatch;
627 %nodefaultctor Datapos;
641 AppObjectPtr appdata;
648 const char * const name;
651 int const nsolvables;
652 AppObjectPtr appdata;
655 %nodefaultctor Solver;
656 %nodefaultdtor Solver;
664 %rename(xfopen) solvfp_xfopen;
665 %rename(xfopen_fd) solvfp_xfopen_fd;
667 %nodefaultctor SolvFp;
671 %newobject solvfp_xfopen;
672 %newobject solvfp_xfopen_fd;
674 SolvFp *solvfp_xfopen(const char *fn, const char *mode = 0);
675 SolvFp *solvfp_xfopen_fd(const char *fn, int fd, const char *mode = 0);
678 SWIGINTERN SolvFp *solvfp_xfopen_fd(const char *fn, int fd, const char *mode) {
682 fp = fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
685 sfp = solv_calloc(1, sizeof(SolvFp));
689 SWIGINTERN SolvFp *solvfp_xfopen(const char *fn, const char *mode) {
692 fp = solv_xfopen(fn, mode);
695 sfp = solv_calloc(1, sizeof(SolvFp));
720 %nodefaultctor Transaction;
721 %nodefaultdtor Transaction;
727 Transaction * const transaction;
741 return $self->fp ? fileno($self->fp) : -1;
744 return $self->fp ? dup(fileno($self->fp)) : -1;
749 return fflush($self->fp) == 0;
755 ret = fclose($self->fp) == 0;
762 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
763 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
764 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
765 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
766 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
767 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
768 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
769 static const Id SOLVER_NOOP = SOLVER_NOOP;
770 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
771 static const Id SOLVER_ERASE = SOLVER_ERASE;
772 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
773 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
774 static const Id SOLVER_MULTIVERSION = SOLVER_MULTIVERSION;
775 static const Id SOLVER_LOCK = SOLVER_LOCK;
776 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
777 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
778 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
779 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
780 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
781 static const Id SOLVER_WEAK = SOLVER_WEAK;
782 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
783 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
784 static const Id SOLVER_FORCEBEST = SOLVER_FORCEBEST;
785 static const Id SOLVER_TARGETED = SOLVER_TARGETED;
786 static const Id SOLVER_SETEV = SOLVER_SETEV;
787 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
788 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
789 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
790 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
791 static const Id SOLVER_SETNAME = SOLVER_SETNAME;
792 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
793 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
795 Job(Pool *pool, int how, Id what) {
796 Job *job = solv_calloc(1, sizeof(*job));
803 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
804 %newobject solvables;
808 pool_job2solvables($self->pool, &q, $self->how, $self->what);
812 %rename("isemptyupdate?") isemptyupdate;
814 bool isemptyupdate() {
815 return pool_isemptyupdatejob($self->pool, $self->how, $self->what);
818 bool __eq__(Job *j) {
819 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
821 bool __ne__(Job *j) {
822 return !Job___eq__($self, j);
824 #if defined(SWIGPERL)
825 %rename("str") __str__;
827 const char *__str__() {
828 return pool_job2str($self->pool, $self->how, $self->what, 0);
830 const char *__repr__() {
831 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
832 return pool_tmpjoin($self->pool, "<Job ", str, ">");
837 static const Id SELECTION_NAME = SELECTION_NAME;
838 static const Id SELECTION_PROVIDES = SELECTION_PROVIDES;
839 static const Id SELECTION_FILELIST = SELECTION_FILELIST;
840 static const Id SELECTION_CANON = SELECTION_CANON;
841 static const Id SELECTION_DOTARCH = SELECTION_DOTARCH;
842 static const Id SELECTION_REL = SELECTION_REL;
843 static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
844 static const Id SELECTION_GLOB = SELECTION_GLOB;
845 static const Id SELECTION_FLAT = SELECTION_FLAT;
846 static const Id SELECTION_NOCASE = SELECTION_NOCASE;
847 static const Id SELECTION_SOURCE_ONLY = SELECTION_SOURCE_ONLY;
848 static const Id SELECTION_WITH_SOURCE = SELECTION_WITH_SOURCE;
850 Selection(Pool *pool) {
852 s = solv_calloc(1, sizeof(*s));
858 queue_free(&$self->q);
864 void make(const char *name, int flags) {
865 $self->flags = selection_make($self->pool, &$self->q, name, flags);
868 %rename("isempty?") isempty;
871 return $self->q.count == 0;
873 void filter(Selection *lsel) {
874 if ($self->pool != lsel->pool)
875 queue_empty(&$self->q);
877 selection_filter($self->pool, &$self->q, &lsel->q);
879 void add(Selection *lsel) {
880 if ($self->pool == lsel->pool)
882 selection_add($self->pool, &$self->q, &lsel->q);
883 $self->flags |= lsel->flags;
886 void add_raw(Id how, Id what) {
887 queue_push2(&$self->q, how, what);
889 %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
891 Queue jobs(int flags) {
894 queue_init_clone(&q, &$self->q);
895 for (i = 0; i < q.count; i += 2)
896 q.elements[i] |= flags;
900 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
901 %newobject solvables;
905 selection_solvables($self->pool, &$self->q, &q);
909 #if defined(SWIGPERL)
910 %rename("str") __str__;
912 const char *__str__() {
913 return pool_selection2str($self->pool, &$self->q, 0);
915 const char *__repr__() {
916 const char *str = pool_selection2str($self->pool, &$self->q, ~0);
917 return pool_tmpjoin($self->pool, "<Selection ", str, ">");
923 return (Chksum *)solv_chksum_create(type);
925 Chksum(Id type, const char *hex) {
926 unsigned char buf[64];
927 int l = solv_chksum_len(type);
930 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
932 return (Chksum *)solv_chksum_create_from_bin(type, buf);
935 solv_chksum_free($self, 0);
939 SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
940 return solv_chksum_get_type(chksum);
943 void add(const char *str) {
944 solv_chksum_add($self, str, strlen((char *)str));
946 void add_fp(FILE *fp) {
949 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
950 solv_chksum_add($self, buf, l);
951 rewind(fp); /* convenience */
953 void add_fd(int fd) {
956 while ((l = read(fd, buf, sizeof(buf))) > 0)
957 solv_chksum_add($self, buf, l);
958 lseek(fd, 0, 0); /* convenience */
960 void add_stat(const char *filename) {
962 if (stat(filename, &stb))
963 memset(&stb, 0, sizeof(stb));
964 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
965 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
966 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
967 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
969 void add_fstat(int fd) {
972 memset(&stb, 0, sizeof(stb));
973 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
974 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
975 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
976 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
980 const unsigned char *b;
981 b = solv_chksum_get($self, &l);
982 return cdata_void((void *)b, l);
987 const unsigned char *b;
990 b = solv_chksum_get($self, &l);
991 ret = solv_malloc(2 * l + 1);
992 solv_bin2hex(b, l, ret);
996 bool __eq__(Chksum *chk) {
998 const unsigned char *b, *bo;
1001 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
1003 b = solv_chksum_get($self, &l);
1004 bo = solv_chksum_get(chk, 0);
1005 return memcmp(b, bo, l) == 0;
1007 bool __ne__(Chksum *chk) {
1008 return !Chksum___eq__($self, chk);
1010 #if defined(SWIGRUBY)
1011 %rename("to_s") __str__;
1012 %rename("inspect") __repr__;
1014 #if defined(SWIGPERL)
1015 %rename("str") __str__;
1018 const char *__str__() {
1021 if (solv_chksum_isfinished($self))
1022 h = Chksum_hex($self);
1023 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
1024 solv_free((void *)h);
1027 %newobject __repr__;
1028 const char *__repr__() {
1029 const char *h = Chksum___str__($self);
1030 const char *str = solv_dupjoin("<Chksum ", h, ">");
1031 solv_free((void *)h);
1038 Pool *pool = pool_create();
1043 void set_debuglevel(int level) {
1044 pool_setdebuglevel($self, level);
1046 int set_flag(int flag, int value) {
1047 return pool_set_flag($self, flag, value);
1049 int get_flag(int flag) {
1050 return pool_get_flag($self, flag);
1052 void set_rootdir(const char *rootdir) {
1053 pool_set_rootdir($self, rootdir);
1055 const char *get_rootdir(int flag) {
1056 return pool_get_rootdir($self);
1058 #if defined(SWIGPYTHON)
1060 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1061 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1062 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
1063 PyObject *result = PyEval_CallObject((PyObject *)d, args);
1068 return 0; /* exception */
1069 ecode = SWIG_AsVal_int(result, &vresult);
1071 return SWIG_IsOK(ecode) ? vresult : 0;
1074 void set_loadcallback(PyObject *callable) {
1075 if ($self->loadcallback == loadcallback) {
1076 PyObject *obj = $self->loadcallbackdata;
1080 Py_INCREF(callable);
1082 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
1085 #if defined(SWIGPERL)
1087 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1091 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1096 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
1098 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
1108 void set_loadcallback(SV *callable) {
1109 if ($self->loadcallback == loadcallback)
1110 SvREFCNT_dec($self->loadcallbackdata);
1112 SvREFCNT_inc(callable);
1113 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
1117 #if defined(SWIGRUBY)
1119 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1120 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1121 VALUE callable = (VALUE)d;
1122 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
1123 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
1124 return res == Qtrue;
1126 SWIGINTERN void mark_Pool(void *ptr) {
1128 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
1129 VALUE callable = (VALUE)pool->loadcallbackdata;
1130 rb_gc_mark(callable);
1134 %typemap(in, numinputs=0) VALUE callable {
1135 $1 = rb_block_given_p() ? rb_block_proc() : 0;
1137 void set_loadcallback(VALUE callable) {
1138 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
1143 Pool_set_loadcallback($self, 0);
1146 Id str2id(const char *str, bool create=1) {
1147 return pool_str2id($self, str, create);
1149 Dep *Dep(const char *str, bool create=1) {
1150 Id id = pool_str2id($self, str, create);
1151 return new_Dep($self, id);
1153 const char *id2str(Id id) {
1154 return pool_id2str($self, id);
1156 const char *dep2str(Id id) {
1157 return pool_dep2str($self, id);
1159 Id rel2id(Id name, Id evr, int flags, bool create=1) {
1160 return pool_rel2id($self, name, evr, flags, create);
1162 Id id2langid(Id id, const char *lang, bool create=1) {
1163 return pool_id2langid($self, id, lang, create);
1165 void setarch(const char *arch = 0) {
1174 pool_setarch($self, arch);
1176 Repo *add_repo(const char *name) {
1177 return repo_create($self, name);
1179 const char *lookup_str(Id entry, Id keyname) {
1180 return pool_lookup_str($self, entry, keyname);
1182 Id lookup_id(Id entry, Id keyname) {
1183 return pool_lookup_id($self, entry, keyname);
1185 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1186 return pool_lookup_num($self, entry, keyname, notfound);
1188 bool lookup_void(Id entry, Id keyname) {
1189 return pool_lookup_void($self, entry, keyname);
1191 %newobject lookup_checksum;
1192 Chksum *lookup_checksum(Id entry, Id keyname) {
1194 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
1195 return solv_chksum_create_from_bin(type, b);
1198 %newobject Dataiterator;
1199 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1200 return new_Dataiterator($self, 0, p, key, match, flags);
1202 const char *solvid2str(Id solvid) {
1203 return pool_solvid2str($self, solvid);
1205 void addfileprovides() {
1206 pool_addfileprovides($self);
1208 Queue addfileprovides_queue() {
1211 pool_addfileprovides_queue($self, &r, 0);
1214 void createwhatprovides() {
1215 pool_createwhatprovides($self);
1218 XSolvable *id2solvable(Id id) {
1219 return new_XSolvable($self, id);
1221 %newobject solvables;
1222 Pool_solvable_iterator * const solvables;
1224 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
1225 return new_Pool_solvable_iterator(pool);
1228 %newobject solvables_iter;
1229 Pool_solvable_iterator * solvables_iter() {
1230 return new_Pool_solvable_iterator($self);
1233 Repo *id2repo(Id id) {
1234 if (id < 1 || id >= $self->nrepos)
1236 return pool_id2repo($self, id);
1239 Pool_repo_iterator * const repos;
1241 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
1242 return new_Pool_repo_iterator(pool);
1245 %newobject repos_iter;
1246 Pool_repo_iterator * repos_iter() {
1247 return new_Pool_repo_iterator($self);
1252 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
1253 pool_set_installed(pool, installed);
1255 Repo *Pool_installed_get(Pool *pool) {
1256 return pool->installed;
1260 Queue matchprovidingids(const char *match, int flags) {
1266 for (id = 1; id < pool->ss.nstrings; id++)
1267 if (pool->whatprovides[id])
1271 if (!datamatcher_init(&ma, match, flags)) {
1272 for (id = 1; id < pool->ss.nstrings; id++)
1273 if (pool->whatprovides[id] && datamatcher_match(&ma, pool_id2str(pool, id)))
1275 datamatcher_free(&ma);
1281 Job *Job(int how, Id what) {
1282 return new_Job($self, how, what);
1285 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1286 %newobject whatprovides;
1287 Queue whatprovides(DepId dep) {
1292 FOR_PROVIDES(p, pp, dep)
1297 Id towhatprovides(Queue q) {
1298 return pool_queuetowhatprovides($self, &q);
1302 %rename("isknownarch?") isknownarch;
1304 bool isknownarch(DepId id) {
1306 if (!id || id == ID_EMPTY)
1308 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1310 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1317 return solver_create($self);
1320 %newobject Selection;
1321 Selection *Selection() {
1322 return new_Selection($self);
1324 %newobject Selection_all;
1325 Selection *Selection_all(int setflags=0) {
1326 Selection *sel = new_Selection($self);
1327 queue_push2(&sel->q, SOLVER_SOLVABLE_ALL | setflags, 0);
1331 Selection *select(const char *name, int flags) {
1332 Selection *sel = new_Selection($self);
1333 sel->flags = selection_make($self, &sel->q, name, flags);
1337 void setpooljobs_helper(Queue jobs) {
1338 queue_free(&$self->pooljobs);
1339 queue_init_clone(&$self->pooljobs, &jobs);
1341 %typemap(out) Queue getpooljobs Queue2Array(Job *, 2, new_Job(arg1, id, idp[1]));
1342 %newobject getpooljobs;
1343 Queue getpooljobs() {
1345 queue_init_clone(&q, &$self->pooljobs);
1349 #if defined(SWIGPYTHON)
1351 def setpooljobs(self, jobs):
1353 for job in jobs: j += [job.how, job.what]
1354 self.setpooljobs_helper(j)
1357 #if defined(SWIGPERL)
1359 sub solv::Solver::setpooljobs {
1360 my ($self, $jobs) = @_;
1361 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
1362 return $self->setpooljobs_helper(\@j);
1366 #if defined(SWIGRUBY)
1369 "class Solv::Pool\n"
1370 " def setpooljobs(jobs)\n"
1372 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
1373 " setpooljobs_helper(jl)\n"
1382 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1383 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1384 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1385 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1386 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1387 static const int REPO_USE_ROOTDIR = REPO_USE_ROOTDIR;
1388 static const int REPO_NO_LOCATION = REPO_NO_LOCATION;
1389 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1390 #ifdef ENABLE_SUSEREPO
1391 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1394 void free(bool reuseids = 0) {
1395 repo_free($self, reuseids);
1397 void empty(bool reuseids = 0) {
1398 repo_empty($self, reuseids);
1401 %rename("isempty?") isempty;
1404 return !$self->nsolvables;
1406 bool add_solv(const char *name, int flags = 0) {
1407 FILE *fp = fopen(name, "r");
1411 r = repo_add_solv($self, fp, flags);
1415 bool add_solv(FILE *fp, int flags = 0) {
1416 return repo_add_solv($self, fp, flags) == 0;
1419 XSolvable *add_solvable() {
1420 Id solvid = repo_add_solvable($self);
1421 return new_XSolvable($self->pool, solvid);
1425 bool add_rpmdb(int flags = 0) {
1426 return repo_add_rpmdb($self, 0, flags);
1428 bool add_rpmdb_reffp(FILE *reffp, int flags = 0) {
1429 return repo_add_rpmdb_reffp($self, reffp, flags);
1431 Id add_rpm(const char *name, int flags = 0) {
1432 return repo_add_rpm($self, name, flags);
1435 #ifdef ENABLE_RPMDB_PUBKEYS
1436 bool add_rpmdb_pubkeys(int flags = 0) {
1437 return repo_add_rpmdb_pubkeys($self, flags);
1439 Id add_pubkey(const char *key, int flags = 0) {
1440 return repo_add_pubkey($self, key, flags);
1444 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1445 return repo_add_rpmmd($self, fp, language, flags);
1447 bool add_repomdxml(FILE *fp, int flags = 0) {
1448 return repo_add_repomdxml($self, fp, flags);
1450 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1451 return repo_add_updateinfoxml($self, fp, flags);
1453 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1454 return repo_add_deltainfoxml($self, fp, flags);
1457 #ifdef ENABLE_DEBIAN
1458 bool add_debdb(int flags = 0) {
1459 return repo_add_debdb($self, flags);
1461 Id add_deb(const char *name, int flags = 0) {
1462 return repo_add_deb($self, name, flags);
1465 #ifdef ENABLE_SUSEREPO
1466 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1467 return repo_add_susetags($self, fp, defvendor, language, flags);
1469 bool add_content(FILE *fp, int flags = 0) {
1470 return repo_add_content($self, fp, flags);
1472 bool add_products(const char *proddir, int flags = 0) {
1473 return repo_add_products($self, proddir, flags);
1476 #ifdef ENABLE_MDKREPO
1477 bool add_mdk(FILE *fp, int flags = 0) {
1478 return repo_add_mdk($self, fp, flags);
1480 bool add_mdk_info(FILE *fp, int flags = 0) {
1481 return repo_add_mdk($self, fp, flags);
1484 #ifdef ENABLE_ARCHREPO
1485 bool add_arch_repo(FILE *fp, int flags = 0) {
1486 return repo_add_arch_repo($self, fp, flags);
1488 Id add_arch_pkg(const char *name, int flags = 0) {
1489 return repo_add_arch_pkg($self, name, flags);
1492 void internalize() {
1493 repo_internalize($self);
1495 const char *lookup_str(Id entry, Id keyname) {
1496 return repo_lookup_str($self, entry, keyname);
1498 Id lookup_id(Id entry, Id keyname) {
1499 return repo_lookup_id($self, entry, keyname);
1501 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1502 return repo_lookup_num($self, entry, keyname, notfound);
1504 void write(FILE *fp) {
1505 repo_write($self, fp);
1507 # HACK, remove if no longer needed!
1508 bool write_first_repodata(FILE *fp) {
1509 int oldnrepodata = $self->nrepodata;
1510 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1511 repo_write($self, fp);
1512 $self->nrepodata = oldnrepodata;
1516 %newobject Dataiterator;
1517 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags) {
1518 return new_Dataiterator($self->pool, $self, p, key, match, flags);
1523 SWIGINTERN Id Repo_id_get(Repo *repo) {
1524 return repo->repoid;
1527 Repo_solvable_iterator * const solvables;
1529 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1530 return new_Repo_solvable_iterator(repo);
1533 %newobject solvables_iter;
1534 Repo_solvable_iterator *solvables_iter() {
1535 return new_Repo_solvable_iterator($self);
1538 XRepodata *add_repodata(int flags = 0) {
1539 Repodata *rd = repo_add_repodata($self, flags);
1540 return new_XRepodata($self, rd->repodataid);
1543 void create_stubs() {
1545 if (!$self->nrepodata)
1547 data = repo_id2repodata($self, $self->nrepodata - 1);
1548 if (data->state != REPODATA_STUB)
1549 repodata_create_stubs(data);
1552 %rename("iscontiguous?") iscontiguous;
1554 bool iscontiguous() {
1556 for (i = $self->start; i < $self->end; i++)
1557 if ($self->pool->solvables[i].repo != $self)
1561 XRepodata *first_repodata() {
1564 if ($self->nrepodata < 2)
1566 /* make sure all repodatas but the first are extensions */
1567 data = repo_id2repodata($self, 1);
1568 if (data->loadcallback)
1570 for (i = 2; i < $self->nrepodata; i++)
1572 data = repo_id2repodata($self, i);
1573 if (!data->loadcallback)
1574 return 0; /* oops, not an extension */
1576 return new_XRepodata($self, 1);
1579 %newobject Selection;
1580 Selection *Selection(int setflags=0) {
1581 Selection *sel = new_Selection($self->pool);
1582 setflags |= SOLVER_SETREPO;
1583 queue_push2(&sel->q, SOLVER_SOLVABLE_REPO | setflags, $self->repoid);
1587 bool __eq__(Repo *repo) {
1588 return $self == repo;
1590 bool __ne__(Repo *repo) {
1591 return $self != repo;
1593 #if defined(SWIGPERL)
1594 %rename("str") __str__;
1597 const char *__str__() {
1600 return solv_strdup($self->name);
1601 sprintf(buf, "Repo#%d", $self->repoid);
1602 return solv_strdup(buf);
1604 %newobject __repr__;
1605 const char *__repr__() {
1609 sprintf(buf, "<Repo #%d ", $self->repoid);
1610 return solv_dupjoin(buf, $self->name, ">");
1612 sprintf(buf, "<Repo #%d>", $self->repoid);
1613 return solv_strdup(buf);
1617 %extend Dataiterator {
1618 static const int SEARCH_STRING = SEARCH_STRING;
1619 static const int SEARCH_STRINGSTART = SEARCH_STRINGSTART;
1620 static const int SEARCH_STRINGEND = SEARCH_STRINGEND;
1621 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1622 static const int SEARCH_GLOB = SEARCH_GLOB;
1623 static const int SEARCH_REGEX = SEARCH_REGEX;
1624 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1625 static const int SEARCH_FILES = SEARCH_FILES;
1626 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1628 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1629 Dataiterator *di = solv_calloc(1, sizeof(*di));
1630 dataiterator_init(di, pool, repo, p, key, match, flags);
1634 dataiterator_free($self);
1637 #if defined(SWIGPYTHON)
1638 %newobject __iter__;
1639 Dataiterator *__iter__() {
1641 ndi = solv_calloc(1, sizeof(*ndi));
1642 dataiterator_init_clone(ndi, $self);
1645 %rename("next") __next__();
1646 %exception __next__ {
1649 PyErr_SetString(PyExc_StopIteration,"no more matches");
1656 perliter(solv::Dataiterator)
1659 %newobject __next__;
1660 Datamatch *__next__() {
1662 if (!dataiterator_step($self)) {
1665 ndi = solv_calloc(1, sizeof(*ndi));
1666 dataiterator_init_clone(ndi, $self);
1667 dataiterator_strdup(ndi);
1673 while ((d = Dataiterator___next__($self)) != 0) {
1674 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1678 void prepend_keyname(Id key) {
1679 dataiterator_prepend_keyname($self, key);
1681 void skip_solvable() {
1682 dataiterator_skip_solvable($self);
1687 Id lookup_id(Id keyname) {
1688 Pool *pool = $self->repo->pool;
1689 Datapos oldpos = pool->pos;
1692 r = pool_lookup_id(pool, SOLVID_POS, keyname);
1696 const char *lookup_str(Id keyname) {
1697 Pool *pool = $self->repo->pool;
1698 Datapos oldpos = pool->pos;
1701 r = pool_lookup_str(pool, SOLVID_POS, keyname);
1705 %newobject lookup_checksum;
1706 Chksum *lookup_checksum(Id keyname) {
1707 Pool *pool = $self->repo->pool;
1708 Datapos oldpos = pool->pos;
1710 const unsigned char *b;
1712 b = pool_lookup_bin_checksum(pool, SOLVID_POS, keyname, &type);
1714 return solv_chksum_create_from_bin(type, b);
1716 const char *lookup_deltaseq() {
1717 Pool *pool = $self->repo->pool;
1718 Datapos oldpos = pool->pos;
1721 seq = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NAME);
1723 seq = pool_tmpjoin(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_EVR));
1724 seq = pool_tmpappend(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM));
1729 const char *lookup_deltalocation(unsigned int *OUTPUT) {
1730 Pool *pool = $self->repo->pool;
1731 Datapos oldpos = pool->pos;
1734 loc = pool_lookup_deltalocation(pool, SOLVID_POS, OUTPUT);
1742 dataiterator_free($self);
1745 %newobject solvable;
1746 XSolvable * const solvable;
1748 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1749 return new_XSolvable(di->pool, di->solvid);
1753 return $self->key->name;
1755 const char *key_idstr() {
1756 return pool_id2str($self->pool, $self->key->name);
1759 return $self->key->type;
1761 const char *type_idstr() {
1762 return pool_id2str($self->pool, $self->key->type);
1765 return $self->kv.id;
1767 const char *idstr() {
1768 return pool_id2str($self->pool, $self->kv.id);
1771 return $self->kv.str;
1774 return $self->kv.num;
1777 return $self->kv.num2;
1781 Pool *pool = $self->pool;
1782 Datapos *pos, oldpos = pool->pos;
1783 dataiterator_setpos($self);
1784 pos = solv_calloc(1, sizeof(*pos));
1789 %newobject parentpos;
1790 Datapos *parentpos() {
1791 Pool *pool = $self->pool;
1792 Datapos *pos, oldpos = pool->pos;
1793 dataiterator_setpos_parent($self);
1794 pos = solv_calloc(1, sizeof(*pos));
1800 dataiterator_setpos($self);
1802 void setpos_parent() {
1803 dataiterator_setpos_parent($self);
1805 #if defined(SWIGPERL)
1806 %rename("str") __str__;
1808 const char *__str__() {
1809 if (!repodata_stringify($self->pool, $self->data, $self->key, &$self->kv, $self->flags))
1811 return $self->kv.str;
1815 %extend Pool_solvable_iterator {
1816 Pool_solvable_iterator(Pool *pool) {
1817 Pool_solvable_iterator *s;
1818 s = solv_calloc(1, sizeof(*s));
1822 #if defined(SWIGPYTHON)
1823 %newobject __iter__;
1824 Pool_solvable_iterator *__iter__() {
1825 Pool_solvable_iterator *s;
1826 s = solv_calloc(1, sizeof(*s));
1830 %rename("next") __next__();
1831 %exception __next__ {
1834 PyErr_SetString(PyExc_StopIteration,"no more matches");
1841 perliter(solv::Pool_solvable_iterator)
1843 %newobject __next__;
1844 XSolvable *__next__() {
1845 Pool *pool = $self->pool;
1846 if ($self->id >= pool->nsolvables)
1848 while (++$self->id < pool->nsolvables)
1849 if (pool->solvables[$self->id].repo)
1850 return new_XSolvable(pool, $self->id);
1856 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
1857 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1861 %newobject __getitem__;
1862 XSolvable *__getitem__(Id key) {
1863 Pool *pool = $self->pool;
1864 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
1865 return new_XSolvable(pool, key);
1869 return $self->pool->nsolvables;
1873 %extend Pool_repo_iterator {
1874 Pool_repo_iterator(Pool *pool) {
1875 Pool_repo_iterator *s;
1876 s = solv_calloc(1, sizeof(*s));
1880 #if defined(SWIGPYTHON)
1881 %newobject __iter__;
1882 Pool_repo_iterator *__iter__() {
1883 Pool_repo_iterator *s;
1884 s = solv_calloc(1, sizeof(*s));
1888 %rename("next") __next__();
1889 %exception __next__ {
1892 PyErr_SetString(PyExc_StopIteration,"no more matches");
1897 %newobject __next__;
1899 Pool *pool = $self->pool;
1900 if ($self->id >= pool->nrepos)
1902 while (++$self->id < pool->nrepos) {
1903 Repo *r = pool_id2repo(pool, $self->id);
1912 while ((n = Pool_repo_iterator___next__($self)) != 0) {
1913 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
1917 Repo *__getitem__(Id key) {
1918 Pool *pool = $self->pool;
1919 if (key > 0 && key < pool->nrepos)
1920 return pool_id2repo(pool, key);
1924 return $self->pool->nrepos;
1928 %extend Repo_solvable_iterator {
1929 Repo_solvable_iterator(Repo *repo) {
1930 Repo_solvable_iterator *s;
1931 s = solv_calloc(1, sizeof(*s));
1935 #if defined(SWIGPYTHON)
1936 %newobject __iter__;
1937 Repo_solvable_iterator *__iter__() {
1938 Repo_solvable_iterator *s;
1939 s = solv_calloc(1, sizeof(*s));
1943 %rename("next") __next__();
1944 %exception __next__ {
1947 PyErr_SetString(PyExc_StopIteration,"no more matches");
1952 %newobject __next__;
1953 XSolvable *__next__() {
1954 Repo *repo = $self->repo;
1955 Pool *pool = repo->pool;
1956 if (repo->start > 0 && $self->id < repo->start)
1957 $self->id = repo->start - 1;
1958 if ($self->id >= repo->end)
1960 while (++$self->id < repo->end)
1961 if (pool->solvables[$self->id].repo == repo)
1962 return new_XSolvable(pool, $self->id);
1968 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
1969 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
1973 %newobject __getitem__;
1974 XSolvable *__getitem__(Id key) {
1975 Repo *repo = $self->repo;
1976 Pool *pool = repo->pool;
1977 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
1978 return new_XSolvable(pool, key);
1982 return $self->repo->pool->nsolvables;
1987 Dep(Pool *pool, Id id) {
1991 s = solv_calloc(1, sizeof(*s));
1997 Dep *Rel(int flags, DepId evrid, bool create=1) {
1998 Id id = pool_rel2id($self->pool, $self->id, evrid, flags, create);
2001 return new_Dep($self->pool, id);
2003 %newobject Selection_name;
2004 Selection *Selection_name(int setflags=0) {
2005 Selection *sel = new_Selection($self->pool);
2006 if (ISRELDEP($self->id)) {
2007 Reldep *rd = GETRELDEP($self->pool, $self->id);
2008 if (rd->flags == REL_EQ) {
2009 setflags |= $self->pool->disttype == DISTTYPE_DEB || strchr(pool_id2str($self->pool, rd->evr), '-') != 0 ? SOLVER_SETEVR : SOLVER_SETEV;
2010 if (ISRELDEP(rd->name))
2011 rd = GETRELDEP($self->pool, rd->name);
2013 if (rd->flags == REL_ARCH)
2014 setflags |= SOLVER_SETARCH;
2016 queue_push2(&sel->q, SOLVER_SOLVABLE_NAME | setflags, $self->id);
2019 %newobject Selection_provides;
2020 Selection *Selection_provides(int setflags=0) {
2021 Selection *sel = new_Selection($self->pool);
2022 if (ISRELDEP($self->id)) {
2023 Reldep *rd = GETRELDEP($self->pool, $self->id);
2024 if (rd->flags == REL_ARCH)
2025 setflags |= SOLVER_SETARCH;
2027 queue_push2(&sel->q, SOLVER_SOLVABLE_PROVIDES | setflags, $self->id);
2031 return pool_dep2str($self->pool, $self->id);
2033 bool __eq__(Dep *s) {
2034 return $self->pool == s->pool && $self->id == s->id;
2036 bool __ne__(Dep *s) {
2037 return !Dep___eq__($self, s);
2039 #if defined(SWIGPERL)
2040 %rename("str") __str__;
2042 const char *__str__() {
2043 return pool_dep2str($self->pool, $self->id);
2045 %newobject __repr__;
2046 const char *__repr__() {
2048 sprintf(buf, "<Id #%d ", $self->id);
2049 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
2054 XSolvable(Pool *pool, Id id) {
2056 if (!id || id >= pool->nsolvables)
2058 s = solv_calloc(1, sizeof(*s));
2064 return pool_solvid2str($self->pool, $self->id);
2066 const char *lookup_str(Id keyname) {
2067 return pool_lookup_str($self->pool, $self->id, keyname);
2069 Id lookup_id(Id keyname) {
2070 return pool_lookup_id($self->pool, $self->id, keyname);
2072 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
2073 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
2075 bool lookup_void(Id keyname) {
2076 return pool_lookup_void($self->pool, $self->id, keyname);
2078 %newobject lookup_checksum;
2079 Chksum *lookup_checksum(Id keyname) {
2081 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
2082 return solv_chksum_create_from_bin(type, b);
2084 Queue lookup_idarray(Id keyname, Id marker = -1) {
2085 Solvable *s = $self->pool->solvables + $self->id;
2088 if (marker == -1 || marker == 1) {
2089 if (keyname == SOLVABLE_PROVIDES)
2090 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
2091 else if (keyname == SOLVABLE_REQUIRES)
2092 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2096 solvable_lookup_deparray(s, keyname, &r, marker);
2099 %typemap(out) Queue lookup_deparray Queue2Array(Dep *, 1, new_Dep(arg1->pool, id));
2100 %newobject lookup_deparray;
2101 Queue lookup_deparray(Id keyname, Id marker = -1) {
2102 Solvable *s = $self->pool->solvables + $self->id;
2105 if (marker == -1 || marker == 1) {
2106 if (keyname == SOLVABLE_PROVIDES)
2107 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
2108 else if (keyname == SOLVABLE_REQUIRES)
2109 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2113 solvable_lookup_deparray(s, keyname, &r, marker);
2116 const char *lookup_location(unsigned int *OUTPUT) {
2117 return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT);
2119 %newobject Dataiterator;
2120 Dataiterator *Dataiterator(Id key, const char *match, int flags) {
2121 return new_Dataiterator($self->pool, 0, $self->id, key, match, flags);
2124 %rename("installable?") installable;
2126 bool installable() {
2127 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
2130 %rename("isinstalled?") isinstalled;
2132 bool isinstalled() {
2133 Pool *pool = $self->pool;
2134 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
2139 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
2140 Pool *pool = xs->pool;
2141 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
2143 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
2144 Pool *pool = xs->pool;
2145 return pool_id2str(pool, pool->solvables[xs->id].name);
2150 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
2151 xs->pool->solvables[xs->id].name = nameid;
2153 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
2154 return xs->pool->solvables[xs->id].name;
2159 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
2160 Pool *pool = xs->pool;
2161 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
2163 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
2164 Pool *pool = xs->pool;
2165 return pool_id2str(pool, pool->solvables[xs->id].evr);
2170 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
2171 xs->pool->solvables[xs->id].evr = evrid;
2173 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
2174 return xs->pool->solvables[xs->id].evr;
2179 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
2180 Pool *pool = xs->pool;
2181 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
2183 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
2184 Pool *pool = xs->pool;
2185 return pool_id2str(pool, pool->solvables[xs->id].arch);
2190 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
2191 xs->pool->solvables[xs->id].arch = archid;
2193 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
2194 return xs->pool->solvables[xs->id].arch;
2199 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
2200 Pool *pool = xs->pool;
2201 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
2203 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
2204 Pool *pool = xs->pool;
2205 return pool_id2str(pool, pool->solvables[xs->id].vendor);
2210 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
2211 xs->pool->solvables[xs->id].vendor = vendorid;
2213 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
2214 return xs->pool->solvables[xs->id].vendor;
2219 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
2220 return xs->pool->solvables[xs->id].repo;
2224 /* old interface, please use the generic add_deparray instead */
2225 void add_provides(DepId id, Id marker = -1) {
2226 Solvable *s = $self->pool->solvables + $self->id;
2227 if (marker == -1 || marker == 1)
2228 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
2229 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
2231 void add_obsoletes(DepId id) {
2232 Solvable *s = $self->pool->solvables + $self->id;
2233 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
2235 void add_conflicts(DepId id) {
2236 Solvable *s = $self->pool->solvables + $self->id;
2237 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2239 void add_requires(DepId id, Id marker = -1) {
2240 Solvable *s = $self->pool->solvables + $self->id;
2241 if (marker == -1 || marker == 1)
2242 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2243 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
2245 void add_recommends(DepId id) {
2246 Solvable *s = $self->pool->solvables + $self->id;
2247 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
2249 void add_suggests(DepId id) {
2250 Solvable *s = $self->pool->solvables + $self->id;
2251 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
2253 void add_supplements(DepId id) {
2254 Solvable *s = $self->pool->solvables + $self->id;
2255 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
2257 void add_enhances(DepId id) {
2258 Solvable *s = $self->pool->solvables + $self->id;
2259 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
2262 void add_deparray(Id keyname, DepId id, Id marker = -1) {
2263 Solvable *s = $self->pool->solvables + $self->id;
2264 if (marker == -1 || marker == 1) {
2265 if (keyname == SOLVABLE_PROVIDES)
2266 marker = marker < 0 ? -SOLVABLE_FILEMARKER : SOLVABLE_FILEMARKER;
2267 else if (keyname == SOLVABLE_REQUIRES)
2268 marker = marker < 0 ? -SOLVABLE_PREREQMARKER : SOLVABLE_PREREQMARKER;
2272 solvable_add_deparray(s, keyname, id, marker);
2275 %newobject Selection;
2276 Selection *Selection(int setflags=0) {
2277 Selection *sel = new_Selection($self->pool);
2278 queue_push2(&sel->q, SOLVER_SOLVABLE | setflags, $self->id);
2282 bool __eq__(XSolvable *s) {
2283 return $self->pool == s->pool && $self->id == s->id;
2285 bool __ne__(XSolvable *s) {
2286 return !XSolvable___eq__($self, s);
2288 #if defined(SWIGPERL)
2289 %rename("str") __str__;
2291 const char *__str__() {
2292 return pool_solvid2str($self->pool, $self->id);
2294 %newobject __repr__;
2295 const char *__repr__() {
2297 sprintf(buf, "<Solvable #%d ", $self->id);
2298 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
2303 Problem(Solver *solv, Id id) {
2305 p = solv_calloc(1, sizeof(*p));
2310 %newobject findproblemrule;
2311 XRule *findproblemrule() {
2312 Id r = solver_findproblemrule($self->solv, $self->id);
2313 return new_XRule($self->solv, r);
2315 %newobject findallproblemrules;
2316 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
2317 Queue findallproblemrules(int unfiltered=0) {
2318 Solver *solv = $self->solv;
2323 solver_findallproblemrules(solv, $self->id, &q);
2326 for (i = j = 0; i < q.count; i++)
2328 SolverRuleinfo rclass;
2329 probr = q.elements[i];
2330 rclass = solver_ruleclass(solv, probr);
2331 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
2333 q.elements[j++] = probr;
2336 queue_truncate(&q, j);
2340 int solution_count() {
2341 return solver_solution_count($self->solv, $self->id);
2343 %newobject solutions;
2344 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
2349 cnt = solver_solution_count($self->solv, $self->id);
2350 for (i = 1; i <= cnt; i++)
2357 Solution(Problem *p, Id id) {
2359 s = solv_calloc(1, sizeof(*s));
2361 s->problemid = p->id;
2365 int element_count() {
2366 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2369 %newobject elements;
2370 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
2371 Queue elements(bool expandreplaces=0) {
2375 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2376 for (i = 1; i <= cnt; i++)
2379 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
2381 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
2387 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
2388 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
2390 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
2391 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2392 queue_push2(&q, p, rp);
2394 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
2395 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2396 queue_push2(&q, p, rp);
2398 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
2399 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2400 queue_push2(&q, p, rp);
2402 if ((illegal & POLICY_ILLEGAL_NAMECHANGE) != 0) {
2403 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_NAMECHANGE);
2404 queue_push2(&q, p, rp);
2409 queue_push2(&q, i, type);
2410 queue_push2(&q, p, rp);
2416 %extend Solutionelement {
2417 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
2419 e = solv_calloc(1, sizeof(*e));
2421 e->problemid = problemid;
2433 if (p == SOLVER_SOLUTION_ERASE)
2438 else if (p == SOLVER_SOLUTION_REPLACE)
2443 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
2444 illegal = POLICY_ILLEGAL_DOWNGRADE;
2445 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
2446 illegal = POLICY_ILLEGAL_ARCHCHANGE;
2447 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2448 illegal = POLICY_ILLEGAL_VENDORCHANGE;
2449 else if (p == SOLVER_SOLUTION_REPLACE_NAMECHANGE)
2450 illegal = POLICY_ILLEGAL_NAMECHANGE;
2452 return pool_tmpjoin($self->solv->pool, "allow ", policy_illegal2str($self->solv, illegal, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp), 0);
2453 return solver_solutionelement2str($self->solv, p, rp);
2455 %newobject replaceelements;
2456 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
2457 Queue replaceelements() {
2462 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2465 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2466 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
2467 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2468 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
2469 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2470 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
2471 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2472 if ((illegal & POLICY_ILLEGAL_NAMECHANGE) != 0)
2473 queue_push(&q, SOLVER_SOLUTION_REPLACE_NAMECHANGE);
2475 queue_push(&q, $self->type);
2478 int illegalreplace() {
2479 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2481 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2483 %newobject solvable;
2484 XSolvable * const solvable;
2485 %newobject replacement;
2486 XSolvable * const replacement;
2489 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
2490 return new_XSolvable(e->solv->pool, e->p);
2492 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
2493 return new_XSolvable(e->solv->pool, e->rp);
2495 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
2496 if (e->type != SOLVER_SOLUTION_JOB)
2498 return (e->p - 1) / 2;
2503 Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
2504 if ($self->type == SOLVER_SOLUTION_JOB)
2505 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
2506 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE || $self->type == SOLVER_SOLUTION_BEST)
2507 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->p);
2508 if ($self->type == SOLVER_SOLUTION_REPLACE || $self->type == SOLVER_SOLUTION_REPLACE_DOWNGRADE || $self->type == SOLVER_SOLUTION_REPLACE_ARCHCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_VENDORCHANGE || $self->type == SOLVER_SOLUTION_REPLACE_NAMECHANGE)
2509 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|extraflags, $self->rp);
2510 if ($self->type == SOLVER_SOLUTION_ERASE)
2511 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE|extraflags, $self->p);
2517 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
2518 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
2519 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
2520 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2521 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2522 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2523 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2524 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2525 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2526 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2527 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2528 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2529 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2530 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2531 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2532 static const int SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM = SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM;
2533 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2534 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2535 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2536 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2538 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2539 static const int SOLVER_SOLUTION_POOLJOB = SOLVER_SOLUTION_POOLJOB;
2540 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2541 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2542 static const int SOLVER_SOLUTION_BEST = SOLVER_SOLUTION_BEST;
2543 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2544 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2545 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2546 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2547 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2548 static const int SOLVER_SOLUTION_REPLACE_NAMECHANGE = SOLVER_SOLUTION_REPLACE_NAMECHANGE;
2550 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2551 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2552 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2553 static const int POLICY_ILLEGAL_NAMECHANGE = POLICY_ILLEGAL_NAMECHANGE;
2555 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2556 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2557 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2558 static const int SOLVER_FLAG_ALLOW_NAMECHANGE = SOLVER_FLAG_ALLOW_NAMECHANGE;
2559 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2560 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2561 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2562 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2563 static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
2564 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2570 int set_flag(int flag, int value) {
2571 return solver_set_flag($self, flag, value);
2573 int get_flag(int flag) {
2574 return solver_get_flag($self, flag);
2576 #if defined(SWIGPYTHON)
2578 def solve(self, jobs):
2580 for job in jobs: j += [job.how, job.what]
2581 return self.solve_helper(j)
2584 #if defined(SWIGPERL)
2586 sub solv::Solver::solve {
2587 my ($self, $jobs) = @_;
2588 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2589 return $self->solve_helper(\@j);
2593 #if defined(SWIGRUBY)
2596 "class Solv::Solver\n"
2597 " def solve(jobs)\n"
2599 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2600 " solve_helper(jl)\n"
2606 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2607 %newobject solve_helper;
2608 Queue solve_helper(Queue jobs) {
2612 solver_solve($self, &jobs);
2613 cnt = solver_problem_count($self);
2614 for (i = 1; i <= cnt; i++)
2618 %newobject transaction;
2619 Transaction *transaction() {
2620 return solver_create_transaction($self);
2624 %extend Transaction {
2625 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2626 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2627 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2628 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2629 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2630 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2631 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2632 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2633 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2634 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2635 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2636 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2637 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2638 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2639 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2640 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2641 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2642 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2643 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2644 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2645 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2646 static const int SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE = SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE;
2647 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2648 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2649 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2650 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2651 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2652 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2654 transaction_free($self);
2657 %rename("isempty?") isempty;
2660 return $self->steps.count == 0;
2663 %newobject othersolvable;
2664 XSolvable *othersolvable(XSolvable *s) {
2665 Id op = transaction_obs_pkg($self, s->id);
2666 return new_XSolvable($self->pool, op);
2669 %newobject allothersolvables;
2670 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2671 Queue allothersolvables(XSolvable *s) {
2674 transaction_all_obs_pkgs($self, s->id, &q);
2678 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2679 %newobject classify;
2680 Queue classify(int mode = 0) {
2683 transaction_classify($self, mode, &q);
2687 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2688 %newobject newpackages;
2689 Queue newpackages() {
2693 cut = transaction_installedresult(self, &q);
2694 queue_truncate(&q, cut);
2698 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2699 %newobject keptpackages;
2700 Queue keptpackages() {
2704 cut = transaction_installedresult(self, &q);
2706 queue_deleten(&q, 0, cut);
2710 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2714 queue_init_clone(&q, &$self->steps);
2718 int steptype(XSolvable *s, int mode) {
2719 return transaction_type($self, s->id, mode);
2721 int calc_installsizechange() {
2722 return transaction_calc_installsizechange($self);
2724 void order(int flags) {
2725 transaction_order($self, flags);
2729 %extend TransactionClass {
2730 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2731 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2732 cl->transaction = trans;
2736 cl->fromid = fromid;
2740 %newobject solvables;
2741 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2745 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2750 return new_Dep($self->transaction->pool, $self->fromid);
2754 return new_Dep($self->transaction->pool, $self->toid);
2759 XRule(Solver *solv, Id id) {
2762 XRule *xr = solv_calloc(1, sizeof(*xr));
2768 Id type, source, target, dep;
2769 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
2770 return new_Ruleinfo($self, type, source, target, dep);
2772 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
2773 %newobject allinfos;
2777 solver_allruleinfos($self->solv, $self->id, &q);
2781 bool __eq__(XRule *xr) {
2782 return $self->solv == xr->solv && $self->id == xr->id;
2784 bool __ne__(XRule *xr) {
2785 return !XRule___eq__($self, xr);
2787 %newobject __repr__;
2788 const char *__repr__() {
2790 sprintf(buf, "<Rule #%d>", $self->id);
2791 return solv_strdup(buf);
2796 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
2797 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
2801 ri->source = source;
2802 ri->target = target;
2806 XSolvable * const solvable;
2807 XSolvable * const othersolvable;
2809 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
2810 return new_XSolvable(ri->solv->pool, ri->source);
2812 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
2813 return new_XSolvable(ri->solv->pool, ri->target);
2816 const char *problemstr() {
2817 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
2822 XRepodata(Repo *repo, Id id) {
2823 XRepodata *xr = solv_calloc(1, sizeof(*xr));
2829 return repodata_new_handle(repo_id2repodata($self->repo, $self->id));
2831 void set_id(Id solvid, Id keyname, DepId id) {
2832 repodata_set_id(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2834 void set_str(Id solvid, Id keyname, const char *str) {
2835 repodata_set_str(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2837 void set_poolstr(Id solvid, Id keyname, const char *str) {
2838 repodata_set_poolstr(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
2840 void add_idarray(Id solvid, Id keyname, DepId id) {
2841 repodata_add_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
2843 void add_flexarray(Id solvid, Id keyname, Id handle) {
2844 repodata_add_flexarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, handle);
2846 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
2847 const unsigned char *buf = solv_chksum_get(chksum, 0);
2849 repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
2851 const char *lookup_str(Id solvid, Id keyname) {
2852 return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
2854 Queue lookup_idarray(Id solvid, Id keyname) {
2857 repodata_lookup_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, &r);
2860 %newobject lookup_checksum;
2861 Chksum *lookup_checksum(Id solvid, Id keyname) {
2863 const unsigned char *b = repodata_lookup_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, &type);
2864 return solv_chksum_create_from_bin(type, b);
2866 void internalize() {
2867 repodata_internalize(repo_id2repodata($self->repo, $self->id));
2869 void create_stubs() {
2870 repodata_create_stubs(repo_id2repodata($self->repo, $self->id));
2872 void write(FILE *fp) {
2873 repodata_write(repo_id2repodata($self->repo, $self->id), fp);
2875 bool add_solv(FILE *fp, int flags = 0) {
2876 Repodata *data = repo_id2repodata($self->repo, $self->id);
2877 int r, oldstate = data->state;
2878 data->state = REPODATA_LOADING;
2879 r = repo_add_solv(data->repo, fp, flags | REPO_USE_LOADING);
2880 if (r || data->state == REPODATA_LOADING)
2881 data->state = oldstate;
2884 void extend_to_repo() {
2885 Repodata *data = repo_id2repodata($self->repo, $self->id);
2886 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
2888 bool __eq__(XRepodata *xr) {
2889 return $self->repo == xr->repo && $self->id == xr->id;
2891 bool __ne__(XRepodata *xr) {
2892 return !XRepodata___eq__($self, xr);
2894 %newobject __repr__;
2895 const char *__repr__() {
2897 sprintf(buf, "<Repodata #%d>", $self->id);
2898 return solv_strdup(buf);