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, ruby and
16 tcl. All example code (except in the specifics sections, of course) lists
17 first the ``C-ish'' interface, then the syntax for perl, python, and ruby
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 perl 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 corresponding 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" if repo.isempty?
146 Libsolv's tcl bindings can be loaded with the following statement:
148 TCL package require solv
150 Objects are either created by calling class name prefixed with ``new_'',
151 or they are returned by calling methods on other objects.
153 TCL set pool [solv::new_Pool]
154 TCL set repo [$pool add_repo "my_first_repo"]
156 Swig provides a ``cget'' method to read object attributes, and a
157 ``configure'' method to write them:
159 TCL $pool configure -appdata 42
160 TCL puts "appdata is [$pool cget -appdata]"
162 The tcl bindings provide a little helper to work with iterators in
165 TCL set iter [$pool solvables_iter]
166 TCL solv::iter s $iter { ... }
168 libsolv's arrays are mapped to tcl's lists:
170 TCL set jobs [list $job1 $job2]
171 TCL set problems [$solver solve $jobs]
172 TCL puts "We have [llength $problems] problems..."
174 Stringification is done by calling the object's ``str'' method.
178 There is one exception: you have to use ``stringify'' for Datamatch
179 objects, as swig reports a clash with the ``str'' attribute.
180 Some objects also support a ``=='' method for equality tests, and a
183 Swig implements all constants as numeric variables, constants belonging
184 to a libsolv class are prefixed with the class name:
186 TCL $pool set_flag $solv::Pool_POOL_FLAG_OBSOLETEUSESCOLORS 1
187 TCL puts [$solvable lookup_str $solv::SOLVABLE_SUMMARY]
192 This is the main namespace of the library, you cannot create objects of this
193 type but it contains some useful constants.
197 Relational flag constants, the first three can be or-ed together
200 the ``less than'' bit
203 the ``equals to'' bit
206 the ``greater than'' bit
209 used for relations that describe an extra architecture filter, the
210 version part of the relation is interpreted as architecture.
215 Access the meta section of a repository or repodata area. This is
216 like an extra Solvable that has the Id SOLVID_META.
219 Use the data position stored inside of the pool instead of accessing
220 some solvable by Id. The bindings have the Datapos objects as an
221 abstraction mechanism, so you most likely do not need this constant.
229 Always one, describes the empty string
232 The keyname Id of the name of the solvable.
235 see the libsolv-constantids manpage for a list of fixed Ids.
240 The pool is libsolv's central resource manager. A pool consists of Solvables,
241 Repositories, Dependencies, each indexed by Ids.
243 === CLASS METHODS ===
246 my $pool = solv::Pool->new();
248 pool = Solv::Pool.new()
250 Create a new pool instance. In most cases you just need one pool.
251 Note that the returned object "owns" the pool, i.e. if the object is
252 freed, the pool is also freed. You can use the disown method to
253 break this ownership relation.
257 void *appdata; /* read/write */
262 Application specific data that may be used in any way by the code using the
265 Solvable solvables[]; /* read only */
266 my $solvable = $pool->{solvables}->[$solvid];
267 solvable = pool.solvables[solvid]
268 solvable = pool.solvables[solvid]
270 Look up a Solvable by its id.
272 Repo repos[]; /* read only */
273 my $repo = $pool->{repos}->[$repoid];
274 repo = pool.repos[repoid]
275 repo = pool.repos[repoid]
277 Look up a Repository by its id.
279 Repo *installed; /* read/write */
280 $pool->{installed} = $repo;
281 pool.installed = repo
282 pool.installed = repo
284 Define which repository contains all the installed packages.
286 const char *errstr; /* read only */
287 my $err = $pool->{errstr};
291 Return the last error string that was stored in the pool.
295 *POOL_FLAG_PROMOTEEPOCH*::
296 Promote the epoch of the providing dependency to the requesting
297 dependency if it does not contain an epoch. Used at some time
298 in old rpm versions, modern systems should never need this.
300 *POOL_FLAG_FORBIDSELFCONFLICTS*::
301 Disallow the installation of packages that conflict with themselves.
302 Debian always allows self-conflicting packages, rpm used to forbid
303 them but switched to also allowing them since rpm-4.9.0.
305 *POOL_FLAG_OBSOLETEUSESPROVIDES*::
306 Make obsolete type dependency match against provides instead of
307 just the name and version of packages. Very old versions of rpm
308 used the name/version, then it got switched to provides and later
309 switched back again to just name/version.
311 *POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES*::
312 An implicit obsoletes is the internal mechanism to remove the
313 old package on an update. The default is to remove all packages
314 with the same name, rpm-5 switched to also removing packages
315 providing the same name.
317 *POOL_FLAG_OBSOLETEUSESCOLORS*::
318 Rpm's multilib implementation distinguishes between 32bit and 64bit
319 packages (the terminology is that they have a different color).
320 If obsoleteusescolors is set, packages with different colors will
321 not obsolete each other.
323 *POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS*::
324 Same as POOL_FLAG_OBSOLETEUSESCOLORS, but used to find out if
325 packages of the same name can be installed in parallel. For
326 current Fedora systems, POOL_FLAG_OBSOLETEUSESCOLORS should be
327 false and POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS should be true
328 (this is the default if FEDORA is defined when libsolv is compiled).
330 *POOL_FLAG_NOINSTALLEDOBSOLETES*::
331 Since version 4.9.0 rpm considers the obsoletes of installed packages
332 when checking for dependency conflicts, thus you may not install a
333 package that is obsoleted by some other installed package unless you
334 also erase the other package.
336 *POOL_FLAG_HAVEDISTEPOCH*::
337 Mandriva added a new field called distepoch that gets checked in
338 version comparison if the epoch/version/release of two packages
341 *POOL_FLAG_NOOBSOLETESMULTIVERSION*::
342 If a package is installed in multiversion mode, rpm used to ignore
343 both the implicit obsoletes and the obsolete dependency of a
344 package. This was changed to ignoring just the implicit obsoletes,
345 thus you may install multiple versions of the same name, but
346 obsoleted packages still get removed.
348 *POOL_FLAG_ADDFILEPROVIDESFILTERED*::
349 Make the addfileprovides method only add files from the standard
350 locations (i.e. the ``bin'' and ``etc'' directories). This is
351 useful if you have only few packages that use non-standard file
352 dependencies, but you still want the fast speed that addfileprovides()
355 *POOL_FLAG_NOWHATPROVIDESAUX*::
356 Disable the creation of the auxillary whatprovides index. This saves
357 a bit of memory but also makes the whatprovides lookups a bit slower.
359 *POOL_FLAG_WHATPROVIDESWITHDISABLED*::
360 Make the whatprovides index also contain disabled packages. This
361 means that you do not need to recreate the index if a package is
362 enabled/disabled, i.e. the pool->considered bitmap is changed.
371 Force a free of the pool. After this call, you must not access any object
372 that still references the pool.
379 Break the ownership relation between the binding object and the pool. After
380 this call, the pool will not get freed even if the object goes out of
381 scope. This also means that you must manually call the free method to free
384 void setdebuglevel(int level)
385 $pool->setdebuglevel($level);
386 pool.setdebuglevel(level)
387 pool.setdebuglevel(level)
389 Set the debug level. A value of zero means no debug output, the higher the
390 value, the more output is generated.
392 int set_flag(int flag, int value)
393 my $oldvalue = $pool->set_flag($flag, $value);
394 oldvalue = pool.set_flag(flag, value)
395 oldvalue = pool.set_flag(flag, value)
397 int get_flag(int flag)
398 my $value = $pool->get_flag($flag);
399 value = pool.get_flag(flag)
400 value = pool.get_flag(flag)
402 Set/get a pool specific flag. The flags define how the system works, e.g. how
403 the package manager treats obsoletes. The default flags should be sane for most
404 applications, but in some cases you may want to tweak a flag, for example if
405 you want to solve package dependencies for some other system.
407 void set_rootdir(const char *rootdir)
408 $pool->set_rootdir(rootdir);
409 pool.set_rootdir(rootdir)
410 pool.set_rootdir(rootdir)
412 const char *get_rootdir()
413 my $rootdir = $pool->get_rootdir();
414 rootdir = pool.get_rootdir()
415 rootdir = pool.get_rootdir()
417 Set/get the rootdir to use. This is useful if you want package management
418 to work only in some directory, for example if you want to setup a chroot
419 jail. Note that the rootdir will only be prepended to file paths if the
420 *REPO_USE_ROOTDIR* flag is used.
422 void setarch(const char *arch = 0)
427 Set the architecture for your system. The architecture is used to determine
428 which packages are installable. It defaults to the result of ``uname -m''.
430 Repo add_repo(const char *name)
431 $repo = $pool->add_repo($name);
432 repo = pool.add_repo(name)
433 repo = pool.add_repo(name)
435 Add a Repository with the specified name to the pool. The repository is empty
436 on creation, use the repository methods to populate it with packages.
438 Repoiterator repos_iter()
439 for my $repo (@{$pool->repos_iter()})
440 for repo in pool.repos_iter():
441 for repo in pool.repos_iter()
443 Iterate over the existing repositories.
445 Solvableiterator solvables_iter()
446 for my $solvable (@{$pool->solvables_iter()})
447 for solvable in pool.solvables_iter():
448 for solvable in pool.solvables_iter()
450 Iterate over the existing solvables.
452 Dep Dep(const char *str, bool create = 1)
453 my $dep = $pool->Dep($string);
454 dep = pool.Dep(string)
455 dep = pool.Dep(string)
457 Create an object describing a string or dependency. If the string is currently
458 not in the pool and _create_ is false, *undef*/*None*/*nil* is returned.
460 void addfileprovides()
461 $pool->addfileprovides();
462 pool.addfileprovides()
463 pool.addfileprovides()
465 Id *addfileprovides_queue()
466 my @ids = $pool->addfileprovides_queue();
467 ids = pool.addfileprovides_queue()
468 ids = pool.addfileprovides_queue()
470 Some package managers like rpm allow dependencies on files contained in other
471 packages. To allow libsolv to deal with those dependencies in an efficient way,
472 you need to call the addfileprovides method after creating and reading all
473 repositories. This method will scan all dependency for file names and then scan
474 all packages for matching files. If a filename has been matched, it will be
475 added to the provides list of the corresponding package. The
476 addfileprovides_queue variant works the same way but returns an array
477 containing all file dependencies. This information can be stored in the
478 meta section of the repositories to speed up the next time the
479 repository is loaded and addfileprovides is called.
481 void createwhatprovides()
482 $pool->createwhatprovides();
483 pool.createwhatprovides()
484 pool.createwhatprovides()
486 Create the internal ``whatprovides'' hash over all of the provides of all
487 installable packages. This method must be called before doing any lookups on
489 It's encouraged to do it right after all repos are set up, usually right after
490 the call to addfileprovides().
492 Solvable *whatprovides(DepId dep)
493 my @solvables = $pool->whatprovides($dep);
494 solvables = pool.whatprovides(dep)
495 solvables = pool.whatprovides(dep)
497 Return all solvables that provide the specified dependency. You can use either
498 a Dep object or a simple Id as argument.
500 Solvable *best_solvables(Solvable *solvables, int flags = 0)
501 my @solvables = $pool->best_solvables($solvables);
502 solvables = pool.best_solvables(solvables)
503 solvables = pool.best_solvables(solvables)
505 Filter list of solvables by repo priority, architecture and version.
507 Solvable *whatcontainsdep(Id keyname, DepId dep, Id marker = -1)
508 my @solvables = $pool->whatcontainsdep($keyname, $dep);
509 solvables = pool.whatcontainsdep(keyname, dep)
510 solvables = pool.whatcontainsdep(keyname, dep)
512 Return all solvables for which keyname contains the dependency.
514 Solvable *whatmatchesdep(Id keyname, DepId dep, Id marker = -1)
515 my @solvables = $pool->whatmatchesdep($keyname, $sdep);
516 solvables = pool.whatmatchesdep(keyname, dep)
517 solvables = pool.whatmatchesdep(keyname, dep)
519 Return all solvables that have dependencies in keyname that match the dependency.
521 Solvable *whatmatchessolvable(Id keyname, Solvable solvable, Id marker = -1)
522 my @solvables = $pool->whatmatchessolvable($keyname, $solvable);
523 solvables = pool.whatmatchessolvable(keyname, solvable)
524 solvables = pool.whatmatchessolvable(keyname, solvable)
526 Return all solvables that match package dependencies against solvable's
529 Id *matchprovidingids(const char *match, int flags)
530 my @ids = $pool->matchprovidingids($match, $flags);
531 ids = pool.matchprovidingids(match, flags)
532 ids = pool.matchprovidingids(match, flags)
534 Search the names of all provides and return the ones matching the specified
535 string. See the Dataiterator class for the allowed flags.
537 Id towhatprovides(Id *ids)
538 my $offset = $pool->towhatprovides(\@ids);
539 offset = pool.towhatprovides(ids)
540 offset = pool.towhatprovides(ids)
542 ``Internalize'' an array containing Ids. The returned value can be used to
543 create solver jobs working on a specific set of packages. See the Solver class
544 for more information.
546 void set_namespaceproviders(DepId ns, DepId evr, bool value = 1)
547 $pool->set_namespaceproviders($ns, $evr, 1);
548 pool.set_namespaceproviders(ns, evr, True)
549 pool.set_namespaceproviders(ns, evr, true)
551 Manually set a namespace provides entry in the whatprovides index.
553 void flush_namespaceproviders(DepId ns, DepId evr)
554 $pool->flush_namespaceproviders($ns, $evr);
555 $pool.flush_namespaceproviders(ns, evr)
556 $pool.flush_namespaceproviders(ns, evr)
558 Flush the cache of all namespaceprovides matching the specified namespace
559 dependency. You can use zero as a wildcard argument.
561 bool isknownarch(DepId id)
562 my $bool = $pool->isknownarch($id);
563 bool = pool.isknownarch(id)
564 bool = pool.isknownarch?(id)
566 Return true if the specified Id describes a known architecture.
569 my $solver = $pool->Solver();
570 solver = pool.Solver()
571 solver = pool.Solver()
573 Create a new solver object.
575 Job Job(int how, Id what)
576 my $job = $pool->Job($how, $what);
577 job = pool.Job(how, what)
578 job = pool.Job(how, what)
580 Create a new Job object. Kind of low level, in most cases you would
581 instead use a Selection or Dep job constructor.
583 Selection Selection()
584 my $sel = $pool->Selection();
585 sel = pool.Selection()
586 sel = pool.Selection()
588 Create an empty selection. Useful as a starting point for merging other
591 Selection Selection_all()
592 my $sel = $pool->Selection_all();
593 sel = pool.Selection_all()
594 sel = pool.Selection_all()
596 Create a selection containing all packages. Useful as starting point for
597 intersecting other selections or for update/distupgrade jobs.
599 Selection select(const char *name, int flags)
600 my $sel = $pool->select($name, $flags);
601 sel = pool.select(name, flags)
602 sel = pool.select(name, flags)
604 Create a selection by matching packages against the specified string. See the
605 Selection class for a list of flags and how to create solver jobs from a
608 Selection matchdeps(const char *name, int flags, Id keyname, Id marker = -1)
609 my $sel = $pool->matchdeps($name, $flags, $keyname);
610 sel = pool.matchdeps(name, flags, keyname)
611 sel = pool.matchdeps(name, flags, keyname)
613 Create a selection by matching package dependencies against the specified string.
614 This can be used if you want to match other dependency types than ``provides''.
616 Selection matchdepid(DepId dep, int flags, Id keyname, Id marker = -1)
617 my $sel = $pool->matchdepid($dep, $flags, $keyname);
618 sel = pool.matchdepid(dep, flags, keyname)
619 sel = pool.matchdepid(dep, flags, keyname)
621 Create a selection by matching package dependencies against the specified
622 dependency. This may be faster than matchdeps and also works with complex
623 dependencies. The downside is that you cannot use globs or case insensitive
626 Selection matchsolvable(Solvable solvable, int flags, Id keyname, Id marker = -1)
627 my $sel = $pool->matchsolvable($solvable, $flags, $keyname);
628 sel = pool.matchsolvable(solvable, flags, keyname)
629 sel = pool.matchsolvable(solvable, flags, keyname)
631 Create a selection by matching package dependencies against the specified
634 void setpooljobs(Jobs *jobs)
635 $pool->setpooljobs(\@jobs);
636 pool.setpooljobs(jobs)
637 pool.setpooljobs(jobs)
640 @jobs = $pool->getpooljobs();
641 jobs = pool.getpooljobs()
642 jobs = pool.getpooljobs()
644 Get/Set fixed jobs stored in the pool. Those jobs are automatically appended to
645 all solver jobs, they are meant for fixed configurations like which packages
646 can be multiversion installed, which packages were userinstalled, or which
647 packages must not be erased.
649 void set_loadcallback(Callable *callback)
650 $pool->setloadcallback(\&callbackfunction);
651 pool.setloadcallback(callbackfunction)
652 pool.setloadcallback { |repodata| ... }
654 Set the callback function called when repository metadata needs to be loaded on
655 demand. To make use of this feature, you need to create repodata stubs that
656 tell the library which data is available but not loaded. If later on the data
657 needs to be accessed, the callback function is called with a repodata argument.
658 You can then load the data (maybe fetching it first from a remote server).
659 The callback should return true if the data has been made available.
662 $pool->appdata_disown()
663 pool.appdata_disown()
664 pool.appdata_disown()
666 Decrement the reference count of the appdata object. This can be used to break
667 circular references (e.g. if the pool's appdata value points to some meta data
668 structure that contains a pool handle). If used incorrectly, this method can
669 lead to application crashes, so beware. (This method is a no-op for ruby and tcl.)
671 Id *get_considered_list()
672 my @ids = $pool->get_considered_list();
673 ids = pool.get_considered_list()
674 ids = pool.get_considered_list()
676 void set_considered_list(Id *ids)
677 $pool->set_considered_list(\@ids);
678 pool.set_considered_list(ids)
679 pool.set_considered_list(ids)
681 Get/set the list of solvables that are eligible for installation. Note that
682 you need to recreate the whatprovides hash after changing the list.
684 Id *get_disabled_list()
685 my @ids = $pool->get_disabled_list();
686 ids = pool.get_disabled_list()
687 ids = pool.get_disabled_list()
689 void set_disabled_list(Id *ids)
690 $pool->set_disabled_list(\@ids);
691 pool.set_disabled_list(ids)
692 pool.set_disabled_list(ids)
694 Get/set the list of solvables that are not eligible for installation. This is
695 basically the inverse of the ``considered'' methods above, i.e. calling
696 ``set_disabled_list()'' with an empty list will make all solvables eligible for
697 installation. Note you need to recreate the whatprovides hash after changing the
700 const char *solvableset2str(Solvable *solvables)
701 my $str = $pool->solvableset2str($solvables);
702 str = pool.solvableset2str(solvables)
703 str = pool.solvableset2str(solvables)
705 Return a string describing a list of solvables. The method tries to reduce
706 the output by using version ranges if possible.
708 === DATA RETRIEVAL METHODS ===
710 In the following functions, the _keyname_ argument describes what to retrieve.
711 For the standard cases you can use the available Id constants. For example,
713 $solv::SOLVABLE_SUMMARY
714 solv.SOLVABLE_SUMMARY
715 Solv::SOLVABLE_SUMMARY
717 selects the ``Summary'' entry of a solvable. The _solvid_ argument selects the
718 desired solvable by Id.
720 const char *lookup_str(Id solvid, Id keyname)
721 my $string = $pool->lookup_str($solvid, $keyname);
722 string = pool.lookup_str(solvid, keyname)
723 string = pool.lookup_str(solvid, keyname)
725 Id lookup_id(Id solvid, Id keyname)
726 my $id = $pool->lookup_id($solvid, $keyname);
727 id = pool.lookup_id(solvid, keyname)
728 id = pool.lookup_id(solvid, keyname)
730 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
731 my $num = $pool->lookup_num($solvid, $keyname);
732 num = pool.lookup_num(solvid, keyname)
733 num = pool.lookup_num(solvid, keyname)
735 bool lookup_void(Id solvid, Id keyname)
736 my $bool = $pool->lookup_void($solvid, $keyname);
737 bool = pool.lookup_void(solvid, keyname)
738 bool = pool.lookup_void(solvid, keyname)
740 Id *lookup_idarray(Id solvid, Id keyname)
741 my @ids = $pool->lookup_idarray($solvid, $keyname);
742 ids = pool.lookup_idarray(solvid, keyname)
743 ids = pool.lookup_idarray(solvid, keyname)
745 Chksum lookup_checksum(Id solvid, Id keyname)
746 my $chksum = $pool->lookup_checksum($solvid, $keyname);
747 chksum = pool.lookup_checksum(solvid, keyname)
748 chksum = pool.lookup_checksum(solvid, keyname)
750 Lookup functions. Return the data element stored in the specified solvable.
751 You should probably use the methods of the Solvable class instead.
753 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
754 my $di = $pool->Dataiterator($keyname, $match, $flags);
755 di = pool.Dataiterator(keyname, match, flags)
756 di = pool.Dataiterator(keyname, match, flags)
758 Dataiterator Dataiterator_solvid(Id solvid, Id keyname, const char *match = 0, int flags = 0)
759 my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags);
760 di = pool.Dataiterator(solvid, keyname, match, flags)
761 di = pool.Dataiterator(solvid, keyname, match, flags)
767 Iterate over the matching data elements. See the Dataiterator class for more
768 information. The Dataiterator method iterates over all solvables in the pool,
769 whereas the Dataiterator_solvid only iterates over the specified solvable.
773 The following methods deal with Ids, i.e. integers representing objects in the
774 pool. They are considered ``low level'', in most cases you would not use them
775 but instead the object orientated methods.
778 $repo = $pool->id2repo($id);
779 repo = pool.id2repo(id)
780 repo = pool.id2repo(id)
782 Lookup an existing Repository by id. You can also do this by using the *repos*
785 Solvable id2solvable(Id id)
786 $solvable = $pool->id2solvable($id);
787 solvable = pool.id2solvable(id)
788 solvable = pool.id2solvable(id)
790 Lookup an existing Repository by id. You can also do this by using the
791 *solvables* attribute.
793 const char *solvid2str(Id id)
794 my $str = $pool->solvid2str($id);
795 str = pool.solvid2str(id)
796 str = pool.solvid2str(id)
798 Return a string describing the Solvable with the specified id. The string
799 consists of the name, version, and architecture of the Solvable.
801 const char *solvidset2str(Id *solvids)
802 my $str = $pool->solvidset2str(\@solvids);
803 str = pool.solvidset2str(solvids)
804 str = pool.solvidset2str(solvids)
806 Return a string describing a list of solvables. The method tries to reduce
807 the output by using version ranges if possible.
809 Id str2id(const char *str, bool create = 1)
810 my $id = pool->str2id($string);
811 id = pool.str2id(string)
812 id = pool.str2id(string)
814 const char *id2str(Id id)
815 $string = pool->id2str($id);
816 string = pool.id2str(id)
817 string = pool.id2str(id)
819 Convert a string into an Id and back. If the string is currently not in the
820 pool and _create_ is false, zero is returned.
822 Id rel2id(Id name, Id evr, int flags, bool create = 1)
823 my $id = pool->rel2id($nameid, $evrid, $flags);
824 id = pool.rel2id(nameid, evrid, flags)
825 id = pool.rel2id(nameid, evrid, flags)
827 Create a ``relational'' dependency. Such dependencies consist of a name part,
828 _flags_ describing the relation, and a version part. The flags are:
830 $solv::REL_EQ | $solv::REL_GT | $solv::REL_LT
831 solv.REL_EQ | solv.REL_GT | solv.REL_LT
832 Solv::REL_EQ | Solv::REL_GT | Solv::REL_LT
834 Thus, if you want a ``\<='' relation, you would use *REL_LT | REL_EQ*.
836 Id id2langid(Id id, const char *lang, bool create = 1)
837 my $id = $pool->id2langid($id, $language);
838 id = pool.id2langid(id, language)
839 id = pool.id2langid(id, language)
841 Create a language specific Id from some other id. This function simply converts
842 the id into a string, appends a dot and the specified language to the string
843 and converts the result back into an Id.
845 const char *dep2str(Id id)
846 $string = pool->dep2str($id);
847 string = pool.dep2str(id)
848 string = pool.dep2str(id)
850 Convert a dependency id into a string. If the id is just a string, this
851 function has the same effect as id2str(). For relational dependencies, the
852 result is the correct ``name relation evr'' string.
857 The dependency class is an object orientated way to work with strings and
858 dependencies. Internally, dependencies are represented as Ids, i.e. simple
859 numbers. Dependency objects can be constructed by using the Pool's Dep()
864 Pool *pool; /* read only */
869 Back reference to the pool this dependency belongs to.
871 Id id; /* read only */
876 The id of this dependency.
880 Dep Rel(int flags, DepId evrid, bool create = 1)
881 my $reldep = $dep->Rel($flags, $evrdep);
882 reldep = dep.Rel(flags, evrdep)
883 reldep = dep.Rel(flags, evrdep)
885 Create a relational dependency from the caller dependency, the flags,
886 and a dependency describing the ``version'' part.
887 See the pool's rel2id method for a description of the flags.
889 Selection Selection_name(int setflags = 0)
890 my $sel = $dep->Selection_name();
891 sel = dep.Selection_name()
892 sel = dep.Selection_name()
894 Create a Selection from a dependency. The selection consists of all packages
895 that have a name equal to the dependency. If the dependency is of a relational
896 type, the packages version must also fulfill the dependency.
898 Selection Selection_provides(int setflags = 0)
899 my $sel = $dep->Selection_provides();
900 sel = dep.Selection_provides()
901 sel = dep.Selection_provides()
903 Create a Selection from a dependency. The selection consists of all packages
904 that have at least one provides matching the dependency.
907 my $str = $dep->str();
911 Return a string describing the dependency.
918 Same as calling the str() method.
925 Two dependencies are equal if they are part of the same pool and have the same
931 A Repository describes a group of packages, normally coming from the same
932 source. Repositories are created by the Pool's add_repo() method.
936 Pool *pool; /* read only */
941 Back reference to the pool this dependency belongs to.
943 Id id; /* read only */
948 The id of the repository.
950 const char *name; /* read/write */
955 The repositories name. To libsolv, the name is just a string with no specific
958 int priority; /* read/write */
963 The priority of the repository. A higher number means that packages of this
964 repository will be chosen over other repositories, even if they have a greater
967 int subpriority; /* read/write */
972 The sub-priority of the repository. This value is compared when the priorities
973 of two repositories are the same. It is useful to make the library prefer
974 on-disk repositories to remote ones.
976 int nsolvables; /* read only */
981 The number of solvables in this repository.
983 void *appdata; /* read/write */
988 Application specific data that may be used in any way by the code using the
991 Datapos *meta; /* read only */
996 Return a Datapos object of the repodata's metadata. You can use the lookup
997 methods of the Datapos class to lookup metadata attributes, like the repository
1002 *REPO_REUSE_REPODATA*::
1003 Reuse the last repository data area (``repodata'') instead of creating a
1006 *REPO_NO_INTERNALIZE*::
1007 Do not internalize the added repository data. This is useful if
1008 you plan to add more data because internalization is a costly
1012 Use the repodata's pool for Id storage instead of the global pool. Useful
1013 if you don't want to pollute the global pool with many unneeded ids, like
1014 when storing the filelist.
1016 *REPO_USE_LOADING*::
1017 Use the repodata that is currently being loaded instead of creating a new
1018 one. This only makes sense if used in a load callback.
1020 *REPO_EXTEND_SOLVABLES*::
1021 Do not create new solvables for the new data, but match existing solvables
1022 and add the data to them. Repository metadata is often split into multiple
1023 parts, with one primary file describing all packages and other parts
1024 holding information that is normally not needed, like the changelog.
1026 *REPO_USE_ROOTDIR*::
1027 Prepend the pool's rootdir to the path when doing file operations.
1029 *REPO_NO_LOCATION*::
1030 Do not add a location element to the solvables. Useful if the solvables
1031 are not in the final position, so you can add the correct location later
1034 *SOLV_ADD_NO_STUBS*::
1035 Do not create stubs for repository parts that can be downloaded on demand.
1037 *SUSETAGS_RECORD_SHARES*::
1038 This is specific to the add_susetags() method. Susetags allows one to refer to
1039 already read packages to save disk space. If this data sharing needs to
1040 work over multiple calls to add_susetags, you need to specify this flag so
1041 that the share information is made available to subsequent calls.
1045 void free(bool reuseids = 0)
1050 Free the repository and all solvables it contains. If _reuseids_ is set to
1051 true, the solvable ids and the repository id may be reused by the library when
1052 added new solvables. Thus you should leave it false if you are not sure that
1053 somebody holds a reference.
1055 void empty(bool reuseids = 0)
1060 Free all the solvables in a repository. The repository will be empty after this
1061 call. See the free() method for the meaning of _reuseids_.
1068 Return true if there are no solvables in this repository.
1071 $repo->internalize();
1075 Internalize added data. Data must be internalized before it is available to the
1076 lookup and data iterator functions.
1078 bool write(FILE *fp)
1083 Write a repo as a ``solv'' file. These files can be read very fast and thus are
1084 a good way to cache repository data. Returns false if there was some error
1087 Solvableiterator solvables_iter()
1088 for my $solvable (@{$repo->solvables_iter()})
1089 for solvable in repo.solvables_iter():
1090 for solvable in repo.solvables_iter()
1092 Iterate over all solvables in a repository.
1094 Repodata add_repodata(int flags = 0)
1095 my $repodata = $repo->add_repodata();
1096 repodata = repo.add_repodata()
1097 repodata = repo.add_repodata()
1099 Add a new repodata area to the repository. This is normally automatically
1100 done by the repo_add methods, so you need this method only in very
1104 $repo->create_stubs();
1108 Calls the create_stubs() repodata method for the last repodata of the
1112 $repo->iscontiguous()
1116 Return true if the solvables of this repository are all in a single block with
1117 no holes, i.e. they have consecutive ids.
1119 Repodata first_repodata()
1120 my $repodata = $repo->first_repodata();
1121 repodata = repo.first_repodata()
1122 repodata = repo.first_repodata()
1124 Checks if all repodatas but the first repodata are extensions, and return the
1125 first repodata if this is the case. Useful if you want to do a store/retrieve
1126 sequence on the repository to reduce the memory using and enable paging, as
1127 this does not work if the repository contains multiple non-extension repodata
1130 Selection Selection(int setflags = 0)
1131 my $sel = $repo->Selection();
1132 sel = repo.Selection()
1133 sel = repo.Selection()
1135 Create a Selection consisting of all packages in the repository.
1137 Dataiterator Dataiterator(Id key, const char *match = 0, int flags = 0)
1138 my $di = $repo->Dataiterator($keyname, $match, $flags);
1139 di = repo.Dataiterator(keyname, match, flags)
1140 di = repo.Dataiterator(keyname, match, flags)
1142 Dataiterator Dataiterator_meta(Id key, const char *match = 0, int flags = 0)
1143 my $di = $repo->Dataiterator_meta($keyname, $match, $flags);
1144 di = repo.Dataiterator_meta(keyname, match, flags)
1145 di = repo.Dataiterator_meta(keyname, match, flags)
1151 Iterate over the matching data elements in this repository. See the
1152 Dataiterator class for more information. The Dataiterator() method
1153 iterates over all solvables in a repository, whereas the Dataiterator_meta
1154 method only iterates over the repository's meta data.
1157 my $str = $repo->str;
1161 Return the name of the repository, or "Repo#<id>" if no name is set.
1164 if ($repo1 == $repo2)
1168 Two repositories are equal if they belong to the same pool and have the same id.
1170 === DATA ADD METHODS ===
1172 Solvable add_solvable()
1173 $repo->add_solvable();
1177 Add a single empty solvable to the repository. Returns a Solvable object, see
1178 the Solvable class for more information.
1180 bool add_solv(const char *name, int flags = 0)
1181 $repo->add_solv($name);
1185 bool add_solv(FILE *fp, int flags = 0)
1186 $repo->add_solv($fp);
1190 Read a ``solv'' file and add its contents to the repository. These files can be
1191 written with the write() method and are normally used as fast cache for
1192 repository metadata.
1194 bool add_rpmdb(int flags = 0)
1199 bool add_rpmdb_reffp(FILE *reffp, int flags = 0)
1200 $repo->add_rpmdb_reffp($reffp);
1201 repo.add_rpmdb_reffp(reffp)
1202 repo.add_rpmdb_reffp(reffp)
1204 Add the contents of the rpm database to the repository. If a solv file
1205 containing an old version of the database is available, it can be passed as
1206 reffp to speed up reading.
1208 Solvable add_rpm(const char *filename, int flags = 0)
1209 my $solvable = $repo->add_rpm($filename);
1210 solvable = repo.add_rpm(filename)
1211 solvable = repo.add_rpm(filename)
1213 Add the metadata of a single rpm package to the repository.
1215 bool add_rpmdb_pubkeys(int flags = 0)
1216 $repo->add_rpmdb_pubkeys();
1217 repo.add_rpmdb_pubkeys()
1218 repo.add_rpmdb_pubkeys()
1220 Add all pubkeys contained in the rpm database to the repository. Note that
1221 newer rpm versions also allow to store the pubkeys in some directory instead
1222 of the rpm database.
1224 Solvable add_pubkey(const char *keyfile, int flags = 0)
1225 my $solvable = $repo->add_pubkey($keyfile);
1226 solvable = repo.add_pubkey(keyfile)
1227 solvable = repo.add_pubkey(keyfile)
1229 Add a pubkey from a file to the repository.
1231 bool add_rpmmd(FILE *fp, const char *language, int flags = 0)
1232 $repo->add_rpmmd($fp, undef);
1233 repo.add_rpmmd(fp, None)
1234 repo.add_rpmmd(fp, nil)
1236 Add metadata stored in the "rpm-md" format (i.e. from files in the ``repodata''
1237 directory) to a repository. Supported files are "primary", "filelists",
1238 "other", "suseinfo". Do not forget to specify the *REPO_EXTEND_SOLVABLES* for
1239 extension files like "filelists" and "other". Use the _language_ parameter if
1240 you have language extension files, otherwise simply use a *undef*/*None*/*nil*
1243 bool add_repomdxml(FILE *fp, int flags = 0)
1244 $repo->add_repomdxml($fp);
1245 repo.add_repomdxml(fp)
1246 repo.add_repomdxml(fp)
1248 Add the repomd.xml meta description from the "rpm-md" format to the repository.
1249 This file contains information about the repository like keywords, and also a
1250 list of all database files with checksums. The data is added to the "meta"
1251 section of the repository, i.e. no package gets created.
1253 bool add_updateinfoxml(FILE *fp, int flags = 0)
1254 $repo->add_updateinfoxml($fp);
1255 repo.add_updateinfoxml(fp)
1256 repo.add_updateinfoxml(fp)
1258 Add the updateinfo.xml file containing available maintenance updates to the
1259 repository. All updates are created as special packages that have a "patch:"
1260 prefix in their name.
1262 bool add_deltainfoxml(FILE *fp, int flags = 0)
1263 $repo->add_deltainfoxml($fp);
1264 repo.add_deltainfoxml(fp)
1265 repo.add_deltainfoxml(fp)
1267 Add the deltainfo.xml file (also called prestodelta.xml) containing available
1268 delta-rpms to the repository. The data is added to the "meta" section, i.e. no
1269 package gets created.
1271 bool add_debdb(int flags = 0)
1276 Add the contents of the debian installed package database to the repository.
1278 bool add_debpackages(FILE *fp, int flags = 0)
1279 $repo->add_debpackages($fp);
1280 repo.add_debpackages($fp)
1281 repo.add_debpackages($fp)
1283 Add the contents of the debian repository metadata (the "packages" file)
1286 Solvable add_deb(const char *filename, int flags = 0)
1287 my $solvable = $repo->add_deb($filename);
1288 solvable = repo.add_deb(filename)
1289 solvable = repo.add_deb(filename)
1291 Add the metadata of a single deb package to the repository.
1293 bool add_mdk(FILE *fp, int flags = 0)
1294 $repo->add_mdk($fp);
1298 Add the contents of the mageia/mandriva repository metadata (the
1299 "synthesis.hdlist" file) to the repository.
1301 bool add_mdk_info(FILE *fp, int flags = 0)
1302 $repo->add_mdk_info($fp);
1303 repo.add_mdk_info(fp)
1304 repo.add_mdk_info(fp)
1306 Extend the packages from the synthesis file with the info.xml and files.xml
1307 data. Do not forget to specify *REPO_EXTEND_SOLVABLES*.
1309 bool add_arch_repo(FILE *fp, int flags = 0)
1310 $repo->add_arch_repo($fp);
1311 repo.add_arch_repo(fp)
1312 repo.add_arch_repo(fp)
1314 Add the contents of the archlinux repository metadata (the ".db.tar" file) to
1317 bool add_arch_local(const char *dir, int flags = 0)
1318 $repo->add_arch_local($dir);
1319 repo.add_arch_local(dir)
1320 repo.add_arch_local(dir)
1322 Add the contents of the archlinux installed package database to the repository.
1323 The _dir_ parameter is usually set to "/var/lib/pacman/local".
1325 bool add_content(FILE *fp, int flags = 0)
1326 $repo->add_content($fp);
1327 repo.add_content(fp)
1328 repo.add_content(fp)
1330 Add the ``content'' meta description from the susetags format to the repository.
1331 This file contains information about the repository like keywords, and also
1332 a list of all database files with checksums. The data is added to the "meta"
1333 section of the repository, i.e. no package gets created.
1335 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0)
1336 $repo->add_susetags($fp, $defvendor, $language);
1337 repo.add_susetags(fp, defvendor, language)
1338 repo.add_susetags(fp, defvendor, language)
1340 Add repository metadata in the susetags format to the repository. Like with
1341 add_rpmmd, you can specify a language if you have language extension files. The
1342 _defvendor_ parameter provides a default vendor for packages with missing
1343 vendors, it is usually provided in the content file.
1345 bool add_products(const char *dir, int flags = 0)
1346 $repo->add_products($dir);
1347 repo.add_products(dir)
1348 repo.add_products(dir)
1350 Add the installed SUSE products database to the repository. The _dir_ parameter
1351 is usually "/etc/products.d".
1356 A solvable describes all the information of one package. Each solvable
1357 belongs to one repository, it can be added and filled manually but in
1358 most cases solvables will get created by the repo_add methods.
1362 Repo *repo; /* read only */
1367 The repository this solvable belongs to.
1369 Pool *pool; /* read only */
1374 The pool this solvable belongs to, same as the pool of the repo.
1376 Id id; /* read only */
1381 The specific id of the solvable.
1383 char *name; /* read/write */
1388 char *evr; /* read/write */
1393 char *arch; /* read/write */
1398 char *vendor; /* read/write */
1403 Easy access to often used attributes of solvables. They are
1404 internally stored as Ids.
1406 Id nameid; /* read/write */
1411 Id evrid; /* read/write */
1416 Id archid; /* read/write */
1421 Id vendorid; /* read/write */
1422 $solvable->{vendorid}
1426 Raw interface to the ids. Useful if you want to search for
1427 a specific id and want to avoid the string compare overhead.
1431 const char *lookup_str(Id keyname)
1432 my $string = $solvable->lookup_str($keyname);
1433 string = solvable.lookup_str(keyname)
1434 string = solvable.lookup_str(keyname)
1436 Id lookup_id(Id keyname)
1437 my $id = $solvable->lookup_id($keyname);
1438 id = solvable.lookup_id(keyname)
1439 id = solvable.lookup_id(keyname)
1441 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0)
1442 my $num = $solvable->lookup_num($keyname);
1443 num = solvable.lookup_num(keyname)
1444 num = solvable.lookup_num(keyname)
1446 bool lookup_void(Id keyname)
1447 my $bool = $solvable->lookup_void($keyname);
1448 bool = solvable.lookup_void(keyname)
1449 bool = solvable.lookup_void(keyname)
1451 Chksum lookup_checksum(Id keyname)
1452 my $chksum = $solvable->lookup_checksum($keyname);
1453 chksum = solvable.lookup_checksum(keyname)
1454 chksum = solvable.lookup_checksum(keyname)
1456 Id *lookup_idarray(Id keyname, Id marker = -1)
1457 my @ids = $solvable->lookup_idarray($keyname);
1458 ids = solvable.lookup_idarray(keyname)
1459 ids = solvable.lookup_idarray(keyname)
1461 Dep *lookup_deparray(Id keyname, Id marker = -1)
1462 my @deps = $solvable->lookup_deparray($keyname);
1463 deps = solvable.lookup_deparray(keyname)
1464 deps = solvable.lookup_deparray(keyname)
1466 Generic lookup methods. Retrieve data stored for the specific keyname.
1467 The lookup_idarray() method will return an array of Ids, use
1468 lookup_deparray if you want an array of Dependency objects instead.
1469 Some Id arrays contain two parts of data divided by a specific marker,
1470 for example the provides array uses the SOLVABLE_FILEMARKER id to
1471 store both the ids provided by the package and the ids added by
1472 the addfileprovides method. The default, -1, translates to the
1473 correct marker for the keyname and returns the first part of the
1474 array, use 1 to select the second part or 0 to retrieve all ids
1475 including the marker.
1477 const char *lookup_location(unsigned int *OUTPUT)
1478 my ($location, $mediano) = $solvable->lookup_location();
1479 location, mediano = solvable.lookup_location()
1480 location, mediano = solvable.lookup_location()
1482 Return a tuple containing the on-media location and an optional
1483 media number for multi-part repositories (e.g. repositories
1484 spawning multiple DVDs).
1486 const char *lookup_sourcepkg()
1487 my $sourcepkg = $solvable->lookup_sourcepkg();
1488 sourcepkg = solvable.lookup_sourcepkg()
1489 sourcepkg = solvable.lookup_sourcepkg()
1491 Return a sourcepkg name associated with solvable.
1493 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
1494 my $di = $solvable->Dataiterator($keyname, $match, $flags);
1495 di = solvable.Dataiterator(keyname, match, flags)
1496 di = solvable.Dataiterator(keyname, match, flags)
1502 Iterate over the matching data elements. See the Dataiterator class for more
1505 void add_deparray(Id keyname, DepId dep, Id marker = -1)
1506 $solvable->add_deparray($keyname, $dep);
1507 solvable.add_deparray(keyname, dep)
1508 solvable.add_deparray(keyname, dep)
1510 Add a new dependency to the attributes stored in keyname.
1512 void unset(Id keyname)
1513 $solvable->unset($keyname);
1514 solvable.unset(keyname)
1515 solvable.unset(keyname)
1517 Delete data stored for the specific keyname.
1520 $solvable->installable()
1521 solvable.installable()
1522 solvable.installable?
1524 Return true if the solvable is installable on the system. Solvables
1525 are not installable if the system does not support their architecture.
1528 $solvable->isinstalled()
1529 solvable.isinstalled()
1530 solvable.isinstalled?
1532 Return true if the solvable is installed on the system.
1534 bool identical(Solvable *other)
1535 $solvable->identical($other)
1536 solvable.identical(other)
1537 solvable.identical?(other)
1539 Return true if the two solvables are identical.
1541 int evrcmp(Solvable *other)
1542 $solvable->evrcmp($other)
1543 solvable.evrcmp(other)
1544 solvable.evrcmp(other)
1546 Returns -1 if the epoch/version/release of the solvable is less than the
1547 one from the other solvable, 1 if it is greater, and 0 if they are equal.
1548 Note that "equal" does not mean that the evr is identical.
1550 int matchesdep(Id keyname, DepId id, Id marker = -1)
1551 $solvable->matchesdep($keyname, $dep)
1552 solvable.matchesdep(keyname, dep)
1553 solvable.matchesdep?(keyname, dep)
1555 Return true if the dependencies stored in keyname match the specified dependency.
1557 Selection Selection(int setflags = 0)
1558 my $sel = $solvable->Selection();
1559 sel = solvable.Selection()
1560 sel = solvable.Selection()
1562 Create a Selection containing just the single solvable.
1565 my $str = $solvable->str();
1566 str = $solvable.str()
1567 str = $solvable.str()
1569 Return a string describing the solvable. The string consists of the name,
1570 version, and architecture of the Solvable.
1573 my $str = $solvable->str;
1577 Same as calling the str() method.
1580 if ($solvable1 == $solvable2)
1581 if solvable1 == solvable2:
1582 if solvable1 == solvable2
1584 Two solvables are equal if they are part of the same pool and have the same
1588 The Dataiterator Class
1589 ----------------------
1590 Dataiterators can be used to do complex string searches or
1591 to iterate over arrays. They can be created via the
1592 constructors in the Pool, Repo, and Solvable classes. The
1593 Repo and Solvable constructors will limit the search to
1594 the repository or the specific package.
1599 Return a match if the search string matches the value.
1601 *SEARCH_STRINGSTART*::
1602 Return a match if the value starts with the search string.
1604 *SEARCH_STRINGEND*::
1605 Return a match if the value ends with the search string.
1607 *SEARCH_SUBSTRING*::
1608 Return a match if the search string can be matched somewhere in the value.
1611 Do a glob match of the search string against the value.
1614 Do a regular expression match of the search string against the value.
1617 Ignore case when matching strings. Works for all the above match types.
1620 Match the complete filenames of the file list, not just the base name.
1622 *SEARCH_COMPLETE_FILELIST*::
1623 When matching the file list, check every file of the package not just the
1624 subset from the primary metadata.
1626 *SEARCH_CHECKSUMS*::
1627 Allow the matching of checksum entries.
1631 void prepend_keyname(Id keyname);
1632 $di->prepend_keyname($keyname);
1633 di.prepend_keyname(keyname)
1634 di.prepend_keyname(keyname)
1636 Do a sub-search in the array stored in keyname.
1638 void skip_solvable();
1639 $di->skip_solvable();
1643 Stop matching the current solvable and advance to the next
1651 Iterate through the matches. If there is a match, the object
1652 in d will be of type Datamatch.
1657 Objects of this type will be created for every value matched
1662 Pool *pool; /* read only */
1667 Back pointer to pool.
1669 Repo *repo; /* read only */
1674 The repository containing the matched object.
1676 Solvable *solvable; /* read only */
1681 The solvable containing the value that was matched.
1683 Id solvid; /* read only */
1688 The id of the solvable that matched.
1695 const char *key_idstr;
1700 The keyname that matched, either as id or string.
1707 const char *type_idstr;
1712 The key type of the value that was matched, either as id or string.
1724 The Id of the value that was matched (only valid for id types),
1725 either as id or string.
1732 The string value that was matched (only valid for string types).
1734 unsigned long long num;
1739 The numeric value that was matched (only valid for numeric types).
1746 The secondary numeric value that was matched (only valid for types
1747 containing two values).
1749 unsigned int binary;
1754 The value in binary form, useful for checksums and other data
1755 that cannot be represented as a string.
1760 my $pos = $d->pos();
1764 The position object of the current match. It can be used to do
1765 sub-searches starting at the match (if it is of an array type).
1766 See the Datapos class for more information.
1769 my $pos = $d->parentpos();
1773 The position object of the array containing the current match.
1774 It can be used to do sub-searches, see the Datapos class for more
1782 Return the stringification of the matched value. Stringification
1783 depends on the search flags, for file list entries it will return
1784 just the base name unless SEARCH_FILES is used, for checksums
1785 it will return an empty string unless SEARCH_CHECKSUMS is used.
1786 Numeric values are currently stringified to an empty string.
1791 Selections are a way to easily deal with sets of packages.
1792 There are multiple constructors to create them, the most useful
1793 is probably the select() method in the Pool class.
1798 Create the selection by matching package names.
1800 *SELECTION_PROVIDES*::
1801 Create the selection by matching package provides.
1803 *SELECTION_FILELIST*::
1804 Create the selection by matching package files.
1807 Create the selection by matching the canonical representation
1808 of the package. This is normally a combination of the name,
1809 the version, and the architecture of a package.
1811 *SELECTION_DOTARCH*::
1812 Allow an ".<architecture>" suffix when matching names or
1816 Allow the specification of a relation when matching names
1817 or dependencies, e.g. "name >= 1.2".
1820 Allow glob matching for package names, package provides, and file names.
1822 *SELECTION_NOCASE*::
1823 Ignore case when matching package names, package provides, and file names.
1826 Return only one selection element describing the selected packages.
1827 The default is to create multiple elements for all globbed packages.
1828 Multiple elements are useful if you want to turn the selection into
1829 an install job, in that case you want an install job for every
1832 *SELECTION_SKIP_KIND*::
1833 Remove a "packagekind:" prefix from the package names.
1835 *SELECTION_MATCH_DEPSTR*::
1836 When matching dependencies, do a string match on the result of dep2str
1837 instead of using the normal dependency intersect algorithm.
1839 *SELECTION_INSTALLED_ONLY*::
1840 Limit the package search to installed packages.
1842 *SELECTION_SOURCE_ONLY*::
1843 Limit the package search to source packages only.
1845 *SELECTION_WITH_SOURCE*::
1846 Extend the package search to also match source packages. The default is
1847 only to match binary packages.
1849 *SELECTION_WITH_DISABLED*::
1850 Extend the package search to also include disabled packages.
1852 *SELECTION_WITH_BADARCH*::
1853 Extend the package search to also include packages that are not installable
1854 on the configured architecture.
1856 *SELECTION_WITH_ALL*::
1857 Shortcut for selecting the three modifiers above.
1860 Add the result of the match to the current selection instead of replacing it.
1862 *SELECTION_SUBTRACT*::
1863 Remove the result of the match to the current selection instead of replacing it.
1865 *SELECTION_FILTER*::
1866 Intersect the result of the match to the current selection instead of replacing it.
1870 Pool *pool; /* read only */
1875 Back pointer to pool.
1877 int flags; /* read only */
1882 The result flags of the selection. The flags are a subset
1883 of the ones used when creating the selection, they describe which
1884 method was used to get the result. For example, if you create the
1885 selection with ``SELECTION_NAME | SELECTION_PROVIDES'', the resulting
1886 flags will either be SELECTION_NAME or SELECTION_PROVIDES depending
1887 if there was a package that matched the name or not. If there was
1888 no match at all, the flags will be zero.
1897 Return true if the selection is empty, i.e. no package could be matched.
1899 Selection clone(int flags = 0)
1900 my $cloned = $sel->clone();
1901 cloned = sel.clone()
1902 cloned = sel.clone()
1904 Return a copy of a selection.
1906 void filter(Selection *other)
1907 $sel->filter($other);
1911 Intersect two selections. Packages will only stay in the selection if there
1912 are also included in the other selecting. Does an in-place modification.
1914 void add(Selection *other)
1919 Build the union of two selections. All packages of the other selection will
1920 be added to the set of packages of the selection object. Does an in-place
1921 modification. Note that the selection flags are no longer meaningful after the
1924 void subtract(Selection *other)
1925 $sel->subtract($other);
1929 Remove the packages of the other selection from the packages of the selection
1930 object. Does an in-place modification.
1932 void add_raw(Id how, Id what)
1933 $sel->add_raw($how, $what);
1934 sel.add_raw(how, what)
1935 sel.add_raw(how, what)
1937 Add a raw element to the selection. Check the Job class for information about
1938 the how and what parameters. Note that the selection flags are no longer meaningful
1939 after the add_raw operation.
1941 Job *jobs(int action)
1942 my @jobs = $sel->jobs($action);
1943 jobs = sel.jobs(action)
1944 jobs = sel.jobs(action)
1946 Convert a selection into an array of Job objects. The action parameter is or-ed
1947 to the ``how'' part of the job, it describes the type of job (e.g. install,
1948 erase). See the Job class for the action and action modifier constants.
1950 Solvable *solvables()
1951 my @solvables = $sel->solvables();
1952 solvables = sel.solvables()
1953 solvables = sel.solvables()
1955 Convert a selection into an array of Solvable objects.
1957 void select(const char *name, int flags)
1958 $sel->select($name, $flags);
1959 sel.select(name, flags)
1960 sel.select(name, flags)
1962 Do a select operation and combine the result with the current selection. You
1963 can choose the desired combination method by using either the SELECTION_ADD,
1964 SELECTION_SUBTRACT, or SELECTION_FILTER flag. If none of the flags are
1965 used, SELECTION_FILTER|SELECTION_WITH_ALL is assumed.
1967 void matchdeps(const char *name, int flags, Id keyname, Id marker = -1)
1968 $sel->matchdeps($name, $flags, $keyname);
1969 sel.matchdeps(name, flags, keyname)
1970 sel.matchdeps(name, flags, keyname)
1972 Do a matchdeps operation and combine the result with the current selection.
1974 void matchdepid(DepId dep, int flags, Id keyname, Id marker = -1)
1975 $sel->matchdepid($dep, $flags, $keyname);
1976 sel.matchdepid(dep, flags, keyname)
1977 sel.matchdepid(dep, flags, keyname)
1979 Do a matchdepid operation and combine the result with the current selection.
1981 void matchsolvable(Solvable solvable, int flags, Id keyname, Id marker = -1)
1982 $sel->matchsolvable($solvable, $flags, $keyname);
1983 sel.matchsolvable(solvable, flags, keyname)
1984 sel.matchsolvable(solvable, flags, keyname)
1986 Do a matchsolvable operation and combine the result with the current selection.
1989 my $str = $sel->str;
1993 Return a string describing the selection.
1998 Jobs are the way to specify to the dependency solver what to do.
1999 Most of the times jobs will get created by calling the jobs() method
2000 on a Selection object, but there is also a Job() constructor in the
2005 Selection constants:
2008 The ``what'' part is the id of a solvable.
2010 *SOLVER_SOLVABLE_NAME*::
2011 The ``what'' part is the id of a package name.
2013 *SOLVER_SOLVABLE_PROVIDES*::
2014 The ``what'' part is the id of a package provides.
2016 *SOLVER_SOLVABLE_ONE_OF*::
2017 The ``what'' part is an offset into the ``whatprovides'' data, created
2018 by calling the towhatprovides() pool method.
2020 *SOLVER_SOLVABLE_REPO*::
2021 The ``what'' part is the id of a repository.
2023 *SOLVER_SOLVABLE_ALL*::
2024 The ``what'' part is ignored, all packages are selected.
2026 *SOLVER_SOLVABLE_SELECTMASK*::
2027 A mask containing all the above selection bits.
2035 Install a package of the specified set of packages. It tries to install
2036 the best matching package (i.e. the highest version of the packages from
2037 the repositories with the highest priority).
2040 Erase all of the packages from the specified set. If a package is not
2041 installed, erasing it will keep it from getting installed.
2044 Update the matching installed packages to their best version. If none
2045 of the specified packages are installed, try to update the installed
2046 packages to the specified versions. See the section about targeted
2047 updates about more information.
2049 *SOLVER_WEAKENDEPS*::
2050 Allow to break the dependencies of the matching packages. Handle with care.
2052 *SOLVER_MULTIVERSION*::
2053 Mark the matched packages for multiversion install. If they get to be
2054 installed because of some other job, the installation will keep the old
2055 version of the package installed (for rpm this is done by using ``-i''
2059 Do not change the state of the matched packages, i.e. when they are
2060 installed they stay installed, if not they are not selected for
2063 *SOLVER_DISTUPGRADE*::
2064 Update the matching installed packages to the best version included in one
2065 of the repositories. After this operation, all come from one of the available
2066 repositories except orphaned packages. Orphaned packages are packages that
2067 have no relation to the packages in the repositories, i.e. no package in the
2068 repositories have the same name or obsolete the orphaned package.
2069 This action brings the installed packages in sync with the ones in the
2070 repository. By default it also turns of arch/vendor/version locking for the
2071 affected packages to simulate a fresh installation. This means that distupgrade can
2072 actually downgrade packages if only lower versions of a package are available
2073 in the repositories. You can tweak this behavior with the SOLVER_FLAG_DUP_
2076 *SOLVER_DROP_ORPHANED*::
2077 Erase all the matching installed packages if they are orphaned. This only makes
2078 sense if there is a ``distupgrade all packages'' job. The default is to erase
2079 orphaned packages only if they block the installation of other packages.
2082 Fix dependency problems of matching installed packages. The default is to ignore
2083 dependency problems for installed packages.
2085 *SOLVER_USERINSTALLED*::
2086 The matching installed packages are considered to be installed by a user,
2087 thus not installed to fulfill some dependency. This is needed input for
2088 the calculation of unneeded packages for jobs that have the
2089 SOLVER_CLEANDEPS flag set.
2091 *SOLVER_ALLOWUNINSTALL*::
2092 Allow the solver to deinstall the matching installed packages if they get
2093 into the way of resolving a dependency. This is like the
2094 SOLVER_FLAG_ALLOW_UNINSTALL flag, but limited to a specific set of packages.
2097 Prefer the specified packages if the solver encounters an alternative. If
2098 a job contains multiple matching favor/disfavor elements, the last one takes
2102 Avoid the specified packages if the solver encounters an alternative. This
2103 can also be used to block recommended or supplemented packages from being
2106 *SOLVER_EXCLUDEFROMWEAK*::
2107 Avoid the specified packages to satisfy recommended or supplemented dependencies.
2108 Unlike SOLVER_DISFAVOR, it does not interfere with other rules.
2111 A mask containing all the above action bits.
2113 Action modifier constants:
2116 Makes the job a weak job. The solver tries to fulfill weak jobs, but does
2117 not report a problem if it is not possible to do so.
2119 *SOLVER_ESSENTIAL*::
2120 Makes the job an essential job. If there is a problem with the job, the
2121 solver will not propose to remove the job as one solution (unless all
2122 other solutions are also to remove essential jobs).
2124 *SOLVER_CLEANDEPS*::
2125 The solver will try to also erase all packages dragged in through
2126 dependencies when erasing the package. This needs SOLVER_USERINSTALLED
2127 jobs to maximize user satisfaction.
2129 *SOLVER_FORCEBEST*::
2130 Insist on the best package for install, update, and distupgrade jobs. If
2131 this flag is not used, the solver will use the second-best package if the
2132 best package cannot be installed for some reason. When this flag is used,
2133 the solver will generate a problem instead.
2136 Forces targeted operation update and distupgrade jobs. See the section
2137 about targeted updates about more information.
2142 The job specified the exact epoch and version of the package set.
2145 The job specified the exact epoch, version, and release of the package set.
2148 The job specified the exact architecture of the packages from the set.
2150 *SOLVER_SETVENDOR*::
2151 The job specified the exact vendor of the packages from the set.
2154 The job specified the exact repository of the packages from the set.
2157 The job specified the exact name of the packages from the set.
2159 *SOLVER_NOAUTOSET*::
2160 Turn of automatic set flag generation for SOLVER_SOLVABLE jobs.
2163 A mask containing all the above set bits.
2165 See the section about set bits for more information.
2169 Pool *pool; /* read only */
2174 Back pointer to pool.
2176 Id how; /* read/write */
2181 Union of the selection, action, action modifier, and set flags.
2182 The selection part describes the semantics of the ``what'' Id.
2184 Id what; /* read/write */
2189 Id describing the set of packages, the meaning depends on the
2190 selection part of the ``how'' attribute.
2194 Solvable *solvables()
2195 my @solvables = $job->solvables();
2196 solvables = job.solvables()
2197 solvables = job.solvables()
2199 Return the set of solvables of the job as an array of Solvable
2202 bool isemptyupdate()
2203 $job->isemptyupdate()
2207 Convenience function to find out if the job describes an update
2208 job with no matching packages, i.e. a job that does nothing.
2209 Some package managers like ``zypper'' like to turn those jobs
2210 into install jobs, i.e. an update of a not-installed package
2211 will result into the installation of the package.
2214 my $str = $job->str;
2218 Return a string describing the job.
2225 Two jobs are equal if they belong to the same pool and both the
2226 ``how'' and the ``what'' attributes are the same.
2228 === TARGETED UPDATES ===
2229 Libsolv has two modes for upgrades and distupgrade: targeted and
2230 untargeted. Untargeted mode means that the installed packages from
2231 the specified set will be updated to the best version. Targeted means
2232 that packages that can be updated to a package in the specified set
2233 will be updated to the best package of the set.
2235 Here's an example to explain the subtle difference. Suppose that
2236 you have package A installed in version "1.1", "A-1.2" is available
2237 in one of the repositories and there is also package "B" that
2238 obsoletes package A.
2240 An untargeted update of "A" will update the installed "A-1.1" to
2241 package "B", because that is the newest version (B obsoletes A and
2244 A targeted update of "A" will update "A-1.1" to "A-1.2", as the
2245 set of packages contains both "A-1.1" and "A-1.2", and "A-1.2" is
2248 An untargeted update of "B" will do nothing, as "B" is not installed.
2250 An targeted update of "B" will update "A-1.1" to "B".
2252 Note that the default is to do "auto-targeting", thus if the specified
2253 set of packages does not include an installed package, the solver
2254 will assume targeted operation even if SOLVER_TARGETED is not used.
2256 This mostly matches the intent of the user, with one exception: In
2257 the example above, an update of "A-1.2" will update "A-1.1" to
2258 "A-1.2" (targeted mode), but a second update of "A-1.2" will suddenly
2259 update to "B", as untargeted mode is chosen because "A-1.2" is now
2262 If you want to have full control over when targeting mode is chosen,
2263 turn off auto-targeting with the SOLVER_FLAG_NO_AUTOTARGET solver option.
2264 In that case, all updates are considered to be untargeted unless they
2265 include the SOLVER_TARGETED flag.
2268 Set bits specify which parts of the specified packages where specified
2269 by the user. It is used by the solver when checking if an operation is
2270 allowed or not. For example, the solver will normally not allow the
2271 downgrade of an installed package. But it will not report a problem if
2272 the SOLVER_SETEVR flag is used, as it then assumes that the user specified
2273 the exact version and thus knows what he is doing.
2275 So if a package "screen-1-1" is installed for the x86_64 architecture and
2276 version "2-1" is only available for the i586 architecture, installing
2277 package "screen-2.1" will ask the user for confirmation because of the
2278 different architecture. When using the Selection class to create jobs
2279 the set bits are automatically added, e.g. selecting ``screen.i586'' will
2280 automatically add SOLVER_SETARCH, and thus no problem will be reported.
2285 Dependency solving is what this library is about. A solver object is needed
2286 for solving to store the result of the solver run. The solver object can be
2287 used multiple times for different jobs, reusing it allows the solver to
2288 re-use the dependency rules it already computed.
2292 Flags to modify some of the solver's behavior:
2294 *SOLVER_FLAG_ALLOW_DOWNGRADE*::
2295 Allow the solver to downgrade packages without asking for confirmation
2296 (i.e. reporting a problem).
2298 *SOLVER_FLAG_ALLOW_ARCHCHANGE*::
2299 Allow the solver to change the architecture of an installed package
2300 without asking for confirmation. Note that changes to/from noarch
2301 are always considered to be allowed.
2303 *SOLVER_FLAG_ALLOW_VENDORCHANGE*::
2304 Allow the solver to change the vendor of an installed package
2305 without asking for confirmation. Each vendor is part of one or more
2306 vendor equivalence classes, normally installed packages may only
2307 change their vendor if the new vendor shares at least one equivalence
2310 *SOLVER_FLAG_ALLOW_NAMECHANGE*::
2311 Allow the solver to change the name of an installed package, i.e.
2312 install a package with a different name that obsoletes the installed
2313 package. This option is on by default.
2315 *SOLVER_FLAG_ALLOW_UNINSTALL*::
2316 Allow the solver to erase installed packages to fulfill the jobs.
2317 This flag also includes the above flags. You may want to set this
2318 flag if you only have SOLVER_ERASE jobs, as in that case it's
2319 better for the user to check the transaction overview instead of
2320 approving every single package that needs to be erased.
2322 *SOLVER_FLAG_DUP_ALLOW_DOWNGRADE*::
2323 Like SOLVER_FLAG_ALLOW_DOWNGRADE, but used in distupgrade mode.
2325 *SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE*::
2326 Like SOLVER_FLAG_ALLOW_ARCHCHANGE, but used in distupgrade mode.
2328 *SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE*::
2329 Like SOLVER_FLAG_ALLOW_VENDORCHANGE, but used in distupgrade mode.
2331 *SOLVER_FLAG_DUP_ALLOW_NAMECHANGE*::
2332 Like SOLVER_FLAG_ALLOW_NAMECHANGE, but used in distupgrade mode.
2334 *SOLVER_FLAG_NO_UPDATEPROVIDE*::
2335 If multiple packages obsolete an installed package, the solver checks
2336 the provides of every such package and ignores all packages that
2337 do not provide the installed package name. Thus, you can have an
2338 official update candidate that provides the old name, and other
2339 packages that also obsolete the package but are not considered for
2340 updating. If you cannot use this feature, you can turn it off
2341 by setting this flag.
2343 *SOLVER_FLAG_NEED_UPDATEPROVIDE*::
2344 This is somewhat the opposite of SOLVER_FLAG_NO_UPDATEPROVIDE: Only
2345 packages that provide the installed package names are considered
2348 *SOLVER_FLAG_SPLITPROVIDES*::
2349 Make the solver aware of special provides of the form
2350 ``<packagename>:<path>'' used in SUSE systems to support package
2353 *SOLVER_FLAG_IGNORE_RECOMMENDED*::
2354 Do not process optional (aka weak) dependencies.
2356 *SOLVER_FLAG_ADD_ALREADY_RECOMMENDED*::
2357 Install recommended or supplemented packages even if they have no
2358 connection to the current transaction. You can use this feature
2359 to implement a simple way for the user to install new recommended
2360 packages that were not available in the past.
2362 *SOLVER_FLAG_NO_INFARCHCHECK*::
2363 Turn off the inferior architecture checking that is normally done
2364 by the solver. Normally, the solver allows only the installation
2365 of packages from the "best" architecture if a package is available
2366 for multiple architectures.
2368 *SOLVER_FLAG_BEST_OBEY_POLICY*::
2369 Make the SOLVER_FORCEBEST job option consider only packages that
2370 meet the policies for installed packages, i.e. no downgrades,
2371 no architecture change, no vendor change (see the first flags
2372 of this section). If the flag is not specified, the solver will
2373 enforce the installation of the best package ignoring the
2374 installed packages, which may conflict with the set policy.
2376 *SOLVER_FLAG_NO_AUTOTARGET*::
2377 Do not enable auto-targeting up update and distupgrade jobs. See
2378 the section on targeted updates for more information.
2380 *SOLVER_FLAG_KEEP_ORPHANS*::
2381 Do not allow orphaned packages to be deinstalled if they get
2382 in the way of resolving other packages.
2384 *SOLVER_FLAG_BREAK_ORPHANS*::
2385 Ignore dependencies of orphaned packages that get in the way
2386 of resolving non-orphaned ones. Setting the flag might result
2387 in no longer working packages in case they are orphaned.
2389 *SOLVER_FLAG_FOCUS_INSTALLED*::
2390 Resolve installed packages before resolving the given jobs.
2391 Setting this flag means that the solver will prefer picking
2392 a package version that fits the other installed packages
2393 over updating installed packages.
2395 *SOLVER_FLAG_FOCUS_BEST*::
2396 First resolve the given jobs, then the dependencies of the
2397 resulting packages, then resolve all already installed
2398 packages. This will result in more packages being updated
2399 as when the flag is not used.
2401 *SOLVER_FLAG_INSTALL_ALSO_UPDATES*::
2402 Update the package if a job is already fulfilled by an installed
2405 *SOLVER_FLAG_YUM_OBSOLETES*::
2406 Turn on yum-like package split handling. See the yum documentation
2409 *SOLVER_FLAG_URPM_REORDER*::
2410 Turn on urpm like package reordering for kernel packages. See
2411 the urpm documentation for more details.
2417 *SOLVER_RULE_UNKNOWN*::
2418 A rule of an unknown class. You should never encounter those.
2421 A rule generated because of a package dependency.
2423 *SOLVER_RULE_UPDATE*::
2424 A rule to implement the update policy of installed packages. Every
2425 installed package has an update rule that consists of the packages
2426 that may replace the installed package.
2428 *SOLVER_RULE_FEATURE*::
2429 Feature rules are fallback rules used when an update rule is disabled. They
2430 include all packages that may replace the installed package ignoring the
2431 update policy, i.e. they contain downgrades, arch changes and so on.
2432 Without them, the solver would simply erase installed packages if their
2433 update rule gets disabled.
2436 Job rules implement the job given to the solver.
2438 *SOLVER_RULE_DISTUPGRADE*::
2439 These are simple negative assertions that make sure that only packages
2440 are kept that are also available in one of the repositories.
2442 *SOLVER_RULE_INFARCH*::
2443 Infarch rules are also negative assertions, they disallow the installation
2444 of packages when there are packages of the same name but with a better
2447 *SOLVER_RULE_CHOICE*::
2448 Choice rules are used to make sure that the solver prefers updating to
2449 installing different packages when some dependency is provided by
2450 multiple packages with different names. The solver may always break
2451 choice rules, so you will not see them when a problem is found.
2453 *SOLVER_RULE_LEARNT*::
2454 These rules are generated by the solver to keep it from running into
2455 the same problem multiple times when it has to backtrack. They are
2456 the main reason why a sat solver is faster than other dependency solver
2459 Special dependency rule types:
2461 *SOLVER_RULE_PKG_NOT_INSTALLABLE*::
2462 This rule was added to prevent the installation of a package of an
2463 architecture that does not work on the system.
2465 *SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP*::
2466 The package contains a required dependency which was not provided by
2469 *SOLVER_RULE_PKG_REQUIRES*::
2470 The package contains a required dependency which was provided by at
2473 *SOLVER_RULE_PKG_SELF_CONFLICT*::
2474 The package conflicts with itself. This is not allowed by older rpm
2477 *SOLVER_RULE_PKG_CONFLICTS*::
2478 The package conflices with some other package.
2480 *SOLVER_RULE_PKG_SAME_NAME*::
2481 This rules make sure that only one version of a package is installed
2484 *SOLVER_RULE_PKG_OBSOLETES*::
2485 To fulfill the dependencies two packages need to be installed, but
2486 one of the packages obsoletes the other one.
2488 *SOLVER_RULE_PKG_IMPLICIT_OBSOLETES*::
2489 To fulfill the dependencies two packages need to be installed, but
2490 one of the packages has provides a dependency that is obsoleted
2491 by the other one. See the POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES
2494 *SOLVER_RULE_PKG_INSTALLED_OBSOLETES*::
2495 To fulfill the dependencies a package needs to be installed that is
2496 obsoleted by an installed package. See the POOL_FLAG_NOINSTALLEDOBSOLETES
2499 *SOLVER_RULE_PKG_RECOMMENDS*::
2500 The package contains a recommended dependency.
2502 *SOLVER_RULE_PKG_SUPPLEMENTS*::
2503 The package contains a dependency to specify it supplements another package.
2505 *SOLVER_RULE_PKG_CONSTRAINS*::
2506 The package contains a constraint against some other package (disttype conda).
2508 *SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP*::
2509 The user asked for installation of a package providing a specific
2510 dependency, but no available package provides it.
2512 *SOLVER_RULE_JOB_UNKNOWN_PACKAGE*::
2513 The user asked for installation of a package with a specific name,
2514 but no available package has that name.
2516 *SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM*::
2517 The user asked for the erasure of a dependency that is provided by the
2518 system (i.e. for special hardware or language dependencies), this
2519 cannot be done with a job.
2521 *SOLVER_RULE_JOB_UNSUPPORTED*::
2522 The user asked for something that is not yet implemented, e.g. the
2523 installation of all packages at once.
2525 Policy error constants
2527 *POLICY_ILLEGAL_DOWNGRADE*::
2528 The solver ask for permission before downgrading packages.
2530 *POLICY_ILLEGAL_ARCHCHANGE*::
2531 The solver ask for permission before changing the architecture of installed
2534 *POLICY_ILLEGAL_VENDORCHANGE*::
2535 The solver ask for permission before changing the vendor of installed
2538 *POLICY_ILLEGAL_NAMECHANGE*::
2539 The solver ask for permission before replacing an installed packages with
2540 a package that has a different name.
2542 Solution element type constants
2544 *SOLVER_SOLUTION_JOB*::
2545 The problem can be solved by removing the specified job.
2547 *SOLVER_SOLUTION_POOLJOB*::
2548 The problem can be solved by removing the specified job that is defined
2551 *SOLVER_SOLUTION_INFARCH*::
2552 The problem can be solved by allowing the installation of the specified
2553 package with an inferior architecture.
2555 *SOLVER_SOLUTION_DISTUPGRADE*::
2556 The problem can be solved by allowing to keep the specified package
2559 *SOLVER_SOLUTION_BEST*::
2560 The problem can be solved by allowing to install the specified package
2561 that is not the best available package.
2563 *SOLVER_SOLUTION_ERASE*::
2564 The problem can be solved by allowing to erase the specified package.
2566 *SOLVER_SOLUTION_REPLACE*::
2567 The problem can be solved by allowing to replace the package with some
2570 *SOLVER_SOLUTION_REPLACE_DOWNGRADE*::
2571 The problem can be solved by allowing to replace the package with some
2572 other package that has a lower version.
2574 *SOLVER_SOLUTION_REPLACE_ARCHCHANGE*::
2575 The problem can be solved by allowing to replace the package with some
2576 other package that has a different architecture.
2578 *SOLVER_SOLUTION_REPLACE_VENDORCHANGE*::
2579 The problem can be solved by allowing to replace the package with some
2580 other package that has a different vendor.
2582 *SOLVER_SOLUTION_REPLACE_NAMECHANGE*::
2583 The problem can be solved by allowing to replace the package with some
2584 other package that has a different name.
2589 *SOLVER_REASON_UNRELATED*::
2590 The package status did not change as it was not related to any job.
2592 *SOLVER_REASON_UNIT_RULE*::
2593 The package was installed/erased/kept because of a unit rule, i.e. a rule
2594 where all literals but one were false.
2596 *SOLVER_REASON_KEEP_INSTALLED*::
2597 The package was chosen when trying to keep as many packages installed as
2600 *SOLVER_REASON_RESOLVE_JOB*::
2601 The decision happened to fulfill a job rule.
2603 *SOLVER_REASON_UPDATE_INSTALLED*::
2604 The decision happened to fulfill a package update request.
2606 *SOLVER_REASON_CLEANDEPS_ERASE*::
2607 The package was erased when cleaning up dependencies from other erased
2610 *SOLVER_REASON_RESOLVE*::
2611 The package was installed to fulfill package dependencies.
2613 *SOLVER_REASON_WEAKDEP*::
2614 The package was installed because of a weak dependency (Recommends or
2617 *SOLVER_REASON_RESOLVE_ORPHAN*::
2618 The decision about the package was made when deciding the fate of orphaned
2621 *SOLVER_REASON_RECOMMENDED*::
2622 This is a special case of SOLVER_REASON_WEAKDEP.
2624 *SOLVER_REASON_SUPPLEMENTED*::
2625 This is a special case of SOLVER_REASON_WEAKDEP.
2627 *SOLVER_REASON_UNSOLVABLE*::
2628 This is a special case where a rule cannot be fulfilled.
2630 *SOLVER_REASON_PREMISE*::
2631 This is a special case for the premises of learnt rules.
2635 Pool *pool; /* read only */
2640 Back pointer to pool.
2644 int set_flag(int flag, int value)
2645 my $oldvalue = $solver->set_flag($flag, $value);
2646 oldvalue = solver.set_flag(flag, value)
2647 oldvalue = solver.set_flag(flag, value)
2649 int get_flag(int flag)
2650 my $value = $solver->get_flag($flag);
2651 value = solver.get_flag(flag)
2652 value = solver.get_flag(flag)
2654 Set/get a solver specific flag. The flags define the policies the solver has
2655 to obey. The flags are explained in the CONSTANTS section of this class.
2657 Problem *solve(Job *jobs)
2658 my @problems = $solver->solve(\@jobs);
2659 problems = solver.solve(jobs)
2660 problems = solver.solve(jobs)
2662 Solve a problem specified in the job list (plus the jobs defined in the pool).
2663 Returns an array of problems that need user interaction, or an empty array
2664 if no problems were encountered. See the Problem class on how to deal with
2667 Transaction transaction()
2668 my $trans = $solver->transaction();
2669 trans = solver.transaction()
2670 trans = solver.transaction()
2672 Return the transaction to implement the calculated package changes. A transaction
2673 is available even if problems were found, this is useful for interactive user
2674 interfaces that show both the job result and the problems.
2676 Solvable *get_recommended(bool noselected=0)
2677 my @solvables = $solver->get_recommended();
2678 solvables = solver.get_recommended()
2679 solvables = solver.get_recommended()
2681 Return all solvables that are recommended by the solver run result. This includes
2682 solvables included in the result; set noselected if you want to filter those.
2684 Solvable *get_suggested(bool noselected=0)
2685 my @solvables = $solver->get_suggested();
2686 solvables = solver.get_suggested()
2687 solvables = solver.get_suggested()
2689 Return all solvables that are suggested by the solver run result. This includes
2690 solvables included in the result; set noselected if you want to filter those.
2692 Decision = get_decision(Solvable *s)
2693 my $decision = $solver->get_decision($solvable);
2694 decision = solver.get_decision(solvable);
2695 decision = solver.get_decision(solvable);
2697 Return a decision object that describes why a specific solvable was installed or erased.
2698 See the Decision class for more information.
2700 Decision *get_decisionlist(Solvable *s)
2701 my @decisions = $solver->get_decisionlist($solvable);
2702 decisions = solver.get_decisionlist(solvable)
2703 decisions = solver.get_decisionlist(solvable)
2705 Return a list of decisions that caused the specific solvable to be installed or
2706 erased. This is usually more useful than the get_decision() method, as it
2707 returns every involved decision instead of just a single one.
2709 Alternative *alternatives()
2710 my @alternatives = $solver->alternatives();
2711 alternatives = solver.alternatives()
2712 alternatives = solver.alternatives()
2714 Return all alternatives recorded in the solver run. See the Alternative class
2715 for more information.
2717 int alternatives_count()
2718 my $cnt = $solver->alternatives_count();
2719 cnt = solver.alternatives_count()
2720 cnt = solver.alternatives_count()
2722 Return the number of alternatives without creating alternative objects.
2727 Problems are the way of the solver to interact with the user. You can simply list
2728 all problems and terminate your program, but a better way is to present solutions to
2729 the user and let him pick the ones he likes.
2733 Solver *solv; /* read only */
2738 Back pointer to solver object.
2740 Id id; /* read only */
2745 Id of the problem. The first problem has Id 1, they are numbered consecutively.
2749 Rule findproblemrule()
2750 my $probrule = $problem->findproblemrule();
2751 probrule = problem.findproblemrule()
2752 probrule = problem.findproblemrule()
2754 Return the rule that caused the problem. Of course in most situations there is no
2755 single responsible rule, but many rules that interconnect with each created the
2756 problem. Nevertheless, the solver uses some heuristic approach to find a rule
2757 that somewhat describes the problem best to the user.
2759 Rule *findallproblemrules(bool unfiltered = 0)
2760 my @probrules = $problem->findallproblemrules();
2761 probrules = problem.findallproblemrules()
2762 probrules = problem.findallproblemrules()
2764 Return all rules responsible for the problem. The returned set of rules contains
2765 all the needed information why there was a problem, but it's hard to present
2766 them to the user in a sensible way. The default is to filter out all update and
2767 job rules (unless the returned rules only consist of those types).
2769 Decision *get_decisionlist()
2770 my @decisions = $problem->get_decisionlist();
2771 decisions = problem.get_decisionlist()
2772 decisions = problem.get_decisionlist()
2774 Return a list of decisions prooving the problem. This is somewhat similar to
2775 the findallproblemrules(), but the output is in an order that makes it easier
2776 to understand why the solver could not find a solution.
2778 Decisionset *get_decisionsetlist()
2779 my @decisionsets = $problem->get_decisionsetlist();
2780 decisionsets = problem.get_decisionsetlist()
2781 decisionsets = problem.get_decisionsetlist()
2783 Like the get_decisionlist() method, but the decisions are merged into
2787 my @learnt = $problem->get_learnt();
2788 learnt = problem.get_learnt()
2789 learnt = problem.get_lerant()
2791 Return a list of learnt rules that are part of the problem proof. This
2792 is useful for presenting a complete proof to the user.
2794 Solution *solutions()
2795 my @solutions = $problem->solutions();
2796 solutions = problem.solutions()
2797 solutions = problem.solutions()
2799 Return an array containing multiple possible solutions to fix the problem. See
2800 the solution class for more information.
2802 int solution_count()
2803 my $cnt = $problem->solution_count();
2804 cnt = problem.solution_count()
2805 cnt = problem.solution_count()
2807 Return the number of solutions without creating solution objects.
2810 my $str = $problem->str;
2814 Return a string describing the problem. This is a convenience function, it is
2815 a shorthand for calling findproblemrule(), then ruleinfo() on the problem
2816 rule and problemstr() on the ruleinfo object.
2821 Rules are the basic block of sat solving. Each package dependency gets translated
2822 into one or multiple rules.
2826 Solver *solv; /* read only */
2831 Back pointer to solver object.
2833 Id id; /* read only */
2840 int type; /* read only */
2845 The basic type of the rule. See the constant section of the solver class for the type list.
2850 my $ruleinfo = $rule->info();
2851 ruleinfo = rule.info()
2852 ruleinfo = rule.info()
2854 Return a Ruleinfo object that contains information about why the rule was created. But
2855 see the allinfos() method below.
2857 Ruleinfo *allinfos()
2858 my @ruleinfos = $rule->allinfos();
2859 ruleinfos = rule.allinfos()
2860 ruleinfos = rule.allinfos()
2862 As the same dependency rule can get created because of multiple dependencies, one
2863 Ruleinfo is not enough to describe the reason. Thus the allinfos() method returns
2864 an array of all infos about a rule.
2866 Decision *get_decisionlist()
2867 my @decisions = $rule->get_decisionlist();
2868 decisions = rule.get_decisionlist()
2869 decisions = rule.get_decisionlist()
2871 Return a list of decisions prooving a learnt rule.
2873 Decision *get_decisionsetlist()
2874 my @decisionsets = $rule->get_decisionsetlist();
2875 decisionsets = rule.get_decisionsetlist()
2876 decisionsets = rule.get_decisionsetlist()
2878 Like the get_decisionlist() method, but the decisions are merged into
2882 my @learnt = $rule->get_learnt();
2883 learnt = rule.get_learnt()
2884 learnt = rule.get_lerant()
2886 Return a list of learnt rules that are part of the learnt rule proof.
2889 if ($rule1 == $rule2)
2893 Two rules are equal if they belong to the same solver and have the same id.
2898 A Ruleinfo describes one reason why a rule was created.
2902 Solver *solv; /* read only */
2907 Back pointer to solver object.
2909 int type; /* read only */
2914 The type of the ruleinfo. See the constant section of the solver class for the
2915 rule type list and the special type list.
2917 Dep *dep; /* read only */
2922 The dependency leading to the creation of the rule.
2924 Dep *dep_id; /* read only */
2929 The Id of the dependency leading to the creation of the rule, or zero.
2931 Solvable *solvable; /* read only */
2932 $ruleinfo->{solvable}
2936 The involved Solvable, e.g. the one containing the dependency.
2938 Solvable *othersolvable; /* read only */
2939 $ruleinfo->{othersolvable}
2940 ruleinfo.othersolvable
2941 ruleinfo.othersolvable
2943 The other involved Solvable (if any), e.g. the one providing
2946 const char *problemstr();
2947 my $str = $ruleinfo->problemstr();
2948 str = ruleinfo.problemstr()
2949 str = ruleinfo.problemstr()
2951 A string describing the ruleinfo from a problem perspective. This probably
2952 only makes sense if the rule is part of a problem.
2955 my $str = $ruleinfo->str;
2959 A string describing the ruleinfo, i.e. the reason why the corresponding rule
2965 A solution solves one specific problem. It consists of multiple solution elements
2966 that all need to be executed.
2970 Solver *solv; /* read only */
2975 Back pointer to solver object.
2977 Id problemid; /* read only */
2978 $solution->{problemid}
2982 Id of the problem the solution solves.
2984 Id id; /* read only */
2989 Id of the solution. The first solution has Id 1, they are numbered consecutively.
2993 Solutionelement *elements(bool expandreplaces = 0)
2994 my @solutionelements = $solution->elements();
2995 solutionelements = solution.elements()
2996 solutionelements = solution.elements()
2998 Return an array containing the elements describing what needs to be done to
2999 implement the specific solution. If expandreplaces is true, elements of type
3000 SOLVER_SOLUTION_REPLACE will be replaced by one or more elements replace
3001 elements describing the policy mismatches.
3004 my $cnt = $solution->solution_count();
3005 cnt = solution.element_count()
3006 cnt = solution.element_count()
3008 Return the number of solution elements without creating objects. Note that the
3009 count does not match the number of objects returned by the elements() method
3010 of expandreplaces is set to true.
3013 The Solutionelement Class
3014 -------------------------
3015 A solution element describes a single action of a solution. The action is always
3016 either to remove one specific job or to add a new job that installs or erases
3017 a single specific package.
3021 Solver *solv; /* read only */
3022 $solutionelement->{solv}
3023 solutionelement.solv
3024 solutionelement.solv
3026 Back pointer to solver object.
3028 Id problemid; /* read only */
3029 $solutionelement->{problemid}
3030 solutionelement.problemid
3031 solutionelement.problemid
3033 Id of the problem the element (partly) solves.
3035 Id solutionid; /* read only */
3036 $solutionelement->{solutionid}
3037 solutionelement.solutionid
3038 solutionelement.solutionid
3040 Id of the solution the element is a part of.
3042 Id id; /* read only */
3043 $solutionelement->{id}
3047 Id of the solution element. The first element has Id 1, they are numbered consecutively.
3049 Id type; /* read only */
3050 $solutionelement->{type}
3051 solutionelement.type
3052 solutionelement.type
3054 Type of the solution element. See the constant section of the solver class for the
3057 Solvable *solvable; /* read only */
3058 $solutionelement->{solvable}
3059 solutionelement.solvable
3060 solutionelement.solvable
3062 The installed solvable that needs to be replaced for replacement elements.
3064 Solvable *replacement; /* read only */
3065 $solutionelement->{replacement}
3066 solutionelement.replacement
3067 solutionelement.replacement
3069 The solvable that needs to be installed to fix the problem.
3071 int jobidx; /* read only */
3072 $solutionelement->{jobidx}
3073 solutionelement.jobidx
3074 solutionelement.jobidx
3076 The index of the job that needs to be removed to fix the problem, or -1 if the
3077 element is of another type. Note that it's better to change the job to SOLVER_NOOP
3078 type so that the numbering of other elements does not get disturbed. This
3079 method works both for types SOLVER_SOLUTION_JOB and SOLVER_SOLUTION_POOLJOB.
3083 Solutionelement *replaceelements()
3084 my @solutionelements = $solutionelement->replaceelements();
3085 solutionelements = solutionelement.replaceelements()
3086 solutionelements = solutionelement.replaceelements()
3088 If the solution element is of type SOLVER_SOLUTION_REPLACE, return an array of
3089 elements describing the policy mismatches, otherwise return a copy of the
3090 element. See also the ``expandreplaces'' option in the solution's elements()
3093 int illegalreplace()
3094 my $illegal = $solutionelement->illegalreplace();
3095 illegal = solutionelement.illegalreplace()
3096 illegal = solutionelement.illegalreplace()
3098 Return an integer that contains the policy mismatch bits or-ed together, or
3099 zero if there was no policy mismatch. See the policy error constants in
3103 my $job = $solutionelement->Job();
3104 illegal = solutionelement.Job()
3105 illegal = solutionelement.Job()
3107 Create a job that implements the solution element. Add this job to the array
3108 of jobs for all elements of type different to SOLVER_SOLUTION_JOB and
3109 SOLVER_SOLUTION_POOLJOB. For the latter two, a SOLVER_NOOB Job is created,
3110 you should replace the old job with the new one.
3113 my $str = $solutionelement->str();
3114 str = solutionelement.str()
3115 str = solutionelement.str()
3117 A string describing the change the solution element consists of.
3120 The Transaction Class
3121 ---------------------
3122 Transactions describe the output of a solver run. A transaction contains
3123 a number of transaction elements, each either the installation of a new
3124 package or the removal of an already installed package. The Transaction
3125 class supports a classify() method that puts the elements into different
3126 groups so that a transaction can be presented to the user in a meaningful
3131 Transaction element types, both active and passive
3133 *SOLVER_TRANSACTION_IGNORE*::
3134 This element does nothing. Used to map element types that do not match
3137 *SOLVER_TRANSACTION_INSTALL*::
3138 This element installs a package.
3140 *SOLVER_TRANSACTION_ERASE*::
3141 This element erases a package.
3143 *SOLVER_TRANSACTION_MULTIINSTALL*::
3144 This element installs a package with a different version keeping the other
3147 *SOLVER_TRANSACTION_MULTIREINSTALL*::
3148 This element reinstalls an installed package keeping the other versions
3151 Transaction element types, active view
3153 *SOLVER_TRANSACTION_REINSTALL*::
3154 This element re-installs a package, i.e. installs the same package again.
3156 *SOLVER_TRANSACTION_CHANGE*::
3157 This element installs a package with same name, version, architecture but
3160 *SOLVER_TRANSACTION_UPGRADE*::
3161 This element installs a newer version of an installed package.
3163 *SOLVER_TRANSACTION_DOWNGRADE*::
3164 This element installs an older version of an installed package.
3166 *SOLVER_TRANSACTION_OBSOLETES*::
3167 This element installs a package that obsoletes an installed package.
3169 Transaction element types, passive view
3171 *SOLVER_TRANSACTION_REINSTALLED*::
3172 This element re-installs a package, i.e. installs the same package again.
3174 *SOLVER_TRANSACTION_CHANGED*::
3175 This element replaces an installed package with one of the same name,
3176 version, architecture but different content.
3178 *SOLVER_TRANSACTION_UPGRADED*::
3179 This element replaces an installed package with a new version.
3181 *SOLVER_TRANSACTION_DOWNGRADED*::
3182 This element replaces an installed package with an old version.
3184 *SOLVER_TRANSACTION_OBSOLETED*::
3185 This element replaces an installed package with a package that obsoletes
3188 Pseudo element types for showing extra information used by classify()
3190 *SOLVER_TRANSACTION_ARCHCHANGE*::
3191 This element replaces an installed package with a package of a different
3194 *SOLVER_TRANSACTION_VENDORCHANGE*::
3195 This element replaces an installed package with a package of a different
3198 Transaction mode flags
3200 *SOLVER_TRANSACTION_SHOW_ACTIVE*::
3201 Filter for active view types. The default is to return passive view type,
3202 i.e. to show how the installed packages get changed.
3204 *SOLVER_TRANSACTION_SHOW_OBSOLETES*::
3205 Do not map the obsolete view type into INSTALL/ERASE elements.
3207 *SOLVER_TRANSACTION_SHOW_ALL*::
3208 If multiple packages replace an installed package, only the best of them
3209 is kept as OBSOLETE element, the other ones are mapped to INSTALL/ERASE
3210 elements. This is because most applications want to show just one package
3211 replacing the installed one. The SOLVER_TRANSACTION_SHOW_ALL makes the
3212 library keep all OBSOLETE elements.
3214 *SOLVER_TRANSACTION_SHOW_MULTIINSTALL*::
3215 The library maps MULTIINSTALL elements to simple INSTALL elements. This
3216 flag can be used to disable the mapping.
3218 *SOLVER_TRANSACTION_CHANGE_IS_REINSTALL*::
3219 Use this flag if you want to map CHANGE elements to the REINSTALL type.
3221 *SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE*::
3222 Use this flag if you want to map OBSOLETE elements to the UPGRADE type.
3224 *SOLVER_TRANSACTION_MERGE_ARCHCHANGES*::
3225 Do not add extra categories for every architecture change, instead cumulate
3226 them in one category.
3228 *SOLVER_TRANSACTION_MERGE_VENDORCHANGES*::
3229 Do not add extra categories for every vendor change, instead cumulate
3230 them in one category.
3232 *SOLVER_TRANSACTION_RPM_ONLY*::
3233 Special view mode that just returns IGNORE, ERASE, INSTALL, MULTIINSTALL
3234 elements. Useful if you want to find out what to feed to the underlying
3237 Transaction order flags
3239 *SOLVER_TRANSACTION_KEEP_ORDERDATA*::
3240 Do not throw away the dependency graph used for ordering the transaction.
3241 This flag is needed if you want to do manual ordering.
3245 Pool *pool; /* read only */
3250 Back pointer to pool.
3259 Returns true if the transaction does not do anything, i.e. has no elements.
3261 Solvable *newsolvables()
3262 my @newsolvables = $trans->newsolvables();
3263 newsolvables = trans.newsolvables()
3264 newsolvables = trans.newsolvables()
3266 Return all packages that are to be installed by the transaction. These are
3267 the packages that need to be downloaded from the repositories.
3269 Solvable *keptsolvables()
3270 my @keptsolvables = $trans->keptsolvables();
3271 keptsolvables = trans.keptsolvables()
3272 keptsolvables = trans.keptsolvables()
3274 Return all installed packages that the transaction will keep installed.
3277 my @steps = $trans->steps();
3278 steps = trans.steps()
3279 steps = trans.steps()
3281 Return all solvables that need to be installed (if the returned solvable
3282 is not already installed) or erased (if the returned solvable is installed).
3283 A step is also called a transaction element.
3285 int steptype(Solvable *solvable, int mode)
3286 my $type = $trans->steptype($solvable, $mode);
3287 type = trans.steptype(solvable, mode)
3288 type = trans.steptype(solvable, mode)
3290 Return the transaction type of the specified solvable. See the CONSTANTS
3291 sections for the mode argument flags and the list of returned types.
3293 TransactionClass *classify(int mode = 0)
3294 my @classes = $trans->classify();
3295 classes = trans.classify()
3296 classes = trans.classify()
3298 Group the transaction elements into classes so that they can be displayed
3299 in a structured way. You can use various mapping mode flags to tweak
3300 the result to match your preferences, see the mode argument flag in
3301 the CONSTANTS section. See the TransactionClass class for how to deal
3302 with the returned objects.
3304 Solvable othersolvable(Solvable *solvable)
3305 my $other = $trans->othersolvable($solvable);
3306 other = trans.othersolvable(solvable)
3307 other = trans.othersolvable(solvable)
3309 Return the ``other'' solvable for a given solvable. For installed packages
3310 the other solvable is the best package with the same name that replaces
3311 the installed package, or the best package of the obsoleting packages if
3312 the package does not get replaced by one with the same name.
3314 For to be installed packages, the ``other'' solvable is the best installed
3315 package with the same name that will be replaced, or the best packages
3316 of all the packages that are obsoleted if the new package does not replace
3317 a package with the same name.
3319 Thus, the ``other'' solvable is normally the package that is also shown
3320 for a given package.
3322 Solvable *allothersolvables(Solvable *solvable)
3323 my @others = $trans->allothersolvables($solvable);
3324 others = trans.allothersolvables(solvable)
3325 others = trans.allothersolvables(solvable)
3327 For installed packages, returns all of the packages that replace us. For to
3328 be installed packages, returns all of the packages that the new package
3329 replaces. The special ``other'' solvable is always the first entry of the
3332 long long calc_installsizechange()
3333 my $change = $trans->calc_installsizechange();
3334 change = trans.calc_installsizechange()
3335 change = trans.calc_installsizechange()
3337 Return the size change of the installed system in kilobytes (kibibytes).
3339 void order(int flags = 0)
3344 Order the steps in the transactions so that dependent packages are updated
3345 before packages that depend on them. For rpm, you can also use rpmlib's
3346 ordering functionality, debian's dpkg does not provide a way to order a
3349 === ACTIVE/PASSIVE VIEW ===
3351 Active view lists what new packages get installed, while passive view shows
3352 what happens to the installed packages. Most often there's not much
3353 difference between the two modes, but things get interesting if multiple
3354 packages get replaced by one new package. Say you have installed packages
3355 A-1-1 and B-1-1, and now install A-2-1 which has a new dependency that
3356 obsoletes B. The transaction elements will be
3358 updated A-1-1 (other: A-2-1)
3359 obsoleted B-1-1 (other: A-2-1)
3361 in passive mode, but
3363 update A-2-1 (other: A-1-1)
3366 in active mode. If the mode contains SOLVER_TRANSACTION_SHOW_ALL, the
3367 passive mode list will be unchanged but the active mode list will just
3371 The Transactionclass Class
3372 --------------------------
3373 Objects of this type are returned by the classify() Transaction method.
3377 Transaction *transaction; /* read only */
3378 $class->{transaction}
3382 Back pointer to transaction object.
3384 int type; /* read only */
3389 The type of the transaction elements in the class.
3391 int count; /* read only */
3396 The number of elements in the class.
3398 const char *fromstr;
3403 The old vendor or architecture.
3410 The new vendor or architecture.
3417 The id of the old vendor or architecture.
3424 The id of the new vendor or architecture.
3429 my @solvables = $class->solvables();
3430 solvables = class.solvables()
3431 solvables = class.solvables()
3433 Return the solvables for all transaction elements in the class.
3438 Checksums (also called hashes) are used to make sure that downloaded data is
3439 not corrupt and also as a fingerprint mechanism to check if data has changed.
3441 === CLASS METHODS ===
3443 Chksum Chksum(Id type)
3444 my $chksum = solv::Chksum->new($type);
3445 chksum = solv.Chksum(type)
3446 chksum = Solv::Chksum.new(type)
3448 Create a checksum object. Currently the following types are supported:
3457 These keys are constants in the *solv* class.
3459 Chksum Chksum(Id type, const char *hex)
3460 my $chksum = solv::Chksum->new($type, $hex);
3461 chksum = solv.Chksum(type, hex)
3462 chksum = Solv::Chksum.new(type, hex)
3464 Create an already finalized checksum object from a hex string.
3466 Chksum Chksum_from_bin(Id type, char *bin)
3467 my $chksum = solv::Chksum->from_bin($type, $bin);
3468 chksum = solv.Chksum.from_bin(type, bin)
3469 chksum = Solv::Chksum.from_bin(type, bin)
3471 Create an already finalized checksum object from a binary checksum.
3475 Id type; /* read only */
3480 Return the type of the checksum object.
3484 void add(const char *str)
3489 Add a (binary) string to the checksum.
3491 void add_fp(FILE *fp)
3492 $chksum->add_fp($file);
3496 Add the contents of a file to the checksum.
3498 void add_stat(const char *filename)
3499 $chksum->add_stat($filename);
3500 chksum.add_stat(filename)
3501 chksum.add_stat(filename)
3503 Stat the file and add the dev/ino/size/mtime member to the checksum. If the
3504 stat fails, the members are zeroed.
3506 void add_fstat(int fd)
3507 $chksum->add_fstat($fd);
3508 chksum.add_fstat(fd)
3509 chksum.add_fstat(fd)
3511 Same as add_stat, but instead of the filename a file descriptor is used.
3513 unsigned char *raw()
3514 my $raw = $chksum->raw();
3518 Finalize the checksum and return the result as raw bytes. This means that the
3519 result can contain NUL bytes or unprintable characters.
3522 my $raw = $chksum->hex();
3526 Finalize the checksum and return the result as hex string.
3528 const char *typestr()
3529 my $typestr = $chksum->typestr();
3530 typestr = chksum.typestr
3531 typestr = chksum.typestr
3533 Return the type of the checksum as a string, e.g. "sha256".
3536 if ($chksum1 == $chksum2)
3537 if chksum1 == chksum2:
3538 if chksum1 == chksum2
3540 Checksums are equal if they are of the same type and the finalized results are
3544 my $str = $chksum->str;
3548 If the checksum is finished, the checksum is returned as "<type>:<hex>" string.
3549 Otherwise "<type>:unfinished" is returned.
3554 This functions were added because libsolv uses standard *FILE* pointers to
3555 read/write files, but languages like perl have their own implementation of
3556 files. The libsolv functions also support decompression and compression, the
3557 algorithm is selected by looking at the file name extension.
3559 FILE *xfopen(char *fn, char *mode = "r")
3560 my $file = solv::xfopen($path);
3561 file = solv.xfopen(path)
3562 file = Solv::xfopen(path)
3564 Open a file at the specified path. The `mode` argument is passed on to the
3567 FILE *xfopen_fd(char *fn, int fileno)
3568 my $file = solv::xfopen_fd($path, $fileno);
3569 file = solv.xfopen_fd(path, fileno)
3570 file = Solv::xfopen_fd(path, fileno)
3572 Create a file handle from the specified file descriptor. The path argument is
3573 only used to select the correct (de-)compression algorithm, use an empty path
3574 if you want to make sure to read/write raw data. The file descriptor is dup()ed
3575 before the file handle is created.
3580 my $fileno = $file->fileno();
3581 fileno = file.fileno()
3582 fileno = file.fileno()
3584 Return file file descriptor of the file. If the file is not open, `-1` is
3587 void cloexec(bool state)
3588 $file->cloexec($state);
3592 Set the close-on-exec flag of the file descriptor. The xfopen function
3593 returns files with close-on-exec turned on, so if you want to pass
3594 a file to some other process you need to call cloexec(0) before calling
3598 my $fileno = $file->dup();
3602 Return a copy of the descriptor of the file. If the file is not open, `-1` is
3610 Flush the file. Returns false if there was an error. Flushing a closed file
3611 always returns true.
3618 Close the file. This is needed for languages like Ruby that do not destruct
3619 objects right after they are no longer referenced. In that case, it is good
3620 style to close open files so that the file descriptors are freed right away.
3621 Returns false if there was an error.
3626 The Repodata stores attributes for packages and the repository itself, each
3627 repository can have multiple repodata areas. You normally only need to
3628 directly access them if you implement lazy downloading of repository data.
3629 Repodata areas are created by calling the repository's add_repodata() method
3630 or by using repo_add methods without the REPO_REUSE_REPODATA or REPO_USE_LOADING
3635 Repo *repo; /* read only */
3640 Back pointer to repository object.
3642 Id id; /* read only */
3647 The id of the repodata area. Repodata ids of different repositories overlap.
3652 $data->internalize();
3656 Internalize newly added data. The lookup functions will only see the new data
3657 after it has been internalized.
3659 bool write(FILE *fp)
3664 Write the contents of the repodata area as solv file.
3666 Id str2dir(const char *dir, bool create = 1)
3667 my $did = data->str2dir($dir);
3668 did = data.str2dir(dir)
3669 did = data.str2dir(dir)
3671 const char *dir2str(Id did, const char *suffix = 0)
3672 $dir = pool->dir2str($did);
3673 dir = pool.dir2str(did)
3674 dir = pool.dir2str(did)
3676 Convert a string (directory) into an Id and back. If the string is currently not in the
3677 pool and _create_ is false, zero is returned.
3679 void add_dirstr(Id solvid, Id keyname, Id dir, const char *str)
3680 $data->add_dirstr($solvid, $keyname, $dir, $string);
3681 data.add_dirstr(solvid, keyname, dir, string)
3682 data.add_dirstr(solvid, keyname, dir, string)
3684 Add a file path consisting of a dirname Id and a basename string.
3686 bool add_solv(FILE *fp, int flags = 0)
3687 $data->add_solv($fp);
3691 Replace a stub repodata object with the data from a solv file. This method
3692 automatically adds the REPO_USE_LOADING flag. It should only be used from
3696 $data->create_stubs();
3700 Create stub repodatas from the information stored in the repodata meta
3703 void extend_to_repo()
3704 $data->extend_to_repo();
3705 data.extend_to_repo()
3706 data.extend_to_repo()
3708 Extend the repodata so that it has the same size as the repo it belongs to.
3709 This method is needed when setting up a new extension repodata so that it
3710 matches the repository size. It is also needed when switching to a just written
3711 repodata extension to make the repodata match the written extension (which is
3712 always of the size of the repo).
3715 if ($data1 == $data2)
3719 Two repodata objects are equal if they belong to the same repository and have
3722 === DATA RETRIEVAL METHODS ===
3724 const char *lookup_str(Id solvid, Id keyname)
3725 my $string = $data->lookup_str($solvid, $keyname);
3726 string = data.lookup_str(solvid, keyname)
3727 string = data.lookup_str(solvid, keyname)
3729 const char *lookup_id(Id solvid, Id keyname)
3730 my $string = $data->lookup_id($solvid, $keyname);
3731 string = data.lookup_id(solvid, keyname)
3732 string = data.lookup_id(solvid, keyname)
3734 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
3735 my $num = $data->lookup_num($solvid, $keyname);
3736 num = data.lookup_num(solvid, keyname)
3737 num = data.lookup_num(solvid, keyname)
3739 bool lookup_void(Id solvid, Id keyname)
3740 my $bool = $data->lookup_void($solvid, $keyname);
3741 bool = data.lookup_void(solvid, keyname)
3742 bool = data.lookup_void(solvid, keyname)
3744 Id *lookup_idarray(Id solvid, Id keyname)
3745 my @ids = $data->lookup_idarray($solvid, $keyname);
3746 ids = data.lookup_idarray(solvid, keyname)
3747 ids = data.lookup_idarray(solvid, keyname)
3749 Chksum lookup_checksum(Id solvid, Id keyname)
3750 my $chksum = $data->lookup_checksum($solvid, $keyname);
3751 chksum = data.lookup_checksum(solvid, keyname)
3752 chksum = data.lookup_checksum(solvid, keyname)
3754 Lookup functions. Return the data element stored in the specified solvable.
3755 The methods probably only make sense to retrieve data from the special
3756 SOLVID_META solvid that stores repodata meta information.
3758 === DATA STORAGE METHODS ===
3760 void set_str(Id solvid, Id keyname, const char *str)
3761 $data->set_str($solvid, $keyname, $str);
3762 data.set_str(solvid, keyname, str)
3763 data.set_str(solvid, keyname, str)
3765 void set_id(Id solvid, Id keyname, DepId id)
3766 $data->set_id($solvid, $keyname, $id);
3767 data.set_id(solvid, keyname, id)
3768 data.set_id(solvid, keyname, id)
3770 void set_num(Id solvid, Id keyname, unsigned long long num)
3771 $data->set_num($solvid, $keyname, $num);
3772 data.set_num(solvid, keyname, num)
3773 data.set_num(solvid, keyname, num)
3775 void set_void(Id solvid, Id keyname)
3776 $data->set_void($solvid, $keyname);
3777 data.set_void(solvid, keyname)
3778 data.set_void(solvid, keyname)
3780 void set_poolstr(Id solvid, Id keyname, const char *str)
3781 $data->set_poolstr($solvid, $keyname, $str);
3782 data.set_poolstr(solvid, keyname, str)
3783 data.set_poolstr(solvid, keyname, str)
3785 void set_checksum(Id solvid, Id keyname, Chksum *chksum)
3786 $data->set_checksum($solvid, $keyname, $chksum);
3787 data.set_checksum(solvid, keyname, chksum)
3788 data.set_checksum(solvid, keyname, chksum)
3790 void set_sourcepkg(Id solvid, const char *sourcepkg)
3791 $data.set_sourcepkg($solvid, $sourcepkg);
3792 data.set_sourcepkg(solvid, sourcepkg)
3793 data.set_sourcepkg(solvid, sourcepkg)
3795 void set_location(Id solvid, unsigned int mediano, const char *location)
3796 $data.set_location($solvid, $mediano, $location);
3797 data.set_location(solvid, mediano, location)
3798 data.set_location(solvid, mediano, location)
3800 void add_idarray(Id solvid, Id keyname, DepId id)
3801 $data->add_idarray($solvid, $keyname, $id);
3802 data.add_idarray(solvid, keyname, id)
3803 data.add_idarray(solvid, keyname, id)
3806 my $handle = $data->new_handle();
3807 handle = data.new_handle()
3808 handle = data.new_handle()
3810 void add_flexarray(Id solvid, Id keyname, Id handle)
3811 $data->add_flexarray($solvid, $keyname, $handle);
3812 data.add_flexarray(solvid, keyname, handle)
3813 data.add_flexarray(solvid, keyname, handle)
3815 void unset(Id solvid, Id keyname)
3816 $data->unset($solvid, $keyname);
3817 data.unset(solvid, keyname)
3818 data.unset(solvid, keyname)
3820 Data storage methods. Probably only useful to store data in the special
3821 SOLVID_META solvid that stores repodata meta information. Note that
3822 repodata areas can have their own Id pool (see the REPO_LOCALPOOL flag),
3823 so be careful if you need to store ids. Arrays are created by calling
3824 the add function for every element. A flexarray is an array of
3825 sub-structures, call new_handle to create a new structure, use the
3826 handle as solvid to fill the structure with data and call add_flexarray
3827 to put the structure in an array.
3832 Datapos objects describe a specific position in the repository data area.
3833 Thus they are only valid until the repository is modified in some way.
3834 Datapos objects can be created by the pos() and parentpos() methods of
3835 a Datamatch object or by accessing the ``meta'' attribute of a repository.
3839 Repo *repo; /* read only */
3844 Back pointer to repository object.
3848 Dataiterator(Id keyname, const char *match, int flags)
3849 my $di = $datapos->Dataiterator($keyname, $match, $flags);
3850 di = datapos.Dataiterator(keyname, match, flags)
3851 di = datapos.Dataiterator(keyname, match, flags)
3853 Create a Dataiterator at the position of the datapos object.
3855 const char *lookup_deltalocation(unsigned int *OUTPUT)
3856 my ($location, $mediano) = $datapos->lookup_deltalocation();
3857 location, mediano = datapos.lookup_deltalocation()
3858 location, mediano = datapos.lookup_deltalocation()
3860 Return a tuple containing the on-media location and an optional media number
3861 for a delta rpm. This obviously only works if the data position points to
3862 structure describing a delta rpm.
3864 const char *lookup_deltaseq()
3865 my $seq = $datapos->lookup_deltaseq();
3866 seq = datapos.lookup_deltaseq();
3867 seq = datapos.lookup_deltaseq();
3869 Return the delta rpm sequence from the structure describing a delta rpm.
3871 === DATA RETRIEVAL METHODS ===
3873 const char *lookup_str(Id keyname)
3874 my $string = $datapos->lookup_str($keyname);
3875 string = datapos.lookup_str(keyname)
3876 string = datapos.lookup_str(keyname)
3878 Id lookup_id(Id solvid, Id keyname)
3879 my $id = $datapos->lookup_id($keyname);
3880 id = datapos.lookup_id(keyname)
3881 id = datapos.lookup_id(keyname)
3883 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0)
3884 my $num = $datapos->lookup_num($keyname);
3885 num = datapos.lookup_num(keyname)
3886 num = datapos.lookup_num(keyname)
3888 bool lookup_void(Id keyname)
3889 my $bool = $datapos->lookup_void($keyname);
3890 bool = datapos.lookup_void(keyname)
3891 bool = datapos.lookup_void(keyname)
3893 Id *lookup_idarray(Id keyname)
3894 my @ids = $datapos->lookup_idarray($keyname);
3895 ids = datapos.lookup_idarray(keyname)
3896 ids = datapos.lookup_idarray(keyname)
3898 Chksum lookup_checksum(Id keyname)
3899 my $chksum = $datapos->lookup_checksum($keyname);
3900 chksum = datapos.lookup_checksum(keyname)
3901 chksum = datapos.lookup_checksum(keyname)
3903 Lookup functions. Note that the returned Ids are always translated into
3904 the Ids of the global pool even if the repodata area contains its own pool.
3906 Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0)
3907 my $di = $datapos->Dataiterator($keyname, $match, $flags);
3908 di = datapos.Dataiterator(keyname, match, flags)
3909 di = datapos.Dataiterator(keyname, match, flags)
3915 Iterate over the matching data elements. See the Dataiterator class for more
3919 The Alternative Class
3920 ---------------------
3921 An Alternative object describes a branch point in the solving process. The
3922 solver found more than one good way to fulfill a dependency and chose one.
3923 It recorded the other possibilities in the alternative object so that they
3924 can be presented to the user in the case a different solution is preferable.
3928 Solver *solv; /* read only */
3929 $alternative->{solv}
3933 Back pointer to solver object.
3935 Id type; /* read only */
3936 $alternative->{type}
3940 The type of the alternative. Alternatives can be created because of rule
3941 fulfillment, because of recommended packages, and because of suggested
3942 packages (currently unused). See below for a list of valid types.
3944 Rule rule; /* read only */
3945 $alternative->{rule}
3949 The rule that caused the creation of the alternative (SOLVER_ALTERNATIVE_TYPE_RULE).
3951 Dep *dep; /* read only */
3956 The dependency that caused the creation of the alternative (SOLVER_ALTERNATIVE_TYPE_RECOMMENDS).
3958 Dep *depsolvable; /* read only */
3959 $ruleinfo->{depsolvable}
3960 ruleinfo.depsolvable
3961 ruleinfo.depsolvable
3963 The package containing the dependency (SOLVER_ALTERNATIVE_TYPE_RECOMMENDS).
3965 Solvable chosen; /* read only */
3966 $alternative->{chosen}
3970 The solvable that the solver chose from the alternative's package set.
3974 *SOLVER_ALTERNATIVE_TYPE_RULE*::
3976 The alternative was created when fulfilling a rule.
3978 *SOLVER_ALTERNATIVE_TYPE_RECOMMENDS*::
3980 The alternative was created when fulfilling a recommends dependency.
3982 *SOLVER_ALTERNATIVE_TYPE_SUGGESTS*::
3984 The alternative was created when fulfilling a suggests dependency.
3989 my @choices = $alternative->choices();
3990 choices = alternative.choices
3991 choices = alternative.choices
3993 Return the set of solvables that the solver could choose from when
3994 creating the alternative.
3997 my $str = $alternative->str;
3998 str = str(alternative)
3999 str = alternative.to_s
4001 Return a string describing the alternative.
4006 A decision is created when the solver fulfills dependencies. It can be
4007 either to install a package to satisfy a dependency or to conflict a
4008 dependency because it conflicts with another package or its dependencies
4009 cannot be met. Most decisions are caused by rule processing, but there
4010 are some other types like orphaned package handling or weak dependency
4015 Solver *solv; /* read only */
4020 Back pointer to solver object.
4022 Id p; /* read only */
4027 The decision package id, positive for installs and negative for conflicts.
4029 int reason; /* read only */
4034 The reason for the decision. See the SOLVER_REASON_ constants.
4036 int infoid; /* read only */
4041 Extra info for the decision. This is the rule id for decisions caused
4042 by rule fulfillment.
4044 Solvable solvable; /* read only */
4045 $decision->{solvable}
4049 The decision package object.
4051 Rule rule() /* read only */
4056 The rule object for decisions that where caused by rule fulfilment.
4061 my $info = $decision->info();
4062 info = decision.info()
4063 info = decision.info()
4065 Return a Ruleinfo object describing the decision. Some reasons like
4066 SOLVER_REASON_WEAKDEP are not caused by rules, but can be expressed
4067 by a Ruleinfo object.
4069 Ruleinfo *allinfos()
4070 my @infos = $decision->allinfos();
4071 infos = decision.allinfos()
4072 infos = decision.allinfos()
4074 Same as info(), but all Ruleinfo objects describing the decision are
4077 const char *reasonstr()
4078 my str = $decision->reasonstr()
4079 str = decision.reasonstr()
4080 str = decision.reasonstr()
4082 Return a string describing why a decision was done (but without
4083 the decision itself).
4086 my $str = $decison->str;
4090 Return a string describing the decision (but without the reason).
4093 The Decisionset Class
4094 ---------------------
4095 A decisionset consists of multiple decisions of the same reason and type
4096 that can be presented to the user as a single action.
4100 Solver *solv; /* read only */
4105 Back pointer to solver object.
4107 Id p; /* read only */
4112 The package id of the first decision, positive for installs and negative for conflicts.
4114 int reason; /* read only */
4119 The reason for the decisions in the set. See the SOLVER_REASON_ constants.
4121 int type; /* read only */
4126 The type of the decision info. See the constant section of the solver class for the
4127 rule type list and the special type list.
4129 Dep *dep; /* read only */
4134 The dependency that caused the decision
4136 Dep *dep_id; /* read only */
4141 The Id of the dependency that caused the decision.
4145 Decision *decisions()
4146 my @decisions = $decisionset->decisions();
4147 decisions = decisionset.decisions()
4148 decisions = decisionset.decisions()
4150 Return all the decisions of the set.
4152 Solvable *solvables()
4153 my @pkgs = $decisionset->solvables();
4154 pkgs = decisionset.solvables()
4155 pkgs = decisionset.solvables()
4157 Return all the packages that were decided in the set.
4159 const char *reasonstr()
4160 my str = $decision->reasonstr();
4161 str = decision.reasonstr()
4162 str = decision.reasonstr()
4164 Return a string describing why the decisions were done (but without
4165 the decisions themself).
4168 my $str = $decison->str;
4172 Return a string describing the decisions (but without the reason).
4177 Michael Schroeder <mls@suse.de>
4180 vim: syntax=asciidoc