9 libsolv-bindings - access libsolv from perl/python/ruby
18 The pool is libsolv's central resource manager. A pool consists of Solvables,
19 Repositories, Dependencies, each indexed by Ids.
24 my $pool = solv::Pool->new();
26 pool = Solv::Pool.new()
28 Create a new pool instance. In most cases you just need
33 void *appdata; /* read/write */
38 Application specific data that may be used in any way by the code using the
41 Solvable solvables[]; /* read only */
42 my $solvable = $pool->{'solvables'}->[$solvid];
43 solvable = pool.solvables[solvid]
44 solvable = pool.solvables[solvid]
46 Look up a Solvable by its id.
48 Repo repos[]; /* read only */
49 my $repo = $pool->{'repos'}->[$repoid];
50 repo = pool.repos[repoid]
51 repo = pool.repos[repoid]
53 Look up a Repository by its id.
55 Repo *installed; /* read/write */
56 $pool->{'installed'} = $repo;
60 Define which repository contains all the installed packages.
64 *POOL_FLAG_PROMOTEEPOCH*::
65 Promote the epoch of the providing dependency to the requesting
66 dependency if it does not contain an epoch. Used at some time
67 in old rpm versions, modern systems should never need this.
69 *POOL_FLAG_FORBIDSELFCONFLICTS*::
70 Disallow the installation of packages that conflict with themselfs.
71 Debian always allowd self-conflicting packages, rpm used to forbid
72 them but switched to also allowing them recently.
74 *POOL_FLAG_OBSOLETEUSESPROVIDES*::
75 Make obsolete type dependency match against provides instead of
76 just the name and version of packages. Very old versions of rpm
77 used the name/version, then it got switched to provides and later
78 switched back again to just name/version.
80 *POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES*::
81 An implicit obsoletes is the internal mechanism to remove the
82 old package on an update. The default is to remove all packages
83 with the same name, rpm-5 switched to also removing packages
84 providing the same name.
86 *POOL_FLAG_OBSOLETEUSESCOLORS*::
87 Rpm's multilib implementation (used in RedHat and Fedora)
88 distinguishes between 32bit and 64bit packages (the terminology
89 is that they have a different color). If obsolteusescolors is
90 set, packages with different colors will not obsolete each other.
91 This is also true for implicit obsoletes, thus you can install
92 both the 32bit and the 64bit version of a package with the
95 *POOL_FLAG_NOINSTALLEDOBSOLETES*::
96 New versions of rpm consider the obsoletes of installed packages
97 when checking for dependency, thus you may not install a package
98 that is obsoleted by some other installed package, unless you
99 also deinstall the other package.
101 *POOL_FLAG_HAVEDISTEPOCH*::
102 Mandriva added a new field called distepoch that gets checked in
103 version comparison if the epoch/version/release of two packages
106 *POOL_FLAG_NOOBSOLETESMULTIVERSION*::
107 If a package is installed in multiversionmode, rpm used to ignore
108 both the implicit obsoletes and the obsolete dependency of a
109 package. This was changed to ignoring just the implicit obsoletes,
110 thus you may install multiple versions of the same name, but
111 obsoleted packages still get removed.
113 *POOL_FLAG_ADDFILEPROVIDESFILTERED*::
114 Make the addfileprovides method only add files from the standard
115 locations (i.e. the ``bin'' and ``etc'' directories). This is
116 useful if you have only few packages that use non-standard file
117 dependencies, but you still wand the fast speed that addfileprovides()
127 Free a pool. This is currently done with a method instead of relying on
128 reference counting or garbage collection because it's hard to track every
131 void setdebuglevel(int level)
132 $pool->setdebuglevel($level);
133 pool.setdebuglevel(level)
134 pool.setdebuglevel(level)
136 Set the debug level. A value of zero means no debug output, the higher the
137 value, the more output is generated.
139 int set_flag(int flag, int value)
140 my $oldvalue = $pool->set_flag($flag, $value);
141 oldvalue = pool.set_flag(flag, value)
142 oldvalue = pool.set_flag(flag, value)
144 int get_flag(int flag)
145 my $value = $pool->get_flag($flag);
146 value = pool.get_flag(flag)
147 value = pool.get_flag(flag)
149 Set/get a pool specific flag. The flags define how the system works, e.g. how
150 the package manager treats obsoletes. The default flags should be sane for most
151 applications, but in some cases you may want to tweak a flag, for example if
152 you want to solv package dependencies for some other system than yours.
154 void set_rootdir(const char *rootdir)
155 $pool->set_rootdir(rootdir);
156 pool.set_rootdir(rootdir)
157 pool.set_rootdir(rootdir)
159 const char *get_rootdir()
160 my $rootdir = $pool->get_rootdir();
161 rootdir = pool.get_rootdir()
162 rootdir = pool.get_rootdir()
164 Set/get the rootdir to use. This is useful if you want package management
165 to work only in some directory, for example if you want to setup a chroot
166 jail. Note that the rootdir will only be prepended to file paths if the
167 *REPO_USE_ROOTDIR* flag is used.
169 void setarch(const char *arch = 0)
174 Set the architecture for your system. The architecture is used to determine
175 which packages are installable. It defaults to the result of ``uname -m''.
177 Repo *add_repo(const char *name)
178 $repo = $pool->add_repo($name);
179 repo = pool.add_repo(name)
180 repo = pool.add_repo(name)
182 Add a Repository with the specified name to the pool. The reposiory is empty
183 on creation, use the repository methods to populate it with packages.
185 Repoiterator *repos_iter()
186 for my $repo (@{$pool->repos_iter()})
187 for repo in pool.repos_iter():
188 for repo in pool.repos_iter()
190 Iterate over the existing repositories.
192 Solvableiterator *solvables_iter()
193 for my $solvable (@{$pool->solvables_iter()})
194 for solvable in pool.solvables_iter():
195 for solvable in pool.solvables_iter()
197 Iterate over the existing solvables.
199 Dep *Dep(const char *str, bool create=1)
200 my $dep = $pool->Dep($string);
201 dep = pool.Dep(string)
202 dep = pool.Dep(string)
204 Create an object describing a string or dependency. If the string is currently
205 not in the pool and _create_ is false, *undef*/*None*/*nil* is returned.
207 void addfileprovides()
208 $pool->addfileprovides();
209 pool.addfileprovides()
210 pool.addfileprovides()
212 Queue addfileprovides_queue()
213 my @ids = $pool->addfileprovides_queue();
214 ids = pool.addfileprovides_queue()
215 ids = pool.addfileprovides_queue()
217 Some package managers like rpm allow dependencies on files contained in other
218 packages. To allow libsolv to deal with those dependencies in an efficient way,
219 you need to call the addfileprovides method after creating and reading all
220 repositories. This method will scan all dependency for file names and than scan
221 all packages for matching files. If a filename has been matched, it will be
222 added to the provides list of the corresponding package. The
223 addfileprovides_queue variant works the same way but returns an array
224 containing all file dependencies. This information can be stored with the
225 repository to speed up the next usage of the repository.
227 void createwhatprovides()
228 $pool->createwhatprovides();
229 pool.createwhatprovides()
230 pool.createwhatprovides()
232 Create the internal ``whatprovides'' hash over all of the provides of all
233 packages. This method must be called before doing any lookups on provides.
234 It's encuraged to do it right after all repos are set up, usually right after
235 the call to addfileprovides().
237 Queue whatprovides(DepId dep)
238 my @solvables = $pool->whatprovides($dep);
239 solvables = pool.whatprovides(dep)
240 solvables = pool.whatprovides(dep)
242 Return all solvables that provide the specified dependency. You can use either
243 a Dep object or an simple Id as argument.
245 Queue matchprovidingids(const char *match, int flags)
246 my @ids = $pool->matchprovidingids($match, $flags);
247 ids = pool.matchprovidingids(match, flags)
248 ids = pool.matchprovidingids(match, flags)
250 Search the names of all provides and return the ones matching the specified
251 string. See the Dataiterator class for the allowed flags.
253 Id towhatprovides(Queue ids)
254 my $offset = $pool->towhatprovides(\@ids);
255 offset = pool.towhatprovides(ids)
256 offset = pool.towhatprovides(ids)
258 ``Internalize'' an array containing Ids. The returned value can be used to
259 create solver jobs working on a specific set of packages. See the Solver class
260 for more information.
262 bool isknownarch(DepId id)
263 my $bool = $pool->isknownarch($id);
264 bool = pool.isknownarch(id)
265 bool = pool.isknownarch?(id)
267 Return true if the specified Id describs a known architecture.
270 my $solver = $pool->Solver();
271 solver = pool.Solver()
272 solver = pool.Solver()
274 Create a new solver object.
276 Solver *Job(int how, Id what)
277 my $job = $pool->Job($how, $what);
278 job = pool.Job(how, what)
279 job = pool.Job(how, what)
281 Create a new Job object. Kind of low level, in most cases you would use a
282 Selection or Dep job constructor instead.
284 Selection *Selection()
285 my $sel = $pool->Selection();
286 sel = pool.Selection()
287 sel = pool.Selection()
289 Create an empty selection. Useful as a starting point for merging other
292 Selection *Selection_all()
293 my $sel = $pool->Selection_all();
294 sel = pool.Selection_all()
295 sel = pool.Selection_all()
297 Create a selection containing all packages. Useful as starting point for
298 intersecting other selections or for update/distupgrade jobs.
300 Selection *select(const char *name, int flags)
301 my $sel = $pool->select($name, $flags);
302 sel = pool.select(name, flags)
303 sel = pool.select(name, flags)
305 Create a selection by matching packages against the specified string. See the
306 Selection class for a list of flags and how to create solver jobs from a
309 void setpooljobs(Jobs *jobs)
310 $pool->setpooljobs(\@jobs);
311 pool.setpooljobs(jobs)
312 pool.setpooljobs(jobs)
315 @jobs = $pool->getpooljobs();
316 jobs = pool.getpooljobs()
317 jobs = pool.getpooljobs()
319 Get/Set fixed jobs stored in the pool. Those jobs are automatically appended to
320 all solver jobs, they are meant for fixed configurations like which packages
321 can be multiversion installed, which packages were userinstalled or must not be
324 void set_loadcallback(Callable *callback)
325 $pool->setloadcallback(\&callbackfunction);
326 pool.setloadcallback(callbackfunction)
327 pool.setloadcallback { |repodata| ... }
329 Set the callback function called when repository metadata needs to be loaded on
330 demand. To make use of this feature, you need to create repodata stubs that
331 tell the library which data is available but not loaded. If later on the data
332 needs to be accessed, the callback function is called with a repodata argument.
333 You can then load the data (maybe fetching it first from an remote server).
334 The callback should return true if the data has been made available.
336 === DATA RETRIEVAL METHODS ===
338 In the following functions, the _keyname_ argument describes what to retrive.
339 For the standard cases you can use the available Id constants. For example,
341 $solv::SOLVABLE_SUMMARY
342 solv.SOLVABLE_SUMMARY
343 Solv::SOLVABLE_SUMMARY
345 selects the ``Summary'' entry of a solvable. The _solvid_ argument selects the
346 desired solvable by Id.
348 const char *lookup_str(Id solvid, Id keyname)
349 my $string = $pool->lookup_str($solvid, $keyname);
350 string = pool.lookup_str(solvid, keyname)
351 string = pool.lookup_str(solvid, keyname)
353 Id lookup_id(Id solvid, Id keyname)
354 my $id = $pool->lookup_id($solvid, $keyname);
355 id = pool.lookup_id(solvid, keyname)
356 id = pool.lookup_id(solvid, keyname)
358 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
359 my $num = $pool->lookup_num($solvid, $keyname);
360 num = pool.lookup_num(solvid, keyname)
361 num = pool.lookup_num(solvid, keyname)
363 bool lookup_void(Id solvid, Id keyname)
364 my $bool = $pool->lookup_void($solvid, $keyname);
365 bool = pool.lookup_void(solvid, keyname)
366 bool = pool.lookup_void(solvid, keyname)
368 Queue lookup_idarray(Id solvid, Id keyname)
369 my @ids = $pool->lookup_idarray($solvid, $keyname);
370 ids = pool.lookup_idarray(solvid, keyname)
371 ids = pool.lookup_idarray(solvid, keyname)
373 Chksum *lookup_checksum(Id solvid, Id keyname)
374 my $chksum = $pool->lookup_checksum($solvid, $keyname);
375 chksum = pool.lookup_checksum(solvid, keyname)
376 chksum = pool.lookup_checksum(solvid, keyname)
378 Lookup functions. Return the data element stored in the specified solvable.
379 You should probably use the methods of the Solvable class instead.
381 Dataiterator *Dataiterator(Id solvid, Id keyname, const char *match, int flags)
382 my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags);
383 di = pool.Dataiterator(solvid, keyname, match, flags)
384 di = pool.Dataiterator(solvid, keyname, match, flags)
390 Iterate over the matching data elements. See the Dataiterator class for more
395 The following methods deal with Ids, i.e. integers representing objects in the
396 pool. They are considered ``low level'', in most cases you would not use them
397 but instead the object orientated methods.
400 $repo = $pool->id2repo($id);
401 repo = pool.id2repo(id)
402 repo = pool.id2repo(id)
404 Lookup an existing Repository by id. You can also do this by using the *repos*
407 Solvable *id2solvable(Id id)
408 $solvable = $pool->id2solvable($id);
409 solvable = pool.id2solvable(id)
410 solvable = pool.id2solvable(id)
412 Lookup an existing Repository by id. You can also do this by using the
413 *solvables* attribute.
415 const char *solvid2str(Id id)
416 my $str = $pool->solvid2str($id);
417 str = pool.solvid2str(id)
418 str = pool.solvid2str(id)
420 Return a string describing the Solvable with the specified id. The string
421 consists of the name, version, and architecture of the Solvable.
423 Id str2id(const char *str, bool create=1)
424 my $id = pool->str2id($string);
425 id = pool.str2id(string)
426 id = pool.str2id(string)
428 const char *id2str(Id id)
429 $string = pool->id2str($id);
430 string = pool.id2str(id)
431 string = pool.id2str(id)
433 Convert a string into an Id and back. If the string is currently not in the
434 pool and _create_ is false, zero is returned.
436 Id rel2id(Id name, Id evr, int flags, bool create=1)
437 my $id = pool->rel2id($nameid, $evrid, $flags);
438 id = pool.rel2id(nameid, evrid, flags)
439 id = pool.rel2id(nameid, evrid, flags)
441 Create a ``relational'' dependency. Such dependencies consist of a name part,
442 the _flags_ describing the relation, and a version part. The flags are:
444 $solv::REL_EQ | $solv::REL_GT | $solv::REL_LT
445 solv.REL_EQ | solv.REL_GT | solv.REL_LT
446 Solv::REL_EQ | Solv::REL_GT | Solv::REL_LT
448 Thus, if you want a ``\<='' relation, you would use *REL_LT | REL_EQ*.
450 Id id2langid(Id id, const char *lang, bool create=1)
451 my $id = $pool->id2langid($id, $language);
452 id = pool.id2langid(id, language)
453 id = pool.id2langid(id, language)
455 Create a language specific Id from some other id. This function simply converts
456 the id into a string, appends a dot and the specified language to the string
457 and converts the result back into an Id.
459 const char *dep2str(Id id)
460 $string = pool->dep2str($id);
461 string = pool.dep2str(id)
462 string = pool.dep2str(id)
464 Convert a dependency id into a string. If the id is just a string, this
465 function has the same effect as id2str(). For relational dependencies, the
466 result is the correct ``name relation evr'' string.
471 The dependency class is an object orientated way to work with strings and
472 dependencies. Internally, dependencies are represented as Ids, i.e. simple
473 numbers. Dependency objects can be constructed by using the Pool's Dep()
478 Pool *pool; /* read only */
483 Back reference to the pool this dependency belongs to.
485 Id id; /* read only */
490 The id of this dependency.
494 Dep *Rel(int flags, DepId evrid, bool create=1)
495 my $reldep = $dep->Rel($flags, $evrdep);
496 reldep = dep.Rel(flags, evrdep)
497 reldep = dep.Rel(flags, evrdep)
499 Create a relational dependency from to string dependencies and a flags
500 argument. See the pool's rel2id method for a description of the flags.
502 Selection *Selection_name(int setflags = 0)
503 my $sel = $dep->Selection_name();
504 sel = dep.Selection_name()
505 sel = dep.Selection_name()
507 Create a Selection from a dependency. The selection consists of all packages
508 that have a name equal to the dependency. If the dependency is of a relational
509 type, the packages version must also fulfill the dependency.
511 Selection *Selection_provides(int setflags = 0)
512 my $sel = $dep->Selection_provides();
513 sel = dep.Selection_provides()
514 sel = dep.Selection_provides()
516 Create a Selection from a dependency. The selection consists of all packages
517 that have at least one provides matching the dependency.
520 my $str = $dep->str();
524 Return a string describing the dependency.
531 Same as calling the str() method.
538 The dependencies are equal if they are part of the same pool and have the same
543 A Repository describes a group of packages, normally comming from the same
544 source. Repositories are created by the Pool's add_repo() method.
548 Pool *pool; /* read only */
553 Back reference to the pool this dependency belongs to.
555 Id id; /* read only */
560 The id of the repository.
562 const char *name; /* read/write */
567 The repositories name. To libsolv, the name is just a string with no specific
570 int prioprity; /* read/write */
575 The priority of the repository. A higher number means that packages of this
576 repository will be chosen over other repositories, even if they have a greater
579 int subprioprity; /* read/write */
580 $repo->{'subpriority'}
584 The sub-priority of the repository. This value is compared when the priorities
585 of two repositories are the same. It is useful to make the library prefer
586 on-disk repositories to remote ones.
588 int nsolvables; /* read only */
589 $repo->{'nsolvables'}
593 The number of solvables in this repository.
595 void *appdata; /* read/write */
600 Application specific data that may be used in any way by the code using the
603 Datapos *meta; /* read only */
608 Return a Datapos object of the repodata's metadata. You can use the lookup
609 methods of the Datapos class to lookup metadata attributes, like the repository
614 *REPO_REUSE_REPODATA*::
615 Reuse the last repository data aera (``repodata'') instead of creating a new
618 *REPO_NO_INTERNALIZE*::
619 Do not internalize the added repository data. This is useful if
620 you plan to add more data because internalization is a costly
624 Use the repodata's pool for Id storage instead of the global pool. Useful
625 if you don't want to pollute the global pool with many unneeded ids, like
626 when storing the filelist.
629 Use the repodata that is currently being loaded instead of creating a new one.
630 This only makes sense if used in a load callback.
632 *REPO_EXTEND_SOLVABLES*::
633 Do not create new solvables for the new data, but match existing solvables and
634 add the data to them. Repository metadata is often split into multiple parts,
635 with one primary file describing all packages and other parts holding
636 information that is normally not needed, like the changelog.
639 Prepend the pool's rootdir to the path when doing file operations.
642 Do not add a location element to the solvables. Useful if the solvables are
643 not in the final position, so you can add the correct location later in your code.
645 *SOLV_ADD_NO_STUBS*::
646 Do not create stubs for repository parts that can be downloaded on demand.
648 *SUSETAGS_RECORD_SHARES*::
649 This is specific to the add_susetags() method. Susetags allows to refer to already
650 read packages to save disk space. If this data sharing needs to work over multiple
651 calls to add_susetags, you need to specify this flag so that the share information
652 is made available to subsequent calls.
656 void free(bool reuseids = 0)
661 Free the repository and all solvables it contains. If _reuseids_ is set to
662 true, the solvable ids and the repository id may be reused by the library when
663 added new solvables. Thus you should leave it false if you are not sure that
664 somebody holds a reference.
666 void empty(bool reuseids = 0)
671 Free all the solvables in a repository. The repository will be empty after this
672 call. See the free() method for the meaning of _reuseids_.
679 Return true if there are no solvables in this repository.
682 $repo->internalize();
686 Internalize added data. Data must be internalized before it is available to the
687 lookup and data iterator functions.
694 Write a repo as a ``solv'' file. These files can be read very fast and thus are
695 a good way to cache repository data. Returns false if there was some error
698 Solvableiterator *solvables_iter()
699 for my $solvable (@{$repo->solvables_iter()})
700 for solvable in repo.solvables_iter():
701 for solvable in repo.solvables_iter()
703 Iterate over all solvables in a repository.
705 Repodata *add_repodata(int flags = 0)
706 my $repodata = $repo->add_repodata();
707 repodata = repo.add_repodata()
708 repodata = repo.add_repodata()
710 Add a new repodata area to the repository. This is normally automatically
711 done by the repo_add methods, so you need this method only in very
715 $repo->create_stubs();
719 Calls the create_stubs() repodata method for the last repodata of the
723 $repo->iscontiguous()
727 Return true if the solvables of this repository are all in a single block with
728 no holes, i.e. they have consecutive ids.
730 Repodata *first_repodata()
731 my $repodata = $repo->first_repodata();
732 repodata = repo.first_repodata()
733 repodata = repo.first_repodata()
735 Checks if all repodatas but the first repodata are extensions, and return the
736 first repodata if this is the case. Useful if you want to do a store/retrive
737 sequence on the repository to reduce the memory using and enable paging, as
738 this does not work if the rpository contains multiple non-extension repodata
741 Selection *Selection(int setflags = 0)
742 my $sel = $repo->Selection();
743 sel = repo.Selection()
744 sel = repo.Selection()
746 Create a Selection consisting of all packages in the repository.
748 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags)
749 my $di = $repo->Dataiterator($solvid, $keyname, $match, $flags);
750 di = repo.Dataiterator(solvid, keyname, match, flags)
751 di = repo.Dataiterator(solvid, keyname, match, flags)
757 Iterate over the matching data elements in this repository. See the
758 Dataiterator class for more information.
765 Return the name of the repository, or "Repo#<id>" if no name is set.
768 if ($repo1 == $repo2)
772 Two repositories are equal if they belong to the same pool and have the same id.
774 === DATA ADD METHODS ===
776 Solvable *add_solvable()
777 $repo->add_solvable();
781 Add a single empty solvable to the repository. Returns a Solvable object, see
782 the Solvable class for more information.
784 bool add_solv(const char *name, int flags = 0)
785 $repo->add_solv($name, $flags);
786 repo.add_solv(name, flags)
787 repo.add_solv(name, flags)
789 bool add_solv(FILE *fp, int flags = 0)
790 $repo->add_solv($fp, $flags);
791 repo.add_solv(fp, flags)
792 repo.add_solv(fp, flags)
794 Read a ``solv'' file and add its contents to the repository. These files can be
795 written with the write() method and are normally used as fast cache for
798 bool add_rpmdb(int flags = 0)
799 $repo->add_rpmdb($flags);
800 repo.add_rpmdb(flags)
801 repo.add_rpmdb(flags)
803 bool add_rpmdb_reffp(FILE *reffp, int flags = 0)
804 $repo->add_rpmdb_reffp($reffp, $flags);
805 repo.add_rpmdb_reffp($reffp, flags)
806 repo.add_rpmdb_reffp($reffp, flags)
808 Add the contents of the rpm database to the repository. If a solv file
809 containing an old version of the database is available, it can be passed as
810 reffp to speed up reading.
812 bool add_rpm(const char *name, int flags = 0)
813 $repo->add_rpm($name, $flags);
814 repo.add_rpm(name, flags)
815 repo.add_rpm(name, flags)
817 Add the metadata of a single rpm package to the repository.
819 bool add_rpmdb_pubkeys(int flags = 0)
820 $repo->add_rpmdb_pubkeys();
821 repo.add_rpmdb_pubkeys()
822 repo.add_rpmdb_pubkeys()
824 Add all pubkeys contained in the rpm database to the repository. Note that
825 newer rpm versions also allow to store the pubkeys in some directory instead
828 bool add_pubkey(const char *keyfile, int flags = 0)
829 $repo->add_pubkey($keyfile);
830 repo.add_pubkey($keyfile)
831 repo.add_pubkey($keyfile)
833 Add a pubkey from a file to the repository.
835 bool add_rpmmd(FILE *fp, const char *language, int flags = 0)
836 $repo->add_rpmmd($fp, $language);
837 repo.add_rpmmd(fp, language)
838 repo.add_rpmmd(fp, language)
840 Add metadata stored in the "rpm-md" format (i.e. from files in the ``repodata''
841 directory) to a repository. Supported files are "primary", "filelists",
842 "other", "suseinfo". Do not forget to specify the *REPO_EXTEND_SOLVABLES* for
843 extension files like "filelists" and "other". Use the _language_ parameter if
844 you have language extension files, otherwise simply use a *undef*/*None*/*nil*
847 bool add_repomdxml(FILE *fp, int flags = 0)
848 $repo->add_repomdxml($fp);
849 repo.add_repomdxml(fp)
850 repo.add_repomdxml(fp)
852 Add the repomd.xml meta description from the "rpm-md" format to the repository.
853 This file contains information about the repository like keywords, and also a
854 list of all database files with checksums. The data is added the the "meta"
855 section of the repository, i.e. no package gets created.
857 bool add_updateinfoxml(FILE *fp, int flags = 0)
858 $repo->add_updateinfoxml($fp);
859 repo.add_updateinfoxml(fp)
860 repo.add_updateinfoxml(fp)
862 Add the updateinfo.xml file containing available maintenance updates to the
863 repository. All updates are created as special packages that have a "patch:"
864 prefix in their name.
866 bool add_deltainfoxml(FILE *fp, int flags = 0)
867 $repo->add_deltainfoxml($fp);
868 repo.add_deltainfoxml(fp)
869 repo.add_deltainfoxml(fp)
871 Add the deltainfo.xml file (also called prestodelta.xml) containing available
872 delta-rpms to the repository. The data is added to the "meta" section, i.e. no
873 package gets created.
875 bool add_debdb(int flags = 0)
880 Add the contents of the debian installed package database to the repository.
882 bool add_debpackages(FILE *fp, int flags = 0)
883 $repo->add_debpackages($fp);
884 repo.add_debpackages($fp)
885 repo.add_debpackages($fp)
887 Add the contents of the debian repository metadata (the "packages" file)
890 bool add_deb(const char *filename, int flags = 0)
891 $repo->add_deb($filename);
892 repo.add_deb(filename)
893 repo.add_deb(filename)
895 Add the metadata of a single deb package to the repository.
897 bool add_mdk(FILE *fp, int flags = 0)
902 Add the contents of the mageia/mandriva repository metadata (the
903 "synthesis.hdlist" file) to the repository.
905 bool add_mdk_info(FILE *fp, int flags = 0)
910 Extend the packages from the synthesis file with the info.xml and files.xml
911 data. Do not forget to specify *REPO_EXTEND_SOLVABLES*.
913 bool add_arch_repo(FILE *fp, int flags = 0)
914 $repo->add_arch_repo($fp);
915 repo.add_arch_repo($fp)
916 repo.add_arch_repo($fp)
918 Add the contents of the archlinux repository metadata (the ".db.tar" file) to
921 bool add_arch_local(const char *dir, int flags = 0)
922 $repo->add_arch_local($dir);
923 repo.add_arch_local($dir)
924 repo.add_arch_local($dir)
926 Add the contents of the archlinux installed package database to the repository.
927 The _dir_ parameter is usually set to "/var/lib/pacman/local".
929 bool add_content(FILE *fp, int flags = 0)
930 $repo->add_content($fp);
934 Add the ``content'' meta description from the susetags format to the repository.
935 This file contains information about the repository like keywords, and also
936 a list of all database files with checksums. The data is added the the "meta"
937 section of the repository, i.e. no package gets created.
939 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0)
940 $repo->add_susetags($fp, $defvendor, $language);
941 repo.add_susetags(fp, defvendor, language)
942 repo.add_susetags(fp, defvendor, language)
944 Add repository metadata in the susetags format to the repository. Like with
945 add_rpmmd, you can specify a language if you have language extension files. The
946 _defvendor_ parameter provides a default vendor for packages with missing
947 vendors, it is usually provided in the content file.
949 bool add_products(const char *dir, int flags = 0)
950 $repo->add_products($dir);
951 repo.add_products(dir)
952 repo.add_products(dir)
954 Add the installed SUSE products database to the repository. The _dir_ parameter
955 is usually "/etc/products.d".
960 A solvable describes all the information of one package. Each solvable belongs to
961 one repository, it can be added and filled manually but in most cases solvables
962 will get created by the repo_add methods.
966 Repo *repo; /* read only */
971 The repository this solvable belongs to.
973 Pool *pool; /* read only */
978 The pool this solvable belongs to, same as the pool of the repo.
980 Id id; /* read only */
985 The specific id of the solvable.
987 char *name; /* read/write */
992 char *evr; /* read/write */
997 char *arch; /* read/write */
1002 char *vendor; /* read/write */
1003 $solvable->{'vendor'}
1007 Easy access to often used attributes of solvables. They are
1008 internally stored as Ids.
1010 Id nameid; /* read/write */
1011 $solvable->{'nameid'}
1015 Id evrid; /* read/write */
1016 $solvable->{'evrid'}
1020 Id archid; /* read/write */
1021 $solvable->{'archid'}
1025 Id vendorid; /* read/write */
1026 $solvable->{'vendorid'}
1030 Raw interface to the ids. Useful if you want to search for
1031 a specific id and want to avoid the string compare overhead.
1035 const char *lookup_str(Id keyname)
1036 my $string = $solvable->lookup_str($keyname);
1037 string = solvable.lookup_str(keyname)
1038 string = solvable.lookup_str(keyname)
1040 Id lookup_id(Id keyname)
1041 my $id = $solvable->lookup_id($keyname);
1042 id = solvable.lookup_id(solvid)
1043 id = solvable.lookup_id(solvid)
1045 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
1046 my $num = $solvable->lookup_num($keyname);
1047 num = solvable.lookup_num(keyname)
1048 num = solvable.lookup_num(keyname)
1050 bool lookup_void(Id keyname)
1051 my $bool = $solvable->lookup_void($keyname);
1052 bool = solvable.lookup_void(keyname)
1053 bool = solvable.lookup_void(keyname)
1055 Chksum *lookup_checksum(Id keyname)
1056 my $chksum = $solvable->lookup_checksum($keyname);
1057 chksum = solvable.lookup_checksum(keyname)
1058 chksum = solvable.lookup_checksum(keyname)
1060 Queue lookup_idarray(Id keyname, Id marker = -1)
1061 my @ids = $solvable->lookup_idarray($keyname);
1062 ids = solvable.lookup_idarray(keyname)
1063 ids = solvable.lookup_idarray(keyname)
1065 Queue lookup_deparray(Id keyname, Id marker = -1)
1066 my @deps = $solvable->lookup_deparray($keyname);
1067 deps = solvable.lookup_deparray(keyname)
1068 deps = solvable.lookup_deparray(keyname)
1070 Generic lookup methods. Retrieve data stored for the specific keyname.
1071 The lookup_idarray() method will return an array of Ids, use
1072 lookup_deparray if you want an array of Dependency objects instead.
1073 Some Id arrays contain two parts of data divided by a specific marker,
1074 for example the provides array uses the SOLVABLE_FILEMARKER id to
1075 store both the ids provided by the package and the ids added by
1076 the addfileprovides method. The default, -1, translates to the
1077 correct marker for the keyname and returns the first part of the
1078 array, use 1 to select the second part or 0 to retrive all ids
1079 including the marker.
1081 const char *lookup_location(unsigned int *OUTPUT);
1082 my ($location, $medianr) = $solvable->lookup_location();
1083 location, medianr = solvable.lookup_location()
1084 location, medianr = solvable.lookup_location()
1086 Return a tuple containing the on-media location and an optional
1087 media number for multi-part repositories (e.g. repositories
1088 spawning multiple DVDs).
1090 void add_deparray(Id keyname, DepId dep, Id marker = -1);
1091 $solvable->add_deparray($keyname, $dep);
1092 solvable.add_deparray(keyname, dep)
1093 solvable.add_deparray(keyname, dep)
1095 Add a new dependency to the attributes stored in keyname.
1098 $solvable->installable()
1099 solvable.installable()
1100 solvable.installable?
1102 Return true if the solvable is installable on the system. Solvables
1103 are not installable if the system does not support their architecture.
1106 $solvable->isinstalled()
1107 solvable.isinstalled()
1108 solvable.isinstalled?
1110 Return true if the solvable is installed on the system.
1112 Selection *Selection(int setflags = 0)
1113 my $sel = $solvable->Selection();
1114 sel = solvable.Selection()
1115 sel = solvable.Selection()
1117 Create a Selection containing just the single solvable.
1120 my $str = $solvable->str();
1121 str = $solvable.str()
1122 str = $solvable.str()
1124 Return a string describing the solvable. The string consists of the name,
1125 version, and architecture of the Solvable.
1128 my $str = "$solvable";
1132 Same as calling the str() method.
1135 if ($solvable1 == $solvable2)
1136 if solvable1 == solvable2:
1137 if solvable1 == solvable2
1139 Two solvables are equal if they are part of the same pool and have the same
1142 THE DATAITERATOR CLASS
1143 ----------------------
1145 Dataiterators can be used to do complex string searches or
1146 to iterate over arrays. They can be created via the
1147 constructors in the Pool, Repo, and Solvable classes. The
1148 Repo and Solvable constructors will limit the search to
1149 the repository or the specific package.
1154 Return a match if the search string matches the value.
1156 *SEARCH_STRINGSTART*::
1157 Return a match if the value starts with the search string.
1159 *SEARCH_STRINGEND*::
1160 Return a match if the value ends with the search string.
1162 *SEARCH_SUBSTRING*::
1163 Return a match if the search string can be matched somewhere
1167 Do a glob match of the search string against the value.
1170 Do a regular expression match of the search string against
1174 Ignore case when matching strings. Works for all the above
1178 Match the complete filenames of the file list, not just the
1181 *SEARCH_COMPLETE_FILELIST*::
1182 When matching the file list, check every file of the package
1183 not just the subset from the primary metadata.
1185 *SEARCH_CHECKSUMS*::
1186 Allow the matching of checksum entries.
1190 void prepend_keyname(Id keyname);
1191 $di->prepend_keyname($keyname);
1192 di.prepend_keyname(keyname)
1193 di.prepend_keyname(keyname)
1195 Do a sub-search in the array stored in keyname.
1197 void skip_solvable();
1198 $di->kip_solvable();
1202 Stop matching the current solvable and advance to the next
1210 Iterate through the matches. If there is a match, the object
1211 in d will be of type Datamatch.
1215 Objects of this type will be created for every value matched
1220 Pool *pool; /* read only */
1225 Back pointer to pool.
1227 Repo *repo; /* read only */
1232 The repository containing the matched object.
1234 Solvable *solvable; /* read only */
1239 The solvable containing the value that was matched.
1241 Id solvid; /* read only */
1246 The id of the solvable that matched.
1255 const char *key_idstr();
1260 The keyname that matched, either as id or string.
1267 const char *type_idstr();
1272 The key type of the value that was matched, either as id or string.
1284 The Id of the value that was matched (only valid for id types),
1285 either as id or string.
1292 The string value that was matched (only valid for string types).
1294 unsigned long long num();
1299 The numeric value that was matched (only valid for numeric types).
1301 unsigned int num2();
1306 The secondary numeric value that was matched (only valid for types
1307 containing two values).
1310 my $pos = $d->pos();
1314 The position object of the current match. It can be used to do
1315 sub-searches starting at the match (if it is of an array type).
1316 See the Datapos class for more information.
1318 Datapos *parentpos();
1319 my $pos = $d->parentpos();
1323 The position object of the array containing the current match.
1324 It can be used to do sub-searches, see the Datapos class for more
1332 Return the stringification of the matched value. Stringification
1333 depends on the search flags, for file list entries it will return
1334 just the base name unless SEARCH_FILES is used, for checksums
1335 it will return an empty string unless SEARCH_CHECKSUMS is used.
1336 Numeric values are currently stringified to an empty string.
1341 Selections are a way to easily deal with sets of packages.
1342 There are multiple constructors to create them, the most useful
1343 is probably the select() method in the Pool class.
1348 Create the selection by matching package names
1350 *SELECTION_PROVIDES*::
1351 Create the selection by matching package provides
1353 *SELECTION_FILELIST*::
1354 Create the selection by matching package files
1357 Create the selection by matching the canonical representation
1358 of the package. This is normally a combination of the name,
1359 the version, and the architecture of a package.
1361 *SELECTION_DOTARCH*::
1362 Allow an ``.<architecture>'' suffix when matching names or
1366 Allow the specification of a relation when matching names
1367 or provides, e.g. "name >= 1.2".
1369 *SELECTION_INSTALLED_ONLY*::
1370 Limit the package search to installed packages.
1372 *SELECTION_SOURCE_ONLY*::
1373 Limit the package search to source packages only.
1375 *SELECTION_WITH_SOURCE*::
1376 Extend the package search to also match source packages. The
1377 default is only to match binary packages.
1380 Allow glob matching for package names, package provides, and
1383 *SELECTION_NOCASE*::
1384 Ignore case when matching package names, package provides,
1388 Return only one selection element describing the selected packages.
1389 The default is to create multiple elements for all globbed packages.
1390 Multiple elements are useful if you want to turn the selection into
1391 an install job, in that case you want an install job for every
1396 Pool *pool; /* read only */
1401 Back pointer to pool.
1406 my $flags = $sel->flags();
1410 Return the result flags of the selection. The flags are a subset
1411 of the ones used when creating the selection, they describe which
1412 method was used to get the result. For example, if you create the
1413 selection with ``SELECTION_NAME | SELECTION_PROVIDES'', the resulting
1414 flags will either be SELECTION_NAME or SELECTION_PROVIDES depending
1415 if there was a package that matched the name or not. If there was
1416 no match at all, the flags will be zero.
1423 Return true if the selection is empty, i.e. no package could be matched.
1425 void filter(Selection *other)
1426 $sel->filter($other);
1430 Intersect two selections. Packages will only stay in the selection if there
1431 are also included in the other selecting. Does an in-place modification.
1433 void add(Selection *other)
1438 Build the union of two selections. All packages of the other selection will
1439 be added to the set of packages of the selection object. Does an in-place
1440 modification. Note that the selection flags are no longer meaningful after the
1443 void add_raw(Id how, Id what)
1444 $sel->add_raw($how, $what);
1445 sel.add_raw(how, what)
1446 sel.add_raw(how, what)
1448 Add a raw element to the selection. Check the Job class for information about
1449 the how and what parameters.
1451 Job **jobs(int action)
1452 my @jobs = $sel->jobs($action);
1453 jobs = sel.jobs(action)
1454 jobs = sel.jobs(action)
1456 Convert a selection into an array of Job objects. The action parameter is or-ed
1457 to the ``how'' part of the job, it describes the type of job (e.g. install,
1458 erase). See the Job class for the action and action modifier constants.
1460 Solvable **solvables()
1461 my @solvables = $sel->solvables();
1462 solvables = sel.solvables()
1463 solvables = sel.solvables()
1465 Convert a selection into an array of Solvable objects.
1472 Return a string describing the selection.
1476 Jobs are the way to specify to the dependency solver what to do.
1477 Most of the times jobs will get created by calling the jobs() method
1478 on a Selection object, but there is also a Job() constructor in the
1483 Selection constants:
1486 The ``what'' part is the id of a solvable.
1488 *SOLVER_SOLVABLE_NAME*::
1489 The ``what'' part is the id of a package name.
1491 *SOLVER_SOLVABLE_PROVIDES*::
1492 The ``what'' part is the id of a package provides.
1494 *SOLVER_SOLVABLE_ONE_OF*::
1495 The ``what'' part is an offset into the ``whatprovides'' data, created
1496 by calling the towhatprovides() pool method.
1498 *SOLVER_SOLVABLE_REPO*::
1499 The ``what'' part is the id of a repository.
1501 *SOLVER_SOLVABLE_ALL*::
1502 The ``what'' part is ignored, all packages are selected.
1504 *SOLVER_SOLVABLE_SELECTMASK*::
1505 A mask containing all the above selection bits.
1513 Install a package of the specified set of packages. It tries to install
1514 the best matching package (i.e. the highest version of the packages from
1515 the repositories with the highest priority).
1518 Erase all of the packages from the specified set. If a package is not
1519 installed, erasing it will keep it from getting installed.
1522 Update the matching installed packages to their best version. If none
1523 of the specified packages are installed, try to update the installed
1524 packages to the specified versions. See the section about targeted
1525 updates about more information.
1527 *SOLVER_WEAKENDEPS*::
1528 Allow to break the dependencies of the matching packages. Handle with care.
1530 *SOLVER_MULTIVERSION*::
1531 Mark the matched packages for multiversion install. If they get to be installed
1532 because of some other job, the installation will keep the old version of the
1533 package installed (for rpm by using ``-i'' instead of ``-U'').
1536 Do not change the state of the matched packages, i.e. when they are installed
1537 they stay installed, if not they are not selected for installation.
1539 *SOLVER_DISTUPGRADE*::
1540 Update the matching installed packages to the best version included in one
1541 of the repositories. After this operation, all come from one of the available
1542 repositories except orphaned packages. Orphaned packages are packages that
1543 have no relation to the packages in the repositories, i.e. no package in the
1544 repositories have the same name or obsolete the orphaned package.
1545 This action brings the installed packages in sync with the ones in the
1546 repository. It also turns of arch/vendor/version locking for the affected
1547 packages to simulate a fresh installation. This means that distupgrade can
1548 actually downgrade packages if only lower versions of a package are available
1549 in the repositories.
1551 *SOLVER_DROP_ORPHANED*::
1552 Erase all the matching installed packages if they are orphaned. This only makes
1553 sense if there is a ``distupgrade all packages'' job. The default is to erase
1554 orphaned packages only if they block the installation of other packages.
1557 Fix dependency problems of matching installed packages. The default is to ignore
1558 dependency problems for installed packages.
1560 *SOLVER_USERINSTALLED*::
1561 The matching installed packages are considered to be installed by a user, thus
1562 not installed to fulfil some dependency. This is needed input for the calculation
1563 of unneeded packages for jobs that have the SOLVER_CLEANDEPS flag set.
1566 A mask containing all the above action bits.
1568 Action modifier constants:
1571 Makes the job a weak job. The solver tries to fulfil weak jobs, but does not
1572 report a problem if it is not possible to do so.
1574 *SOLVER_ESSENTIAL*::
1575 Makes the job an essential job. If there is a problem with the job, the solver
1576 will not propose to remove the job as one solution (unless all other solutions
1577 are also to remove essential jobs).
1579 *SOLVER_CLEANDEPS*::
1580 The solver will try to also erase all packages dragged in through dependencies
1581 when erasing the package. This needs SOLVER_USERINSTALLED jobs to maximize user
1584 *SOLVER_FORCEBEST*::
1585 Insist on the best package for install, update, and distupgrade jobs. If this
1586 flag is not used, the solver will use the second-best package if the best
1587 package cannot be installed for some reason. When this flag is used, the solver
1588 will generate a problem instead.
1591 Forces targeted operation update and distupgrade jobs. See the section about
1592 targeted updates about more information.
1597 The job specified the exact epoch and version of the package set.
1600 The job specified the exact epoch, version, and release of the package set.
1603 The job specified the exact architecture of the packages from the set.
1605 *SOLVER_SETVENDOR*::
1606 The job specified the exact vendor of the packages from the set.
1609 The job specified the exact repository of the packages from the set.
1612 The job specified the exact name of the packages from the set.
1614 *SOLVER_NOAUTOSET*::
1615 Turn of automatic set flag generation for SOLVER_SOLVABLE jobs.
1618 A mask containing all the above set bits.
1620 See the section about set bits for more information.
1624 Pool *pool; /* read only */
1629 Back pointer to pool.
1631 Id how; /* read/write */
1636 Union of the selection, action, action modifier, and set flags.
1637 The selection part describes the semantics of the ``what'' Id.
1639 Id what; /* read/write */
1644 Id describing the set of packages, the meaning depends on the
1645 selection part of the ``how'' attribute.
1649 Solvable **solvables()
1650 my @solvables = $job->solvables();
1651 solvables = job.solvables()
1652 solvables = job.solvables()
1654 Return the set of solvables of the job as an array of Solvable
1657 bool isemptyupdate();
1658 $job->isemptyupdate()
1662 Convenience function to find out if the job describes an update
1663 job with no matching packages, i.e. a job that does nothing.
1664 Some package managers like ``zypper'' like to turn those jobs
1665 into install jobs, i.e. an update of a not-installed package
1666 will result into the installation of the package.
1673 Return a string describing the job.
1680 Two jobs are equal if they belong to the same pool and both the
1681 ``how'' and the ``what'' attributes are the same.
1683 === TARGETED UPDATES ===
1684 Libsolv has two modes for upgrades and distupgrade: targeted and
1685 untargeted. Untargeted mode means that the installed packages from
1686 the specified set will be updated to the best version. Targeted means
1687 that packages that can be updated to a package in the specified set
1688 will be updated to the best package of the set.
1690 Here's an example to explain the subtle difference. Suppose that
1691 you have package A installed in version "1.1", "A-1.2" is available
1692 in one of the repositories and there is also package "B" that
1693 obsoletes package A.
1695 An untargeted update of "A" will update the installed "A-1.1" to
1696 package "B", because that is the newest version (B obsoletes A and
1699 A targeted update of "A" will update "A-1.1" to "A-1.2", as the
1700 set of packages contains both "A-1.1" and "A-1.2", and "A-1.2" is
1703 An untargeted update of "B" will do nothing, as "B" is not installed.
1705 An targeted update of "B" will update "A-1.1" to "B".
1707 Note that the default is to do "auto-targeting", thus if the specified
1708 set of packages does not include an installed package, the solver
1709 will assume targeted operation even if SOLVER_TARGETED is not used.
1711 This mostly matches the intent of the user, with one exception: In
1712 the example above, an update of "A-1.2" will update "A-1.1" to
1713 "A-1.2" (targeted mode), but a second update of "A-1.2" will suddenly
1714 update to "B", as untargeted mode is chosen because "A-1.2" is now
1717 If you want to have full control over when targeting mode is chosen,
1718 turn off auto-targeting with the SOLVER_FLAG_NO_AUTOTARGET solver option.
1719 In that case, all updates are considered to be untargeted unless they
1720 include the SOLVER_TARGETED flag.
1723 Set bits specify which parts of the specified packages where specified
1724 by the user. It is used by the solver when checking if an operation is
1725 allowed or not. For example, the solver will normally not allow the
1726 downgrade of an installed package. But it will not report a problem if
1727 the SOLVER_SETEVR flag is used, as it then assumes that the user specified
1728 the exact version and thus knows what he is doing.
1730 So if a package "screen-1-1" is installed for the x86_64 architecture and
1731 version "2-1" is only available for the i586 architecture, installing
1732 package "screen-2.1" will ask the user for confirmation because of the
1733 different architecture. When using the Selection class to create jobs
1734 the set bits are automatically added, e.g. selecting ``screen.i586'' will
1735 automatically add SOLVER_SETARCH, and thus no problem will be reported.
1742 Flags to modify some of the solver's behaviour:
1744 *SOLVER_FLAG_ALLOW_DOWNGRADE*::
1745 Allow the solver to downgrade packages without asking for confirmation
1746 (i.e. reporting a problem).
1748 *SOLVER_FLAG_ALLOW_ARCHCHANGE*::
1749 Allow the solver to change the architecture of an installed package
1750 without asking for confirmation. Note that changes to/from noarch
1751 are always considered to be allowed.
1753 *SOLVER_FLAG_ALLOW_VENDORCHANGE*::
1754 Allow the solver to change the vendor of an installed package
1755 without asking for confirmation. Each vendor is part of one or more
1756 vendor equivalence classes, normally installed packages may only
1757 change their vendor if the new vendor shares at least one equivalence
1760 *SOLVER_FLAG_ALLOW_NAMECHANGE*::
1761 Allow the solver to change the name of an installed package, i.e.
1762 install a package with a different name that obsoletes the installed
1763 package. This option is on by default.
1765 *SOLVER_FLAG_ALLOW_UNINSTALL*::
1766 Allow the solver to deinstall installed packages to fulfil the jobs.
1767 This flag also includes the above flags. You may want to set this
1768 flag if you only have SOLVER_ERASE jobs, as in that case it's
1769 better for the user to check the transaction overview instead of
1770 approving every single package that needs to be deinstalled.
1772 *SOLVER_FLAG_NO_UPDATEPROVIDE*::
1773 If multiple packages obsolete an installed package, the solver checks
1774 the provides of every such package and ignores all packages that
1775 do not provide the installed package name. Thus, you can have an
1776 official update candidate that provides the old name, and other
1777 packages that also obsolete the package but are not considered for
1778 updating. If you cannot use this feature, you can turn it off
1779 by setting this flag.
1781 *SOLVER_FLAG_SPLITPROVIDES*::
1782 Make the solver aware of special provides of the form
1783 ``<packagename>:<path>'' used in SUSE systems to support package
1786 *SOLVER_FLAG_IGNORE_RECOMMENDED*::
1787 Do not process optional (aka weak) dependencies.
1789 *SOLVER_FLAG_ADD_ALREADY_RECOMMENDED*::
1790 Install recommened or supplemented packages even if they have no
1791 connection to the current transaction. You can use this feature
1792 to implement a simple way for the user to install new recommended
1793 packages that were not available in the past.
1795 *SOLVER_FLAG_NO_INFARCHCHECK*::
1796 Turn off the inferior architecture checking that is normally done
1797 by the solver. Normally, the solver allows only the installation
1798 of packages from the "best" architecture if a package is available
1799 for multiple architectures.
1801 *SOLVER_FLAG_BEST_OBEY_POLICY*::
1802 Make the SOLVER_FORCEBEST job option consider only packages that
1803 meet the policies for installed packages, i.e. no downgrades,
1804 no architecture change, no vendor change (see the first flags
1805 of this section). If the flag is not specified, the solver will
1806 enforce the installation of the best package ignoring the
1807 installed packages, which may conflict with the set policy.
1809 *SOLVER_FLAG_NO_AUTOTARGET*::
1810 Do not enable auto-targeting up update and distupgrade jobs. See
1811 the section on targeted updates for more information.
1815 *SOLVER_RULE_UNKNOWN*::
1816 A rule of an unknown class. You should never encounter those.
1819 A package dependency rule, called rpm rule for historical reasons.
1821 *SOLVER_RULE_UPDATE*::
1822 A rule to implement the update policy of installed packages. Every
1823 installed package has an update rule that consists of the packages
1824 that may replace the installed package.
1826 *SOLVER_RULE_FEATURE*::
1827 Feature rules are fallback rules used when a update rule is disabled.
1828 They include all packages that may replace the installed package
1829 ignoring the update policy, i.e. they contain downgrades, arch
1830 changes and so on. Without them, the solver would simply deinstall
1831 installed packages if their update rule gets disabled.
1834 Job rules implement the job given to the solver.
1836 *SOLVER_RULE_DISTUPGRADE*::
1837 This are simple negative assertions that make sure that only packages
1838 are kept that are also available in one of the repositories.
1840 *SOLVER_RULE_INFARCH*::
1841 Infarch rules are also negative assertions, they disallow the installation
1842 of packages when there are packages of the same name but with a better
1845 *SOLVER_RULE_CHOICE*::
1846 Choice rules are used to make sure that the solver preferes updating to
1847 installing different packages when some dependency is provided by
1848 multiple packages with different names. The solver may always break
1849 choice rules, so you will not see them when a problem is found.
1851 *SOLVER_RULE_LEARNT*::
1852 These rules are generated by the solver to keep it from running into
1853 the same problem multiple times when it has to backtrack. They are
1854 the main reason why a sat solver is faster then other dependency solver
1857 Special dependency rule types:
1859 *SOLVER_RULE_RPM_NOT_INSTALLABLE*::
1860 This rule was added to prevent the installation of a package of an
1861 architecture that does not work on the system.
1863 *SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP*::
1864 The package contanis a required dependency which was not provided by
1867 *SOLVER_RULE_RPM_PACKAGE_REQUIRES*::
1868 Similar to SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, but in this case
1869 some packages provided the dependency but none of them could be
1870 installed due to other dependency issues.
1872 *SOLVER_RULE_RPM_SELF_CONFLICT*::
1873 The package conflicts with itself. This is not allowed by older rpm
1876 *SOLVER_RULE_RPM_PACKAGE_CONFLICT*::
1877 To fulfill the dependencies two packages need to be installed, but
1878 one of the packages contains a conflict with the other one.
1880 *SOLVER_RULE_RPM_SAME_NAME*::
1881 The dependencies can only be fulfilled by multiple versions of
1882 a package, but installing multiple versions of the same package
1885 *SOLVER_RULE_RPM_PACKAGE_OBSOLETES*::
1886 To fulfill the dependencies two packages need to be installed, but
1887 one of the packages obsoletes the other one.
1889 *SOLVER_RULE_RPM_IMPLICIT_OBSOLETES*::
1890 To fulfill the dependencies two packages need to be installed, but
1891 one of the packages has provides a dependency that is obsoleted
1892 by the other one. See the POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES
1895 *SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES*::
1896 To fulfill the dependencies a package needs to be installed that is
1897 obsoleted by an installed package. See the POOL_FLAG_NOINSTALLEDOBSOLETES
1900 *SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP*::
1901 The user asked for installation of a package providing a specific
1902 dependency, but no available package provides it.
1904 *SOLVER_RULE_JOB_UNKNOWN_PACKAGE*::
1905 The user asked for installation of a package with a specific name,
1906 but no available package has that name.
1908 *SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM*::
1909 The user asked for the erasure of a dependency that is provided by the
1910 system (i.e. for special hardware or language dependencies), this
1911 cannot be done with a job.
1913 *SOLVER_RULE_JOB_UNSUPPORTED*::
1914 The user asked for something that is not yet implemented, e.g. the
1915 installation of all packages at once.
1917 Policy error constants
1919 *POLICY_ILLEGAL_DOWNGRADE*::
1920 The solver ask for permission before downgrading packages.
1922 *POLICY_ILLEGAL_ARCHCHANGE*::
1923 The solver ask for permission before changing the architecture of installed
1926 *POLICY_ILLEGAL_VENDORCHANGE*::
1927 The solver ask for permission before changing the vendor of installed
1930 *POLICY_ILLEGAL_NAMECHANGE*::
1931 The solver ask for permission before replacing an installed packages with
1932 a packge that has a different name.
1934 Solution element type constants
1936 *SOLVER_SOLUTION_JOB*::
1937 The problem can be solved by removing the specified job.
1939 *SOLVER_SOLUTION_POOLJOB*::
1940 The problem can be solved by removing the specified job that is defined in the pool.
1942 *SOLVER_SOLUTION_INFARCH*::
1943 The problem can be solved by allowing the installation of the specified package
1944 with an inferior architecture.
1946 *SOLVER_SOLUTION_DISTUPGRADE*::
1947 The problem can be solved by allowing to keep the specified package installed.
1949 *SOLVER_SOLUTION_BEST*::
1950 The problem can be solved by allowing to install the specified package that is
1951 not the best available package.
1953 *SOLVER_SOLUTION_ERASE*::
1954 The problem can be solved by allowing to erase the specified package.
1956 *SOLVER_SOLUTION_REPLACE*::
1957 The problem can be solved by allowing to replace the package with some other
1960 *SOLVER_SOLUTION_REPLACE_DOWNGRADE*::
1961 The problem can be solved by allowing to replace the package with some other
1962 package that has a lower version.
1964 *SOLVER_SOLUTION_REPLACE_ARCHCHANGE*::
1965 The problem can be solved by allowing to replace the package with some other
1966 package that has a different architecture.
1968 *SOLVER_SOLUTION_REPLACE_VENDORCHANGE*::
1969 The problem can be solved by allowing to replace the package with some other
1970 package that has a different vendor.
1972 *SOLVER_SOLUTION_REPLACE_NAMECHANGE*::
1973 The problem can be solved by allowing to replace the package with some other
1974 package that has a different name.
1979 Pool *pool; /* read only */
1984 Back pointer to pool.
1988 int set_flag(int flag, int value)
1989 my $oldvalue = $pool->set_flag($flag, $value);
1990 oldvalue = pool.set_flag(flag, value)
1991 oldvalue = pool.set_flag(flag, value)
1993 int get_flag(int flag)
1994 my $value = $pool->get_flag($flag);
1995 value = pool.get_flag(flag)
1996 value = pool.get_flag(flag)
1998 Set/get a solver specific flag. The flags define the policies the solver has
1999 to obey. The flags are explained in the CONSTANTS section of this class.
2001 Problem **solve(Job *jobs)
2002 my @problems = $solver->solve(\@jobs);
2003 problems = solver.solve(jobs)
2004 problems = solver.solve(jobs)
2006 Solve a problem specified in the job list (plus the jobs defined in the pool).
2007 Returns an array of problems that need user interaction, or an empty array
2008 if no problems were encountered. See the Problem class on how to deal with
2011 Transaction *transaction()
2012 my $trans = $solver->transaction();
2013 trans = solver.transaction()
2014 trans = solver.transaction()
2016 Return the transaction to implement the calculated package changes. A transaction
2017 is available even if problems were found, this is useful for interactive user
2018 interfaces that show both the job result and the problems.
2023 Problems are the way of the solver to interact with the user. You can simply list
2024 all problems and terminate your program, but a better way is to present solutions to
2025 the user and let him pick the ones he likes.
2029 Solver *solv; /* read only */
2034 Back pointer to solver object.
2036 Id id; /* read only */
2041 Id of the problem. The first problem has Id 1, they are numbered consecutively.
2045 Rule *findproblemrule()
2046 my $probrule = $problem->findproblemrule();
2047 probrule = problem.findproblemrule()
2048 probrule = problem.findproblemrule()
2050 Return the rule that caused the problem. Of cource in most situations there is no
2051 single responsible rule, but many rules that interconnect with each created the
2052 problem. Nevertheless, the solver uses some heuristic approch to find a rule
2053 that somewhat describes the problem best to the user.
2055 Rule **findallproblemrules(bool unfiltered = 0)
2056 my @probrules = $problem->findallproblemrules();
2057 probrules = problem.findallproblemrule()
2058 probrules = problem.findallproblemrule()
2060 Return all rules responsible for the problem. The returned set of rules contains
2061 all the needed information why there was a problem, but it's hard to present
2062 them to the user in a sensible way. The default is to filter out all update and
2063 job rules (unless the returned rules only consist of those types).
2065 Solutions **solutions()
2066 my @solutions = $problem->solutions();
2067 solutions = problem.solutions()
2068 solutions = problem.solutions()
2070 Return an array containing multiple possible solutions to fix the problem. See
2071 the solution class for more information.
2073 int solution_count()
2074 my $cnt = $problem->solution_count();
2075 cnt = problem.solution_count()
2076 cnt = problem.solution_count()
2078 Return the number of solutions without creating solution objects.
2083 Rules are the basic block of sat solving. Each package dependency gets translated
2084 into one or multiple rules.
2088 Solver *solv; /* read only */
2093 Back pointer to solver object.
2095 Id id; /* read only */
2102 int type; /* read only */
2107 The basic type of the rule. See the constant section of the solver class for the type list.
2112 my $ruleinfo = $rule->info();
2113 ruleinfo = rule.info()
2114 ruleinfo = rule.info()
2116 Return a Ruleinfo object that contains information about why the rule was created. But
2117 see the allinfos() method below.
2119 Ruleinfo **allinfos()
2120 my @ruleinfos = $rule->allinfos();
2121 ruleinfos = rule.allinfos()
2122 ruleinfos = rule.allinfos()
2124 As the same dependency rule can get created because of multiple dependencies, one
2125 Ruleinfo is not enough to describe the reason. Thus the allinfos() method returns
2126 an array of all infos about a rule.
2129 if ($rule1 == $rule2)
2133 Two rules are equal if they belong to the same solver and have the same id.
2138 A Ruleinfo describes one reason why a rule was created.
2142 Solver *solv; /* read only */
2147 Back pointer to solver object.
2149 int type; /* read only */
2154 The type of the ruleinfo. See the constant section of the solver class for the
2155 rule type list and the special type list.
2157 Id dep; /* read only */
2162 The id of the dependency leading to the creation of the rule, or zero.
2164 Solvable *solvable; /* read only */
2165 $ruleinfo->{'solvable'}
2169 The involved Solvable, e.g. the one containing the dependency.
2171 Solvable *othersolvable; /* read only */
2172 $ruleinfo->{'othersolvable'}
2173 ruleinfo.othersolvable
2174 ruleinfo.othersolvable
2176 The other involved Solvable (if any), e.g. the one containing providing
2177 the dependency for conflicts.
2179 const char *problemstr();
2180 my $str = $ruleinfo->problemstr();
2181 str = ruleinfo.problemstr()
2182 str = ruleinfo.problemstr()
2184 A string describing the ruleinfo from a problem perspective. This probably
2185 only makes sense if the rule is part of a problem.
2190 A solution solves one specific problem. It consists of multiple solution elements
2191 that all need to be executed.
2195 Solver *solv; /* read only */
2200 Back pointer to solver object.
2202 Id problemid; /* read only */
2203 $solution->{'problemid'}
2207 Id of the problem the solution solves.
2209 Id id; /* read only */
2214 Id of the solution. The first solution has Id 1, they are numbered consecutively.
2218 Solutionelement **elements(bool expandreplaces = 0)
2219 my @solutionelements = $solution->elements();
2220 solutionelements = solution.elements()
2221 solutionelements = solution.elements()
2223 Return an array containing the elements describing what neeeds to be done to
2224 implement the specific solution. If expandreplaces is true, elements of type
2225 SOLVER_SOLUTION_REPLACE will be replaced by one or more elements replace
2226 elements describing the policy mismatches.
2229 my $cnt = $solution->solution_count();
2230 cnt = solution.element_count()
2231 cnt = solution.element_count()
2233 Return the number of solution elements without creating objects. Note that the
2234 count does not match the number of objects returned by the elements() method
2235 of expandreplaces is set to true.
2238 THE SOLUTIONELEMENT CLASS
2239 -------------------------
2241 A solution element describes a single action of a solution. The action is always
2242 either to remove one specific job or to add a new job that installs or erases
2243 a single specific package.
2247 Solver *solv; /* read only */
2248 $solutionelement->{'solv'}
2249 solutionelement.solv
2250 solutionelement.solv
2252 Back pointer to solver object.
2254 Id problemid; /* read only */
2255 $solutionelement->{'problemid'}
2256 solutionelement.problemid
2257 solutionelement.problemid
2259 Id of the problem the element (partly) solves.
2261 Id solutionid; /* read only */
2262 $solutionelement->{'solutionid'}
2263 solutionelement.solutionid
2264 solutionelement.solutionid
2266 Id of the solution the element is a part of.
2268 Id id; /* read only */
2269 $solutionelement->{'id'}
2273 Id of the solution element. The first element has Id 1, they are numbered consecutively.
2275 Id type; /* read only */
2276 $solutionelement->{'type'}
2277 solutionelement.type
2278 solutionelement.type
2280 Type of the solution element. See the constant section of the solver class for the
2283 Solvable *solvable; /* read only */
2284 $solutionelement->{'solvable'}
2285 solutionelement.solvable
2286 solutionelement.solvable
2288 The installed solvable that needs to be replaced for replacement elements.
2290 Solvable *replacement; /* read only */
2291 $solutionelement->{'replacement'}
2292 solutionelement.replacement
2293 solutionelement.replacement
2295 The solvable that needs to be installed to fix the problem.
2297 int jobidx; /* read only */
2298 $solutionelement->{'jobidx'}
2299 solutionelement.jobidx
2300 solutionelement.jobidx
2302 The index of the job that needs to be removed to fix the problem, or -1 if the
2303 element is of another type. Note that it's better to change the job to SOLVER_NOOP
2304 type so that the numbering of other elements does not get disturbed. This
2305 method works both for types SOLVER_SOLUTION_JOB and SOLVER_SOLUTION_POOLJOB.
2309 Solutionelement **replaceelements()
2310 my @solutionelements = $solutionelement->replaceelements();
2311 solutionelements = solutionelement.replaceelements()
2312 solutionelements = solutionelement.replaceelements()
2314 If the solution element is of type SOLVER_SOLUTION_REPLACE, return an array of
2315 elements describing the policy mismatches, otherwise return a copy of the
2316 element. See also the ``expandreplaces'' option in the solution's elements()
2319 int illegalreplace()
2320 my $illegal = $solutionelement->illegalreplace();
2321 illegal = solutionelement.illegalreplace()
2322 illegal = solutionelement.illegalreplace()
2324 Return an integer that contains the policy mismatch bits or-ed together, or
2325 zero if there was no policy mismatch. See the policy error constants in
2329 my $job = $solutionelement->Job();
2330 illegal = solutionelement.Job()
2331 illegal = solutionelement.Job()
2333 Create a job that implements the solution element. Add this job to the array
2334 of jobs for all elements of type different to SOLVER_SOLUTION_JOB and
2335 SOLVER_SOLUTION_POOLJOB. For the later two, a SOLVER_NOOB Job is created,
2336 you should replace the old job with the new one.
2339 my $str = $solutionelement->str();
2340 str = solutionelement.str()
2341 str = solutionelement.str()
2343 A string describing the change the solution element consists of.
2345 THE TRANSACTION CLASS
2346 ---------------------
2351 Checksums (also called hashes) are used to make sure that downloaded data is
2352 not corrupt and also as a fingerprint mechanism to check if data has changed.
2354 === CLASS METHODS ===
2356 Chksum *Chksum(Id type)
2357 my $chksum = solv::Chksum->new($type);
2358 chksum = solv.Chksum(type)
2359 chksum = Solv::Chksum.new(type)
2361 Create a checksum object. Currently the following types are supported:
2367 These keys are constants in the *solv* class.
2369 Chksum *Chksum(Id type, const char *hex)
2370 my $chksum = solv::Chksum->new($type, $hex);
2371 chksum = solv.Chksum(type, hex)
2372 chksum = Solv::Chksum.new(type, hex)
2374 Create an already finalized checksum object.
2378 Id type; /* read only */
2383 Return the type of the checksum object.
2387 void add(const char *str)
2392 Add a string to the checksum.
2394 void add_fp(FILE *fp)
2395 $chksum->add_fp($file);
2399 Add the contents of a file to the checksum.
2401 void add_stat(const char *filename)
2402 $chksum->add_stat($filename);
2403 chksum.add_stat(filename)
2404 chksum.add_stat(filename)
2406 Stat the file and add the dev/ino/size/mtime member to the checksum. If the
2407 stat fails, the members are zeroed.
2409 void add_fstat(int fd)
2410 $chksum->add_fstat($fd);
2411 chksum.add_fstat(fd)
2412 chksum.add_fstat(fd)
2414 Same as add_stat, but instead of the filename a file descriptor is used.
2416 unsigned char *raw()
2417 my $raw = $chksum->raw();
2421 Finalize the checksum and return the result as raw bytes. This means that the
2422 result can contain NUL bytes or unprintable characters.
2425 my $raw = $chksum->hex();
2429 Finalize the checksum and return the result as hex string.
2432 if ($chksum1 == $chksum2)
2433 if chksum1 == chksum2:
2434 if chksum1 == chksum2
2436 Checksums are equal if they are of the same type and the finalized results are
2440 my $str = "$chksum";
2444 If the checksum is finished, the checksum is returned as "<type>:<hex>" string.
2445 Otherwise "<type>:unfinished" is returned.
2450 This functions were added because libsolv uses standard *FILE* pointers to
2451 read/write files, but languages like perl have their own implementation of
2452 files. The libsolv functions also support decompression and compression, the
2453 algorithm is selected by looking at the file name extension.
2455 FILE *xfopen(char *fn, char *mode = "r")
2456 my $file = solv::xfopen($path);
2457 file = solv.xfopen(path)
2458 file = Solv::xfopen(path)
2460 Open a file at the specified path. The `mode` argument is passed on to the
2463 FILE *xfopen_fd(char *fn, int fileno)
2464 my $file = solv::xfopen_fd($path, $fileno);
2465 file = solv.xfopen_fd(path, fileno)
2466 file = Solv::xfopen_fd(path, fileno)
2468 Create a file handle from the specified file descriptor. The path argument is
2469 only used to select the correct (de-)compression algorithm, use an empty path
2470 if you want to make sure to read/write raw data.
2475 my $fileno = $file->fileno();
2476 fileno = file.fileno()
2477 fileno = file.fileno()
2479 Return file file descriptor of the file. If the file is not open, `-1` is
2483 my $fileno = $file->dup();
2487 Return a copy of the descriptor of the file. If the file is not open, `-1` is
2495 Flush the file. Returns false if there was an error. Flushing a closed file
2496 always returns true.
2503 Close the file. This is needed for languages like Ruby, that do not destruct
2504 objects right after they are no longer referenced. In that case, it is good
2505 style to close open files so that the file descriptors are freed right away.
2506 Returns false if there was an error.
2514 Michael Schroeder <mls@suse.de>