9 libsolv-bindings - access libsolv from perl/python/ruby
14 Libsolv's language bindings offer an abstract, object orientated interface
15 to the library. The supported languages are currently perl, python, and ruby.
16 All example code (except in the specifics sections, of course) lists first
17 the ``C-ish'' interface, then the syntax for perl, python, and ruby (in that
23 Libsolv's perl bindings can be loaded with the following statement:
27 Objects are either created by calling the new() method on a class or they
28 are returned by calling methods on other objects.
30 my $pool = solv::Pool->new();
31 my $repo = $pool->add_repo("my_first_repo");
33 Swig encapsulates all objects as tied hashes, thus the attributes can be
34 accessed by treating the object as standard hash reference:
36 $pool->{appdata} = 42;
37 printf "appdata is %d\n", $pool->{appdata};
39 A special exception to this are iterator objects, they are encapsulated as
40 tied arrays so that it is possible to iterate with a for() statement:
42 my $iter = $pool->solvables_iter();
43 for my $solvable (@$iter) { ... };
45 As a downside of this approach, iterator objects cannot have attributes.
47 If an array needs to be passed to a method it is usually done by reference,
48 if a method returns an array it returns it on the stack:
50 my @problems = $solver->solve(\@jobs);
52 Due to a bug in swig, stringification does not work for libsolv's objects.
53 Instead, you have to call the object's str() method.
55 print $dep->str() . "\n";
57 Swig implements all constants as numeric variables (instead of the more
58 natural constant subs), so don't forget the leading ``$'' when accessing a
59 constant. Also do not forget to prepend the namespace of the constant:
61 $pool->set_flag($solv::Pool::POOL_FLAG_OBSOLETEUSESCOLORS, 1);
66 The python bindings can be loaded with:
70 Objects are either created by calling the constructor method for a class or they
71 are returned by calling methods on other objects.
74 repo = pool.add_repo("my_first_repo")
76 Attributes can be accessed as usual:
79 print "appdata is %d" % (pool.appdata)
81 Iterators also work as expected:
83 for solvable in pool.solvables_iter():
85 Arrays are passed and returned as list objects:
88 problems = solver.solve(jobs)
90 The bindings define stringification for many classes, some also have a
91 __repr__ method to ease debugging.
96 Constants are attributes of the classes:
98 pool.set_flag(solv.Pool.POOL_FLAG_OBSOLETEUSESCOLORS, 1);
103 The ruby bindings can be loaded with:
107 Objects are either created by calling the new method on a class or they
108 are returned by calling methods on other objects. Note that all classes start
109 with an uppercase letter in ruby, so the class is called ``Solv''.
111 pool = Solv::Pool.new
112 repo = pool.add_repo("my_first_repo")
114 Attributes can be accessed as usual:
117 puts "appdata is #{pool.appdata}"
119 Iterators also work as expected:
121 for solvable in pool.solvables_iter() do ...
123 Arrays are passed and returned as array objects:
126 problems = solver.solve(jobs)
128 Most classes define a to_s method, so objects can be easily stringified.
129 Many also define an inspect() method.
134 Constants live in the namespace of the class they belong to:
136 pool.set_flag(Solv::Pool::POOL_FLAG_OBSOLETEUSESCOLORS, 1);
138 Note that boolean methods have an added trailing ``?'', to be consistent with
141 puts "empty repo" if repo.isempty?
146 This is the main namespace of the library, you cannot create objects of this
147 type but it contains some useful constants.
151 Relational flag constants, the first three can be or-ed together
154 the ``less than'' bit
157 the ``equals to'' bit
160 the ``greater then'' bit
163 used for relations that describe an extra architecture filter, the
164 version part of the relation is interpreted as architecture.
169 Access the meta section of a repository or repodata area. This is
170 like an extra Solvable that has the Id SOLVID_META.
173 Use the data position stored inside of the pool instead of accessing
174 some solvable by Id. The bindings have the Datapos objects as an
175 abstraction mechanism, so you do not need this constant.
183 Always one, describes the empty string
186 The keyname Id of the name of the solvable.
189 see the libsolv-constantids manpage for a list of fixed Ids.
194 The pool is libsolv's central resource manager. A pool consists of Solvables,
195 Repositories, Dependencies, each indexed by Ids.
197 === CLASS METHODS ===
200 my $pool = solv::Pool->new();
202 pool = Solv::Pool.new()
204 Create a new pool instance. In most cases you just need one pool.
205 Note that the returned object "owns" the pool, i.e. if the object is
206 freed, the pool is also freed. You can use the disown method to
207 break this ownership relation.
211 void *appdata; /* read/write */
216 Application specific data that may be used in any way by the code using the
219 Solvable solvables[]; /* read only */
220 my $solvable = $pool->{solvables}->[$solvid];
221 solvable = pool.solvables[solvid]
222 solvable = pool.solvables[solvid]
224 Look up a Solvable by its id.
226 Repo repos[]; /* read only */
227 my $repo = $pool->{repos}->[$repoid];
228 repo = pool.repos[repoid]
229 repo = pool.repos[repoid]
231 Look up a Repository by its id.
233 Repo *installed; /* read/write */
234 $pool->{installed} = $repo;
235 pool.installed = repo
236 pool.installed = repo
238 Define which repository contains all the installed packages.
240 const char *errstr; /* read only */
241 my $err = $pool->{errstr};
245 Return the last error string that was stored in the pool.
249 *POOL_FLAG_PROMOTEEPOCH*::
250 Promote the epoch of the providing dependency to the requesting
251 dependency if it does not contain an epoch. Used at some time
252 in old rpm versions, modern systems should never need this.
254 *POOL_FLAG_FORBIDSELFCONFLICTS*::
255 Disallow the installation of packages that conflict with themselves.
256 Debian always allows self-conflicting packages, rpm used to forbid
257 them but switched to also allowing them recently.
259 *POOL_FLAG_OBSOLETEUSESPROVIDES*::
260 Make obsolete type dependency match against provides instead of
261 just the name and version of packages. Very old versions of rpm
262 used the name/version, then it got switched to provides and later
263 switched back again to just name/version.
265 *POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES*::
266 An implicit obsoletes is the internal mechanism to remove the
267 old package on an update. The default is to remove all packages
268 with the same name, rpm-5 switched to also removing packages
269 providing the same name.
271 *POOL_FLAG_OBSOLETEUSESCOLORS*::
272 Rpm's multilib implementation (used in RedHat and Fedora)
273 distinguishes between 32bit and 64bit packages (the terminology
274 is that they have a different color). If obsoleteusescolors is
275 set, packages with different colors will not obsolete each other.
277 *POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS*::
278 Same as POOL_FLAG_OBSOLETEUSESCOLORS, but used to find out if
279 packages of the same name can be installed in parallel. For
280 current Fedora systems, POOL_FLAG_OBSOLETEUSESCOLORS should be
281 false and POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS should be true
282 (this is the default if FEDORA is defined when libsolv is compiled).
284 *POOL_FLAG_NOINSTALLEDOBSOLETES*::
285 New versions of rpm consider the obsoletes of installed packages
286 when checking for dependency, thus you may not install a package
287 that is obsoleted by some other installed package, unless you
288 also erase the other package.
290 *POOL_FLAG_HAVEDISTEPOCH*::
291 Mandriva added a new field called distepoch that gets checked in
292 version comparison if the epoch/version/release of two packages
295 *POOL_FLAG_NOOBSOLETESMULTIVERSION*::
296 If a package is installed in multiversionmode, rpm used to ignore
297 both the implicit obsoletes and the obsolete dependency of a
298 package. This was changed to ignoring just the implicit obsoletes,
299 thus you may install multiple versions of the same name, but
300 obsoleted packages still get removed.
302 *POOL_FLAG_ADDFILEPROVIDESFILTERED*::
303 Make the addfileprovides method only add files from the standard
304 locations (i.e. the ``bin'' and ``etc'' directories). This is
305 useful if you have only few packages that use non-standard file
306 dependencies, but you still wand the fast speed that addfileprovides()
316 Force a free of the pool. After this call, you must not access any object
317 that still references the pool.
324 Break the ownership relation betwen the binding object and the pool. After
325 this call, the pool will not get freed even if the object goes out of
326 scope. This also means that you must manually call the free method to free
329 void setdebuglevel(int level)
330 $pool->setdebuglevel($level);
331 pool.setdebuglevel(level)
332 pool.setdebuglevel(level)
334 Set the debug level. A value of zero means no debug output, the higher the
335 value, the more output is generated.
337 int set_flag(int flag, int value)
338 my $oldvalue = $pool->set_flag($flag, $value);
339 oldvalue = pool.set_flag(flag, value)
340 oldvalue = pool.set_flag(flag, value)
342 int get_flag(int flag)
343 my $value = $pool->get_flag($flag);
344 value = pool.get_flag(flag)
345 value = pool.get_flag(flag)
347 Set/get a pool specific flag. The flags define how the system works, e.g. how
348 the package manager treats obsoletes. The default flags should be sane for most
349 applications, but in some cases you may want to tweak a flag, for example if
350 you want to solv package dependencies for some other system than yours.
352 void set_rootdir(const char *rootdir)
353 $pool->set_rootdir(rootdir);
354 pool.set_rootdir(rootdir)
355 pool.set_rootdir(rootdir)
357 const char *get_rootdir()
358 my $rootdir = $pool->get_rootdir();
359 rootdir = pool.get_rootdir()
360 rootdir = pool.get_rootdir()
362 Set/get the rootdir to use. This is useful if you want package management
363 to work only in some directory, for example if you want to setup a chroot
364 jail. Note that the rootdir will only be prepended to file paths if the
365 *REPO_USE_ROOTDIR* flag is used.
367 void setarch(const char *arch = 0)
372 Set the architecture for your system. The architecture is used to determine
373 which packages are installable. It defaults to the result of ``uname -m''.
375 Repo add_repo(const char *name)
376 $repo = $pool->add_repo($name);
377 repo = pool.add_repo(name)
378 repo = pool.add_repo(name)
380 Add a Repository with the specified name to the pool. The repository is empty
381 on creation, use the repository methods to populate it with packages.
383 Repoiterator repos_iter()
384 for my $repo (@{$pool->repos_iter()})
385 for repo in pool.repos_iter():
386 for repo in pool.repos_iter()
388 Iterate over the existing repositories.
390 Solvableiterator solvables_iter()
391 for my $solvable (@{$pool->solvables_iter()})
392 for solvable in pool.solvables_iter():
393 for solvable in pool.solvables_iter()
395 Iterate over the existing solvables.
397 Dep Dep(const char *str, bool create = 1)
398 my $dep = $pool->Dep($string);
399 dep = pool.Dep(string)
400 dep = pool.Dep(string)
402 Create an object describing a string or dependency. If the string is currently
403 not in the pool and _create_ is false, *undef*/*None*/*nil* is returned.
405 void addfileprovides()
406 $pool->addfileprovides();
407 pool.addfileprovides()
408 pool.addfileprovides()
410 Id *addfileprovides_queue()
411 my @ids = $pool->addfileprovides_queue();
412 ids = pool.addfileprovides_queue()
413 ids = pool.addfileprovides_queue()
415 Some package managers like rpm allow dependencies on files contained in other
416 packages. To allow libsolv to deal with those dependencies in an efficient way,
417 you need to call the addfileprovides method after creating and reading all
418 repositories. This method will scan all dependency for file names and than scan
419 all packages for matching files. If a filename has been matched, it will be
420 added to the provides list of the corresponding package. The
421 addfileprovides_queue variant works the same way but returns an array
422 containing all file dependencies. This information can be stored in the
423 meta section of the repositories to speed up the next time the
424 repository is loaded and addfileprovides is called.
426 void createwhatprovides()
427 $pool->createwhatprovides();
428 pool.createwhatprovides()
429 pool.createwhatprovides()
431 Create the internal ``whatprovides'' hash over all of the provides of all
432 packages. This method must be called before doing any lookups on provides.
433 It's encouraged to do it right after all repos are set up, usually right after
434 the call to addfileprovides().
436 Solvable *whatprovides(DepId dep)
437 my @solvables = $pool->whatprovides($dep);
438 solvables = pool.whatprovides(dep)
439 solvables = pool.whatprovides(dep)
441 Return all solvables that provide the specified dependency. You can use either
442 a Dep object or an simple Id as argument.
444 Id *matchprovidingids(const char *match, int flags)
445 my @ids = $pool->matchprovidingids($match, $flags);
446 ids = pool.matchprovidingids(match, flags)
447 ids = pool.matchprovidingids(match, flags)
449 Search the names of all provides and return the ones matching the specified
450 string. See the Dataiterator class for the allowed flags.
452 Id towhatprovides(Id *ids)
453 my $offset = $pool->towhatprovides(\@ids);
454 offset = pool.towhatprovides(ids)
455 offset = pool.towhatprovides(ids)
457 ``Internalize'' an array containing Ids. The returned value can be used to
458 create solver jobs working on a specific set of packages. See the Solver class
459 for more information.
461 bool isknownarch(DepId id)
462 my $bool = $pool->isknownarch($id);
463 bool = pool.isknownarch(id)
464 bool = pool.isknownarch?(id)
466 Return true if the specified Id describes a known architecture.
469 my $solver = $pool->Solver();
470 solver = pool.Solver()
471 solver = pool.Solver()
473 Create a new solver object.
475 Job Job(int how, Id what)
476 my $job = $pool->Job($how, $what);
477 job = pool.Job(how, what)
478 job = pool.Job(how, what)
480 Create a new Job object. Kind of low level, in most cases you would use a
481 Selection or Dep job constructor instead.
483 Selection Selection()
484 my $sel = $pool->Selection();
485 sel = pool.Selection()
486 sel = pool.Selection()
488 Create an empty selection. Useful as a starting point for merging other
491 Selection Selection_all()
492 my $sel = $pool->Selection_all();
493 sel = pool.Selection_all()
494 sel = pool.Selection_all()
496 Create a selection containing all packages. Useful as starting point for
497 intersecting other selections or for update/distupgrade jobs.
499 Selection select(const char *name, int flags)
500 my $sel = $pool->select($name, $flags);
501 sel = pool.select(name, flags)
502 sel = pool.select(name, flags)
504 Create a selection by matching packages against the specified string. See the
505 Selection class for a list of flags and how to create solver jobs from a
508 void setpooljobs(Jobs *jobs)
509 $pool->setpooljobs(\@jobs);
510 pool.setpooljobs(jobs)
511 pool.setpooljobs(jobs)
514 @jobs = $pool->getpooljobs();
515 jobs = pool.getpooljobs()
516 jobs = pool.getpooljobs()
518 Get/Set fixed jobs stored in the pool. Those jobs are automatically appended to
519 all solver jobs, they are meant for fixed configurations like which packages
520 can be multiversion installed, which packages were userinstalled or must not be
523 void set_loadcallback(Callable *callback)
524 $pool->setloadcallback(\&callbackfunction);
525 pool.setloadcallback(callbackfunction)
526 pool.setloadcallback { |repodata| ... }
528 Set the callback function called when repository metadata needs to be loaded on
529 demand. To make use of this feature, you need to create repodata stubs that
530 tell the library which data is available but not loaded. If later on the data
531 needs to be accessed, the callback function is called with a repodata argument.
532 You can then load the data (maybe fetching it first from an remote server).
533 The callback should return true if the data has been made available.
535 === DATA RETRIEVAL METHODS ===
537 In the following functions, the _keyname_ argument describes what to retrieve.
538 For the standard cases you can use the available Id constants. For example,
540 $solv::SOLVABLE_SUMMARY
541 solv.SOLVABLE_SUMMARY
542 Solv::SOLVABLE_SUMMARY
544 selects the ``Summary'' entry of a solvable. The _solvid_ argument selects the
545 desired solvable by Id.
547 const char *lookup_str(Id solvid, Id keyname)
548 my $string = $pool->lookup_str($solvid, $keyname);
549 string = pool.lookup_str(solvid, keyname)
550 string = pool.lookup_str(solvid, keyname)
552 Id lookup_id(Id solvid, Id keyname)
553 my $id = $pool->lookup_id($solvid, $keyname);
554 id = pool.lookup_id(solvid, keyname)
555 id = pool.lookup_id(solvid, keyname)
557 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
558 my $num = $pool->lookup_num($solvid, $keyname);
559 num = pool.lookup_num(solvid, keyname)
560 num = pool.lookup_num(solvid, keyname)
562 bool lookup_void(Id solvid, Id keyname)
563 my $bool = $pool->lookup_void($solvid, $keyname);
564 bool = pool.lookup_void(solvid, keyname)
565 bool = pool.lookup_void(solvid, keyname)
567 Id *lookup_idarray(Id solvid, Id keyname)
568 my @ids = $pool->lookup_idarray($solvid, $keyname);
569 ids = pool.lookup_idarray(solvid, keyname)
570 ids = pool.lookup_idarray(solvid, keyname)
572 Chksum lookup_checksum(Id solvid, Id keyname)
573 my $chksum = $pool->lookup_checksum($solvid, $keyname);
574 chksum = pool.lookup_checksum(solvid, keyname)
575 chksum = pool.lookup_checksum(solvid, keyname)
577 Lookup functions. Return the data element stored in the specified solvable.
578 You should probably use the methods of the Solvable class instead.
580 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
581 my $di = $pool->Dataiterator($keyname, $match, $flags);
582 di = pool.Dataiterator(keyname, match, flags)
583 di = pool.Dataiterator(keyname, match, flags)
585 Dataiterator Dataiterator_solvid(Id solvid, Id keyname, const char *match = 0, int flags = 0)
586 my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags);
587 di = pool.Dataiterator(solvid, keyname, match, flags)
588 di = pool.Dataiterator(solvid, keyname, match, flags)
594 Iterate over the matching data elements. See the Dataiterator class for more
595 information. The Dataiterator method iterates over all solvables in the pool,
596 whereas the Dataiterator_solvid only iterates over the specified solvable.
600 The following methods deal with Ids, i.e. integers representing objects in the
601 pool. They are considered ``low level'', in most cases you would not use them
602 but instead the object orientated methods.
605 $repo = $pool->id2repo($id);
606 repo = pool.id2repo(id)
607 repo = pool.id2repo(id)
609 Lookup an existing Repository by id. You can also do this by using the *repos*
612 Solvable id2solvable(Id id)
613 $solvable = $pool->id2solvable($id);
614 solvable = pool.id2solvable(id)
615 solvable = pool.id2solvable(id)
617 Lookup an existing Repository by id. You can also do this by using the
618 *solvables* attribute.
620 const char *solvid2str(Id id)
621 my $str = $pool->solvid2str($id);
622 str = pool.solvid2str(id)
623 str = pool.solvid2str(id)
625 Return a string describing the Solvable with the specified id. The string
626 consists of the name, version, and architecture of the Solvable.
628 Id str2id(const char *str, bool create = 1)
629 my $id = pool->str2id($string);
630 id = pool.str2id(string)
631 id = pool.str2id(string)
633 const char *id2str(Id id)
634 $string = pool->id2str($id);
635 string = pool.id2str(id)
636 string = pool.id2str(id)
638 Convert a string into an Id and back. If the string is currently not in the
639 pool and _create_ is false, zero is returned.
641 Id rel2id(Id name, Id evr, int flags, bool create = 1)
642 my $id = pool->rel2id($nameid, $evrid, $flags);
643 id = pool.rel2id(nameid, evrid, flags)
644 id = pool.rel2id(nameid, evrid, flags)
646 Create a ``relational'' dependency. Such dependencies consist of a name part,
647 the _flags_ describing the relation, and a version part. The flags are:
649 $solv::REL_EQ | $solv::REL_GT | $solv::REL_LT
650 solv.REL_EQ | solv.REL_GT | solv.REL_LT
651 Solv::REL_EQ | Solv::REL_GT | Solv::REL_LT
653 Thus, if you want a ``\<='' relation, you would use *REL_LT | REL_EQ*.
655 Id id2langid(Id id, const char *lang, bool create = 1)
656 my $id = $pool->id2langid($id, $language);
657 id = pool.id2langid(id, language)
658 id = pool.id2langid(id, language)
660 Create a language specific Id from some other id. This function simply converts
661 the id into a string, appends a dot and the specified language to the string
662 and converts the result back into an Id.
664 const char *dep2str(Id id)
665 $string = pool->dep2str($id);
666 string = pool.dep2str(id)
667 string = pool.dep2str(id)
669 Convert a dependency id into a string. If the id is just a string, this
670 function has the same effect as id2str(). For relational dependencies, the
671 result is the correct ``name relation evr'' string.
676 The dependency class is an object orientated way to work with strings and
677 dependencies. Internally, dependencies are represented as Ids, i.e. simple
678 numbers. Dependency objects can be constructed by using the Pool's Dep()
683 Pool *pool; /* read only */
688 Back reference to the pool this dependency belongs to.
690 Id id; /* read only */
695 The id of this dependency.
699 Dep Rel(int flags, DepId evrid, bool create = 1)
700 my $reldep = $dep->Rel($flags, $evrdep);
701 reldep = dep.Rel(flags, evrdep)
702 reldep = dep.Rel(flags, evrdep)
704 Create a relational dependency from to string dependencies and a flags
705 argument. See the pool's rel2id method for a description of the flags.
707 Selection Selection_name(int setflags = 0)
708 my $sel = $dep->Selection_name();
709 sel = dep.Selection_name()
710 sel = dep.Selection_name()
712 Create a Selection from a dependency. The selection consists of all packages
713 that have a name equal to the dependency. If the dependency is of a relational
714 type, the packages version must also fulfill the dependency.
716 Selection Selection_provides(int setflags = 0)
717 my $sel = $dep->Selection_provides();
718 sel = dep.Selection_provides()
719 sel = dep.Selection_provides()
721 Create a Selection from a dependency. The selection consists of all packages
722 that have at least one provides matching the dependency.
725 my $str = $dep->str();
729 Return a string describing the dependency.
736 Same as calling the str() method.
743 The dependencies are equal if they are part of the same pool and have the same
749 A Repository describes a group of packages, normally coming from the same
750 source. Repositories are created by the Pool's add_repo() method.
754 Pool *pool; /* read only */
759 Back reference to the pool this dependency belongs to.
761 Id id; /* read only */
766 The id of the repository.
768 const char *name; /* read/write */
773 The repositories name. To libsolv, the name is just a string with no specific
776 int priority; /* read/write */
781 The priority of the repository. A higher number means that packages of this
782 repository will be chosen over other repositories, even if they have a greater
785 int subpriority; /* read/write */
790 The sub-priority of the repository. This value is compared when the priorities
791 of two repositories are the same. It is useful to make the library prefer
792 on-disk repositories to remote ones.
794 int nsolvables; /* read only */
799 The number of solvables in this repository.
801 void *appdata; /* read/write */
806 Application specific data that may be used in any way by the code using the
809 Datapos *meta; /* read only */
814 Return a Datapos object of the repodata's metadata. You can use the lookup
815 methods of the Datapos class to lookup metadata attributes, like the repository
820 *REPO_REUSE_REPODATA*::
821 Reuse the last repository data area (``repodata'') instead of creating a
824 *REPO_NO_INTERNALIZE*::
825 Do not internalize the added repository data. This is useful if
826 you plan to add more data because internalization is a costly
830 Use the repodata's pool for Id storage instead of the global pool. Useful
831 if you don't want to pollute the global pool with many unneeded ids, like
832 when storing the filelist.
835 Use the repodata that is currently being loaded instead of creating a new
836 one. This only makes sense if used in a load callback.
838 *REPO_EXTEND_SOLVABLES*::
839 Do not create new solvables for the new data, but match existing solvables
840 and add the data to them. Repository metadata is often split into multiple
841 parts, with one primary file describing all packages and other parts
842 holding information that is normally not needed, like the changelog.
845 Prepend the pool's rootdir to the path when doing file operations.
848 Do not add a location element to the solvables. Useful if the solvables
849 are not in the final position, so you can add the correct location later
852 *SOLV_ADD_NO_STUBS*::
853 Do not create stubs for repository parts that can be downloaded on demand.
855 *SUSETAGS_RECORD_SHARES*::
856 This is specific to the add_susetags() method. Susetags allows to refer to
857 already read packages to save disk space. If this data sharing needs to
858 work over multiple calls to add_susetags, you need to specify this flag so
859 that the share information is made available to subsequent calls.
863 void free(bool reuseids = 0)
868 Free the repository and all solvables it contains. If _reuseids_ is set to
869 true, the solvable ids and the repository id may be reused by the library when
870 added new solvables. Thus you should leave it false if you are not sure that
871 somebody holds a reference.
873 void empty(bool reuseids = 0)
878 Free all the solvables in a repository. The repository will be empty after this
879 call. See the free() method for the meaning of _reuseids_.
886 Return true if there are no solvables in this repository.
889 $repo->internalize();
893 Internalize added data. Data must be internalized before it is available to the
894 lookup and data iterator functions.
901 Write a repo as a ``solv'' file. These files can be read very fast and thus are
902 a good way to cache repository data. Returns false if there was some error
905 Solvableiterator solvables_iter()
906 for my $solvable (@{$repo->solvables_iter()})
907 for solvable in repo.solvables_iter():
908 for solvable in repo.solvables_iter()
910 Iterate over all solvables in a repository.
912 Repodata add_repodata(int flags = 0)
913 my $repodata = $repo->add_repodata();
914 repodata = repo.add_repodata()
915 repodata = repo.add_repodata()
917 Add a new repodata area to the repository. This is normally automatically
918 done by the repo_add methods, so you need this method only in very
922 $repo->create_stubs();
926 Calls the create_stubs() repodata method for the last repodata of the
930 $repo->iscontiguous()
934 Return true if the solvables of this repository are all in a single block with
935 no holes, i.e. they have consecutive ids.
937 Repodata first_repodata()
938 my $repodata = $repo->first_repodata();
939 repodata = repo.first_repodata()
940 repodata = repo.first_repodata()
942 Checks if all repodatas but the first repodata are extensions, and return the
943 first repodata if this is the case. Useful if you want to do a store/retrieve
944 sequence on the repository to reduce the memory using and enable paging, as
945 this does not work if the repository contains multiple non-extension repodata
948 Selection Selection(int setflags = 0)
949 my $sel = $repo->Selection();
950 sel = repo.Selection()
951 sel = repo.Selection()
953 Create a Selection consisting of all packages in the repository.
955 Dataiterator Dataiterator(Id key, const char *match = 0, int flags = 0)
956 my $di = $repo->Dataiterator($keyname, $match, $flags);
957 di = repo.Dataiterator(keyname, match, flags)
958 di = repo.Dataiterator(keyname, match, flags)
960 Dataiterator Dataiterator_meta(Id key, const char *match = 0, int flags = 0)
961 my $di = $repo->Dataiterator_meta($keyname, $match, $flags);
962 di = repo.Dataiterator_meta(keyname, match, flags)
963 di = repo.Dataiterator_meta(keyname, match, flags)
969 Iterate over the matching data elements in this repository. See the
970 Dataiterator class for more information. The Dataiterator() method
971 iterates over all solvables in a repository, whereas the Dataiterator_meta
972 method only iterates over the repository's meta data.
975 my $str = $repo->str;
979 Return the name of the repository, or "Repo#<id>" if no name is set.
982 if ($repo1 == $repo2)
986 Two repositories are equal if they belong to the same pool and have the same id.
988 === DATA ADD METHODS ===
990 Solvable add_solvable()
991 $repo->add_solvable();
995 Add a single empty solvable to the repository. Returns a Solvable object, see
996 the Solvable class for more information.
998 bool add_solv(const char *name, int flags = 0)
999 $repo->add_solv($name);
1003 bool add_solv(FILE *fp, int flags = 0)
1004 $repo->add_solv($fp);
1008 Read a ``solv'' file and add its contents to the repository. These files can be
1009 written with the write() method and are normally used as fast cache for
1010 repository metadata.
1012 bool add_rpmdb(int flags = 0)
1017 bool add_rpmdb_reffp(FILE *reffp, int flags = 0)
1018 $repo->add_rpmdb_reffp($reffp);
1019 repo.add_rpmdb_reffp(reffp)
1020 repo.add_rpmdb_reffp(reffp)
1022 Add the contents of the rpm database to the repository. If a solv file
1023 containing an old version of the database is available, it can be passed as
1024 reffp to speed up reading.
1026 Solvable add_rpm(const char *filename, int flags = 0)
1027 my $solvable = $repo->add_rpm($filename);
1028 solvable = repo.add_rpm(filename)
1029 solvable = repo.add_rpm(filename)
1031 Add the metadata of a single rpm package to the repository.
1033 bool add_rpmdb_pubkeys(int flags = 0)
1034 $repo->add_rpmdb_pubkeys();
1035 repo.add_rpmdb_pubkeys()
1036 repo.add_rpmdb_pubkeys()
1038 Add all pubkeys contained in the rpm database to the repository. Note that
1039 newer rpm versions also allow to store the pubkeys in some directory instead
1040 of the rpm database.
1042 Solvable add_pubkey(const char *keyfile, int flags = 0)
1043 my $solvable = $repo->add_pubkey($keyfile);
1044 solvable = repo.add_pubkey(keyfile)
1045 solvable = repo.add_pubkey(keyfile)
1047 Add a pubkey from a file to the repository.
1049 bool add_rpmmd(FILE *fp, const char *language, int flags = 0)
1050 $repo->add_rpmmd($fp, undef);
1051 repo.add_rpmmd(fp, None)
1052 repo.add_rpmmd(fp, nil)
1054 Add metadata stored in the "rpm-md" format (i.e. from files in the ``repodata''
1055 directory) to a repository. Supported files are "primary", "filelists",
1056 "other", "suseinfo". Do not forget to specify the *REPO_EXTEND_SOLVABLES* for
1057 extension files like "filelists" and "other". Use the _language_ parameter if
1058 you have language extension files, otherwise simply use a *undef*/*None*/*nil*
1061 bool add_repomdxml(FILE *fp, int flags = 0)
1062 $repo->add_repomdxml($fp);
1063 repo.add_repomdxml(fp)
1064 repo.add_repomdxml(fp)
1066 Add the repomd.xml meta description from the "rpm-md" format to the repository.
1067 This file contains information about the repository like keywords, and also a
1068 list of all database files with checksums. The data is added the the "meta"
1069 section of the repository, i.e. no package gets created.
1071 bool add_updateinfoxml(FILE *fp, int flags = 0)
1072 $repo->add_updateinfoxml($fp);
1073 repo.add_updateinfoxml(fp)
1074 repo.add_updateinfoxml(fp)
1076 Add the updateinfo.xml file containing available maintenance updates to the
1077 repository. All updates are created as special packages that have a "patch:"
1078 prefix in their name.
1080 bool add_deltainfoxml(FILE *fp, int flags = 0)
1081 $repo->add_deltainfoxml($fp);
1082 repo.add_deltainfoxml(fp)
1083 repo.add_deltainfoxml(fp)
1085 Add the deltainfo.xml file (also called prestodelta.xml) containing available
1086 delta-rpms to the repository. The data is added to the "meta" section, i.e. no
1087 package gets created.
1089 bool add_debdb(int flags = 0)
1094 Add the contents of the debian installed package database to the repository.
1096 bool add_debpackages(FILE *fp, int flags = 0)
1097 $repo->add_debpackages($fp);
1098 repo.add_debpackages($fp)
1099 repo.add_debpackages($fp)
1101 Add the contents of the debian repository metadata (the "packages" file)
1104 Solvable add_deb(const char *filename, int flags = 0)
1105 my $solvable = $repo->add_deb($filename);
1106 solvable = repo.add_deb(filename)
1107 solvable = repo.add_deb(filename)
1109 Add the metadata of a single deb package to the repository.
1111 bool add_mdk(FILE *fp, int flags = 0)
1112 $repo->add_mdk($fp);
1116 Add the contents of the mageia/mandriva repository metadata (the
1117 "synthesis.hdlist" file) to the repository.
1119 bool add_mdk_info(FILE *fp, int flags = 0)
1120 $repo->add_mdk($fp);
1124 Extend the packages from the synthesis file with the info.xml and files.xml
1125 data. Do not forget to specify *REPO_EXTEND_SOLVABLES*.
1127 bool add_arch_repo(FILE *fp, int flags = 0)
1128 $repo->add_arch_repo($fp);
1129 repo.add_arch_repo(fp)
1130 repo.add_arch_repo(fp)
1132 Add the contents of the archlinux repository metadata (the ".db.tar" file) to
1135 bool add_arch_local(const char *dir, int flags = 0)
1136 $repo->add_arch_local($dir);
1137 repo.add_arch_local(dir)
1138 repo.add_arch_local(dir)
1140 Add the contents of the archlinux installed package database to the repository.
1141 The _dir_ parameter is usually set to "/var/lib/pacman/local".
1143 bool add_content(FILE *fp, int flags = 0)
1144 $repo->add_content($fp);
1145 repo.add_content(fp)
1146 repo.add_content(fp)
1148 Add the ``content'' meta description from the susetags format to the repository.
1149 This file contains information about the repository like keywords, and also
1150 a list of all database files with checksums. The data is added the the "meta"
1151 section of the repository, i.e. no package gets created.
1153 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0)
1154 $repo->add_susetags($fp, $defvendor, $language);
1155 repo.add_susetags(fp, defvendor, language)
1156 repo.add_susetags(fp, defvendor, language)
1158 Add repository metadata in the susetags format to the repository. Like with
1159 add_rpmmd, you can specify a language if you have language extension files. The
1160 _defvendor_ parameter provides a default vendor for packages with missing
1161 vendors, it is usually provided in the content file.
1163 bool add_products(const char *dir, int flags = 0)
1164 $repo->add_products($dir);
1165 repo.add_products(dir)
1166 repo.add_products(dir)
1168 Add the installed SUSE products database to the repository. The _dir_ parameter
1169 is usually "/etc/products.d".
1174 A solvable describes all the information of one package. Each solvable
1175 belongs to one repository, it can be added and filled manually but in
1176 most cases solvables will get created by the repo_add methods.
1180 Repo *repo; /* read only */
1185 The repository this solvable belongs to.
1187 Pool *pool; /* read only */
1192 The pool this solvable belongs to, same as the pool of the repo.
1194 Id id; /* read only */
1199 The specific id of the solvable.
1201 char *name; /* read/write */
1206 char *evr; /* read/write */
1211 char *arch; /* read/write */
1216 char *vendor; /* read/write */
1221 Easy access to often used attributes of solvables. They are
1222 internally stored as Ids.
1224 Id nameid; /* read/write */
1229 Id evrid; /* read/write */
1234 Id archid; /* read/write */
1239 Id vendorid; /* read/write */
1240 $solvable->{vendorid}
1244 Raw interface to the ids. Useful if you want to search for
1245 a specific id and want to avoid the string compare overhead.
1249 const char *lookup_str(Id keyname)
1250 my $string = $solvable->lookup_str($keyname);
1251 string = solvable.lookup_str(keyname)
1252 string = solvable.lookup_str(keyname)
1254 Id lookup_id(Id keyname)
1255 my $id = $solvable->lookup_id($keyname);
1256 id = solvable.lookup_id(solvid)
1257 id = solvable.lookup_id(solvid)
1259 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
1260 my $num = $solvable->lookup_num($keyname);
1261 num = solvable.lookup_num(keyname)
1262 num = solvable.lookup_num(keyname)
1264 bool lookup_void(Id keyname)
1265 my $bool = $solvable->lookup_void($keyname);
1266 bool = solvable.lookup_void(keyname)
1267 bool = solvable.lookup_void(keyname)
1269 Chksum lookup_checksum(Id keyname)
1270 my $chksum = $solvable->lookup_checksum($keyname);
1271 chksum = solvable.lookup_checksum(keyname)
1272 chksum = solvable.lookup_checksum(keyname)
1274 Id *lookup_idarray(Id keyname, Id marker = -1)
1275 my @ids = $solvable->lookup_idarray($keyname);
1276 ids = solvable.lookup_idarray(keyname)
1277 ids = solvable.lookup_idarray(keyname)
1279 Dep *lookup_deparray(Id keyname, Id marker = -1)
1280 my @deps = $solvable->lookup_deparray($keyname);
1281 deps = solvable.lookup_deparray(keyname)
1282 deps = solvable.lookup_deparray(keyname)
1284 Generic lookup methods. Retrieve data stored for the specific keyname.
1285 The lookup_idarray() method will return an array of Ids, use
1286 lookup_deparray if you want an array of Dependency objects instead.
1287 Some Id arrays contain two parts of data divided by a specific marker,
1288 for example the provides array uses the SOLVABLE_FILEMARKER id to
1289 store both the ids provided by the package and the ids added by
1290 the addfileprovides method. The default, -1, translates to the
1291 correct marker for the keyname and returns the first part of the
1292 array, use 1 to select the second part or 0 to retrieve all ids
1293 including the marker.
1295 const char *lookup_location(unsigned int *OUTPUT);
1296 my ($location, $medianr) = $solvable->lookup_location();
1297 location, medianr = solvable.lookup_location()
1298 location, medianr = solvable.lookup_location()
1300 Return a tuple containing the on-media location and an optional
1301 media number for multi-part repositories (e.g. repositories
1302 spawning multiple DVDs).
1304 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
1305 my $di = $solvable->Dataiterator($keyname, $match, $flags);
1306 di = solvable.Dataiterator(keyname, match, flags)
1307 di = solvable.Dataiterator(keyname, match, flags)
1313 Iterate over the matching data elements. See the Dataiterator class for more
1316 void add_deparray(Id keyname, DepId dep, Id marker = -1);
1317 $solvable->add_deparray($keyname, $dep);
1318 solvable.add_deparray(keyname, dep)
1319 solvable.add_deparray(keyname, dep)
1321 Add a new dependency to the attributes stored in keyname.
1323 void unset(Id keyname);
1324 $solvable->unset($keyname);
1325 solvable.unset(keyname)
1326 solvable.unset(keyname)
1328 Delete data stored for the specific keyname.
1331 $solvable->installable()
1332 solvable.installable()
1333 solvable.installable?
1335 Return true if the solvable is installable on the system. Solvables
1336 are not installable if the system does not support their architecture.
1339 $solvable->isinstalled()
1340 solvable.isinstalled()
1341 solvable.isinstalled?
1343 Return true if the solvable is installed on the system.
1345 bool identical(Solvable *other)
1346 $solvable->identical($other)
1347 $solvable.identical(other)
1348 $solvable.identical?(other)
1350 Return true if the two solvables are identical.
1352 int evrcmp(Solvable *other)
1353 $solvable->evrcmp(other)
1354 $solvable.evrcmp(other)
1355 $solvable.evrcmp(other)
1357 Returns -1 if the epoch/version/release of the solvable is less then the
1358 one from the other solvable, 1 if it is greater, and 0 if they are equal.
1359 Note that "equal" does not mean that the evr is identical.
1361 Selection Selection(int setflags = 0)
1362 my $sel = $solvable->Selection();
1363 sel = solvable.Selection()
1364 sel = solvable.Selection()
1366 Create a Selection containing just the single solvable.
1369 my $str = $solvable->str();
1370 str = $solvable.str()
1371 str = $solvable.str()
1373 Return a string describing the solvable. The string consists of the name,
1374 version, and architecture of the Solvable.
1377 my $str = $solvable->str;
1381 Same as calling the str() method.
1384 if ($solvable1 == $solvable2)
1385 if solvable1 == solvable2:
1386 if solvable1 == solvable2
1388 Two solvables are equal if they are part of the same pool and have the same
1392 The Dataiterator Class
1393 ----------------------
1394 Dataiterators can be used to do complex string searches or
1395 to iterate over arrays. They can be created via the
1396 constructors in the Pool, Repo, and Solvable classes. The
1397 Repo and Solvable constructors will limit the search to
1398 the repository or the specific package.
1403 Return a match if the search string matches the value.
1405 *SEARCH_STRINGSTART*::
1406 Return a match if the value starts with the search string.
1408 *SEARCH_STRINGEND*::
1409 Return a match if the value ends with the search string.
1411 *SEARCH_SUBSTRING*::
1412 Return a match if the search string can be matched somewhere in the value.
1415 Do a glob match of the search string against the value.
1418 Do a regular expression match of the search string against the value.
1421 Ignore case when matching strings. Works for all the above match types.
1424 Match the complete filenames of the file list, not just the base name.
1426 *SEARCH_COMPLETE_FILELIST*::
1427 When matching the file list, check every file of the package not just the
1428 subset from the primary metadata.
1430 *SEARCH_CHECKSUMS*::
1431 Allow the matching of checksum entries.
1435 void prepend_keyname(Id keyname);
1436 $di->prepend_keyname($keyname);
1437 di.prepend_keyname(keyname)
1438 di.prepend_keyname(keyname)
1440 Do a sub-search in the array stored in keyname.
1442 void skip_solvable();
1443 $di->kip_solvable();
1447 Stop matching the current solvable and advance to the next
1455 Iterate through the matches. If there is a match, the object
1456 in d will be of type Datamatch.
1460 Objects of this type will be created for every value matched
1465 Pool *pool; /* read only */
1470 Back pointer to pool.
1472 Repo *repo; /* read only */
1477 The repository containing the matched object.
1479 Solvable *solvable; /* read only */
1484 The solvable containing the value that was matched.
1486 Id solvid; /* read only */
1491 The id of the solvable that matched.
1498 const char *key_idstr;
1503 The keyname that matched, either as id or string.
1510 const char *type_idstr;
1515 The key type of the value that was matched, either as id or string.
1527 The Id of the value that was matched (only valid for id types),
1528 either as id or string.
1535 The string value that was matched (only valid for string types).
1537 unsigned long long num;
1542 The numeric value that was matched (only valid for numeric types).
1549 The secondary numeric value that was matched (only valid for types
1550 containing two values).
1552 unsigned int binary;
1557 The value in binary form, useful for checksums and other data
1558 that cannot be represented as a string.
1563 my $pos = $d->pos();
1567 The position object of the current match. It can be used to do
1568 sub-searches starting at the match (if it is of an array type).
1569 See the Datapos class for more information.
1571 Datapos parentpos();
1572 my $pos = $d->parentpos();
1576 The position object of the array containing the current match.
1577 It can be used to do sub-searches, see the Datapos class for more
1585 Return the stringification of the matched value. Stringification
1586 depends on the search flags, for file list entries it will return
1587 just the base name unless SEARCH_FILES is used, for checksums
1588 it will return an empty string unless SEARCH_CHECKSUMS is used.
1589 Numeric values are currently stringified to an empty string.
1594 Selections are a way to easily deal with sets of packages.
1595 There are multiple constructors to create them, the most useful
1596 is probably the select() method in the Pool class.
1601 Create the selection by matching package names.
1603 *SELECTION_PROVIDES*::
1604 Create the selection by matching package provides.
1606 *SELECTION_FILELIST*::
1607 Create the selection by matching package files.
1610 Create the selection by matching the canonical representation
1611 of the package. This is normally a combination of the name,
1612 the version, and the architecture of a package.
1614 *SELECTION_DOTARCH*::
1615 Allow an ``.<architecture>'' suffix when matching names or
1619 Allow the specification of a relation when matching names
1620 or provides, e.g. "name >= 1.2".
1622 *SELECTION_INSTALLED_ONLY*::
1623 Limit the package search to installed packages.
1625 *SELECTION_SOURCE_ONLY*::
1626 Limit the package search to source packages only.
1628 *SELECTION_WITH_SOURCE*::
1629 Extend the package search to also match source packages. The default is
1630 only to match binary packages.
1633 Allow glob matching for package names, package provides, and file names.
1635 *SELECTION_NOCASE*::
1636 Ignore case when matching package names, package provides, and file names.
1639 Return only one selection element describing the selected packages.
1640 The default is to create multiple elements for all globbed packages.
1641 Multiple elements are useful if you want to turn the selection into
1642 an install job, in that case you want an install job for every
1647 Pool *pool; /* read only */
1652 Back pointer to pool.
1657 my $flags = $sel->flags();
1661 Return the result flags of the selection. The flags are a subset
1662 of the ones used when creating the selection, they describe which
1663 method was used to get the result. For example, if you create the
1664 selection with ``SELECTION_NAME | SELECTION_PROVIDES'', the resulting
1665 flags will either be SELECTION_NAME or SELECTION_PROVIDES depending
1666 if there was a package that matched the name or not. If there was
1667 no match at all, the flags will be zero.
1674 Return true if the selection is empty, i.e. no package could be matched.
1676 void filter(Selection *other)
1677 $sel->filter($other);
1681 Intersect two selections. Packages will only stay in the selection if there
1682 are also included in the other selecting. Does an in-place modification.
1684 void add(Selection *other)
1689 Build the union of two selections. All packages of the other selection will
1690 be added to the set of packages of the selection object. Does an in-place
1691 modification. Note that the selection flags are no longer meaningful after the
1694 void add_raw(Id how, Id what)
1695 $sel->add_raw($how, $what);
1696 sel.add_raw(how, what)
1697 sel.add_raw(how, what)
1699 Add a raw element to the selection. Check the Job class for information about
1700 the how and what parameters.
1702 Job *jobs(int action)
1703 my @jobs = $sel->jobs($action);
1704 jobs = sel.jobs(action)
1705 jobs = sel.jobs(action)
1707 Convert a selection into an array of Job objects. The action parameter is or-ed
1708 to the ``how'' part of the job, it describes the type of job (e.g. install,
1709 erase). See the Job class for the action and action modifier constants.
1711 Solvable *solvables()
1712 my @solvables = $sel->solvables();
1713 solvables = sel.solvables()
1714 solvables = sel.solvables()
1716 Convert a selection into an array of Solvable objects.
1719 my $str = $sel->str;
1723 Return a string describing the selection.
1727 Jobs are the way to specify to the dependency solver what to do.
1728 Most of the times jobs will get created by calling the jobs() method
1729 on a Selection object, but there is also a Job() constructor in the
1734 Selection constants:
1737 The ``what'' part is the id of a solvable.
1739 *SOLVER_SOLVABLE_NAME*::
1740 The ``what'' part is the id of a package name.
1742 *SOLVER_SOLVABLE_PROVIDES*::
1743 The ``what'' part is the id of a package provides.
1745 *SOLVER_SOLVABLE_ONE_OF*::
1746 The ``what'' part is an offset into the ``whatprovides'' data, created
1747 by calling the towhatprovides() pool method.
1749 *SOLVER_SOLVABLE_REPO*::
1750 The ``what'' part is the id of a repository.
1752 *SOLVER_SOLVABLE_ALL*::
1753 The ``what'' part is ignored, all packages are selected.
1755 *SOLVER_SOLVABLE_SELECTMASK*::
1756 A mask containing all the above selection bits.
1764 Install a package of the specified set of packages. It tries to install
1765 the best matching package (i.e. the highest version of the packages from
1766 the repositories with the highest priority).
1769 Erase all of the packages from the specified set. If a package is not
1770 installed, erasing it will keep it from getting installed.
1773 Update the matching installed packages to their best version. If none
1774 of the specified packages are installed, try to update the installed
1775 packages to the specified versions. See the section about targeted
1776 updates about more information.
1778 *SOLVER_WEAKENDEPS*::
1779 Allow to break the dependencies of the matching packages. Handle with care.
1781 *SOLVER_MULTIVERSION*::
1782 Mark the matched packages for multiversion install. If they get to be
1783 installed because of some other job, the installation will keep the old
1784 version of the package installed (for rpm this is done by using ``-i''
1788 Do not change the state of the matched packages, i.e. when they are
1789 installed they stay installed, if not they are not selected for
1792 *SOLVER_DISTUPGRADE*::
1793 Update the matching installed packages to the best version included in one
1794 of the repositories. After this operation, all come from one of the available
1795 repositories except orphaned packages. Orphaned packages are packages that
1796 have no relation to the packages in the repositories, i.e. no package in the
1797 repositories have the same name or obsolete the orphaned package.
1798 This action brings the installed packages in sync with the ones in the
1799 repository. By default it also turns of arch/vendor/version locking for the
1800 affected packages to simulate a fresh installation. This means that distupgrade can
1801 actually downgrade packages if only lower versions of a package are available
1802 in the repositories. You can tweak this behavior with the SOLVER_FLAG_DUP_
1805 *SOLVER_DROP_ORPHANED*::
1806 Erase all the matching installed packages if they are orphaned. This only makes
1807 sense if there is a ``distupgrade all packages'' job. The default is to erase
1808 orphaned packages only if they block the installation of other packages.
1811 Fix dependency problems of matching installed packages. The default is to ignore
1812 dependency problems for installed packages.
1814 *SOLVER_USERINSTALLED*::
1815 The matching installed packages are considered to be installed by a user,
1816 thus not installed to fulfill some dependency. This is needed input for
1817 the calculation of unneeded packages for jobs that have the
1818 SOLVER_CLEANDEPS flag set.
1821 A mask containing all the above action bits.
1823 Action modifier constants:
1826 Makes the job a weak job. The solver tries to fulfill weak jobs, but does
1827 not report a problem if it is not possible to do so.
1829 *SOLVER_ESSENTIAL*::
1830 Makes the job an essential job. If there is a problem with the job, the
1831 solver will not propose to remove the job as one solution (unless all
1832 other solutions are also to remove essential jobs).
1834 *SOLVER_CLEANDEPS*::
1835 The solver will try to also erase all packages dragged in through
1836 dependencies when erasing the package. This needs SOLVER_USERINSTALLED
1837 jobs to maximize user satisfaction.
1839 *SOLVER_FORCEBEST*::
1840 Insist on the best package for install, update, and distupgrade jobs. If
1841 this flag is not used, the solver will use the second-best package if the
1842 best package cannot be installed for some reason. When this flag is used,
1843 the solver will generate a problem instead.
1846 Forces targeted operation update and distupgrade jobs. See the section
1847 about targeted updates about more information.
1852 The job specified the exact epoch and version of the package set.
1855 The job specified the exact epoch, version, and release of the package set.
1858 The job specified the exact architecture of the packages from the set.
1860 *SOLVER_SETVENDOR*::
1861 The job specified the exact vendor of the packages from the set.
1864 The job specified the exact repository of the packages from the set.
1867 The job specified the exact name of the packages from the set.
1869 *SOLVER_NOAUTOSET*::
1870 Turn of automatic set flag generation for SOLVER_SOLVABLE jobs.
1873 A mask containing all the above set bits.
1875 See the section about set bits for more information.
1879 Pool *pool; /* read only */
1884 Back pointer to pool.
1886 Id how; /* read/write */
1891 Union of the selection, action, action modifier, and set flags.
1892 The selection part describes the semantics of the ``what'' Id.
1894 Id what; /* read/write */
1899 Id describing the set of packages, the meaning depends on the
1900 selection part of the ``how'' attribute.
1904 Solvable *solvables()
1905 my @solvables = $job->solvables();
1906 solvables = job.solvables()
1907 solvables = job.solvables()
1909 Return the set of solvables of the job as an array of Solvable
1912 bool isemptyupdate();
1913 $job->isemptyupdate()
1917 Convenience function to find out if the job describes an update
1918 job with no matching packages, i.e. a job that does nothing.
1919 Some package managers like ``zypper'' like to turn those jobs
1920 into install jobs, i.e. an update of a not-installed package
1921 will result into the installation of the package.
1924 my $str = $job->str;
1928 Return a string describing the job.
1935 Two jobs are equal if they belong to the same pool and both the
1936 ``how'' and the ``what'' attributes are the same.
1938 === TARGETED UPDATES ===
1939 Libsolv has two modes for upgrades and distupgrade: targeted and
1940 untargeted. Untargeted mode means that the installed packages from
1941 the specified set will be updated to the best version. Targeted means
1942 that packages that can be updated to a package in the specified set
1943 will be updated to the best package of the set.
1945 Here's an example to explain the subtle difference. Suppose that
1946 you have package A installed in version "1.1", "A-1.2" is available
1947 in one of the repositories and there is also package "B" that
1948 obsoletes package A.
1950 An untargeted update of "A" will update the installed "A-1.1" to
1951 package "B", because that is the newest version (B obsoletes A and
1954 A targeted update of "A" will update "A-1.1" to "A-1.2", as the
1955 set of packages contains both "A-1.1" and "A-1.2", and "A-1.2" is
1958 An untargeted update of "B" will do nothing, as "B" is not installed.
1960 An targeted update of "B" will update "A-1.1" to "B".
1962 Note that the default is to do "auto-targeting", thus if the specified
1963 set of packages does not include an installed package, the solver
1964 will assume targeted operation even if SOLVER_TARGETED is not used.
1966 This mostly matches the intent of the user, with one exception: In
1967 the example above, an update of "A-1.2" will update "A-1.1" to
1968 "A-1.2" (targeted mode), but a second update of "A-1.2" will suddenly
1969 update to "B", as untargeted mode is chosen because "A-1.2" is now
1972 If you want to have full control over when targeting mode is chosen,
1973 turn off auto-targeting with the SOLVER_FLAG_NO_AUTOTARGET solver option.
1974 In that case, all updates are considered to be untargeted unless they
1975 include the SOLVER_TARGETED flag.
1978 Set bits specify which parts of the specified packages where specified
1979 by the user. It is used by the solver when checking if an operation is
1980 allowed or not. For example, the solver will normally not allow the
1981 downgrade of an installed package. But it will not report a problem if
1982 the SOLVER_SETEVR flag is used, as it then assumes that the user specified
1983 the exact version and thus knows what he is doing.
1985 So if a package "screen-1-1" is installed for the x86_64 architecture and
1986 version "2-1" is only available for the i586 architecture, installing
1987 package "screen-2.1" will ask the user for confirmation because of the
1988 different architecture. When using the Selection class to create jobs
1989 the set bits are automatically added, e.g. selecting ``screen.i586'' will
1990 automatically add SOLVER_SETARCH, and thus no problem will be reported.
1994 Dependency solving is what this library is about. A solver object is needed
1995 for solving to store the result of the solver run. The solver object can be
1996 used multiple times for different jobs, reusing it allows the solver to
1997 re-use the dependency rules it already computed.
2001 Flags to modify some of the solver's behavior:
2003 *SOLVER_FLAG_ALLOW_DOWNGRADE*::
2004 Allow the solver to downgrade packages without asking for confirmation
2005 (i.e. reporting a problem).
2007 *SOLVER_FLAG_ALLOW_ARCHCHANGE*::
2008 Allow the solver to change the architecture of an installed package
2009 without asking for confirmation. Note that changes to/from noarch
2010 are always considered to be allowed.
2012 *SOLVER_FLAG_ALLOW_VENDORCHANGE*::
2013 Allow the solver to change the vendor of an installed package
2014 without asking for confirmation. Each vendor is part of one or more
2015 vendor equivalence classes, normally installed packages may only
2016 change their vendor if the new vendor shares at least one equivalence
2019 *SOLVER_FLAG_ALLOW_NAMECHANGE*::
2020 Allow the solver to change the name of an installed package, i.e.
2021 install a package with a different name that obsoletes the installed
2022 package. This option is on by default.
2024 *SOLVER_FLAG_ALLOW_UNINSTALL*::
2025 Allow the solver to erase installed packages to fulfill the jobs.
2026 This flag also includes the above flags. You may want to set this
2027 flag if you only have SOLVER_ERASE jobs, as in that case it's
2028 better for the user to check the transaction overview instead of
2029 approving every single package that needs to be erased.
2031 *SOLVER_FLAG_DUP_ALLOW_DOWNGRADE*::
2032 Like SOLVER_FLAG_ALLOW_DOWNGRADE, but used in distupgrade mode.
2034 *SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE*::
2035 Like SOLVER_FLAG_ALLOW_ARCHCHANGE, but used in distupgrade mode.
2037 *SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE*::
2038 Like SOLVER_FLAG_ALLOW_VENDORCHANGE, but used in distupgrade mode.
2040 *SOLVER_FLAG_DUP_ALLOW_NAMECHANGE*::
2041 Like SOLVER_FLAG_ALLOW_NAMECHANGE, but used in distupgrade mode.
2043 *SOLVER_FLAG_NO_UPDATEPROVIDE*::
2044 If multiple packages obsolete an installed package, the solver checks
2045 the provides of every such package and ignores all packages that
2046 do not provide the installed package name. Thus, you can have an
2047 official update candidate that provides the old name, and other
2048 packages that also obsolete the package but are not considered for
2049 updating. If you cannot use this feature, you can turn it off
2050 by setting this flag.
2052 *SOLVER_FLAG_SPLITPROVIDES*::
2053 Make the solver aware of special provides of the form
2054 ``<packagename>:<path>'' used in SUSE systems to support package
2057 *SOLVER_FLAG_IGNORE_RECOMMENDED*::
2058 Do not process optional (aka weak) dependencies.
2060 *SOLVER_FLAG_ADD_ALREADY_RECOMMENDED*::
2061 Install recommended or supplemented packages even if they have no
2062 connection to the current transaction. You can use this feature
2063 to implement a simple way for the user to install new recommended
2064 packages that were not available in the past.
2066 *SOLVER_FLAG_NO_INFARCHCHECK*::
2067 Turn off the inferior architecture checking that is normally done
2068 by the solver. Normally, the solver allows only the installation
2069 of packages from the "best" architecture if a package is available
2070 for multiple architectures.
2072 *SOLVER_FLAG_BEST_OBEY_POLICY*::
2073 Make the SOLVER_FORCEBEST job option consider only packages that
2074 meet the policies for installed packages, i.e. no downgrades,
2075 no architecture change, no vendor change (see the first flags
2076 of this section). If the flag is not specified, the solver will
2077 enforce the installation of the best package ignoring the
2078 installed packages, which may conflict with the set policy.
2080 *SOLVER_FLAG_NO_AUTOTARGET*::
2081 Do not enable auto-targeting up update and distupgrade jobs. See
2082 the section on targeted updates for more information.
2086 *SOLVER_RULE_UNKNOWN*::
2087 A rule of an unknown class. You should never encounter those.
2090 A package dependency rule, called rpm rule for historical reasons.
2092 *SOLVER_RULE_UPDATE*::
2093 A rule to implement the update policy of installed packages. Every
2094 installed package has an update rule that consists of the packages
2095 that may replace the installed package.
2097 *SOLVER_RULE_FEATURE*::
2098 Feature rules are fallback rules used when a update rule is disabled. They
2099 include all packages that may replace the installed package ignoring the
2100 update policy, i.e. they contain downgrades, arch changes and so on.
2101 Without them, the solver would simply erase installed packages if their
2102 update rule gets disabled.
2105 Job rules implement the job given to the solver.
2107 *SOLVER_RULE_DISTUPGRADE*::
2108 This are simple negative assertions that make sure that only packages
2109 are kept that are also available in one of the repositories.
2111 *SOLVER_RULE_INFARCH*::
2112 Infarch rules are also negative assertions, they disallow the installation
2113 of packages when there are packages of the same name but with a better
2116 *SOLVER_RULE_CHOICE*::
2117 Choice rules are used to make sure that the solver prefers updating to
2118 installing different packages when some dependency is provided by
2119 multiple packages with different names. The solver may always break
2120 choice rules, so you will not see them when a problem is found.
2122 *SOLVER_RULE_LEARNT*::
2123 These rules are generated by the solver to keep it from running into
2124 the same problem multiple times when it has to backtrack. They are
2125 the main reason why a sat solver is faster then other dependency solver
2128 Special dependency rule types:
2130 *SOLVER_RULE_RPM_NOT_INSTALLABLE*::
2131 This rule was added to prevent the installation of a package of an
2132 architecture that does not work on the system.
2134 *SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP*::
2135 The package contains a required dependency which was not provided by
2138 *SOLVER_RULE_RPM_PACKAGE_REQUIRES*::
2139 Similar to SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, but in this case
2140 some packages provided the dependency but none of them could be
2141 installed due to other dependency issues.
2143 *SOLVER_RULE_RPM_SELF_CONFLICT*::
2144 The package conflicts with itself. This is not allowed by older rpm
2147 *SOLVER_RULE_RPM_PACKAGE_CONFLICT*::
2148 To fulfill the dependencies two packages need to be installed, but
2149 one of the packages contains a conflict with the other one.
2151 *SOLVER_RULE_RPM_SAME_NAME*::
2152 The dependencies can only be fulfilled by multiple versions of
2153 a package, but installing multiple versions of the same package
2156 *SOLVER_RULE_RPM_PACKAGE_OBSOLETES*::
2157 To fulfill the dependencies two packages need to be installed, but
2158 one of the packages obsoletes the other one.
2160 *SOLVER_RULE_RPM_IMPLICIT_OBSOLETES*::
2161 To fulfill the dependencies two packages need to be installed, but
2162 one of the packages has provides a dependency that is obsoleted
2163 by the other one. See the POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES
2166 *SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES*::
2167 To fulfill the dependencies a package needs to be installed that is
2168 obsoleted by an installed package. See the POOL_FLAG_NOINSTALLEDOBSOLETES
2171 *SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP*::
2172 The user asked for installation of a package providing a specific
2173 dependency, but no available package provides it.
2175 *SOLVER_RULE_JOB_UNKNOWN_PACKAGE*::
2176 The user asked for installation of a package with a specific name,
2177 but no available package has that name.
2179 *SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM*::
2180 The user asked for the erasure of a dependency that is provided by the
2181 system (i.e. for special hardware or language dependencies), this
2182 cannot be done with a job.
2184 *SOLVER_RULE_JOB_UNSUPPORTED*::
2185 The user asked for something that is not yet implemented, e.g. the
2186 installation of all packages at once.
2188 Policy error constants
2190 *POLICY_ILLEGAL_DOWNGRADE*::
2191 The solver ask for permission before downgrading packages.
2193 *POLICY_ILLEGAL_ARCHCHANGE*::
2194 The solver ask for permission before changing the architecture of installed
2197 *POLICY_ILLEGAL_VENDORCHANGE*::
2198 The solver ask for permission before changing the vendor of installed
2201 *POLICY_ILLEGAL_NAMECHANGE*::
2202 The solver ask for permission before replacing an installed packages with
2203 a package that has a different name.
2205 Solution element type constants
2207 *SOLVER_SOLUTION_JOB*::
2208 The problem can be solved by removing the specified job.
2210 *SOLVER_SOLUTION_POOLJOB*::
2211 The problem can be solved by removing the specified job that is defined
2214 *SOLVER_SOLUTION_INFARCH*::
2215 The problem can be solved by allowing the installation of the specified
2216 package with an inferior architecture.
2218 *SOLVER_SOLUTION_DISTUPGRADE*::
2219 The problem can be solved by allowing to keep the specified package
2222 *SOLVER_SOLUTION_BEST*::
2223 The problem can be solved by allowing to install the specified package
2224 that is not the best available package.
2226 *SOLVER_SOLUTION_ERASE*::
2227 The problem can be solved by allowing to erase the specified package.
2229 *SOLVER_SOLUTION_REPLACE*::
2230 The problem can be solved by allowing to replace the package with some
2233 *SOLVER_SOLUTION_REPLACE_DOWNGRADE*::
2234 The problem can be solved by allowing to replace the package with some
2235 other package that has a lower version.
2237 *SOLVER_SOLUTION_REPLACE_ARCHCHANGE*::
2238 The problem can be solved by allowing to replace the package with some
2239 other package that has a different architecture.
2241 *SOLVER_SOLUTION_REPLACE_VENDORCHANGE*::
2242 The problem can be solved by allowing to replace the package with some
2243 other package that has a different vendor.
2245 *SOLVER_SOLUTION_REPLACE_NAMECHANGE*::
2246 The problem can be solved by allowing to replace the package with some
2247 other package that has a different name.
2252 *SOLVER_REASON_UNRELATED*::
2253 The package status did not change as it was not related to any job.
2255 *SOLVER_REASON_UNIT_RULE*::
2256 The package was installed/erased/kept because of a unit rule, i.e. a rule
2257 where all literals but one were false.
2259 *SOLVER_REASON_KEEP_INSTALLED*::
2260 The package was chosen when trying to keep as many packages installed as
2263 *SOLVER_REASON_RESOLVE_JOB*::
2264 The decision happened to fulfill a job rule.
2266 *SOLVER_REASON_UPDATE_INSTALLED*::
2267 The decision happened to fulfill a package update request.
2269 *SOLVER_REASON_CLEANDEPS_ERASE*::
2270 The package was erased when cleaning up dependencies from other erased
2273 *SOLVER_REASON_RESOLVE*::
2274 The package was installed to fulfill package dependencies.
2276 *SOLVER_REASON_WEAKDEP*::
2277 The package was installed because of a weak dependency (Recommends or
2280 *SOLVER_REASON_RESOLVE_ORPHAN*::
2281 The decision about the package was made when deciding the fate of orphaned
2284 *SOLVER_REASON_RECOMMENDED*::
2285 This is a special case of SOLVER_REASON_WEAKDEP.
2287 *SOLVER_REASON_SUPPLEMENTED*::
2288 This is a special case of SOLVER_REASON_WEAKDEP.
2293 Pool *pool; /* read only */
2298 Back pointer to pool.
2302 int set_flag(int flag, int value)
2303 my $oldvalue = $solver->set_flag($flag, $value);
2304 oldvalue = solver.set_flag(flag, value)
2305 oldvalue = solver.set_flag(flag, value)
2307 int get_flag(int flag)
2308 my $value = $solver->get_flag($flag);
2309 value = solver.get_flag(flag)
2310 value = solver.get_flag(flag)
2312 Set/get a solver specific flag. The flags define the policies the solver has
2313 to obey. The flags are explained in the CONSTANTS section of this class.
2315 Problem *solve(Job *jobs)
2316 my @problems = $solver->solve(\@jobs);
2317 problems = solver.solve(jobs)
2318 problems = solver.solve(jobs)
2320 Solve a problem specified in the job list (plus the jobs defined in the pool).
2321 Returns an array of problems that need user interaction, or an empty array
2322 if no problems were encountered. See the Problem class on how to deal with
2325 Transaction transaction()
2326 my $trans = $solver->transaction();
2327 trans = solver.transaction()
2328 trans = solver.transaction()
2330 Return the transaction to implement the calculated package changes. A transaction
2331 is available even if problems were found, this is useful for interactive user
2332 interfaces that show both the job result and the problems.
2334 int reason = describe_decision(Solvable *s, Rule *OUTPUT)
2335 my ($reason, $rule) = $solver->describe_decision($solvable);
2336 (reason, rule) = solver.describe_decision(solvable)
2337 (reason, rule) = solver.describe_decision(solvable)
2339 Return the reason why a specific solvable was installed or erased. For most of
2340 the reasons the rule that triggered the decision is also returned.
2344 Problems are the way of the solver to interact with the user. You can simply list
2345 all problems and terminate your program, but a better way is to present solutions to
2346 the user and let him pick the ones he likes.
2350 Solver *solv; /* read only */
2355 Back pointer to solver object.
2357 Id id; /* read only */
2362 Id of the problem. The first problem has Id 1, they are numbered consecutively.
2366 Rule findproblemrule()
2367 my $probrule = $problem->findproblemrule();
2368 probrule = problem.findproblemrule()
2369 probrule = problem.findproblemrule()
2371 Return the rule that caused the problem. Of course in most situations there is no
2372 single responsible rule, but many rules that interconnect with each created the
2373 problem. Nevertheless, the solver uses some heuristic approach to find a rule
2374 that somewhat describes the problem best to the user.
2376 Rule *findallproblemrules(bool unfiltered = 0)
2377 my @probrules = $problem->findallproblemrules();
2378 probrules = problem.findallproblemrule()
2379 probrules = problem.findallproblemrule()
2381 Return all rules responsible for the problem. The returned set of rules contains
2382 all the needed information why there was a problem, but it's hard to present
2383 them to the user in a sensible way. The default is to filter out all update and
2384 job rules (unless the returned rules only consist of those types).
2386 Solution *solutions()
2387 my @solutions = $problem->solutions();
2388 solutions = problem.solutions()
2389 solutions = problem.solutions()
2391 Return an array containing multiple possible solutions to fix the problem. See
2392 the solution class for more information.
2394 int solution_count()
2395 my $cnt = $problem->solution_count();
2396 cnt = problem.solution_count()
2397 cnt = problem.solution_count()
2399 Return the number of solutions without creating solution objects.
2402 my $str = $problem->str;
2406 Return a string describing the problem. This is a convenience function, it is
2407 a shorthand for calling findproblemrule(), then ruleinfo() on the problem
2408 rule and problemstr() on the ruleinfo object.
2412 Rules are the basic block of sat solving. Each package dependency gets translated
2413 into one or multiple rules.
2417 Solver *solv; /* read only */
2422 Back pointer to solver object.
2424 Id id; /* read only */
2431 int type; /* read only */
2436 The basic type of the rule. See the constant section of the solver class for the type list.
2441 my $ruleinfo = $rule->info();
2442 ruleinfo = rule.info()
2443 ruleinfo = rule.info()
2445 Return a Ruleinfo object that contains information about why the rule was created. But
2446 see the allinfos() method below.
2448 Ruleinfo *allinfos()
2449 my @ruleinfos = $rule->allinfos();
2450 ruleinfos = rule.allinfos()
2451 ruleinfos = rule.allinfos()
2453 As the same dependency rule can get created because of multiple dependencies, one
2454 Ruleinfo is not enough to describe the reason. Thus the allinfos() method returns
2455 an array of all infos about a rule.
2458 if ($rule1 == $rule2)
2462 Two rules are equal if they belong to the same solver and have the same id.
2466 A Ruleinfo describes one reason why a rule was created.
2470 Solver *solv; /* read only */
2475 Back pointer to solver object.
2477 int type; /* read only */
2482 The type of the ruleinfo. See the constant section of the solver class for the
2483 rule type list and the special type list.
2485 Dep *dep; /* read only */
2490 The dependency leading to the creation of the rule.
2492 Dep *dep_id; /* read only */
2493 $ruleinfo->{'dep_id'}
2497 The Id of the dependency leading to the creation of the rule, or zero.
2499 Solvable *solvable; /* read only */
2500 $ruleinfo->{solvable}
2504 The involved Solvable, e.g. the one containing the dependency.
2506 Solvable *othersolvable; /* read only */
2507 $ruleinfo->{othersolvable}
2508 ruleinfo.othersolvable
2509 ruleinfo.othersolvable
2511 The other involved Solvable (if any), e.g. the one containing providing
2512 the dependency for conflicts.
2514 const char *problemstr();
2515 my $str = $ruleinfo->problemstr();
2516 str = ruleinfo.problemstr()
2517 str = ruleinfo.problemstr()
2519 A string describing the ruleinfo from a problem perspective. This probably
2520 only makes sense if the rule is part of a problem.
2524 A solution solves one specific problem. It consists of multiple solution elements
2525 that all need to be executed.
2529 Solver *solv; /* read only */
2534 Back pointer to solver object.
2536 Id problemid; /* read only */
2537 $solution->{problemid}
2541 Id of the problem the solution solves.
2543 Id id; /* read only */
2548 Id of the solution. The first solution has Id 1, they are numbered consecutively.
2552 Solutionelement *elements(bool expandreplaces = 0)
2553 my @solutionelements = $solution->elements();
2554 solutionelements = solution.elements()
2555 solutionelements = solution.elements()
2557 Return an array containing the elements describing what needs to be done to
2558 implement the specific solution. If expandreplaces is true, elements of type
2559 SOLVER_SOLUTION_REPLACE will be replaced by one or more elements replace
2560 elements describing the policy mismatches.
2563 my $cnt = $solution->solution_count();
2564 cnt = solution.element_count()
2565 cnt = solution.element_count()
2567 Return the number of solution elements without creating objects. Note that the
2568 count does not match the number of objects returned by the elements() method
2569 of expandreplaces is set to true.
2572 The Solutionelement Class
2573 -------------------------
2574 A solution element describes a single action of a solution. The action is always
2575 either to remove one specific job or to add a new job that installs or erases
2576 a single specific package.
2580 Solver *solv; /* read only */
2581 $solutionelement->{solv}
2582 solutionelement.solv
2583 solutionelement.solv
2585 Back pointer to solver object.
2587 Id problemid; /* read only */
2588 $solutionelement->{problemid}
2589 solutionelement.problemid
2590 solutionelement.problemid
2592 Id of the problem the element (partly) solves.
2594 Id solutionid; /* read only */
2595 $solutionelement->{solutionid}
2596 solutionelement.solutionid
2597 solutionelement.solutionid
2599 Id of the solution the element is a part of.
2601 Id id; /* read only */
2602 $solutionelement->{id}
2606 Id of the solution element. The first element has Id 1, they are numbered consecutively.
2608 Id type; /* read only */
2609 $solutionelement->{type}
2610 solutionelement.type
2611 solutionelement.type
2613 Type of the solution element. See the constant section of the solver class for the
2616 Solvable *solvable; /* read only */
2617 $solutionelement->{solvable}
2618 solutionelement.solvable
2619 solutionelement.solvable
2621 The installed solvable that needs to be replaced for replacement elements.
2623 Solvable *replacement; /* read only */
2624 $solutionelement->{replacement}
2625 solutionelement.replacement
2626 solutionelement.replacement
2628 The solvable that needs to be installed to fix the problem.
2630 int jobidx; /* read only */
2631 $solutionelement->{jobidx}
2632 solutionelement.jobidx
2633 solutionelement.jobidx
2635 The index of the job that needs to be removed to fix the problem, or -1 if the
2636 element is of another type. Note that it's better to change the job to SOLVER_NOOP
2637 type so that the numbering of other elements does not get disturbed. This
2638 method works both for types SOLVER_SOLUTION_JOB and SOLVER_SOLUTION_POOLJOB.
2642 Solutionelement *replaceelements()
2643 my @solutionelements = $solutionelement->replaceelements();
2644 solutionelements = solutionelement.replaceelements()
2645 solutionelements = solutionelement.replaceelements()
2647 If the solution element is of type SOLVER_SOLUTION_REPLACE, return an array of
2648 elements describing the policy mismatches, otherwise return a copy of the
2649 element. See also the ``expandreplaces'' option in the solution's elements()
2652 int illegalreplace()
2653 my $illegal = $solutionelement->illegalreplace();
2654 illegal = solutionelement.illegalreplace()
2655 illegal = solutionelement.illegalreplace()
2657 Return an integer that contains the policy mismatch bits or-ed together, or
2658 zero if there was no policy mismatch. See the policy error constants in
2662 my $job = $solutionelement->Job();
2663 illegal = solutionelement.Job()
2664 illegal = solutionelement.Job()
2666 Create a job that implements the solution element. Add this job to the array
2667 of jobs for all elements of type different to SOLVER_SOLUTION_JOB and
2668 SOLVER_SOLUTION_POOLJOB. For the later two, a SOLVER_NOOB Job is created,
2669 you should replace the old job with the new one.
2672 my $str = $solutionelement->str();
2673 str = solutionelement.str()
2674 str = solutionelement.str()
2676 A string describing the change the solution element consists of.
2678 The Transaction Class
2679 ---------------------
2680 Transactions describe the output of a solver run. A transaction contains
2681 a number of transaction elements, each either the installation of a new
2682 package or the removal of an already installed package. The Transaction
2683 class supports a classify() method that puts the elements into different
2684 groups so that a transaction can be presented to the user in a meaningful
2689 Transaction element types, both active and passive
2691 *SOLVER_TRANSACTION_IGNORE*::
2692 This element does nothing. Used to map element types that do not match
2695 *SOLVER_TRANSACTION_INSTALL*::
2696 This element installs a package.
2698 *SOLVER_TRANSACTION_ERASE*::
2699 This element erases a package.
2701 *SOLVER_TRANSACTION_MULTIINSTALL*::
2702 This element installs a package with a different version keeping the other
2705 *SOLVER_TRANSACTION_MULTIREINSTALL*::
2706 This element reinstalls a installed package keeping the other versions
2709 Transaction element types, active view
2711 *SOLVER_TRANSACTION_REINSTALL*::
2712 This element re-installs a package, i.e. installs the same package again.
2714 *SOLVER_TRANSACTION_CHANGE*::
2715 This element installs a package with same name, version, architecture but
2718 *SOLVER_TRANSACTION_UPGRADE*::
2719 This element installs a newer version of an installed package.
2721 *SOLVER_TRANSACTION_DOWNGRADE*::
2722 This element installs a older version of an installed package.
2724 *SOLVER_TRANSACTION_OBSOLETES*::
2725 This element installs a package that obsoletes an installed package.
2727 Transaction element types, passive view
2729 *SOLVER_TRANSACTION_REINSTALLED*::
2730 This element re-installs a package, i.e. installs the same package again.
2732 *SOLVER_TRANSACTION_CHANGED*::
2733 This element replaces an installed package with one of the same name,
2734 version, architecture but different content.
2736 *SOLVER_TRANSACTION_UPGRADED*::
2737 This element replaces an installed package with a new version.
2739 *SOLVER_TRANSACTION_DOWNGRADED*::
2740 This element replaces an installed package with an old version.
2742 *SOLVER_TRANSACTION_OBSOLETED*::
2743 This element replaces an installed package with a package that obsoletes
2746 Pseudo element types for showing extra information used by classify()
2748 *SOLVER_TRANSACTION_ARCHCHANGE*::
2749 This element replaces an installed package with a package of a different
2752 *SOLVER_TRANSACTION_VENDORCHANGE*::
2753 This element replaces an installed package with a package of a different
2756 Transaction mode flags
2758 *SOLVER_TRANSACTION_SHOW_ACTIVE*::
2759 Filter for active view types. The default is to return passive view type,
2760 i.e. to show how the installed packages get changed.
2762 *SOLVER_TRANSACTION_SHOW_OBSOLETES*::
2763 Do not map the obsolete view type into INSTALL/ERASE elements.
2765 *SOLVER_TRANSACTION_SHOW_ALL*::
2766 If multiple packages replace an installed package, only the best of them
2767 is kept as OBSOLETE element, the other ones are mapped to INSTALL/ERASE
2768 elements. This is because most applications want to show just one package
2769 replacing the installed one. The SOLVER_TRANSACTION_SHOW_ALL makes the
2770 library keep all OBSOLETE elements.
2772 *SOLVER_TRANSACTION_SHOW_MULTIINSTALL*::
2773 The library maps MULTIINSTALL elements to simple INSTALL elements. This
2774 flag can be used to disable the mapping.
2776 *SOLVER_TRANSACTION_CHANGE_IS_REINSTALL*::
2777 Use this flag if you want to map CHANGE elements to the REINSTALL type.
2779 *SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE*::
2780 Use this flag if you want to map OBSOLETE elements to the UPGRADE type.
2782 *SOLVER_TRANSACTION_MERGE_ARCHCHANGES*::
2783 Do not add extra categories for every architecture change, instead cumulate
2784 them in one category.
2786 *SOLVER_TRANSACTION_MERGE_VENDORCHANGES*::
2787 Do not add extra categories for every vendor change, instead cumulate
2788 them in one category.
2790 *SOLVER_TRANSACTION_RPM_ONLY*::
2791 Special view mode that just returns IGNORE, ERASE, INSTALL, MULTIINSTALL
2792 elements. Useful if you want to find out what to feed to the underlying
2795 Transaction order flags
2797 *SOLVER_TRANSACTION_KEEP_ORDERDATA*::
2798 Do not throw away the dependency graph used for ordering the transaction.
2799 This flag is needed if you want to do manual ordering.
2803 Pool *pool; /* read only */
2808 Back pointer to pool.
2817 Returns true if the transaction does not do anything, i.e. has no elements.
2819 Solvable *newsolvables();
2820 my @newsolvables = $trans->newsolvables();
2821 newsolvables = trans.newsolvables()
2822 newsolvables = trans.newsolvables()
2824 Return all packages that are to be installed by the transaction. This are
2825 the packages that need to be downloaded from the repositories.
2827 Solvable *keptsolvables();
2828 my @keptsolvables = $trans->keptsolvables();
2829 keptsolvables = trans.keptsolvables()
2830 keptsolvables = trans.keptsolvables()
2832 Return all installed packages that the transaction will keep installed.
2835 my @steps = $trans->steps();
2836 steps = trans.steps()
2837 steps = trans.steps()
2839 Return all solvables that need to be installed (if the returned solvable
2840 is not already installed) or erased (if the returned solvable is installed).
2841 A step is also called a transaction element.
2843 int steptype(Solvable *solvable, int mode)
2844 my $type = $trans->steptype($solvable, $mode);
2845 type = trans.steptype(solvable, mode)
2846 type = trans.steptype(solvable, mode)
2848 Return the transaction type of the specified solvable. See the CONSTANTS
2849 sections for the mode argument flags and the list of returned types.
2851 TransactionClass *classify(int mode = 0)
2852 my @classes = $trans->classify();
2853 classes = trans.classify()
2854 classes = trans.classify()
2856 Group the transaction elements into classes so that they can be displayed
2857 in a structured way. You can use various mapping mode flags to tweak
2858 the result to match your preferences, see the mode argument flag in
2859 the CONSTANTS section. See the TransactionClass class for how to deal
2860 with the returned objects.
2862 Solvable othersolvable(Solvable *solvable);
2863 my $other = $trans->othersolvable($solvable);
2864 other = trans.othersolvable(solvable)
2865 other = trans.othersolvable(solvable)
2867 Return the ``other'' solvable for a given solvable. For installed packages
2868 the other solvable is the best package with the same name that replaces
2869 the installed package, or the best package of the obsoleting packages if
2870 the package does not get replaced by one with the same name.
2872 For to be installed packages, the ``other'' solvable is the best installed
2873 package with the same name that will be replaced, or the best packages
2874 of all the packages that are obsoleted if the new package does not replace
2875 a package with the same name.
2877 Thus, the ``other'' solvable is normally the package that is also shown
2878 for a given package.
2880 Solvable *allothersolvables(Solvable *solvable);
2881 my @others = $trans->allothersolvables($solvable);
2882 others = trans.allothersolvables(solvable)
2883 others = trans.allothersolvables(solvable)
2885 For installed packages, returns all of the packages that replace us. For to
2886 be installed packages, returns all of the packages that the new package
2887 replaces. The special ``other'' solvable is always the first entry of the
2890 int calc_installsizechange();
2891 my $change = $trans->calc_installsizechange();
2892 change = trans.calc_installsizechange()
2893 change = trans.calc_installsizechange()
2895 Return the size change of the installed system in kilobytes (kibibytes).
2897 void order(int flags = 0);
2902 Order the steps in the transactions so that dependant packages are updated
2903 before packages that depend on them. For rpm, you can also use rpmlib's
2904 ordering functionality, debian's dpkg does not provide a way to order a
2907 === ACTIVE/PASSIVE VIEW ===
2909 Active view list what new packages get installed, while passive view shows
2910 what happens to the installed packages. Most often there's not much
2911 difference between the two modes, but things get interesting of multiple
2912 package get replaced by one new package. Say you have installed package
2913 A-1-1 and B-1-1, and now install A-2-1 with has a new dependency that
2914 obsoletes B. The transaction elements will be
2916 updated A-1-1 (other: A-2-1)
2917 obsoleted B-1-1 (other: A-2-1)
2919 in passive mode, but
2921 update A-2-1 (other: A-1-1)
2924 in active mode. If the mode contains SOLVER_TRANSACTION_SHOW_ALL, the
2925 passive mode list will be unchanged but the active mode list will just
2928 The Transactionclass Class
2929 --------------------------
2930 Objects of this type are returned by the classify() Transaction method.
2934 Transaction *transaction; /* read only */
2935 $class->{transaction}
2939 Back pointer to transaction object.
2941 int type; /* read only */
2946 The type of the transaction elements in the class.
2948 int count; /* read only */
2953 The number of elements in the class.
2955 const char *fromstr;
2960 The old vendor or architecture.
2967 The new vendor or architecture.
2974 The id of the old vendor or architecture.
2981 The id of the new vendor or architecture.
2986 my @solvables = $class->solvables();
2987 solvables = class.solvables()
2988 solvables = class.solvables()
2990 Return the solvables for all transaction elements in the class.
2994 Checksums (also called hashes) are used to make sure that downloaded data is
2995 not corrupt and also as a fingerprint mechanism to check if data has changed.
2997 === CLASS METHODS ===
2999 Chksum Chksum(Id type)
3000 my $chksum = solv::Chksum->new($type);
3001 chksum = solv.Chksum(type)
3002 chksum = Solv::Chksum.new(type)
3004 Create a checksum object. Currently the following types are supported:
3010 These keys are constants in the *solv* class.
3012 Chksum Chksum(Id type, const char *hex)
3013 my $chksum = solv::Chksum->new($type, $hex);
3014 chksum = solv.Chksum(type, hex)
3015 chksum = Solv::Chksum.new(type, hex)
3017 Create an already finalized checksum object.
3021 Id type; /* read only */
3026 Return the type of the checksum object.
3030 void add(const char *str)
3035 Add a string to the checksum.
3037 void add_fp(FILE *fp)
3038 $chksum->add_fp($file);
3042 Add the contents of a file to the checksum.
3044 void add_stat(const char *filename)
3045 $chksum->add_stat($filename);
3046 chksum.add_stat(filename)
3047 chksum.add_stat(filename)
3049 Stat the file and add the dev/ino/size/mtime member to the checksum. If the
3050 stat fails, the members are zeroed.
3052 void add_fstat(int fd)
3053 $chksum->add_fstat($fd);
3054 chksum.add_fstat(fd)
3055 chksum.add_fstat(fd)
3057 Same as add_stat, but instead of the filename a file descriptor is used.
3059 unsigned char *raw()
3060 my $raw = $chksum->raw();
3064 Finalize the checksum and return the result as raw bytes. This means that the
3065 result can contain NUL bytes or unprintable characters.
3068 my $raw = $chksum->hex();
3072 Finalize the checksum and return the result as hex string.
3074 const char *typestr()
3075 my $typestr = $chksum->typestr();
3076 typestr = chksum.typestr
3077 typestr = chksum.typestr
3079 Return the type of the checksum as a string, e.g. "sha256".
3082 if ($chksum1 == $chksum2)
3083 if chksum1 == chksum2:
3084 if chksum1 == chksum2
3086 Checksums are equal if they are of the same type and the finalized results are
3090 my $str = $chksum->str;
3094 If the checksum is finished, the checksum is returned as "<type>:<hex>" string.
3095 Otherwise "<type>:unfinished" is returned.
3100 This functions were added because libsolv uses standard *FILE* pointers to
3101 read/write files, but languages like perl have their own implementation of
3102 files. The libsolv functions also support decompression and compression, the
3103 algorithm is selected by looking at the file name extension.
3105 FILE *xfopen(char *fn, char *mode = "r")
3106 my $file = solv::xfopen($path);
3107 file = solv.xfopen(path)
3108 file = Solv::xfopen(path)
3110 Open a file at the specified path. The `mode` argument is passed on to the
3113 FILE *xfopen_fd(char *fn, int fileno)
3114 my $file = solv::xfopen_fd($path, $fileno);
3115 file = solv.xfopen_fd(path, fileno)
3116 file = Solv::xfopen_fd(path, fileno)
3118 Create a file handle from the specified file descriptor. The path argument is
3119 only used to select the correct (de-)compression algorithm, use an empty path
3120 if you want to make sure to read/write raw data.
3125 my $fileno = $file->fileno();
3126 fileno = file.fileno()
3127 fileno = file.fileno()
3129 Return file file descriptor of the file. If the file is not open, `-1` is
3133 my $fileno = $file->dup();
3137 Return a copy of the descriptor of the file. If the file is not open, `-1` is
3145 Flush the file. Returns false if there was an error. Flushing a closed file
3146 always returns true.
3153 Close the file. This is needed for languages like Ruby, that do not destruct
3154 objects right after they are no longer referenced. In that case, it is good
3155 style to close open files so that the file descriptors are freed right away.
3156 Returns false if there was an error.
3161 The Repodata stores attributes for packages and the repository itself, each
3162 repository can have multiple repodata areas. You normally only need to
3163 directly access them if you implement lazy downloading of repository data.
3164 Repodata areas are created by calling the repository's add_repodata() method
3165 or by using repo_add methods without the REPO_REUSE_REPODATA or REPO_USE_LOADING
3170 Repo *repo; /* read only */
3175 Back pointer to repository object.
3177 Id id; /* read only */
3182 The id of the repodata area. Repodata ids of different repositories overlap.
3187 $data->internalize();
3191 Internalize newly added data. The lookup functions will only see the new data
3192 after it has been internalized.
3194 bool write(FILE *fp);
3199 Write the contents of the repodata area as solv file.
3201 bool add_solv(FILE *fp, int flags = 0);
3202 $data->add_solv($fp);
3206 Replace a stub repodata object with the data from a solv file. This method
3207 automatically adds the REPO_USE_LOADING flag. It should only be used from
3210 void create_stubs();
3211 $data->create_stubs()
3215 Create stub repodatas from the information stored in the repodata meta
3218 void extend_to_repo();
3219 $data->extend_to_repo();
3220 data.extend_to_repo()
3221 data.extend_to_repo()
3223 Extend the repodata so that it has the same size as the repo it belongs to.
3224 This method is only needed when switching to a just written repodata extension
3225 to make the repodata match the written extension (which is always of the
3229 if ($data1 == $data2)
3233 Two repodata objects are equal if they belong to the same repository and have
3236 === DATA RETRIEVAL METHODS ===
3238 const char *lookup_str(Id solvid, Id keyname)
3239 my $string = $data->lookup_str($solvid, $keyname);
3240 string = data.lookup_str(solvid, keyname)
3241 string = data.lookup_str(solvid, keyname)
3243 Id *lookup_idarray(Id solvid, Id keyname)
3244 my @ids = $data->lookup_idarray($solvid, $keyname);
3245 ids = data.lookup_idarray(solvid, keyname)
3246 ids = data.lookup_idarray(solvid, keyname)
3248 Chksum lookup_checksum(Id solvid, Id keyname)
3249 my $chksum = $data->lookup_checksum($solvid, $keyname);
3250 chksum = data.lookup_checksum(solvid, keyname)
3251 chksum = data.lookup_checksum(solvid, keyname)
3253 Lookup functions. Return the data element stored in the specified solvable.
3254 The methods probably only make sense to retrieve data from the special
3255 SOLVID_META solvid that stores repodata meta information.
3257 === DATA STORAGE METHODS ===
3259 void set_id(Id solvid, Id keyname, DepId id);
3260 $data->set_id($solvid, $keyname, $id);
3261 data.set_id(solvid, keyname, id)
3262 data.set_id(solvid, keyname, id)
3264 void set_str(Id solvid, Id keyname, const char *str);
3265 $data->set_str($solvid, $keyname, $str);
3266 data.set_str(solvid, keyname, str)
3267 data.set_str(solvid, keyname, str)
3269 void set_poolstr(Id solvid, Id keyname, const char *str);
3270 $data->set_poolstr($solvid, $keyname, $str);
3271 data.set_poolstr(solvid, keyname, str)
3272 data.set_poolstr(solvid, keyname, str)
3274 void set_checksum(Id solvid, Id keyname, Chksum *chksum);
3275 $data->set_checksum($solvid, $keyname, $chksum);
3276 data.set_checksum(solvid, keyname, chksum)
3277 data.set_checksum(solvid, keyname, chksum)
3279 void add_idarray(Id solvid, Id keyname, DepId id);
3280 $data->add_idarray($solvid, $keyname, $id);
3281 data.add_idarray(solvid, keyname, id)
3282 data.add_idarray(solvid, keyname, id)
3285 my $handle = $data->new_handle();
3286 handle = data.new_handle()
3287 handle = data.new_handle()
3289 void add_flexarray(Id solvid, Id keyname, Id handle);
3290 $data->add_flexarray($solvid, $keyname, $handle);
3291 data.add_flexarray(solvid, keyname, handle)
3292 data.add_flexarray(solvid, keyname, handle)
3294 Data storage methods. Probably only useful to store data in the special
3295 SOLVID_META solvid that stores repodata meta information. Note that
3296 repodata areas can have their own Id pool (see the REPO_LOCALPOOL flag),
3297 so be careful if you need to store ids. Arrays are created by calling
3298 the add function for every element. A flexarray is an array of
3299 sub-structures, call new_handle to create a new structure, use the
3300 handle as solvid to fill the structure with data and call add_flexarray
3301 to put the structure in an array.
3306 Datapos objects describe a specific position in the repository data area.
3307 Thus they are only valid until the repository is modified in some way.
3308 Datapos objects can be created by the pos() and parentpos() methods of
3309 a Datamatch object or by accessing the ``meta'' attribute of a repository.
3313 Repo *repo; /* read only */
3318 Back pointer to repository object.
3322 Dataiterator(Id keyname, const char *match, int flags)
3323 my $di = $datapos->Dataiterator($keyname, $match, $flags);
3324 di = datapos.Dataiterator(keyname, match, flags)
3325 di = datapos.Dataiterator(keyname, match, flags)
3327 Create a Dataiterator at the position of the datapos object.
3329 const char *lookup_deltalocation(unsigned int *OUTPUT);
3330 my ($location, $medianr) = $datapos->lookup_deltalocation();
3331 location, medianr = datapos.lookup_deltalocation()
3332 location, medianr = datapos.lookup_deltalocation()
3334 Return a tuple containing the on-media location and an optional media number
3335 for a delta rpm. This obviously only works if the data position points to
3336 structure describing a delta rpm.
3338 const char *lookup_deltaseq();
3339 my $seq = $datapos->lookup_deltaseq();
3340 seq = datapos.lookup_deltaseq();
3341 seq = datapos.lookup_deltaseq();
3343 Return the delta rpm sequence from the structure describing a delta rpm.
3345 === DATA RETRIEVAL METHODS ===
3347 const char *lookup_str(Id keyname)
3348 my $string = $datapos->lookup_str($keyname);
3349 string = datapos.lookup_str(keyname)
3350 string = datapos.lookup_str(keyname)
3352 Id lookup_id(Id solvid, Id keyname)
3353 my $id = $datapos->lookup_id($keyname);
3354 id = datapos.lookup_id(keyname)
3355 id = datapos.lookup_id(keyname)
3357 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0)
3358 my $num = $datapos->lookup_num($keyname);
3359 num = datapos.lookup_num(keyname)
3360 num = datapos.lookup_num(keyname)
3362 bool lookup_void(Id keyname)
3363 my $bool = $datapos->lookup_void($keyname);
3364 bool = datapos.lookup_void(keyname)
3365 bool = datapos.lookup_void(keyname)
3367 Id *lookup_idarray(Id keyname)
3368 my @ids = $datapos->lookup_idarray($keyname);
3369 ids = datapos.lookup_idarray(keyname)
3370 ids = datapos.lookup_idarray(keyname)
3372 Chksum lookup_checksum(Id keyname)
3373 my $chksum = $datapos->lookup_checksum($keyname);
3374 chksum = datapos.lookup_checksum(keyname)
3375 chksum = datapos.lookup_checksum(keyname)
3377 Lookup functions. Note that the returned Ids are always translated into
3378 the Ids of the global pool even if the repodata area contains its own pool.
3380 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
3381 my $di = $datapos->Dataiterator($keyname, $match, $flags);
3382 di = datapos.Dataiterator(keyname, match, flags)
3383 di = datapos.Dataiterator(keyname, match, flags)
3389 Iterate over the matching data elements. See the Dataiterator class for more
3394 Michael Schroeder <mls@suse.de>