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
10 %markfunc Pool "mark_Pool";
24 %typemap(in,noblock=1,fragment="SWIG_AsCharPtrAndSize") (const unsigned char *str, size_t len) (int res, char *buf = 0, size_t size = 0, int alloc = 0) {
25 res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
26 if (!SWIG_IsOK(res)) {
27 #if defined(SWIGPYTHON)
28 const void *pybuf = 0;
29 Py_ssize_t pysize = 0;
30 res = PyObject_AsReadBuffer($input, &pybuf, &pysize);
32 %argument_fail(res, "BinaryBlob", $symname, $argnum);
38 %argument_fail(res, "const char *", $symname, $argnum);
41 $1 = (unsigned char *)buf;
45 %typemap(freearg,noblock=1,match="in") (const unsigned char *str, int len) {
46 if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
49 %typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") BinaryBlob {
50 #if defined(SWIGPYTHON) && defined(PYTHON3)
51 $result = $1.data ? Py_BuildValue("y#", $1.data, $1.len) : SWIG_Py_Void();
53 $result = SWIG_FromCharPtrAndSize($1.data, $1.len);
60 #if defined(SWIGPYTHON)
62 /* Check if is a list */
64 if (PyList_Check($input)) {
65 int size = PyList_Size($input);
67 for (i = 0; i < size; i++) {
68 PyObject *o = PyList_GetItem($input,i);
70 int e = SWIG_AsVal_int(o, &v);
72 SWIG_exception_fail(SWIG_ArgError(e), "list must contain only integers");
79 PyErr_SetString(PyExc_TypeError,"not a list");
86 PyObject *o = PyList_New($1.count);
87 for (i = 0; i < $1.count; i++)
88 PyList_SetItem(o, i, SWIG_From_int($1.elements[i]));
93 %define Queue2Array(type, step, con) %{
95 int cnt = $1.count / step;
96 Id *idp = $1.elements;
97 PyObject *o = PyList_New(cnt);
98 for (i = 0; i < cnt; i++, idp += step)
101 #define result resultx
104 PyList_SetItem(o, i, $result);
115 #if defined(SWIGPERL)
120 if (!SvROK($input) || SvTYPE(SvRV($input)) != SVt_PVAV)
121 SWIG_croak("Argument $argnum is not an array reference.");
122 av = (AV*)SvRV($input);
124 for (i = 0; i <= size; i++) {
125 SV **sv = av_fetch(av, i, 0);
127 int e = SWIG_AsVal_int(*sv, &v);
129 SWIG_croak("list must contain only integers");
135 # av_push(o, SvREFCNT_inc(SWIG_From_int($1.elements[i])));
136 # $result = newRV_noinc((SV*)o); argvi++;
138 %typemap(out) Queue {
140 if (argvi + $1.count + 1 >= items) {
141 EXTEND(sp, (argvi + $1.count + 1) - items + 1);
143 for (i = 0; i < $1.count; i++)
144 ST(argvi++) = SvREFCNT_inc(SWIG_From_int($1.elements[i]));
148 %define Queue2Array(type, step, con) %{
150 int cnt = $1.count / step;
151 Id *idp = $1.elements;
152 if (argvi + cnt + 1 >= items) {
153 EXTEND(sp, (argvi + cnt + 1) - items + 1);
155 for (i = 0; i < cnt; i++, idp += step)
158 #define result resultx
161 SvREFCNT_inc(ST(argvi - 1));
171 %typemap(arginit) Queue {
174 %typemap(freearg) Queue {
178 #if defined(SWIGRUBY)
183 size = RARRAY_LEN($input);
185 o = RARRAY_PTR($input);
186 for (i = 0; i < size; i++, o++) {
188 int e = SWIG_AsVal_int(*o, &v);
191 SWIG_Error(SWIG_RuntimeError, "list must contain only integers");
197 %typemap(out) Queue {
199 VALUE o = rb_ary_new2($1.count);
200 for (i = 0; i < $1.count; i++)
201 rb_ary_store(o, i, SWIG_From_int($1.elements[i]));
205 %typemap(arginit) Queue {
208 %typemap(freearg) Queue {
211 %define Queue2Array(type, step, con) %{
213 int cnt = $1.count / step;
214 Id *idp = $1.elements;
215 VALUE o = rb_ary_new2(cnt);
216 for (i = 0; i < cnt; i++, idp += step)
219 #define result resultx
222 rb_ary_store(o, i, $result);
234 #if defined(SWIGPERL)
236 # work around a swig bug
240 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv,pPerl)
242 # ifndef MULTIPLICITY
243 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(cv)
245 # define SWIG_CALLXS(_name) TOPMARK=MARK-PL_stack_base;_name(PERL_GET_THX, cv)
251 %define perliter(class)
254 my $i = ${##class##::ITERATORS}{$_[0]};
256 $_[1] == $i->[0] - 1 ? $i->[1] : undef;
258 $_[0]->__getitem__($_[1]);
261 sub class##::FETCHSIZE {
262 my $i = ${##class##::ITERATORS}{$_[0]};
264 ($i->[1] = $_[0]->__next__()) ? ++$i->[0] : 0;
274 #define SWIG_PERL_ITERATOR 0x80
276 SWIGRUNTIMEINLINE SV *
277 SWIG_Perl_NewArrayObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
278 SV *result = sv_newmortal();
279 if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
284 sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
285 stash=SvSTASH(SvRV(obj));
286 if (flags & SWIG_POINTER_OWN) {
288 GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
290 gv_init(gv, stash, "OWNER", 5, FALSE);
292 hv_store_ent(hv, obj, newSViv(1), 0);
294 if (flags & SWIG_PERL_ITERATOR) {
296 GV *gv=*(GV**)hv_fetch(stash, "ITERATORS", 9, TRUE);
299 gv_init(gv, stash, "ITERATORS", 9, FALSE);
301 hv_store_ent(hv, obj, newRV_inc((SV *)av), 0);
303 sv_magic((SV *)array, (SV *)obj, 'P', Nullch, 0);
305 self=newRV_noinc((SV *)array);
306 sv_setsv(result, self);
307 SvREFCNT_dec((SV *)self);
308 sv_bless(result, stash);
310 sv_setref_pv(result, (char *) SWIG_Perl_TypeProxyName(t), ptr);
317 %typemap(out) Perlarray {
318 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow); argvi++;
320 %typemap(out) Perliterator {
321 ST(argvi) = SWIG_Perl_NewArrayObj(SWIG_PERL_OBJECT_CALL SWIG_as_voidptr(result), $1_descriptor, $owner | $shadow | SWIG_PERL_ITERATOR); argvi++;
324 %typemap(out) Pool_solvable_iterator * = Perlarray;
325 %typemap(out) Pool_solvable_iterator * solvables_iter = Perliterator;
326 %typemap(out) Pool_repo_iterator * = Perlarray;
327 %typemap(out) Pool_repo_iterator * repos_iter = Perliterator;
328 %typemap(out) Repo_solvable_iterator * = Perlarray;
329 %typemap(out) Repo_solvable_iterator * solvables_iter = Perliterator;
330 %typemap(out) Dataiterator * = Perliterator;
335 #if defined(SWIGPYTHON)
336 typedef PyObject *AppObjectPtr;
337 %typemap(out) AppObjectPtr {
338 $result = $1 ? $1 : Py_None;
342 #if defined(SWIGPERL)
343 typedef SV *AppObjectPtr;
344 %typemap(in) AppObjectPtr {
345 $1 = SvROK($input) ? SvRV($input) : 0;
347 %typemap(out) AppObjectPtr {
348 $result = $1 ? newRV_inc($1) : newSV(0);
352 #if defined(SWIGRUBY)
353 typedef VALUE AppObjectPtr;
354 %typemap(in) AppObjectPtr {
357 %typemap(out) AppObjectPtr {
366 %fragment("SWIG_AsValFilePtr","header") {}
370 %fragment("SWIG_AsValSolvFpPtr","header", fragment="SWIG_AsValFilePtr") {
374 SWIG_AsValSolvFpPtr(VALUE obj, FILE **val) {
376 SWIG_AsValSolvFpPtr(void *obj, FILE **val) {
378 static swig_type_info* desc = 0;
382 if (!desc) desc = SWIG_TypeQuery("SolvFp *");
383 if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
385 *val = vptr ? ((SolvFp *)vptr)->fp : 0;
389 ecode = SWIG_AsValFilePtr(obj, val);
390 if (ecode == SWIG_OK)
393 return SWIG_TypeError;
399 %fragment("SWIG_AsValDepId","header") {
403 SWIG_AsValDepId(VALUE obj, int *val) {
405 SWIG_AsValDepId(void *obj, int *val) {
407 static swig_type_info* desc = 0;
410 if (!desc) desc = SWIG_TypeQuery("Dep *");
411 ecode = SWIG_AsVal_int(obj, val);
412 if (SWIG_IsOK(ecode))
414 if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
416 *val = vptr ? ((Dep *)vptr)->id : 0;
419 return SWIG_TypeError;
424 %typemap(out) disown_helper {
426 SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 );
429 SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 );
432 SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 );
434 $result = SWIG_From_int((int)(0));
437 %include "typemaps.i"
439 %typemap(in,numinputs=0,noblock=1) XRule **OUTPUT ($*1_ltype temp) {
442 %typemap(argout,noblock=1) XRule **OUTPUT {
443 %append_output(SWIG_NewPointerObj((void*)(*$1), SWIGTYPE_p_XRule, SWIG_POINTER_OWN | %newpointer_flags));
446 %typemaps_asval(%checkcode(POINTER), SWIG_AsValSolvFpPtr, "SWIG_AsValSolvFpPtr", FILE*);
447 %typemaps_asval(%checkcode(INT32), SWIG_AsValDepId, "SWIG_AsValDepId", DepId);
453 #include <sys/stat.h>
454 #include <sys/utsname.h>
455 #include <sys/types.h>
458 /* argh, swig undefs bool for perl */
464 #include "poolarch.h"
468 #include "solverdebug.h"
469 #include "repo_solv.h"
471 #include "selection.h"
473 #include "repo_write.h"
475 #include "repo_rpmdb.h"
478 #include "repo_pubkey.h"
481 #include "repo_deb.h"
484 #include "repo_rpmmd.h"
485 #include "repo_updateinfoxml.h"
486 #include "repo_deltainfoxml.h"
487 #include "repo_repomdxml.h"
489 #ifdef ENABLE_SUSEREPO
490 #include "repo_products.h"
491 #include "repo_susetags.h"
492 #include "repo_content.h"
494 #ifdef ENABLE_MDKREPO
495 #include "repo_mdk.h"
497 #ifdef ENABLE_ARCHREPO
498 #include "repo_arch.h"
500 #include "solv_xfopen.h"
502 /* for old ruby versions */
504 #define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
507 #define RARRAY_LEN(ary) (RARRAY(ary)->len)
510 #define SOLVER_SOLUTION_ERASE -100
511 #define SOLVER_SOLUTION_REPLACE -101
512 #define SOLVER_SOLUTION_REPLACE_DOWNGRADE -102
513 #define SOLVER_SOLUTION_REPLACE_ARCHCHANGE -103
514 #define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
515 #define SOLVER_SOLUTION_REPLACE_NAMECHANGE -105
517 typedef void *AppObjectPtr;
543 } Pool_solvable_iterator;
548 } Pool_repo_iterator;
553 } Repo_solvable_iterator;
593 Transaction *transaction;
611 typedef Dataiterator Datamatch;
613 typedef int disown_helper;
618 %mixin Dataiterator "Enumerable";
619 %mixin Pool_solvable_iterator "Enumerable";
620 %mixin Pool_repo_iterator "Enumerable";
621 %mixin Repo_solvable_iterator "Enumerable";
629 %constant Id SOLVID_META;
630 %constant Id SOLVID_POS;
632 %constant int REL_EQ;
633 %constant int REL_GT;
634 %constant int REL_LT;
635 %constant int REL_ARCH;
646 # put before pool/repo so we can access the constructor
647 %nodefaultdtor Dataiterator;
648 typedef struct {} Dataiterator;
671 typedef struct {} Pool_solvable_iterator;
672 typedef struct {} Pool_repo_iterator;
673 typedef struct {} Repo_solvable_iterator;
675 %nodefaultctor Datamatch;
676 %nodefaultdtor Datamatch;
683 %nodefaultctor Datapos;
697 AppObjectPtr appdata;
704 const char * const name;
707 int const nsolvables;
708 AppObjectPtr appdata;
711 %nodefaultctor Solver;
712 %nodefaultdtor Solver;
723 unsigned int const created;
724 unsigned int const expires;
725 const char * const keyid;
729 %rename(xfopen) solvfp_xfopen;
730 %rename(xfopen_fd) solvfp_xfopen_fd;
732 %nodefaultctor SolvFp;
736 %newobject solvfp_xfopen;
737 %newobject solvfp_xfopen_fd;
739 SolvFp *solvfp_xfopen(const char *fn, const char *mode = 0);
740 SolvFp *solvfp_xfopen_fd(const char *fn, int fd, const char *mode = 0);
743 SWIGINTERN SolvFp *solvfp_xfopen_fd(const char *fn, int fd, const char *mode) {
747 fp = fd == -1 ? 0 : solv_xfopen_fd(fn, fd, mode);
750 sfp = solv_calloc(1, sizeof(SolvFp));
754 SWIGINTERN SolvFp *solvfp_xfopen(const char *fn, const char *mode) {
757 fp = solv_xfopen(fn, mode);
760 sfp = solv_calloc(1, sizeof(SolvFp));
785 %nodefaultctor Transaction;
786 %nodefaultdtor Transaction;
792 Transaction * const transaction;
806 return $self->fp ? fileno($self->fp) : -1;
809 return $self->fp ? dup(fileno($self->fp)) : -1;
814 return fflush($self->fp) == 0;
820 ret = fclose($self->fp) == 0;
827 static const Id SOLVER_SOLVABLE = SOLVER_SOLVABLE;
828 static const Id SOLVER_SOLVABLE_NAME = SOLVER_SOLVABLE_NAME;
829 static const Id SOLVER_SOLVABLE_PROVIDES = SOLVER_SOLVABLE_PROVIDES;
830 static const Id SOLVER_SOLVABLE_ONE_OF = SOLVER_SOLVABLE_ONE_OF;
831 static const Id SOLVER_SOLVABLE_REPO = SOLVER_SOLVABLE_REPO;
832 static const Id SOLVER_SOLVABLE_ALL = SOLVER_SOLVABLE_ALL;
833 static const Id SOLVER_SELECTMASK = SOLVER_SELECTMASK;
834 static const Id SOLVER_NOOP = SOLVER_NOOP;
835 static const Id SOLVER_INSTALL = SOLVER_INSTALL;
836 static const Id SOLVER_ERASE = SOLVER_ERASE;
837 static const Id SOLVER_UPDATE = SOLVER_UPDATE;
838 static const Id SOLVER_WEAKENDEPS = SOLVER_WEAKENDEPS;
839 static const Id SOLVER_MULTIVERSION = SOLVER_MULTIVERSION;
840 static const Id SOLVER_LOCK = SOLVER_LOCK;
841 static const Id SOLVER_DISTUPGRADE = SOLVER_DISTUPGRADE;
842 static const Id SOLVER_VERIFY = SOLVER_VERIFY;
843 static const Id SOLVER_DROP_ORPHANED = SOLVER_DROP_ORPHANED;
844 static const Id SOLVER_USERINSTALLED = SOLVER_USERINSTALLED;
845 static const Id SOLVER_JOBMASK = SOLVER_JOBMASK;
846 static const Id SOLVER_WEAK = SOLVER_WEAK;
847 static const Id SOLVER_ESSENTIAL = SOLVER_ESSENTIAL;
848 static const Id SOLVER_CLEANDEPS = SOLVER_CLEANDEPS;
849 static const Id SOLVER_FORCEBEST = SOLVER_FORCEBEST;
850 static const Id SOLVER_TARGETED = SOLVER_TARGETED;
851 static const Id SOLVER_NOTBYUSER = SOLVER_NOTBYUSER;
852 static const Id SOLVER_SETEV = SOLVER_SETEV;
853 static const Id SOLVER_SETEVR = SOLVER_SETEVR;
854 static const Id SOLVER_SETARCH = SOLVER_SETARCH;
855 static const Id SOLVER_SETVENDOR = SOLVER_SETVENDOR;
856 static const Id SOLVER_SETREPO = SOLVER_SETREPO;
857 static const Id SOLVER_SETNAME = SOLVER_SETNAME;
858 static const Id SOLVER_NOAUTOSET = SOLVER_NOAUTOSET;
859 static const Id SOLVER_SETMASK = SOLVER_SETMASK;
861 Job(Pool *pool, int how, Id what) {
862 Job *job = solv_calloc(1, sizeof(*job));
869 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
870 %newobject solvables;
874 pool_job2solvables($self->pool, &q, $self->how, $self->what);
878 %rename("isemptyupdate?") isemptyupdate;
880 bool isemptyupdate() {
881 return pool_isemptyupdatejob($self->pool, $self->how, $self->what);
884 bool __eq__(Job *j) {
885 return $self->pool == j->pool && $self->how == j->how && $self->what == j->what;
887 bool __ne__(Job *j) {
888 return !Job___eq__($self, j);
890 #if defined(SWIGPERL)
891 %rename("str") __str__;
893 const char *__str__() {
894 return pool_job2str($self->pool, $self->how, $self->what, 0);
896 const char *__repr__() {
897 const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
898 return pool_tmpjoin($self->pool, "<Job ", str, ">");
903 static const Id SELECTION_NAME = SELECTION_NAME;
904 static const Id SELECTION_PROVIDES = SELECTION_PROVIDES;
905 static const Id SELECTION_FILELIST = SELECTION_FILELIST;
906 static const Id SELECTION_CANON = SELECTION_CANON;
907 static const Id SELECTION_DOTARCH = SELECTION_DOTARCH;
908 static const Id SELECTION_REL = SELECTION_REL;
909 static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
910 static const Id SELECTION_GLOB = SELECTION_GLOB;
911 static const Id SELECTION_FLAT = SELECTION_FLAT;
912 static const Id SELECTION_NOCASE = SELECTION_NOCASE;
913 static const Id SELECTION_SOURCE_ONLY = SELECTION_SOURCE_ONLY;
914 static const Id SELECTION_WITH_SOURCE = SELECTION_WITH_SOURCE;
916 Selection(Pool *pool) {
918 s = solv_calloc(1, sizeof(*s));
924 queue_free(&$self->q);
931 %rename("isempty?") isempty;
934 return $self->q.count == 0;
936 void filter(Selection *lsel) {
937 if ($self->pool != lsel->pool)
938 queue_empty(&$self->q);
940 selection_filter($self->pool, &$self->q, &lsel->q);
942 void add(Selection *lsel) {
943 if ($self->pool == lsel->pool)
945 selection_add($self->pool, &$self->q, &lsel->q);
946 $self->flags |= lsel->flags;
949 void add_raw(Id how, Id what) {
950 queue_push2(&$self->q, how, what);
952 %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1]));
954 Queue jobs(int flags) {
957 queue_init_clone(&q, &$self->q);
958 for (i = 0; i < q.count; i += 2)
959 q.elements[i] |= flags;
963 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
964 %newobject solvables;
968 selection_solvables($self->pool, &$self->q, &q);
972 #if defined(SWIGPERL)
973 %rename("str") __str__;
975 const char *__str__() {
976 return pool_selection2str($self->pool, &$self->q, 0);
978 const char *__repr__() {
979 const char *str = pool_selection2str($self->pool, &$self->q, ~0);
980 return pool_tmpjoin($self->pool, "<Selection ", str, ">");
986 return solv_chksum_create(type);
988 Chksum(Id type, const char *hex) {
989 unsigned char buf[64];
990 int l = solv_chksum_len(type);
993 if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
995 return solv_chksum_create_from_bin(type, buf);
998 solv_chksum_free($self, 0);
1002 SWIGINTERN Id Chksum_type_get(Chksum *chk) {
1003 return solv_chksum_get_type(chk);
1006 void add(const unsigned char *str, size_t len) {
1007 solv_chksum_add($self, str, (int)len);
1009 void add_fp(FILE *fp) {
1012 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
1013 solv_chksum_add($self, buf, l);
1014 rewind(fp); /* convenience */
1016 void add_fd(int fd) {
1019 while ((l = read(fd, buf, sizeof(buf))) > 0)
1020 solv_chksum_add($self, buf, l);
1021 lseek(fd, 0, 0); /* convenience */
1023 void add_stat(const char *filename) {
1025 if (stat(filename, &stb))
1026 memset(&stb, 0, sizeof(stb));
1027 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
1028 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
1029 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
1030 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
1032 void add_fstat(int fd) {
1034 if (fstat(fd, &stb))
1035 memset(&stb, 0, sizeof(stb));
1036 solv_chksum_add($self, &stb.st_dev, sizeof(stb.st_dev));
1037 solv_chksum_add($self, &stb.st_ino, sizeof(stb.st_ino));
1038 solv_chksum_add($self, &stb.st_size, sizeof(stb.st_size));
1039 solv_chksum_add($self, &stb.st_mtime, sizeof(stb.st_mtime));
1044 const unsigned char *b;
1045 b = solv_chksum_get($self, &l);
1053 const unsigned char *b;
1056 b = solv_chksum_get($self, &l);
1057 ret = solv_malloc(2 * l + 1);
1058 solv_bin2hex(b, l, ret);
1061 const char *typestr() {
1062 return solv_chksum_type2str(solv_chksum_get_type($self));
1065 bool __eq__(Chksum *chk) {
1067 const unsigned char *b, *bo;
1070 if (solv_chksum_get_type($self) != solv_chksum_get_type(chk))
1072 b = solv_chksum_get($self, &l);
1073 bo = solv_chksum_get(chk, 0);
1074 return memcmp(b, bo, l) == 0;
1076 bool __ne__(Chksum *chk) {
1077 return !Chksum___eq__($self, chk);
1079 #if defined(SWIGRUBY)
1080 %rename("to_s") __str__;
1082 #if defined(SWIGPERL)
1083 %rename("str") __str__;
1086 const char *__str__() {
1089 if (solv_chksum_isfinished($self))
1090 h = Chksum_hex($self);
1091 str = solv_dupjoin(solv_chksum_type2str(solv_chksum_get_type($self)), ":", h ? h : "unfinished");
1092 solv_free((void *)h);
1095 %newobject __repr__;
1096 const char *__repr__() {
1097 const char *h = Chksum___str__($self);
1098 const char *str = solv_dupjoin("<Chksum ", h, ">");
1099 solv_free((void *)h);
1105 static const int POOL_FLAG_PROMOTEEPOCH = POOL_FLAG_PROMOTEEPOCH;
1106 static const int POOL_FLAG_FORBIDSELFCONFLICTS = POOL_FLAG_FORBIDSELFCONFLICTS;
1107 static const int POOL_FLAG_OBSOLETEUSESPROVIDES = POOL_FLAG_OBSOLETEUSESPROVIDES;
1108 static const int POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES = POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES;
1109 static const int POOL_FLAG_OBSOLETEUSESCOLORS = POOL_FLAG_OBSOLETEUSESCOLORS;
1110 static const int POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS = POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS;
1111 static const int POOL_FLAG_NOINSTALLEDOBSOLETES = POOL_FLAG_NOINSTALLEDOBSOLETES;
1112 static const int POOL_FLAG_HAVEDISTEPOCH = POOL_FLAG_HAVEDISTEPOCH;
1113 static const int POOL_FLAG_NOOBSOLETESMULTIVERSION = POOL_FLAG_NOOBSOLETESMULTIVERSION;
1116 Pool *pool = pool_create();
1119 void set_debuglevel(int level) {
1120 pool_setdebuglevel($self, level);
1122 int set_flag(int flag, int value) {
1123 return pool_set_flag($self, flag, value);
1125 int get_flag(int flag) {
1126 return pool_get_flag($self, flag);
1128 void set_rootdir(const char *rootdir) {
1129 pool_set_rootdir($self, rootdir);
1131 const char *get_rootdir(int flag) {
1132 return pool_get_rootdir($self);
1134 #if defined(SWIGPYTHON)
1136 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1137 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1138 PyObject *args = Py_BuildValue("(O)", SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0));
1139 PyObject *result = PyEval_CallObject((PyObject *)d, args);
1144 return 0; /* exception */
1145 ecode = SWIG_AsVal_int(result, &vresult);
1147 return SWIG_IsOK(ecode) ? vresult : 0;
1150 void set_loadcallback(PyObject *callable) {
1151 if ($self->loadcallback == loadcallback) {
1152 PyObject *obj = $self->loadcallbackdata;
1156 Py_INCREF(callable);
1158 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
1161 #if defined(SWIGPERL)
1163 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1167 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1172 XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_OWNER | SWIG_SHADOW));
1174 count = perl_call_sv((SV *)d, G_EVAL|G_SCALAR);
1184 void set_loadcallback(SV *callable) {
1185 if ($self->loadcallback == loadcallback)
1186 SvREFCNT_dec($self->loadcallbackdata);
1188 SvREFCNT_inc(callable);
1189 pool_setloadcallback($self, callable ? loadcallback : 0, callable);
1193 #if defined(SWIGRUBY)
1195 SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
1196 XRepodata *xd = new_XRepodata(data->repo, data->repodataid);
1197 VALUE callable = (VALUE)d;
1198 VALUE rd = SWIG_NewPointerObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, SWIG_POINTER_OWN | 0);
1199 VALUE res = rb_funcall(callable, rb_intern("call"), 1, rd);
1200 return res == Qtrue;
1202 SWIGINTERN void mark_Pool(void *ptr) {
1204 if (pool->loadcallback == loadcallback && pool->loadcallbackdata) {
1205 VALUE callable = (VALUE)pool->loadcallbackdata;
1206 rb_gc_mark(callable);
1210 %typemap(in, numinputs=0) VALUE callable {
1211 $1 = rb_block_given_p() ? rb_block_proc() : 0;
1213 void set_loadcallback(VALUE callable) {
1214 pool_setloadcallback($self, callable ? loadcallback : 0, (void *)callable);
1219 Pool_set_loadcallback($self, 0);
1222 disown_helper free() {
1223 Pool_set_loadcallback($self, 0);
1227 disown_helper disown() {
1230 Id str2id(const char *str, bool create=1) {
1231 return pool_str2id($self, str, create);
1234 Dep *Dep(const char *str, bool create=1) {
1235 Id id = pool_str2id($self, str, create);
1236 return new_Dep($self, id);
1238 const char *id2str(Id id) {
1239 return pool_id2str($self, id);
1241 const char *dep2str(Id id) {
1242 return pool_dep2str($self, id);
1244 Id rel2id(Id name, Id evr, int flags, bool create=1) {
1245 return pool_rel2id($self, name, evr, flags, create);
1247 Id id2langid(Id id, const char *lang, bool create=1) {
1248 return pool_id2langid($self, id, lang, create);
1250 void setarch(const char *arch = 0) {
1259 pool_setarch($self, arch);
1261 Repo *add_repo(const char *name) {
1262 return repo_create($self, name);
1264 const char *lookup_str(Id entry, Id keyname) {
1265 return pool_lookup_str($self, entry, keyname);
1267 Id lookup_id(Id entry, Id keyname) {
1268 return pool_lookup_id($self, entry, keyname);
1270 unsigned long long lookup_num(Id entry, Id keyname, unsigned long long notfound = 0) {
1271 return pool_lookup_num($self, entry, keyname, notfound);
1273 bool lookup_void(Id entry, Id keyname) {
1274 return pool_lookup_void($self, entry, keyname);
1276 %newobject lookup_checksum;
1277 Chksum *lookup_checksum(Id entry, Id keyname) {
1279 const unsigned char *b = pool_lookup_bin_checksum($self, entry, keyname, &type);
1280 return solv_chksum_create_from_bin(type, b);
1283 %newobject Dataiterator;
1284 Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) {
1285 return new_Dataiterator($self, 0, 0, key, match, flags);
1287 %newobject Dataiterator_solvid;
1288 Dataiterator *Dataiterator_solvid(Id p, Id key, const char *match = 0, int flags = 0) {
1289 return new_Dataiterator($self, 0, p, key, match, flags);
1291 const char *solvid2str(Id solvid) {
1292 return pool_solvid2str($self, solvid);
1294 void addfileprovides() {
1295 pool_addfileprovides($self);
1297 Queue addfileprovides_queue() {
1300 pool_addfileprovides_queue($self, &r, 0);
1303 void createwhatprovides() {
1304 pool_createwhatprovides($self);
1307 %newobject id2solvable;
1308 XSolvable *id2solvable(Id id) {
1309 return new_XSolvable($self, id);
1311 %newobject solvables;
1312 Pool_solvable_iterator * const solvables;
1314 SWIGINTERN Pool_solvable_iterator * Pool_solvables_get(Pool *pool) {
1315 return new_Pool_solvable_iterator(pool);
1318 %newobject solvables_iter;
1319 Pool_solvable_iterator * solvables_iter() {
1320 return new_Pool_solvable_iterator($self);
1323 Repo *id2repo(Id id) {
1324 if (id < 1 || id >= $self->nrepos)
1326 return pool_id2repo($self, id);
1330 Pool_repo_iterator * const repos;
1332 SWIGINTERN Pool_repo_iterator * Pool_repos_get(Pool *pool) {
1333 return new_Pool_repo_iterator(pool);
1336 %newobject repos_iter;
1337 Pool_repo_iterator * repos_iter() {
1338 return new_Pool_repo_iterator($self);
1342 const char * const errstr;
1344 SWIGINTERN void Pool_installed_set(Pool *pool, Repo *installed) {
1345 pool_set_installed(pool, installed);
1347 Repo *Pool_installed_get(Pool *pool) {
1348 return pool->installed;
1350 const char *Pool_errstr_get(Pool *pool) {
1351 return pool_errstr(pool);
1355 Queue matchprovidingids(const char *match, int flags) {
1361 for (id = 1; id < pool->ss.nstrings; id++)
1362 if (pool->whatprovides[id])
1366 if (!datamatcher_init(&ma, match, flags)) {
1367 for (id = 1; id < pool->ss.nstrings; id++)
1368 if (pool->whatprovides[id] && datamatcher_match(&ma, pool_id2str(pool, id)))
1370 datamatcher_free(&ma);
1377 Job *Job(int how, Id what) {
1378 return new_Job($self, how, what);
1381 %typemap(out) Queue whatprovides Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1382 %newobject whatprovides;
1383 Queue whatprovides(DepId dep) {
1388 FOR_PROVIDES(p, pp, dep)
1393 Id towhatprovides(Queue q) {
1394 return pool_queuetowhatprovides($self, &q);
1398 %rename("isknownarch?") isknownarch;
1400 bool isknownarch(DepId id) {
1402 if (!id || id == ID_EMPTY)
1404 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1406 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1413 return solver_create($self);
1416 %newobject Selection;
1417 Selection *Selection() {
1418 return new_Selection($self);
1420 %newobject Selection_all;
1421 Selection *Selection_all(int setflags=0) {
1422 Selection *sel = new_Selection($self);
1423 queue_push2(&sel->q, SOLVER_SOLVABLE_ALL | setflags, 0);
1427 Selection *select(const char *name, int flags) {
1428 Selection *sel = new_Selection($self);
1429 sel->flags = selection_make($self, &sel->q, name, flags);
1433 void setpooljobs_helper(Queue jobs) {
1434 queue_free(&$self->pooljobs);
1435 queue_init_clone(&$self->pooljobs, &jobs);
1437 %typemap(out) Queue getpooljobs Queue2Array(Job *, 2, new_Job(arg1, id, idp[1]));
1438 %newobject getpooljobs;
1439 Queue getpooljobs() {
1441 queue_init_clone(&q, &$self->pooljobs);
1445 #if defined(SWIGPYTHON)
1447 def setpooljobs(self, jobs):
1449 for job in jobs: j += [job.how, job.what]
1450 self.setpooljobs_helper(j)
1453 #if defined(SWIGPERL)
1455 sub solv::Solver::setpooljobs {
1456 my ($self, $jobs) = @_;
1457 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
1458 return $self->setpooljobs_helper(\@j);
1462 #if defined(SWIGRUBY)
1465 "class Solv::Pool\n"
1466 " def setpooljobs(jobs)\n"
1468 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
1469 " setpooljobs_helper(jl)\n"
1478 static const int REPO_REUSE_REPODATA = REPO_REUSE_REPODATA;
1479 static const int REPO_NO_INTERNALIZE = REPO_NO_INTERNALIZE;
1480 static const int REPO_LOCALPOOL = REPO_LOCALPOOL;
1481 static const int REPO_USE_LOADING = REPO_USE_LOADING;
1482 static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
1483 static const int REPO_USE_ROOTDIR = REPO_USE_ROOTDIR;
1484 static const int REPO_NO_LOCATION = REPO_NO_LOCATION;
1485 static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS; /* repo_solv */
1486 #ifdef ENABLE_SUSEREPO
1487 static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES; /* repo_susetags */
1490 void free(bool reuseids = 0) {
1491 repo_free($self, reuseids);
1493 void empty(bool reuseids = 0) {
1494 repo_empty($self, reuseids);
1497 %rename("isempty?") isempty;
1500 return !$self->nsolvables;
1502 bool add_solv(const char *name, int flags = 0) {
1503 FILE *fp = fopen(name, "r");
1507 r = repo_add_solv($self, fp, flags);
1511 bool add_solv(FILE *fp, int flags = 0) {
1512 return repo_add_solv($self, fp, flags) == 0;
1515 %newobject add_solvable;
1516 XSolvable *add_solvable() {
1517 Id solvid = repo_add_solvable($self);
1518 return new_XSolvable($self->pool, solvid);
1522 bool add_rpmdb(int flags = 0) {
1523 return repo_add_rpmdb($self, 0, flags) == 0;
1525 bool add_rpmdb_reffp(FILE *reffp, int flags = 0) {
1526 return repo_add_rpmdb_reffp($self, reffp, flags) == 0;
1529 XSolvable *add_rpm(const char *name, int flags = 0) {
1530 return new_XSolvable($self->pool, repo_add_rpm($self, name, flags));
1533 #ifdef ENABLE_PUBKEY
1535 bool add_rpmdb_pubkeys(int flags = 0) {
1536 return repo_add_rpmdb_pubkeys($self, flags) == 0;
1539 %newobject add_pubkey;
1540 XSolvable *add_pubkey(const char *keyfile, int flags = 0) {
1541 return new_XSolvable($self->pool, repo_add_pubkey($self, keyfile, flags));
1543 bool add_keyring(FILE *fp, int flags = 0) {
1544 return repo_add_keyring($self, fp, flags);
1546 bool add_keydir(const char *keydir, const char *suffix, int flags = 0) {
1547 return repo_add_keydir($self, keydir, suffix, flags);
1551 bool add_rpmmd(FILE *fp, const char *language, int flags = 0) {
1552 return repo_add_rpmmd($self, fp, language, flags) == 0;
1554 bool add_repomdxml(FILE *fp, int flags = 0) {
1555 return repo_add_repomdxml($self, fp, flags) == 0;
1557 bool add_updateinfoxml(FILE *fp, int flags = 0) {
1558 return repo_add_updateinfoxml($self, fp, flags) == 0;
1560 bool add_deltainfoxml(FILE *fp, int flags = 0) {
1561 return repo_add_deltainfoxml($self, fp, flags) == 0;
1564 #ifdef ENABLE_DEBIAN
1565 bool add_debdb(int flags = 0) {
1566 return repo_add_debdb($self, flags) == 0;
1568 bool add_debpackages(FILE *fp, int flags = 0) {
1569 return repo_add_debpackages($self, fp, flags) == 0;
1572 XSolvable *add_deb(const char *name, int flags = 0) {
1573 return new_XSolvable($self->pool, repo_add_deb($self, name, flags));
1576 #ifdef ENABLE_SUSEREPO
1577 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0) {
1578 return repo_add_susetags($self, fp, defvendor, language, flags) == 0;
1580 bool add_content(FILE *fp, int flags = 0) {
1581 return repo_add_content($self, fp, flags) == 0;
1583 bool add_products(const char *proddir, int flags = 0) {
1584 return repo_add_products($self, proddir, flags) == 0;
1587 #ifdef ENABLE_MDKREPO
1588 bool add_mdk(FILE *fp, int flags = 0) {
1589 return repo_add_mdk($self, fp, flags) == 0;
1591 bool add_mdk_info(FILE *fp, int flags = 0) {
1592 return repo_add_mdk_info($self, fp, flags) == 0;
1595 #ifdef ENABLE_ARCHREPO
1596 bool add_arch_repo(FILE *fp, int flags = 0) {
1597 return repo_add_arch_repo($self, fp, flags) == 0;
1599 bool add_arch_local(const char *dir, int flags = 0) {
1600 return repo_add_arch_local($self, dir, flags) == 0;
1602 %newobject add_arch_pkg;
1603 XSolvable *add_arch_pkg(const char *name, int flags = 0) {
1604 return new_XSolvable($self->pool, repo_add_arch_pkg($self, name, flags));
1607 void internalize() {
1608 repo_internalize($self);
1610 bool write(FILE *fp) {
1611 return repo_write($self, fp) == 0;
1613 # HACK, remove if no longer needed!
1614 bool write_first_repodata(FILE *fp) {
1615 int oldnrepodata = $self->nrepodata;
1617 $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
1618 res = repo_write($self, fp);
1619 $self->nrepodata = oldnrepodata;
1623 %newobject Dataiterator;
1624 Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) {
1625 return new_Dataiterator($self->pool, $self, 0, key, match, flags);
1627 %newobject Dataiterator_meta;
1628 Dataiterator *Dataiterator_meta(Id key, const char *match = 0, int flags = 0) {
1629 return new_Dataiterator($self->pool, $self, SOLVID_META, key, match, flags);
1634 SWIGINTERN Id Repo_id_get(Repo *repo) {
1635 return repo->repoid;
1638 %newobject solvables;
1639 Repo_solvable_iterator * const solvables;
1641 SWIGINTERN Repo_solvable_iterator * Repo_solvables_get(Repo *repo) {
1642 return new_Repo_solvable_iterator(repo);
1646 Datapos * const meta;
1648 SWIGINTERN Datapos * Repo_meta_get(Repo *repo) {
1649 Datapos *pos = solv_calloc(1, sizeof(*pos));
1650 pos->solvid = SOLVID_META;
1656 %newobject solvables_iter;
1657 Repo_solvable_iterator *solvables_iter() {
1658 return new_Repo_solvable_iterator($self);
1661 %newobject add_repodata;
1662 XRepodata *add_repodata(int flags = 0) {
1663 Repodata *rd = repo_add_repodata($self, flags);
1664 return new_XRepodata($self, rd->repodataid);
1667 void create_stubs() {
1669 if (!$self->nrepodata)
1671 data = repo_id2repodata($self, $self->nrepodata - 1);
1672 if (data->state != REPODATA_STUB)
1673 (void)repodata_create_stubs(data);
1676 %rename("iscontiguous?") iscontiguous;
1678 bool iscontiguous() {
1680 for (i = $self->start; i < $self->end; i++)
1681 if ($self->pool->solvables[i].repo != $self)
1685 %newobject first_repodata;
1686 XRepodata *first_repodata() {
1689 if ($self->nrepodata < 2)
1691 /* make sure all repodatas but the first are extensions */
1692 data = repo_id2repodata($self, 1);
1693 if (data->loadcallback)
1695 for (i = 2; i < $self->nrepodata; i++)
1697 data = repo_id2repodata($self, i);
1698 if (!data->loadcallback)
1699 return 0; /* oops, not an extension */
1701 return new_XRepodata($self, 1);
1704 %newobject Selection;
1705 Selection *Selection(int setflags=0) {
1706 Selection *sel = new_Selection($self->pool);
1707 setflags |= SOLVER_SETREPO;
1708 queue_push2(&sel->q, SOLVER_SOLVABLE_REPO | setflags, $self->repoid);
1712 #ifdef ENABLE_PUBKEY
1713 %newobject find_pubkey;
1714 XSolvable *find_pubkey(const char *keyid) {
1715 return new_XSolvable($self->pool, repo_find_pubkey($self, keyid));
1719 bool __eq__(Repo *repo) {
1720 return $self == repo;
1722 bool __ne__(Repo *repo) {
1723 return $self != repo;
1725 #if defined(SWIGPERL)
1726 %rename("str") __str__;
1729 const char *__str__() {
1732 return solv_strdup($self->name);
1733 sprintf(buf, "Repo#%d", $self->repoid);
1734 return solv_strdup(buf);
1736 %newobject __repr__;
1737 const char *__repr__() {
1741 sprintf(buf, "<Repo #%d ", $self->repoid);
1742 return solv_dupjoin(buf, $self->name, ">");
1744 sprintf(buf, "<Repo #%d>", $self->repoid);
1745 return solv_strdup(buf);
1749 %extend Dataiterator {
1750 static const int SEARCH_STRING = SEARCH_STRING;
1751 static const int SEARCH_STRINGSTART = SEARCH_STRINGSTART;
1752 static const int SEARCH_STRINGEND = SEARCH_STRINGEND;
1753 static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
1754 static const int SEARCH_GLOB = SEARCH_GLOB;
1755 static const int SEARCH_REGEX = SEARCH_REGEX;
1756 static const int SEARCH_NOCASE = SEARCH_NOCASE;
1757 static const int SEARCH_FILES = SEARCH_FILES;
1758 static const int SEARCH_COMPLETE_FILELIST = SEARCH_COMPLETE_FILELIST;
1759 static const int SEARCH_CHECKSUMS = SEARCH_CHECKSUMS;
1761 Dataiterator(Pool *pool, Repo *repo, Id p, Id key, const char *match, int flags) {
1762 Dataiterator *di = solv_calloc(1, sizeof(*di));
1763 dataiterator_init(di, pool, repo, p, key, match, flags);
1767 dataiterator_free($self);
1770 #if defined(SWIGPYTHON)
1772 def __iter__(self): return self
1775 %rename("next") __next__();
1777 %exception __next__ {
1780 PyErr_SetString(PyExc_StopIteration,"no more matches");
1786 perliter(solv::Dataiterator)
1788 %newobject __next__;
1789 Datamatch *__next__() {
1791 if (!dataiterator_step($self)) {
1794 ndi = solv_calloc(1, sizeof(*ndi));
1795 dataiterator_init_clone(ndi, $self);
1796 dataiterator_strdup(ndi);
1802 while ((d = Dataiterator___next__($self)) != 0) {
1803 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(d), SWIGTYPE_p_Datamatch, SWIG_POINTER_OWN | 0));
1807 void prepend_keyname(Id key) {
1808 dataiterator_prepend_keyname($self, key);
1810 void skip_solvable() {
1811 dataiterator_skip_solvable($self);
1816 Id lookup_id(Id keyname) {
1817 Pool *pool = $self->repo->pool;
1818 Datapos oldpos = pool->pos;
1821 r = pool_lookup_id(pool, SOLVID_POS, keyname);
1825 const char *lookup_str(Id keyname) {
1826 Pool *pool = $self->repo->pool;
1827 Datapos oldpos = pool->pos;
1830 r = pool_lookup_str(pool, SOLVID_POS, keyname);
1834 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
1835 Pool *pool = $self->repo->pool;
1836 Datapos oldpos = pool->pos;
1837 unsigned long long r;
1839 r = pool_lookup_num(pool, SOLVID_POS, keyname, notfound);
1843 bool lookup_void(Id keyname) {
1844 Pool *pool = $self->repo->pool;
1845 Datapos oldpos = pool->pos;
1848 r = pool_lookup_void(pool, SOLVID_POS, keyname);
1852 %newobject lookup_checksum;
1853 Chksum *lookup_checksum(Id keyname) {
1854 Pool *pool = $self->repo->pool;
1855 Datapos oldpos = pool->pos;
1857 const unsigned char *b;
1859 b = pool_lookup_bin_checksum(pool, SOLVID_POS, keyname, &type);
1861 return solv_chksum_create_from_bin(type, b);
1863 const char *lookup_deltaseq() {
1864 Pool *pool = $self->repo->pool;
1865 Datapos oldpos = pool->pos;
1868 seq = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NAME);
1870 seq = pool_tmpjoin(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_EVR));
1871 seq = pool_tmpappend(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM));
1876 const char *lookup_deltalocation(unsigned int *OUTPUT) {
1877 Pool *pool = $self->repo->pool;
1878 Datapos oldpos = pool->pos;
1881 loc = pool_lookup_deltalocation(pool, SOLVID_POS, OUTPUT);
1885 Queue lookup_idarray(Id keyname) {
1886 Pool *pool = $self->repo->pool;
1887 Datapos oldpos = pool->pos;
1891 pool_lookup_idarray(pool, SOLVID_POS, keyname, &r);
1895 %newobject Dataiterator;
1896 Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) {
1897 Pool *pool = $self->repo->pool;
1898 Datapos oldpos = pool->pos;
1901 di = new_Dataiterator(pool, 0, SOLVID_POS, key, match, flags);
1909 dataiterator_free($self);
1912 %newobject solvable;
1913 XSolvable * const solvable;
1915 const char * const key_idstr;
1917 const char * const type_idstr;
1919 const char * const idstr;
1920 const char * const str;
1921 BinaryBlob const binary;
1922 unsigned long long const num;
1923 unsigned int const num2;
1925 SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) {
1926 return new_XSolvable(di->pool, di->solvid);
1928 SWIGINTERN Id Datamatch_key_id_get(Dataiterator *di) {
1929 return di->key->name;
1931 SWIGINTERN const char *Datamatch_key_idstr_get(Dataiterator *di) {
1932 return pool_id2str(di->pool, di->key->name);
1934 SWIGINTERN Id Datamatch_type_id_get(Dataiterator *di) {
1935 return di->key->type;
1937 SWIGINTERN const char *Datamatch_type_idstr_get(Dataiterator *di) {
1938 return pool_id2str(di->pool, di->key->type);
1940 SWIGINTERN Id Datamatch_id_get(Dataiterator *di) {
1943 SWIGINTERN const char *Datamatch_idstr_get(Dataiterator *di) {
1944 if (di->data && (di->key->type == REPOKEY_TYPE_DIR || di->key->type == REPOKEY_TYPE_DIRSTRARRAY || di->key->type == REPOKEY_TYPE_DIRNUMNUMARRAY))
1945 return repodata_dir2str(di->data, di->kv.id, 0);
1946 if (di->data && di->data->localpool)
1947 return stringpool_id2str(&di->data->spool, di->kv.id);
1948 return pool_id2str(di->pool, di->kv.id);
1950 SWIGINTERN const char * const Datamatch_str_get(Dataiterator *di) {
1953 SWIGINTERN BinaryBlob Datamatch_binary_get(Dataiterator *di) {
1957 if (di->key->type == REPOKEY_TYPE_BINARY)
1959 bl.data = di->kv.str;
1960 bl.len = di->kv.num;
1962 else if ((bl.len = solv_chksum_len(di->key->type)) != 0)
1963 bl.data = di->kv.str;
1966 SWIGINTERN unsigned long long Datamatch_num_get(Dataiterator *di) {
1967 if (di->key->type == REPOKEY_TYPE_NUM)
1968 return SOLV_KV_NUM64(&di->kv);
1971 SWIGINTERN unsigned int Datamatch_num2_get(Dataiterator *di) {
1977 Pool *pool = $self->pool;
1978 Datapos *pos, oldpos = pool->pos;
1979 dataiterator_setpos($self);
1980 pos = solv_calloc(1, sizeof(*pos));
1985 %newobject parentpos;
1986 Datapos *parentpos() {
1987 Pool *pool = $self->pool;
1988 Datapos *pos, oldpos = pool->pos;
1989 dataiterator_setpos_parent($self);
1990 pos = solv_calloc(1, sizeof(*pos));
1995 #if defined(SWIGPERL)
1996 /* cannot use str here because swig reports a bogus conflict... */
1997 %rename("stringify") __str__;
1999 *solv::Datamatch::str = *solvc::Datamatch_stringify;
2002 const char *__str__() {
2003 KeyValue kv = $self->kv;
2004 const char *str = repodata_stringify($self->pool, $self->data, $self->key, &kv, SEARCH_FILES | SEARCH_CHECKSUMS);
2005 return str ? str : "";
2009 %extend Pool_solvable_iterator {
2010 Pool_solvable_iterator(Pool *pool) {
2011 Pool_solvable_iterator *s;
2012 s = solv_calloc(1, sizeof(*s));
2016 #if defined(SWIGPYTHON)
2018 def __iter__(self): return self
2021 %rename("next") __next__();
2023 %exception __next__ {
2026 PyErr_SetString(PyExc_StopIteration,"no more matches");
2032 perliter(solv::Pool_solvable_iterator)
2034 %newobject __next__;
2035 XSolvable *__next__() {
2036 Pool *pool = $self->pool;
2037 if ($self->id >= pool->nsolvables)
2039 while (++$self->id < pool->nsolvables)
2040 if (pool->solvables[$self->id].repo)
2041 return new_XSolvable(pool, $self->id);
2047 while ((n = Pool_solvable_iterator___next__($self)) != 0) {
2048 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
2052 %newobject __getitem__;
2053 XSolvable *__getitem__(Id key) {
2054 Pool *pool = $self->pool;
2055 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo)
2056 return new_XSolvable(pool, key);
2060 return $self->pool->nsolvables;
2064 %extend Pool_repo_iterator {
2065 Pool_repo_iterator(Pool *pool) {
2066 Pool_repo_iterator *s;
2067 s = solv_calloc(1, sizeof(*s));
2071 #if defined(SWIGPYTHON)
2073 def __iter__(self): return self
2076 %rename("next") __next__();
2078 %exception __next__ {
2081 PyErr_SetString(PyExc_StopIteration,"no more matches");
2087 perliter(solv::Pool_repo_iterator)
2089 %newobject __next__;
2091 Pool *pool = $self->pool;
2092 if ($self->id >= pool->nrepos)
2094 while (++$self->id < pool->nrepos) {
2095 Repo *r = pool_id2repo(pool, $self->id);
2104 while ((n = Pool_repo_iterator___next__($self)) != 0) {
2105 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
2109 Repo *__getitem__(Id key) {
2110 Pool *pool = $self->pool;
2111 if (key > 0 && key < pool->nrepos)
2112 return pool_id2repo(pool, key);
2116 return $self->pool->nrepos;
2120 %extend Repo_solvable_iterator {
2121 Repo_solvable_iterator(Repo *repo) {
2122 Repo_solvable_iterator *s;
2123 s = solv_calloc(1, sizeof(*s));
2127 #if defined(SWIGPYTHON)
2129 def __iter__(self): return self
2132 %rename("next") __next__();
2134 %exception __next__ {
2137 PyErr_SetString(PyExc_StopIteration,"no more matches");
2143 perliter(solv::Repo_solvable_iterator)
2145 %newobject __next__;
2146 XSolvable *__next__() {
2147 Repo *repo = $self->repo;
2148 Pool *pool = repo->pool;
2149 if (repo->start > 0 && $self->id < repo->start)
2150 $self->id = repo->start - 1;
2151 if ($self->id >= repo->end)
2153 while (++$self->id < repo->end)
2154 if (pool->solvables[$self->id].repo == repo)
2155 return new_XSolvable(pool, $self->id);
2161 while ((n = Repo_solvable_iterator___next__($self)) != 0) {
2162 rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_XSolvable, SWIG_POINTER_OWN | 0));
2166 %newobject __getitem__;
2167 XSolvable *__getitem__(Id key) {
2168 Repo *repo = $self->repo;
2169 Pool *pool = repo->pool;
2170 if (key > 0 && key < pool->nsolvables && pool->solvables[key].repo == repo)
2171 return new_XSolvable(pool, key);
2175 return $self->repo->pool->nsolvables;
2180 Dep(Pool *pool, Id id) {
2184 s = solv_calloc(1, sizeof(*s));
2190 Dep *Rel(int flags, DepId evrid, bool create=1) {
2191 Id id = pool_rel2id($self->pool, $self->id, evrid, flags, create);
2194 return new_Dep($self->pool, id);
2196 %newobject Selection_name;
2197 Selection *Selection_name(int setflags=0) {
2198 Selection *sel = new_Selection($self->pool);
2199 if (ISRELDEP($self->id)) {
2200 Reldep *rd = GETRELDEP($self->pool, $self->id);
2201 if (rd->flags == REL_EQ) {
2202 setflags |= $self->pool->disttype == DISTTYPE_DEB || strchr(pool_id2str($self->pool, rd->evr), '-') != 0 ? SOLVER_SETEVR : SOLVER_SETEV;
2203 if (ISRELDEP(rd->name))
2204 rd = GETRELDEP($self->pool, rd->name);
2206 if (rd->flags == REL_ARCH)
2207 setflags |= SOLVER_SETARCH;
2209 queue_push2(&sel->q, SOLVER_SOLVABLE_NAME | setflags, $self->id);
2212 %newobject Selection_provides;
2213 Selection *Selection_provides(int setflags=0) {
2214 Selection *sel = new_Selection($self->pool);
2215 if (ISRELDEP($self->id)) {
2216 Reldep *rd = GETRELDEP($self->pool, $self->id);
2217 if (rd->flags == REL_ARCH)
2218 setflags |= SOLVER_SETARCH;
2220 queue_push2(&sel->q, SOLVER_SOLVABLE_PROVIDES | setflags, $self->id);
2224 return pool_dep2str($self->pool, $self->id);
2226 bool __eq__(Dep *s) {
2227 return $self->pool == s->pool && $self->id == s->id;
2229 bool __ne__(Dep *s) {
2230 return !Dep___eq__($self, s);
2232 #if defined(SWIGPERL)
2233 %rename("str") __str__;
2235 const char *__str__() {
2236 return pool_dep2str($self->pool, $self->id);
2238 %newobject __repr__;
2239 const char *__repr__() {
2241 sprintf(buf, "<Id #%d ", $self->id);
2242 return solv_dupjoin(buf, pool_dep2str($self->pool, $self->id), ">");
2247 XSolvable(Pool *pool, Id id) {
2249 if (!id || id >= pool->nsolvables)
2251 s = solv_calloc(1, sizeof(*s));
2257 return pool_solvid2str($self->pool, $self->id);
2259 const char *lookup_str(Id keyname) {
2260 return pool_lookup_str($self->pool, $self->id, keyname);
2262 Id lookup_id(Id keyname) {
2263 return pool_lookup_id($self->pool, $self->id, keyname);
2265 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0) {
2266 return pool_lookup_num($self->pool, $self->id, keyname, notfound);
2268 bool lookup_void(Id keyname) {
2269 return pool_lookup_void($self->pool, $self->id, keyname);
2271 %newobject lookup_checksum;
2272 Chksum *lookup_checksum(Id keyname) {
2274 const unsigned char *b = pool_lookup_bin_checksum($self->pool, $self->id, keyname, &type);
2275 return solv_chksum_create_from_bin(type, b);
2277 Queue lookup_idarray(Id keyname, Id marker = -1) {
2278 Solvable *s = $self->pool->solvables + $self->id;
2281 solvable_lookup_deparray(s, keyname, &r, marker);
2284 %typemap(out) Queue lookup_deparray Queue2Array(Dep *, 1, new_Dep(arg1->pool, id));
2285 %newobject lookup_deparray;
2286 Queue lookup_deparray(Id keyname, Id marker = -1) {
2287 Solvable *s = $self->pool->solvables + $self->id;
2290 solvable_lookup_deparray(s, keyname, &r, marker);
2293 const char *lookup_location(unsigned int *OUTPUT) {
2294 return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT);
2296 %newobject Dataiterator;
2297 Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) {
2298 return new_Dataiterator($self->pool, 0, $self->id, key, match, flags);
2301 %rename("installable?") installable;
2303 bool installable() {
2304 return pool_installable($self->pool, pool_id2solvable($self->pool, $self->id));
2307 %rename("isinstalled?") isinstalled;
2309 bool isinstalled() {
2310 Pool *pool = $self->pool;
2311 return pool->installed && pool_id2solvable(pool, $self->id)->repo == pool->installed;
2316 SWIGINTERN void XSolvable_name_set(XSolvable *xs, const char *name) {
2317 Pool *pool = xs->pool;
2318 pool->solvables[xs->id].name = pool_str2id(pool, name, 1);
2320 SWIGINTERN const char *XSolvable_name_get(XSolvable *xs) {
2321 Pool *pool = xs->pool;
2322 return pool_id2str(pool, pool->solvables[xs->id].name);
2327 SWIGINTERN void XSolvable_nameid_set(XSolvable *xs, Id nameid) {
2328 xs->pool->solvables[xs->id].name = nameid;
2330 SWIGINTERN Id XSolvable_nameid_get(XSolvable *xs) {
2331 return xs->pool->solvables[xs->id].name;
2336 SWIGINTERN void XSolvable_evr_set(XSolvable *xs, const char *evr) {
2337 Pool *pool = xs->pool;
2338 pool->solvables[xs->id].evr = pool_str2id(pool, evr, 1);
2340 SWIGINTERN const char *XSolvable_evr_get(XSolvable *xs) {
2341 Pool *pool = xs->pool;
2342 return pool_id2str(pool, pool->solvables[xs->id].evr);
2347 SWIGINTERN void XSolvable_evrid_set(XSolvable *xs, Id evrid) {
2348 xs->pool->solvables[xs->id].evr = evrid;
2350 SWIGINTERN Id XSolvable_evrid_get(XSolvable *xs) {
2351 return xs->pool->solvables[xs->id].evr;
2356 SWIGINTERN void XSolvable_arch_set(XSolvable *xs, const char *arch) {
2357 Pool *pool = xs->pool;
2358 pool->solvables[xs->id].arch = pool_str2id(pool, arch, 1);
2360 SWIGINTERN const char *XSolvable_arch_get(XSolvable *xs) {
2361 Pool *pool = xs->pool;
2362 return pool_id2str(pool, pool->solvables[xs->id].arch);
2367 SWIGINTERN void XSolvable_archid_set(XSolvable *xs, Id archid) {
2368 xs->pool->solvables[xs->id].arch = archid;
2370 SWIGINTERN Id XSolvable_archid_get(XSolvable *xs) {
2371 return xs->pool->solvables[xs->id].arch;
2376 SWIGINTERN void XSolvable_vendor_set(XSolvable *xs, const char *vendor) {
2377 Pool *pool = xs->pool;
2378 pool->solvables[xs->id].vendor = pool_str2id(pool, vendor, 1);
2380 SWIGINTERN const char *XSolvable_vendor_get(XSolvable *xs) {
2381 Pool *pool = xs->pool;
2382 return pool_id2str(pool, pool->solvables[xs->id].vendor);
2387 SWIGINTERN void XSolvable_vendorid_set(XSolvable *xs, Id vendorid) {
2388 xs->pool->solvables[xs->id].vendor = vendorid;
2390 SWIGINTERN Id XSolvable_vendorid_get(XSolvable *xs) {
2391 return xs->pool->solvables[xs->id].vendor;
2396 SWIGINTERN Repo *XSolvable_repo_get(XSolvable *xs) {
2397 return xs->pool->solvables[xs->id].repo;
2401 /* old interface, please use the generic add_deparray instead */
2402 void add_provides(DepId id, Id marker = -1) {
2403 Solvable *s = $self->pool->solvables + $self->id;
2404 marker = solv_depmarker(SOLVABLE_PROVIDES, marker);
2405 s->provides = repo_addid_dep(s->repo, s->provides, id, marker);
2407 void add_obsoletes(DepId id) {
2408 Solvable *s = $self->pool->solvables + $self->id;
2409 s->obsoletes = repo_addid_dep(s->repo, s->obsoletes, id, 0);
2411 void add_conflicts(DepId id) {
2412 Solvable *s = $self->pool->solvables + $self->id;
2413 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2415 void add_requires(DepId id, Id marker = -1) {
2416 Solvable *s = $self->pool->solvables + $self->id;
2417 marker = solv_depmarker(SOLVABLE_REQUIRES, marker);
2418 s->requires = repo_addid_dep(s->repo, s->requires, id, marker);
2420 void add_recommends(DepId id) {
2421 Solvable *s = $self->pool->solvables + $self->id;
2422 s->recommends = repo_addid_dep(s->repo, s->recommends, id, 0);
2424 void add_suggests(DepId id) {
2425 Solvable *s = $self->pool->solvables + $self->id;
2426 s->suggests = repo_addid_dep(s->repo, s->suggests, id, 0);
2428 void add_supplements(DepId id) {
2429 Solvable *s = $self->pool->solvables + $self->id;
2430 s->supplements = repo_addid_dep(s->repo, s->supplements, id, 0);
2432 void add_enhances(DepId id) {
2433 Solvable *s = $self->pool->solvables + $self->id;
2434 s->enhances = repo_addid_dep(s->repo, s->enhances, id, 0);
2437 void unset(Id keyname) {
2438 Solvable *s = $self->pool->solvables + $self->id;
2439 repo_unset(s->repo, $self->id, keyname);
2442 void add_deparray(Id keyname, DepId id, Id marker = -1) {
2443 Solvable *s = $self->pool->solvables + $self->id;
2444 solvable_add_deparray(s, keyname, id, marker);
2447 %newobject Selection;
2448 Selection *Selection(int setflags=0) {
2449 Selection *sel = new_Selection($self->pool);
2450 queue_push2(&sel->q, SOLVER_SOLVABLE | setflags, $self->id);
2455 %rename("identical?") identical;
2457 bool identical(XSolvable *s2) {
2458 return solvable_identical($self->pool->solvables + $self->id, s2->pool->solvables + s2->id);
2460 int evrcmp(XSolvable *s2) {
2461 return pool_evrcmp($self->pool, $self->pool->solvables[$self->id].evr, s2->pool->solvables[s2->id].evr, EVRCMP_COMPARE);
2464 bool __eq__(XSolvable *s) {
2465 return $self->pool == s->pool && $self->id == s->id;
2467 bool __ne__(XSolvable *s) {
2468 return !XSolvable___eq__($self, s);
2470 #if defined(SWIGPERL)
2471 %rename("str") __str__;
2473 const char *__str__() {
2474 return pool_solvid2str($self->pool, $self->id);
2476 %newobject __repr__;
2477 const char *__repr__() {
2479 sprintf(buf, "<Solvable #%d ", $self->id);
2480 return solv_dupjoin(buf, pool_solvid2str($self->pool, $self->id), ">");
2485 Problem(Solver *solv, Id id) {
2487 p = solv_calloc(1, sizeof(*p));
2492 %newobject findproblemrule;
2493 XRule *findproblemrule() {
2494 Id r = solver_findproblemrule($self->solv, $self->id);
2495 return new_XRule($self->solv, r);
2497 %newobject findallproblemrules;
2498 %typemap(out) Queue findallproblemrules Queue2Array(XRule *, 1, new_XRule(arg1->solv, id));
2499 Queue findallproblemrules(int unfiltered=0) {
2500 Solver *solv = $self->solv;
2505 solver_findallproblemrules(solv, $self->id, &q);
2508 for (i = j = 0; i < q.count; i++)
2510 SolverRuleinfo rclass;
2511 probr = q.elements[i];
2512 rclass = solver_ruleclass(solv, probr);
2513 if (rclass == SOLVER_RULE_UPDATE || rclass == SOLVER_RULE_JOB)
2515 q.elements[j++] = probr;
2518 queue_truncate(&q, j);
2522 int solution_count() {
2523 return solver_solution_count($self->solv, $self->id);
2525 %typemap(out) Queue solutions Queue2Array(Solution *, 1, new_Solution(arg1, id));
2526 %newobject solutions;
2531 cnt = solver_solution_count($self->solv, $self->id);
2532 for (i = 1; i <= cnt; i++)
2536 #if defined(SWIGPERL)
2537 %rename("str") __str__;
2539 const char *__str__() {
2540 return solver_problem2str($self->solv, $self->id);
2545 Solution(Problem *p, Id id) {
2547 s = solv_calloc(1, sizeof(*s));
2549 s->problemid = p->id;
2553 int element_count() {
2554 return solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2557 %typemap(out) Queue elements Queue2Array(Solutionelement *, 4, new_Solutionelement(arg1->solv, arg1->problemid, arg1->id, id, idp[1], idp[2], idp[3]));
2558 %newobject elements;
2559 Queue elements(bool expandreplaces=0) {
2563 cnt = solver_solutionelement_count($self->solv, $self->problemid, $self->id);
2564 for (i = 1; i <= cnt; i++)
2567 solver_next_solutionelement($self->solv, $self->problemid, $self->id, i - 1, &p, &rp);
2569 type = rp ? SOLVER_SOLUTION_REPLACE : SOLVER_SOLUTION_ERASE;
2575 if (type == SOLVER_SOLUTION_REPLACE && expandreplaces) {
2576 int illegal = policy_is_illegal(self->solv, self->solv->pool->solvables + p, self->solv->pool->solvables + rp, 0);
2578 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0) {
2579 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2580 queue_push2(&q, p, rp);
2582 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0) {
2583 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2584 queue_push2(&q, p, rp);
2586 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0) {
2587 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2588 queue_push2(&q, p, rp);
2590 if ((illegal & POLICY_ILLEGAL_NAMECHANGE) != 0) {
2591 queue_push2(&q, i, SOLVER_SOLUTION_REPLACE_NAMECHANGE);
2592 queue_push2(&q, p, rp);
2597 queue_push2(&q, i, type);
2598 queue_push2(&q, p, rp);
2604 %extend Solutionelement {
2605 Solutionelement(Solver *solv, Id problemid, Id solutionid, Id id, Id type, Id p, Id rp) {
2607 e = solv_calloc(1, sizeof(*e));
2609 e->problemid = problemid;
2621 if (p == SOLVER_SOLUTION_ERASE)
2626 else if (p == SOLVER_SOLUTION_REPLACE)
2631 else if (p == SOLVER_SOLUTION_REPLACE_DOWNGRADE)
2632 illegal = POLICY_ILLEGAL_DOWNGRADE;
2633 else if (p == SOLVER_SOLUTION_REPLACE_ARCHCHANGE)
2634 illegal = POLICY_ILLEGAL_ARCHCHANGE;
2635 else if (p == SOLVER_SOLUTION_REPLACE_VENDORCHANGE)
2636 illegal = POLICY_ILLEGAL_VENDORCHANGE;
2637 else if (p == SOLVER_SOLUTION_REPLACE_NAMECHANGE)
2638 illegal = POLICY_ILLEGAL_NAMECHANGE;
2640 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);
2641 return solver_solutionelement2str($self->solv, p, rp);
2643 %typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, arg1->id, id, arg1->p, arg1->rp));
2644 %newobject replaceelements;
2645 Queue replaceelements() {
2650 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2653 illegal = policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2654 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
2655 queue_push(&q, SOLVER_SOLUTION_REPLACE_DOWNGRADE);
2656 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
2657 queue_push(&q, SOLVER_SOLUTION_REPLACE_ARCHCHANGE);
2658 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
2659 queue_push(&q, SOLVER_SOLUTION_REPLACE_VENDORCHANGE);
2660 if ((illegal & POLICY_ILLEGAL_NAMECHANGE) != 0)
2661 queue_push(&q, SOLVER_SOLUTION_REPLACE_NAMECHANGE);
2663 queue_push(&q, $self->type);
2666 int illegalreplace() {
2667 if ($self->type != SOLVER_SOLUTION_REPLACE || $self->p <= 0 || $self->rp <= 0)
2669 return policy_is_illegal($self->solv, $self->solv->pool->solvables + $self->p, $self->solv->pool->solvables + $self->rp, 0);
2671 %newobject solvable;
2672 XSolvable * const solvable;
2673 %newobject replacement;
2674 XSolvable * const replacement;
2677 SWIGINTERN XSolvable *Solutionelement_solvable_get(Solutionelement *e) {
2678 return new_XSolvable(e->solv->pool, e->p);
2680 SWIGINTERN XSolvable *Solutionelement_replacement_get(Solutionelement *e) {
2681 return new_XSolvable(e->solv->pool, e->rp);
2683 SWIGINTERN int Solutionelement_jobidx_get(Solutionelement *e) {
2684 if (e->type != SOLVER_SOLUTION_JOB && e->type != SOLVER_SOLUTION_POOLJOB)
2686 return (e->p - 1) / 2;
2691 Id extraflags = solver_solutionelement_extrajobflags($self->solv, $self->problemid, $self->solutionid);
2692 if ($self->type == SOLVER_SOLUTION_JOB || SOLVER_SOLUTION_POOLJOB)
2693 return new_Job($self->solv->pool, SOLVER_NOOP, 0);
2694 if ($self->type == SOLVER_SOLUTION_INFARCH || $self->type == SOLVER_SOLUTION_DISTUPGRADE || $self->type == SOLVER_SOLUTION_BEST)
2695 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|SOLVER_NOTBYUSER|extraflags, $self->p);
2696 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)
2697 return new_Job($self->solv->pool, SOLVER_INSTALL|SOLVER_SOLVABLE|SOLVER_NOTBYUSER|extraflags, $self->rp);
2698 if ($self->type == SOLVER_SOLUTION_ERASE)
2699 return new_Job($self->solv->pool, SOLVER_ERASE|SOLVER_SOLVABLE|extraflags, $self->p);
2705 static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
2706 static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
2707 static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
2708 static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
2709 static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
2710 static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
2711 static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
2712 static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
2713 static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
2714 static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
2715 static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
2716 static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
2717 static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
2718 static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
2719 static const int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
2720 static const int SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM = SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM;
2721 static const int SOLVER_RULE_JOB_UNKNOWN_PACKAGE = SOLVER_RULE_JOB_UNKNOWN_PACKAGE;
2722 static const int SOLVER_RULE_JOB_UNSUPPORTED = SOLVER_RULE_JOB_UNSUPPORTED;
2723 static const int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
2724 static const int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
2725 static const int SOLVER_RULE_CHOICE = SOLVER_RULE_CHOICE;
2726 static const int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
2728 static const int SOLVER_SOLUTION_JOB = SOLVER_SOLUTION_JOB;
2729 static const int SOLVER_SOLUTION_POOLJOB = SOLVER_SOLUTION_POOLJOB;
2730 static const int SOLVER_SOLUTION_INFARCH = SOLVER_SOLUTION_INFARCH;
2731 static const int SOLVER_SOLUTION_DISTUPGRADE = SOLVER_SOLUTION_DISTUPGRADE;
2732 static const int SOLVER_SOLUTION_BEST = SOLVER_SOLUTION_BEST;
2733 static const int SOLVER_SOLUTION_ERASE = SOLVER_SOLUTION_ERASE;
2734 static const int SOLVER_SOLUTION_REPLACE = SOLVER_SOLUTION_REPLACE;
2735 static const int SOLVER_SOLUTION_REPLACE_DOWNGRADE = SOLVER_SOLUTION_REPLACE_DOWNGRADE;
2736 static const int SOLVER_SOLUTION_REPLACE_ARCHCHANGE = SOLVER_SOLUTION_REPLACE_ARCHCHANGE;
2737 static const int SOLVER_SOLUTION_REPLACE_VENDORCHANGE = SOLVER_SOLUTION_REPLACE_VENDORCHANGE;
2738 static const int SOLVER_SOLUTION_REPLACE_NAMECHANGE = SOLVER_SOLUTION_REPLACE_NAMECHANGE;
2740 static const int POLICY_ILLEGAL_DOWNGRADE = POLICY_ILLEGAL_DOWNGRADE;
2741 static const int POLICY_ILLEGAL_ARCHCHANGE = POLICY_ILLEGAL_ARCHCHANGE;
2742 static const int POLICY_ILLEGAL_VENDORCHANGE = POLICY_ILLEGAL_VENDORCHANGE;
2743 static const int POLICY_ILLEGAL_NAMECHANGE = POLICY_ILLEGAL_NAMECHANGE;
2745 static const int SOLVER_FLAG_ALLOW_DOWNGRADE = SOLVER_FLAG_ALLOW_DOWNGRADE;
2746 static const int SOLVER_FLAG_ALLOW_ARCHCHANGE = SOLVER_FLAG_ALLOW_ARCHCHANGE;
2747 static const int SOLVER_FLAG_ALLOW_VENDORCHANGE = SOLVER_FLAG_ALLOW_VENDORCHANGE;
2748 static const int SOLVER_FLAG_ALLOW_NAMECHANGE = SOLVER_FLAG_ALLOW_NAMECHANGE;
2749 static const int SOLVER_FLAG_ALLOW_UNINSTALL = SOLVER_FLAG_ALLOW_UNINSTALL;
2750 static const int SOLVER_FLAG_NO_UPDATEPROVIDE = SOLVER_FLAG_NO_UPDATEPROVIDE;
2751 static const int SOLVER_FLAG_SPLITPROVIDES = SOLVER_FLAG_SPLITPROVIDES;
2752 static const int SOLVER_FLAG_IGNORE_RECOMMENDED = SOLVER_FLAG_IGNORE_RECOMMENDED;
2753 static const int SOLVER_FLAG_ADD_ALREADY_RECOMMENDED = SOLVER_FLAG_ADD_ALREADY_RECOMMENDED;
2754 static const int SOLVER_FLAG_NO_INFARCHCHECK = SOLVER_FLAG_NO_INFARCHCHECK;
2755 static const int SOLVER_FLAG_BEST_OBEY_POLICY = SOLVER_FLAG_BEST_OBEY_POLICY;
2756 static const int SOLVER_FLAG_NO_AUTOTARGET = SOLVER_FLAG_NO_AUTOTARGET;
2757 static const int SOLVER_FLAG_DUP_ALLOW_DOWNGRADE = SOLVER_FLAG_DUP_ALLOW_DOWNGRADE;
2758 static const int SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE = SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE;
2759 static const int SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE = SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE;
2760 static const int SOLVER_FLAG_DUP_ALLOW_NAMECHANGE = SOLVER_FLAG_DUP_ALLOW_NAMECHANGE;
2762 static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
2763 static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;
2764 static const int SOLVER_REASON_KEEP_INSTALLED = SOLVER_REASON_KEEP_INSTALLED;
2765 static const int SOLVER_REASON_RESOLVE_JOB = SOLVER_REASON_RESOLVE_JOB;
2766 static const int SOLVER_REASON_UPDATE_INSTALLED = SOLVER_REASON_UPDATE_INSTALLED;
2767 static const int SOLVER_REASON_CLEANDEPS_ERASE = SOLVER_REASON_CLEANDEPS_ERASE;
2768 static const int SOLVER_REASON_RESOLVE = SOLVER_REASON_RESOLVE;
2769 static const int SOLVER_REASON_WEAKDEP = SOLVER_REASON_WEAKDEP;
2770 static const int SOLVER_REASON_RESOLVE_ORPHAN = SOLVER_REASON_RESOLVE_ORPHAN;
2771 static const int SOLVER_REASON_RECOMMENDED = SOLVER_REASON_RECOMMENDED;
2772 static const int SOLVER_REASON_SUPPLEMENTED = SOLVER_REASON_SUPPLEMENTED;
2778 int set_flag(int flag, int value) {
2779 return solver_set_flag($self, flag, value);
2781 int get_flag(int flag) {
2782 return solver_get_flag($self, flag);
2784 #if defined(SWIGPYTHON)
2786 def solve(self, jobs):
2788 for job in jobs: j += [job.how, job.what]
2789 return self.solve_helper(j)
2792 #if defined(SWIGPERL)
2794 sub solv::Solver::solve {
2795 my ($self, $jobs) = @_;
2796 my @j = map {($_->{'how'}, $_->{'what'})} @$jobs;
2797 return $self->solve_helper(\@j);
2801 #if defined(SWIGRUBY)
2804 "class Solv::Solver\n"
2805 " def solve(jobs)\n"
2807 " jobs.each do |j| ; jl << j.how << j.what ; end\n"
2808 " solve_helper(jl)\n"
2814 %typemap(out) Queue solve_helper Queue2Array(Problem *, 1, new_Problem(arg1, id));
2815 %newobject solve_helper;
2816 Queue solve_helper(Queue jobs) {
2820 solver_solve($self, &jobs);
2821 cnt = solver_problem_count($self);
2822 for (i = 1; i <= cnt; i++)
2826 %newobject transaction;
2827 Transaction *transaction() {
2828 return solver_create_transaction($self);
2831 int describe_decision(XSolvable *s, XRule **OUTPUT) {
2833 int reason = solver_describe_decision($self, s->id, &ruleid);
2834 *OUTPUT = new_XRule($self, ruleid);
2839 %extend Transaction {
2840 static const int SOLVER_TRANSACTION_IGNORE = SOLVER_TRANSACTION_IGNORE;
2841 static const int SOLVER_TRANSACTION_ERASE = SOLVER_TRANSACTION_ERASE;
2842 static const int SOLVER_TRANSACTION_REINSTALLED = SOLVER_TRANSACTION_REINSTALLED;
2843 static const int SOLVER_TRANSACTION_DOWNGRADED = SOLVER_TRANSACTION_DOWNGRADED;
2844 static const int SOLVER_TRANSACTION_CHANGED = SOLVER_TRANSACTION_CHANGED;
2845 static const int SOLVER_TRANSACTION_UPGRADED = SOLVER_TRANSACTION_UPGRADED;
2846 static const int SOLVER_TRANSACTION_OBSOLETED = SOLVER_TRANSACTION_OBSOLETED;
2847 static const int SOLVER_TRANSACTION_INSTALL = SOLVER_TRANSACTION_INSTALL;
2848 static const int SOLVER_TRANSACTION_REINSTALL = SOLVER_TRANSACTION_REINSTALL;
2849 static const int SOLVER_TRANSACTION_DOWNGRADE = SOLVER_TRANSACTION_DOWNGRADE;
2850 static const int SOLVER_TRANSACTION_CHANGE = SOLVER_TRANSACTION_CHANGE;
2851 static const int SOLVER_TRANSACTION_UPGRADE = SOLVER_TRANSACTION_UPGRADE;
2852 static const int SOLVER_TRANSACTION_OBSOLETES = SOLVER_TRANSACTION_OBSOLETES;
2853 static const int SOLVER_TRANSACTION_MULTIINSTALL = SOLVER_TRANSACTION_MULTIINSTALL;
2854 static const int SOLVER_TRANSACTION_MULTIREINSTALL = SOLVER_TRANSACTION_MULTIREINSTALL;
2855 static const int SOLVER_TRANSACTION_MAXTYPE = SOLVER_TRANSACTION_MAXTYPE;
2856 static const int SOLVER_TRANSACTION_SHOW_ACTIVE = SOLVER_TRANSACTION_SHOW_ACTIVE;
2857 static const int SOLVER_TRANSACTION_SHOW_ALL = SOLVER_TRANSACTION_SHOW_ALL;
2858 static const int SOLVER_TRANSACTION_SHOW_OBSOLETES = SOLVER_TRANSACTION_SHOW_OBSOLETES;
2859 static const int SOLVER_TRANSACTION_SHOW_MULTIINSTALL = SOLVER_TRANSACTION_SHOW_MULTIINSTALL;
2860 static const int SOLVER_TRANSACTION_CHANGE_IS_REINSTALL = SOLVER_TRANSACTION_CHANGE_IS_REINSTALL;
2861 static const int SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE = SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE;
2862 static const int SOLVER_TRANSACTION_MERGE_VENDORCHANGES = SOLVER_TRANSACTION_MERGE_VENDORCHANGES;
2863 static const int SOLVER_TRANSACTION_MERGE_ARCHCHANGES = SOLVER_TRANSACTION_MERGE_ARCHCHANGES;
2864 static const int SOLVER_TRANSACTION_RPM_ONLY = SOLVER_TRANSACTION_RPM_ONLY;
2865 static const int SOLVER_TRANSACTION_ARCHCHANGE = SOLVER_TRANSACTION_ARCHCHANGE;
2866 static const int SOLVER_TRANSACTION_VENDORCHANGE = SOLVER_TRANSACTION_VENDORCHANGE;
2867 static const int SOLVER_TRANSACTION_KEEP_ORDERDATA = SOLVER_TRANSACTION_KEEP_ORDERDATA;
2869 transaction_free($self);
2872 %rename("isempty?") isempty;
2875 return $self->steps.count == 0;
2878 %newobject othersolvable;
2879 XSolvable *othersolvable(XSolvable *s) {
2880 Id op = transaction_obs_pkg($self, s->id);
2881 return new_XSolvable($self->pool, op);
2884 %typemap(out) Queue allothersolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2885 %newobject allothersolvables;
2886 Queue allothersolvables(XSolvable *s) {
2889 transaction_all_obs_pkgs($self, s->id, &q);
2893 %typemap(out) Queue classify Queue2Array(TransactionClass *, 4, new_TransactionClass(arg1, arg2, id, idp[1], idp[2], idp[3]));
2894 %newobject classify;
2895 Queue classify(int mode = 0) {
2898 transaction_classify($self, mode, &q);
2902 # deprecated, use newsolvables instead
2903 %typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2904 %newobject newpackages;
2905 Queue newpackages() {
2909 cut = transaction_installedresult(self, &q);
2910 queue_truncate(&q, cut);
2914 # deprecated, use keptsolvables instead
2915 %typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2916 %newobject keptpackages;
2917 Queue keptpackages() {
2921 cut = transaction_installedresult(self, &q);
2923 queue_deleten(&q, 0, cut);
2927 %typemap(out) Queue newsolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2928 %newobject newsolvables;
2929 Queue newsolvables() {
2933 cut = transaction_installedresult(self, &q);
2934 queue_truncate(&q, cut);
2938 %typemap(out) Queue keptsolvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2939 %newobject keptsolvables;
2940 Queue keptsolvables() {
2944 cut = transaction_installedresult(self, &q);
2946 queue_deleten(&q, 0, cut);
2950 %typemap(out) Queue steps Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
2954 queue_init_clone(&q, &$self->steps);
2958 int steptype(XSolvable *s, int mode) {
2959 return transaction_type($self, s->id, mode);
2961 int calc_installsizechange() {
2962 return transaction_calc_installsizechange($self);
2964 void order(int flags=0) {
2965 transaction_order($self, flags);
2969 %extend TransactionClass {
2970 TransactionClass(Transaction *trans, int mode, Id type, int count, Id fromid, Id toid) {
2971 TransactionClass *cl = solv_calloc(1, sizeof(*cl));
2972 cl->transaction = trans;
2976 cl->fromid = fromid;
2980 %typemap(out) Queue solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1->transaction->pool, id));
2981 %newobject solvables;
2985 transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
2988 const char * const fromstr;
2989 const char * const tostr;
2991 SWIGINTERN const char *TransactionClass_fromstr_get(TransactionClass *cl) {
2992 return pool_id2str(cl->transaction->pool, cl->fromid);
2994 SWIGINTERN const char *TransactionClass_tostr_get(TransactionClass *cl) {
2995 return pool_id2str(cl->transaction->pool, cl->toid);
3001 XRule(Solver *solv, Id id) {
3004 XRule *xr = solv_calloc(1, sizeof(*xr));
3011 SWIGINTERN int XRule_type_get(XRule *xr) {
3012 return solver_ruleclass(xr->solv, xr->id);
3017 Id type, source, target, dep;
3018 type = solver_ruleinfo($self->solv, $self->id, &source, &target, &dep);
3019 return new_Ruleinfo($self, type, source, target, dep);
3021 %typemap(out) Queue allinfos Queue2Array(Ruleinfo *, 4, new_Ruleinfo(arg1, id, idp[1], idp[2], idp[3]));
3022 %newobject allinfos;
3026 solver_allruleinfos($self->solv, $self->id, &q);
3030 bool __eq__(XRule *xr) {
3031 return $self->solv == xr->solv && $self->id == xr->id;
3033 bool __ne__(XRule *xr) {
3034 return !XRule___eq__($self, xr);
3036 %newobject __repr__;
3037 const char *__repr__() {
3039 sprintf(buf, "<Rule #%d>", $self->id);
3040 return solv_strdup(buf);
3045 Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep_id) {
3046 Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
3050 ri->source = source;
3051 ri->target = target;
3052 ri->dep_id = dep_id;
3055 %newobject solvable;
3056 XSolvable * const solvable;
3057 %newobject othersolvable;
3058 XSolvable * const othersolvable;
3062 SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
3063 return new_XSolvable(ri->solv->pool, ri->source);
3065 SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
3066 return new_XSolvable(ri->solv->pool, ri->target);
3068 SWIGINTERN Dep *Ruleinfo_dep_get(Ruleinfo *ri) {
3069 return new_Dep(ri->solv->pool, ri->dep_id);
3072 const char *problemstr() {
3073 return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep_id);
3078 XRepodata(Repo *repo, Id id) {
3079 XRepodata *xr = solv_calloc(1, sizeof(*xr));
3085 return repodata_new_handle(repo_id2repodata($self->repo, $self->id));
3087 void set_id(Id solvid, Id keyname, DepId id) {
3088 repodata_set_id(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
3090 void set_str(Id solvid, Id keyname, const char *str) {
3091 repodata_set_str(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
3093 void set_poolstr(Id solvid, Id keyname, const char *str) {
3094 repodata_set_poolstr(repo_id2repodata($self->repo, $self->id), solvid, keyname, str);
3096 void add_idarray(Id solvid, Id keyname, DepId id) {
3097 repodata_add_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, id);
3099 void add_flexarray(Id solvid, Id keyname, Id handle) {
3100 repodata_add_flexarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, handle);
3102 void set_checksum(Id solvid, Id keyname, Chksum *chksum) {
3103 const unsigned char *buf = solv_chksum_get(chksum, 0);
3105 repodata_set_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, solv_chksum_get_type(chksum), buf);
3107 const char *lookup_str(Id solvid, Id keyname) {
3108 return repodata_lookup_str(repo_id2repodata($self->repo, $self->id), solvid, keyname);
3110 Queue lookup_idarray(Id solvid, Id keyname) {
3113 repodata_lookup_idarray(repo_id2repodata($self->repo, $self->id), solvid, keyname, &r);
3116 %newobject lookup_checksum;
3117 Chksum *lookup_checksum(Id solvid, Id keyname) {
3119 const unsigned char *b = repodata_lookup_bin_checksum(repo_id2repodata($self->repo, $self->id), solvid, keyname, &type);
3120 return solv_chksum_create_from_bin(type, b);
3122 void internalize() {
3123 repodata_internalize(repo_id2repodata($self->repo, $self->id));
3125 void create_stubs() {
3126 Repodata *data = repo_id2repodata($self->repo, $self->id);
3127 data = repodata_create_stubs(data);
3128 $self->id = data->repodataid;
3130 bool write(FILE *fp) {
3131 return repodata_write(repo_id2repodata($self->repo, $self->id), fp) == 0;
3133 bool add_solv(FILE *fp, int flags = 0) {
3134 Repodata *data = repo_id2repodata($self->repo, $self->id);
3135 int r, oldstate = data->state;
3136 data->state = REPODATA_LOADING;
3137 r = repo_add_solv(data->repo, fp, flags | REPO_USE_LOADING);
3138 if (r || data->state == REPODATA_LOADING)
3139 data->state = oldstate;
3142 void extend_to_repo() {
3143 Repodata *data = repo_id2repodata($self->repo, $self->id);
3144 repodata_extend_block(data, data->repo->start, data->repo->end - data->repo->start);
3146 bool __eq__(XRepodata *xr) {
3147 return $self->repo == xr->repo && $self->id == xr->id;
3149 bool __ne__(XRepodata *xr) {
3150 return !XRepodata___eq__($self, xr);
3152 %newobject __repr__;
3153 const char *__repr__() {
3155 sprintf(buf, "<Repodata #%d>", $self->id);
3156 return solv_strdup(buf);
3160 #ifdef ENABLE_PUBKEY
3163 return solvsig_create(fp);
3166 solvsig_free($self);
3170 return $self->htype ? (Chksum *)solv_chksum_create($self->htype) : 0;
3172 #ifdef ENABLE_PGPVRFY
3174 XSolvable *verify(Repo *repo, Chksum *chksum) {
3175 Id p = solvsig_verify($self, repo, chksum);
3176 return new_XSolvable(repo->pool, p);