9 libsolv-bindings - access libsolv from perl/python/ruby
14 Libsolv's language bindings offer an abstract, object orientated interface
15 to the library. The supported languages are currently perl, python, and ruby.
16 All example code (except in the specifics sections, of course) lists first
17 the ``C-ish'' interface, then the syntax for perl, python, and ruby (in that
23 Libsolv's perl bindings can be loaded with the following statement:
27 Objects are either created by calling the new() method on a class or they
28 are returned by calling methods on other objects.
30 my $pool = solv::Pool->new();
31 my $repo = $pool->add_repo("my_first_repo");
33 Swig encapsulates all objects as tied hashes, thus the attributes can be
34 accessed by treating the object as standard hash reference:
36 $pool->{appdata} = 42;
37 printf "appdata is %d\n", $pool->{appdata};
39 An special exception to this are iterator objects, they are encapsulated as
40 tied arrays so that it is possible to iterate with a for() statement:
42 my $iter = $pool->solvables_iter();
43 for my $solvable (@$iter) { ... };
45 As a downside of this approach, iterator objects cannot have attributes.
47 If an array needs to be passed to a method it is usually done by reference,
48 if a method returns an array it returns it on the stack:
50 my @problems = $solver->solve(\@jobs);
52 Due to a bug in swig, stringification does not work for libsolv's object.
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 an returned as list objects:
88 problems = solver.solve(jobs)
90 The bindings define stringification for many classes, some also have a
91 __repr__ method to ease debugging.
96 Constants are attributes of the classes:
98 pool.set_flag(solv.Pool.POOL_FLAG_OBSOLETEUSESCOLORS, 1);
103 The ruby bindings can be loaded with:
107 Objects are either created by calling the new method on a class or they
108 are returned by calling methods on other objects. Note that all classes start
109 with an uppercase letter in ruby, so the class is called ``Solv''.
111 pool = Solv::Pool.new
112 repo = pool.add_repo("my_first_repo")
114 Attributes can be accessed as usual:
117 puts "appdata is #{pool.appdata}"
119 Iterators also work as expected:
121 for solvable in pool.solvables_iter() do ...
123 Arrays are passed an returned as array objects:
126 problems = solver.solve(jobs)
128 Most classes define a to_s method, so objects can be easily stringified.
129 Many also define an inspect() method.
134 Constants live in the namespace of the class they belong to:
136 pool.set_flag(Solv::Pool::POOL_FLAG_OBSOLETEUSESCOLORS, 1);
138 Note that boolean methods have an added trailing ``?'', to be consistent with
141 puts "empty repo" if repo.isempty?
146 This is the main namespace of the library, you cannot create objects of this
147 type but it contains some useful constants.
151 Relational flag constants, the first three can be or-ed together
154 the ``less than'' bit
157 the ``equals to'' bit
160 the ``greater then'' bit
163 used for relations that describe an extra architecture filter, the
164 version part of the relation is interpreted as architecture.
169 Access the meta section of a repository or repodata area. This is
170 like an extra Solvable that has the Id SOLVID_META.
173 Use the data position stored inside of the pool instead of accessing
174 some solvable by Id. The bindings have the Datapos objects as an
175 abstraction mechanism, so you do not need this constant.
183 Always one, describes the empty string
186 The keyname Id of the name of the solvable.
189 see the libsolv-constantids manpage for a list of fixed Ids.
194 The pool is libsolv's central resource manager. A pool consists of Solvables,
195 Repositories, Dependencies, each indexed by Ids.
197 === CLASS METHODS ===
200 my $pool = solv::Pool->new();
202 pool = Solv::Pool.new()
204 Create a new pool instance. In most cases you just need
209 void *appdata; /* read/write */
214 Application specific data that may be used in any way by the code using the
217 Solvable solvables[]; /* read only */
218 my $solvable = $pool->{solvables}->[$solvid];
219 solvable = pool.solvables[solvid]
220 solvable = pool.solvables[solvid]
222 Look up a Solvable by its id.
224 Repo repos[]; /* read only */
225 my $repo = $pool->{repos}->[$repoid];
226 repo = pool.repos[repoid]
227 repo = pool.repos[repoid]
229 Look up a Repository by its id.
231 Repo *installed; /* read/write */
232 $pool->{installed} = $repo;
233 pool.installed = repo
234 pool.installed = repo
236 Define which repository contains all the installed packages.
238 const char *errstr; /* read only */
239 my $err = $pool->{errstr};
243 Return the last error string that was stored in the pool.
247 *POOL_FLAG_PROMOTEEPOCH*::
248 Promote the epoch of the providing dependency to the requesting
249 dependency if it does not contain an epoch. Used at some time
250 in old rpm versions, modern systems should never need this.
252 *POOL_FLAG_FORBIDSELFCONFLICTS*::
253 Disallow the installation of packages that conflict with themselves.
254 Debian always allows self-conflicting packages, rpm used to forbid
255 them but switched to also allowing them recently.
257 *POOL_FLAG_OBSOLETEUSESPROVIDES*::
258 Make obsolete type dependency match against provides instead of
259 just the name and version of packages. Very old versions of rpm
260 used the name/version, then it got switched to provides and later
261 switched back again to just name/version.
263 *POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES*::
264 An implicit obsoletes is the internal mechanism to remove the
265 old package on an update. The default is to remove all packages
266 with the same name, rpm-5 switched to also removing packages
267 providing the same name.
269 *POOL_FLAG_OBSOLETEUSESCOLORS*::
270 Rpm's multilib implementation (used in RedHat and Fedora)
271 distinguishes between 32bit and 64bit packages (the terminology
272 is that they have a different color). If obsoleteusescolors is
273 set, packages with different colors will not obsolete each other.
275 *POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS*::
276 Same as POOL_FLAG_OBSOLETEUSESCOLORS, but used to find out if
277 packages of the same name can be installed in parallel. For
278 current Fedora systems, POOL_FLAG_OBSOLETEUSESCOLORS should be
279 false and POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS should be true
280 (this is the default if FEDORA is defined when libsolv is
283 *POOL_FLAG_NOINSTALLEDOBSOLETES*::
284 New versions of rpm consider the obsoletes of installed packages
285 when checking for dependency, thus you may not install a package
286 that is obsoleted by some other installed package, unless you
287 also erase the other package.
289 *POOL_FLAG_HAVEDISTEPOCH*::
290 Mandriva added a new field called distepoch that gets checked in
291 version comparison if the epoch/version/release of two packages
294 *POOL_FLAG_NOOBSOLETESMULTIVERSION*::
295 If a package is installed in multiversionmode, rpm used to ignore
296 both the implicit obsoletes and the obsolete dependency of a
297 package. This was changed to ignoring just the implicit obsoletes,
298 thus you may install multiple versions of the same name, but
299 obsoleted packages still get removed.
301 *POOL_FLAG_ADDFILEPROVIDESFILTERED*::
302 Make the addfileprovides method only add files from the standard
303 locations (i.e. the ``bin'' and ``etc'' directories). This is
304 useful if you have only few packages that use non-standard file
305 dependencies, but you still wand the fast speed that addfileprovides()
315 Free a pool. This is currently done with a method instead of relying on
316 reference counting or garbage collection because it's hard to track every
319 void setdebuglevel(int level)
320 $pool->setdebuglevel($level);
321 pool.setdebuglevel(level)
322 pool.setdebuglevel(level)
324 Set the debug level. A value of zero means no debug output, the higher the
325 value, the more output is generated.
327 int set_flag(int flag, int value)
328 my $oldvalue = $pool->set_flag($flag, $value);
329 oldvalue = pool.set_flag(flag, value)
330 oldvalue = pool.set_flag(flag, value)
332 int get_flag(int flag)
333 my $value = $pool->get_flag($flag);
334 value = pool.get_flag(flag)
335 value = pool.get_flag(flag)
337 Set/get a pool specific flag. The flags define how the system works, e.g. how
338 the package manager treats obsoletes. The default flags should be sane for most
339 applications, but in some cases you may want to tweak a flag, for example if
340 you want to solv package dependencies for some other system than yours.
342 void set_rootdir(const char *rootdir)
343 $pool->set_rootdir(rootdir);
344 pool.set_rootdir(rootdir)
345 pool.set_rootdir(rootdir)
347 const char *get_rootdir()
348 my $rootdir = $pool->get_rootdir();
349 rootdir = pool.get_rootdir()
350 rootdir = pool.get_rootdir()
352 Set/get the rootdir to use. This is useful if you want package management
353 to work only in some directory, for example if you want to setup a chroot
354 jail. Note that the rootdir will only be prepended to file paths if the
355 *REPO_USE_ROOTDIR* flag is used.
357 void setarch(const char *arch = 0)
362 Set the architecture for your system. The architecture is used to determine
363 which packages are installable. It defaults to the result of ``uname -m''.
365 Repo add_repo(const char *name)
366 $repo = $pool->add_repo($name);
367 repo = pool.add_repo(name)
368 repo = pool.add_repo(name)
370 Add a Repository with the specified name to the pool. The repository is empty
371 on creation, use the repository methods to populate it with packages.
373 Repoiterator repos_iter()
374 for my $repo (@{$pool->repos_iter()})
375 for repo in pool.repos_iter():
376 for repo in pool.repos_iter()
378 Iterate over the existing repositories.
380 Solvableiterator solvables_iter()
381 for my $solvable (@{$pool->solvables_iter()})
382 for solvable in pool.solvables_iter():
383 for solvable in pool.solvables_iter()
385 Iterate over the existing solvables.
387 Dep Dep(const char *str, bool create = 1)
388 my $dep = $pool->Dep($string);
389 dep = pool.Dep(string)
390 dep = pool.Dep(string)
392 Create an object describing a string or dependency. If the string is currently
393 not in the pool and _create_ is false, *undef*/*None*/*nil* is returned.
395 void addfileprovides()
396 $pool->addfileprovides();
397 pool.addfileprovides()
398 pool.addfileprovides()
400 Id *addfileprovides_queue()
401 my @ids = $pool->addfileprovides_queue();
402 ids = pool.addfileprovides_queue()
403 ids = pool.addfileprovides_queue()
405 Some package managers like rpm allow dependencies on files contained in other
406 packages. To allow libsolv to deal with those dependencies in an efficient way,
407 you need to call the addfileprovides method after creating and reading all
408 repositories. This method will scan all dependency for file names and than scan
409 all packages for matching files. If a filename has been matched, it will be
410 added to the provides list of the corresponding package. The
411 addfileprovides_queue variant works the same way but returns an array
412 containing all file dependencies. This information can be stored in the
413 meta section of the repositories to speed up the next time the
414 repository is loaded and addfileprovides is called.
416 void createwhatprovides()
417 $pool->createwhatprovides();
418 pool.createwhatprovides()
419 pool.createwhatprovides()
421 Create the internal ``whatprovides'' hash over all of the provides of all
422 packages. This method must be called before doing any lookups on provides.
423 It's encouraged to do it right after all repos are set up, usually right after
424 the call to addfileprovides().
426 Solvable *whatprovides(DepId dep)
427 my @solvables = $pool->whatprovides($dep);
428 solvables = pool.whatprovides(dep)
429 solvables = pool.whatprovides(dep)
431 Return all solvables that provide the specified dependency. You can use either
432 a Dep object or an simple Id as argument.
434 Id *matchprovidingids(const char *match, int flags)
435 my @ids = $pool->matchprovidingids($match, $flags);
436 ids = pool.matchprovidingids(match, flags)
437 ids = pool.matchprovidingids(match, flags)
439 Search the names of all provides and return the ones matching the specified
440 string. See the Dataiterator class for the allowed flags.
442 Id towhatprovides(Id *ids)
443 my $offset = $pool->towhatprovides(\@ids);
444 offset = pool.towhatprovides(ids)
445 offset = pool.towhatprovides(ids)
447 ``Internalize'' an array containing Ids. The returned value can be used to
448 create solver jobs working on a specific set of packages. See the Solver class
449 for more information.
451 bool isknownarch(DepId id)
452 my $bool = $pool->isknownarch($id);
453 bool = pool.isknownarch(id)
454 bool = pool.isknownarch?(id)
456 Return true if the specified Id describes a known architecture.
459 my $solver = $pool->Solver();
460 solver = pool.Solver()
461 solver = pool.Solver()
463 Create a new solver object.
465 Job Job(int how, Id what)
466 my $job = $pool->Job($how, $what);
467 job = pool.Job(how, what)
468 job = pool.Job(how, what)
470 Create a new Job object. Kind of low level, in most cases you would use a
471 Selection or Dep job constructor instead.
473 Selection Selection()
474 my $sel = $pool->Selection();
475 sel = pool.Selection()
476 sel = pool.Selection()
478 Create an empty selection. Useful as a starting point for merging other
481 Selection Selection_all()
482 my $sel = $pool->Selection_all();
483 sel = pool.Selection_all()
484 sel = pool.Selection_all()
486 Create a selection containing all packages. Useful as starting point for
487 intersecting other selections or for update/distupgrade jobs.
489 Selection select(const char *name, int flags)
490 my $sel = $pool->select($name, $flags);
491 sel = pool.select(name, flags)
492 sel = pool.select(name, flags)
494 Create a selection by matching packages against the specified string. See the
495 Selection class for a list of flags and how to create solver jobs from a
498 void setpooljobs(Jobs *jobs)
499 $pool->setpooljobs(\@jobs);
500 pool.setpooljobs(jobs)
501 pool.setpooljobs(jobs)
504 @jobs = $pool->getpooljobs();
505 jobs = pool.getpooljobs()
506 jobs = pool.getpooljobs()
508 Get/Set fixed jobs stored in the pool. Those jobs are automatically appended to
509 all solver jobs, they are meant for fixed configurations like which packages
510 can be multiversion installed, which packages were userinstalled or must not be
513 void set_loadcallback(Callable *callback)
514 $pool->setloadcallback(\&callbackfunction);
515 pool.setloadcallback(callbackfunction)
516 pool.setloadcallback { |repodata| ... }
518 Set the callback function called when repository metadata needs to be loaded on
519 demand. To make use of this feature, you need to create repodata stubs that
520 tell the library which data is available but not loaded. If later on the data
521 needs to be accessed, the callback function is called with a repodata argument.
522 You can then load the data (maybe fetching it first from an remote server).
523 The callback should return true if the data has been made available.
525 === DATA RETRIEVAL METHODS ===
527 In the following functions, the _keyname_ argument describes what to retrieve.
528 For the standard cases you can use the available Id constants. For example,
530 $solv::SOLVABLE_SUMMARY
531 solv.SOLVABLE_SUMMARY
532 Solv::SOLVABLE_SUMMARY
534 selects the ``Summary'' entry of a solvable. The _solvid_ argument selects the
535 desired solvable by Id.
537 const char *lookup_str(Id solvid, Id keyname)
538 my $string = $pool->lookup_str($solvid, $keyname);
539 string = pool.lookup_str(solvid, keyname)
540 string = pool.lookup_str(solvid, keyname)
542 Id lookup_id(Id solvid, Id keyname)
543 my $id = $pool->lookup_id($solvid, $keyname);
544 id = pool.lookup_id(solvid, keyname)
545 id = pool.lookup_id(solvid, keyname)
547 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
548 my $num = $pool->lookup_num($solvid, $keyname);
549 num = pool.lookup_num(solvid, keyname)
550 num = pool.lookup_num(solvid, keyname)
552 bool lookup_void(Id solvid, Id keyname)
553 my $bool = $pool->lookup_void($solvid, $keyname);
554 bool = pool.lookup_void(solvid, keyname)
555 bool = pool.lookup_void(solvid, keyname)
557 Id *lookup_idarray(Id solvid, Id keyname)
558 my @ids = $pool->lookup_idarray($solvid, $keyname);
559 ids = pool.lookup_idarray(solvid, keyname)
560 ids = pool.lookup_idarray(solvid, keyname)
562 Chksum lookup_checksum(Id solvid, Id keyname)
563 my $chksum = $pool->lookup_checksum($solvid, $keyname);
564 chksum = pool.lookup_checksum(solvid, keyname)
565 chksum = pool.lookup_checksum(solvid, keyname)
567 Lookup functions. Return the data element stored in the specified solvable.
568 You should probably use the methods of the Solvable class instead.
570 Dataiterator Dataiterator(Id solvid, Id keyname, const char *match, int flags)
571 my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags);
572 di = pool.Dataiterator(solvid, keyname, match, flags)
573 di = pool.Dataiterator(solvid, keyname, match, flags)
579 Iterate over the matching data elements. See the Dataiterator class for more
584 The following methods deal with Ids, i.e. integers representing objects in the
585 pool. They are considered ``low level'', in most cases you would not use them
586 but instead the object orientated methods.
589 $repo = $pool->id2repo($id);
590 repo = pool.id2repo(id)
591 repo = pool.id2repo(id)
593 Lookup an existing Repository by id. You can also do this by using the *repos*
596 Solvable id2solvable(Id id)
597 $solvable = $pool->id2solvable($id);
598 solvable = pool.id2solvable(id)
599 solvable = pool.id2solvable(id)
601 Lookup an existing Repository by id. You can also do this by using the
602 *solvables* attribute.
604 const char *solvid2str(Id id)
605 my $str = $pool->solvid2str($id);
606 str = pool.solvid2str(id)
607 str = pool.solvid2str(id)
609 Return a string describing the Solvable with the specified id. The string
610 consists of the name, version, and architecture of the Solvable.
612 Id str2id(const char *str, bool create = 1)
613 my $id = pool->str2id($string);
614 id = pool.str2id(string)
615 id = pool.str2id(string)
617 const char *id2str(Id id)
618 $string = pool->id2str($id);
619 string = pool.id2str(id)
620 string = pool.id2str(id)
622 Convert a string into an Id and back. If the string is currently not in the
623 pool and _create_ is false, zero is returned.
625 Id rel2id(Id name, Id evr, int flags, bool create = 1)
626 my $id = pool->rel2id($nameid, $evrid, $flags);
627 id = pool.rel2id(nameid, evrid, flags)
628 id = pool.rel2id(nameid, evrid, flags)
630 Create a ``relational'' dependency. Such dependencies consist of a name part,
631 the _flags_ describing the relation, and a version part. The flags are:
633 $solv::REL_EQ | $solv::REL_GT | $solv::REL_LT
634 solv.REL_EQ | solv.REL_GT | solv.REL_LT
635 Solv::REL_EQ | Solv::REL_GT | Solv::REL_LT
637 Thus, if you want a ``\<='' relation, you would use *REL_LT | REL_EQ*.
639 Id id2langid(Id id, const char *lang, bool create = 1)
640 my $id = $pool->id2langid($id, $language);
641 id = pool.id2langid(id, language)
642 id = pool.id2langid(id, language)
644 Create a language specific Id from some other id. This function simply converts
645 the id into a string, appends a dot and the specified language to the string
646 and converts the result back into an Id.
648 const char *dep2str(Id id)
649 $string = pool->dep2str($id);
650 string = pool.dep2str(id)
651 string = pool.dep2str(id)
653 Convert a dependency id into a string. If the id is just a string, this
654 function has the same effect as id2str(). For relational dependencies, the
655 result is the correct ``name relation evr'' string.
660 The dependency class is an object orientated way to work with strings and
661 dependencies. Internally, dependencies are represented as Ids, i.e. simple
662 numbers. Dependency objects can be constructed by using the Pool's Dep()
667 Pool *pool; /* read only */
672 Back reference to the pool this dependency belongs to.
674 Id id; /* read only */
679 The id of this dependency.
683 Dep Rel(int flags, DepId evrid, bool create = 1)
684 my $reldep = $dep->Rel($flags, $evrdep);
685 reldep = dep.Rel(flags, evrdep)
686 reldep = dep.Rel(flags, evrdep)
688 Create a relational dependency from to string dependencies and a flags
689 argument. See the pool's rel2id method for a description of the flags.
691 Selection Selection_name(int setflags = 0)
692 my $sel = $dep->Selection_name();
693 sel = dep.Selection_name()
694 sel = dep.Selection_name()
696 Create a Selection from a dependency. The selection consists of all packages
697 that have a name equal to the dependency. If the dependency is of a relational
698 type, the packages version must also fulfill the dependency.
700 Selection Selection_provides(int setflags = 0)
701 my $sel = $dep->Selection_provides();
702 sel = dep.Selection_provides()
703 sel = dep.Selection_provides()
705 Create a Selection from a dependency. The selection consists of all packages
706 that have at least one provides matching the dependency.
709 my $str = $dep->str();
713 Return a string describing the dependency.
720 Same as calling the str() method.
727 The dependencies are equal if they are part of the same pool and have the same
733 A Repository describes a group of packages, normally coming from the same
734 source. Repositories are created by the Pool's add_repo() method.
738 Pool *pool; /* read only */
743 Back reference to the pool this dependency belongs to.
745 Id id; /* read only */
750 The id of the repository.
752 const char *name; /* read/write */
757 The repositories name. To libsolv, the name is just a string with no specific
760 int priority; /* read/write */
765 The priority of the repository. A higher number means that packages of this
766 repository will be chosen over other repositories, even if they have a greater
769 int subpriority; /* read/write */
774 The sub-priority of the repository. This value is compared when the priorities
775 of two repositories are the same. It is useful to make the library prefer
776 on-disk repositories to remote ones.
778 int nsolvables; /* read only */
783 The number of solvables in this repository.
785 void *appdata; /* read/write */
790 Application specific data that may be used in any way by the code using the
793 Datapos *meta; /* read only */
798 Return a Datapos object of the repodata's metadata. You can use the lookup
799 methods of the Datapos class to lookup metadata attributes, like the repository
804 *REPO_REUSE_REPODATA*::
805 Reuse the last repository data area (``repodata'') instead of creating a new
808 *REPO_NO_INTERNALIZE*::
809 Do not internalize the added repository data. This is useful if
810 you plan to add more data because internalization is a costly
814 Use the repodata's pool for Id storage instead of the global pool. Useful
815 if you don't want to pollute the global pool with many unneeded ids, like
816 when storing the filelist.
819 Use the repodata that is currently being loaded instead of creating a new one.
820 This only makes sense if used in a load callback.
822 *REPO_EXTEND_SOLVABLES*::
823 Do not create new solvables for the new data, but match existing solvables and
824 add the data to them. Repository metadata is often split into multiple parts,
825 with one primary file describing all packages and other parts holding
826 information that is normally not needed, like the changelog.
829 Prepend the pool's rootdir to the path when doing file operations.
832 Do not add a location element to the solvables. Useful if the solvables are
833 not in the final position, so you can add the correct location later in your code.
835 *SOLV_ADD_NO_STUBS*::
836 Do not create stubs for repository parts that can be downloaded on demand.
838 *SUSETAGS_RECORD_SHARES*::
839 This is specific to the add_susetags() method. Susetags allows to refer to already
840 read packages to save disk space. If this data sharing needs to work over multiple
841 calls to add_susetags, you need to specify this flag so that the share information
842 is made available to subsequent calls.
846 void free(bool reuseids = 0)
851 Free the repository and all solvables it contains. If _reuseids_ is set to
852 true, the solvable ids and the repository id may be reused by the library when
853 added new solvables. Thus you should leave it false if you are not sure that
854 somebody holds a reference.
856 void empty(bool reuseids = 0)
861 Free all the solvables in a repository. The repository will be empty after this
862 call. See the free() method for the meaning of _reuseids_.
869 Return true if there are no solvables in this repository.
872 $repo->internalize();
876 Internalize added data. Data must be internalized before it is available to the
877 lookup and data iterator functions.
884 Write a repo as a ``solv'' file. These files can be read very fast and thus are
885 a good way to cache repository data. Returns false if there was some error
888 Solvableiterator solvables_iter()
889 for my $solvable (@{$repo->solvables_iter()})
890 for solvable in repo.solvables_iter():
891 for solvable in repo.solvables_iter()
893 Iterate over all solvables in a repository.
895 Repodata add_repodata(int flags = 0)
896 my $repodata = $repo->add_repodata();
897 repodata = repo.add_repodata()
898 repodata = repo.add_repodata()
900 Add a new repodata area to the repository. This is normally automatically
901 done by the repo_add methods, so you need this method only in very
905 $repo->create_stubs();
909 Calls the create_stubs() repodata method for the last repodata of the
913 $repo->iscontiguous()
917 Return true if the solvables of this repository are all in a single block with
918 no holes, i.e. they have consecutive ids.
920 Repodata first_repodata()
921 my $repodata = $repo->first_repodata();
922 repodata = repo.first_repodata()
923 repodata = repo.first_repodata()
925 Checks if all repodatas but the first repodata are extensions, and return the
926 first repodata if this is the case. Useful if you want to do a store/retrieve
927 sequence on the repository to reduce the memory using and enable paging, as
928 this does not work if the repository contains multiple non-extension repodata
931 Selection Selection(int setflags = 0)
932 my $sel = $repo->Selection();
933 sel = repo.Selection()
934 sel = repo.Selection()
936 Create a Selection consisting of all packages in the repository.
938 Dataiterator Dataiterator(Id p, Id key, const char *match, int flags)
939 my $di = $repo->Dataiterator($solvid, $keyname, $match, $flags);
940 di = repo.Dataiterator(solvid, keyname, match, flags)
941 di = repo.Dataiterator(solvid, keyname, match, flags)
947 Iterate over the matching data elements in this repository. See the
948 Dataiterator class for more information.
951 my $str = $repo->str;
955 Return the name of the repository, or "Repo#<id>" if no name is set.
958 if ($repo1 == $repo2)
962 Two repositories are equal if they belong to the same pool and have the same id.
964 === DATA ADD METHODS ===
966 Solvable add_solvable()
967 $repo->add_solvable();
971 Add a single empty solvable to the repository. Returns a Solvable object, see
972 the Solvable class for more information.
974 bool add_solv(const char *name, int flags = 0)
975 $repo->add_solv($name);
979 bool add_solv(FILE *fp, int flags = 0)
980 $repo->add_solv($fp);
984 Read a ``solv'' file and add its contents to the repository. These files can be
985 written with the write() method and are normally used as fast cache for
988 bool add_rpmdb(int flags = 0)
993 bool add_rpmdb_reffp(FILE *reffp, int flags = 0)
994 $repo->add_rpmdb_reffp($reffp);
995 repo.add_rpmdb_reffp(reffp)
996 repo.add_rpmdb_reffp(reffp)
998 Add the contents of the rpm database to the repository. If a solv file
999 containing an old version of the database is available, it can be passed as
1000 reffp to speed up reading.
1002 Solvable add_rpm(const char *filename, int flags = 0)
1003 my $solvable = $repo->add_rpm($filename);
1004 solvable = repo.add_rpm(filename)
1005 solvable = repo.add_rpm(filename)
1007 Add the metadata of a single rpm package to the repository.
1009 bool add_rpmdb_pubkeys(int flags = 0)
1010 $repo->add_rpmdb_pubkeys();
1011 repo.add_rpmdb_pubkeys()
1012 repo.add_rpmdb_pubkeys()
1014 Add all pubkeys contained in the rpm database to the repository. Note that
1015 newer rpm versions also allow to store the pubkeys in some directory instead
1016 of the rpm database.
1018 Solvable add_pubkey(const char *keyfile, int flags = 0)
1019 my $solvable = $repo->add_pubkey($keyfile);
1020 solvable = repo.add_pubkey(keyfile)
1021 solvable = repo.add_pubkey(keyfile)
1023 Add a pubkey from a file to the repository.
1025 bool add_rpmmd(FILE *fp, const char *language, int flags = 0)
1026 $repo->add_rpmmd($fp, undef);
1027 repo.add_rpmmd(fp, None)
1028 repo.add_rpmmd(fp, nil)
1030 Add metadata stored in the "rpm-md" format (i.e. from files in the ``repodata''
1031 directory) to a repository. Supported files are "primary", "filelists",
1032 "other", "suseinfo". Do not forget to specify the *REPO_EXTEND_SOLVABLES* for
1033 extension files like "filelists" and "other". Use the _language_ parameter if
1034 you have language extension files, otherwise simply use a *undef*/*None*/*nil*
1037 bool add_repomdxml(FILE *fp, int flags = 0)
1038 $repo->add_repomdxml($fp);
1039 repo.add_repomdxml(fp)
1040 repo.add_repomdxml(fp)
1042 Add the repomd.xml meta description from the "rpm-md" format to the repository.
1043 This file contains information about the repository like keywords, and also a
1044 list of all database files with checksums. The data is added the the "meta"
1045 section of the repository, i.e. no package gets created.
1047 bool add_updateinfoxml(FILE *fp, int flags = 0)
1048 $repo->add_updateinfoxml($fp);
1049 repo.add_updateinfoxml(fp)
1050 repo.add_updateinfoxml(fp)
1052 Add the updateinfo.xml file containing available maintenance updates to the
1053 repository. All updates are created as special packages that have a "patch:"
1054 prefix in their name.
1056 bool add_deltainfoxml(FILE *fp, int flags = 0)
1057 $repo->add_deltainfoxml($fp);
1058 repo.add_deltainfoxml(fp)
1059 repo.add_deltainfoxml(fp)
1061 Add the deltainfo.xml file (also called prestodelta.xml) containing available
1062 delta-rpms to the repository. The data is added to the "meta" section, i.e. no
1063 package gets created.
1065 bool add_debdb(int flags = 0)
1070 Add the contents of the debian installed package database to the repository.
1072 bool add_debpackages(FILE *fp, int flags = 0)
1073 $repo->add_debpackages($fp);
1074 repo.add_debpackages($fp)
1075 repo.add_debpackages($fp)
1077 Add the contents of the debian repository metadata (the "packages" file)
1080 Solvable add_deb(const char *filename, int flags = 0)
1081 my $solvable = $repo->add_deb($filename);
1082 solvable = repo.add_deb(filename)
1083 solvable = repo.add_deb(filename)
1085 Add the metadata of a single deb package to the repository.
1087 bool add_mdk(FILE *fp, int flags = 0)
1088 $repo->add_mdk($fp);
1092 Add the contents of the mageia/mandriva repository metadata (the
1093 "synthesis.hdlist" file) to the repository.
1095 bool add_mdk_info(FILE *fp, int flags = 0)
1096 $repo->add_mdk($fp);
1100 Extend the packages from the synthesis file with the info.xml and files.xml
1101 data. Do not forget to specify *REPO_EXTEND_SOLVABLES*.
1103 bool add_arch_repo(FILE *fp, int flags = 0)
1104 $repo->add_arch_repo($fp);
1105 repo.add_arch_repo(fp)
1106 repo.add_arch_repo(fp)
1108 Add the contents of the archlinux repository metadata (the ".db.tar" file) to
1111 bool add_arch_local(const char *dir, int flags = 0)
1112 $repo->add_arch_local($dir);
1113 repo.add_arch_local(dir)
1114 repo.add_arch_local(dir)
1116 Add the contents of the archlinux installed package database to the repository.
1117 The _dir_ parameter is usually set to "/var/lib/pacman/local".
1119 bool add_content(FILE *fp, int flags = 0)
1120 $repo->add_content($fp);
1121 repo.add_content(fp)
1122 repo.add_content(fp)
1124 Add the ``content'' meta description from the susetags format to the repository.
1125 This file contains information about the repository like keywords, and also
1126 a list of all database files with checksums. The data is added the the "meta"
1127 section of the repository, i.e. no package gets created.
1129 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0)
1130 $repo->add_susetags($fp, $defvendor, $language);
1131 repo.add_susetags(fp, defvendor, language)
1132 repo.add_susetags(fp, defvendor, language)
1134 Add repository metadata in the susetags format to the repository. Like with
1135 add_rpmmd, you can specify a language if you have language extension files. The
1136 _defvendor_ parameter provides a default vendor for packages with missing
1137 vendors, it is usually provided in the content file.
1139 bool add_products(const char *dir, int flags = 0)
1140 $repo->add_products($dir);
1141 repo.add_products(dir)
1142 repo.add_products(dir)
1144 Add the installed SUSE products database to the repository. The _dir_ parameter
1145 is usually "/etc/products.d".
1150 A solvable describes all the information of one package. Each solvable
1151 belongs to one repository, it can be added and filled manually but in
1152 most cases solvables will get created by the repo_add methods.
1156 Repo *repo; /* read only */
1161 The repository this solvable belongs to.
1163 Pool *pool; /* read only */
1168 The pool this solvable belongs to, same as the pool of the repo.
1170 Id id; /* read only */
1175 The specific id of the solvable.
1177 char *name; /* read/write */
1182 char *evr; /* read/write */
1187 char *arch; /* read/write */
1192 char *vendor; /* read/write */
1197 Easy access to often used attributes of solvables. They are
1198 internally stored as Ids.
1200 Id nameid; /* read/write */
1205 Id evrid; /* read/write */
1210 Id archid; /* read/write */
1215 Id vendorid; /* read/write */
1216 $solvable->{vendorid}
1220 Raw interface to the ids. Useful if you want to search for
1221 a specific id and want to avoid the string compare overhead.
1225 const char *lookup_str(Id keyname)
1226 my $string = $solvable->lookup_str($keyname);
1227 string = solvable.lookup_str(keyname)
1228 string = solvable.lookup_str(keyname)
1230 Id lookup_id(Id keyname)
1231 my $id = $solvable->lookup_id($keyname);
1232 id = solvable.lookup_id(solvid)
1233 id = solvable.lookup_id(solvid)
1235 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
1236 my $num = $solvable->lookup_num($keyname);
1237 num = solvable.lookup_num(keyname)
1238 num = solvable.lookup_num(keyname)
1240 bool lookup_void(Id keyname)
1241 my $bool = $solvable->lookup_void($keyname);
1242 bool = solvable.lookup_void(keyname)
1243 bool = solvable.lookup_void(keyname)
1245 Chksum lookup_checksum(Id keyname)
1246 my $chksum = $solvable->lookup_checksum($keyname);
1247 chksum = solvable.lookup_checksum(keyname)
1248 chksum = solvable.lookup_checksum(keyname)
1250 Id *lookup_idarray(Id keyname, Id marker = -1)
1251 my @ids = $solvable->lookup_idarray($keyname);
1252 ids = solvable.lookup_idarray(keyname)
1253 ids = solvable.lookup_idarray(keyname)
1255 Dep *lookup_deparray(Id keyname, Id marker = -1)
1256 my @deps = $solvable->lookup_deparray($keyname);
1257 deps = solvable.lookup_deparray(keyname)
1258 deps = solvable.lookup_deparray(keyname)
1260 Generic lookup methods. Retrieve data stored for the specific keyname.
1261 The lookup_idarray() method will return an array of Ids, use
1262 lookup_deparray if you want an array of Dependency objects instead.
1263 Some Id arrays contain two parts of data divided by a specific marker,
1264 for example the provides array uses the SOLVABLE_FILEMARKER id to
1265 store both the ids provided by the package and the ids added by
1266 the addfileprovides method. The default, -1, translates to the
1267 correct marker for the keyname and returns the first part of the
1268 array, use 1 to select the second part or 0 to retrieve all ids
1269 including the marker.
1271 const char *lookup_location(unsigned int *OUTPUT);
1272 my ($location, $medianr) = $solvable->lookup_location();
1273 location, medianr = solvable.lookup_location()
1274 location, medianr = solvable.lookup_location()
1276 Return a tuple containing the on-media location and an optional
1277 media number for multi-part repositories (e.g. repositories
1278 spawning multiple DVDs).
1280 void add_deparray(Id keyname, DepId dep, Id marker = -1);
1281 $solvable->add_deparray($keyname, $dep);
1282 solvable.add_deparray(keyname, dep)
1283 solvable.add_deparray(keyname, dep)
1285 Add a new dependency to the attributes stored in keyname.
1288 $solvable->installable()
1289 solvable.installable()
1290 solvable.installable?
1292 Return true if the solvable is installable on the system. Solvables
1293 are not installable if the system does not support their architecture.
1296 $solvable->isinstalled()
1297 solvable.isinstalled()
1298 solvable.isinstalled?
1300 Return true if the solvable is installed on the system.
1302 Selection Selection(int setflags = 0)
1303 my $sel = $solvable->Selection();
1304 sel = solvable.Selection()
1305 sel = solvable.Selection()
1307 Create a Selection containing just the single solvable.
1310 my $str = $solvable->str();
1311 str = $solvable.str()
1312 str = $solvable.str()
1314 Return a string describing the solvable. The string consists of the name,
1315 version, and architecture of the Solvable.
1318 my $str = $solvable->str;
1322 Same as calling the str() method.
1325 if ($solvable1 == $solvable2)
1326 if solvable1 == solvable2:
1327 if solvable1 == solvable2
1329 Two solvables are equal if they are part of the same pool and have the same
1333 The Dataiterator Class
1334 ----------------------
1335 Dataiterators can be used to do complex string searches or
1336 to iterate over arrays. They can be created via the
1337 constructors in the Pool, Repo, and Solvable classes. The
1338 Repo and Solvable constructors will limit the search to
1339 the repository or the specific package.
1344 Return a match if the search string matches the value.
1346 *SEARCH_STRINGSTART*::
1347 Return a match if the value starts with the search string.
1349 *SEARCH_STRINGEND*::
1350 Return a match if the value ends with the search string.
1352 *SEARCH_SUBSTRING*::
1353 Return a match if the search string can be matched somewhere
1357 Do a glob match of the search string against the value.
1360 Do a regular expression match of the search string against
1364 Ignore case when matching strings. Works for all the above
1368 Match the complete filenames of the file list, not just the
1371 *SEARCH_COMPLETE_FILELIST*::
1372 When matching the file list, check every file of the package
1373 not just the subset from the primary metadata.
1375 *SEARCH_CHECKSUMS*::
1376 Allow the matching of checksum entries.
1380 void prepend_keyname(Id keyname);
1381 $di->prepend_keyname($keyname);
1382 di.prepend_keyname(keyname)
1383 di.prepend_keyname(keyname)
1385 Do a sub-search in the array stored in keyname.
1387 void skip_solvable();
1388 $di->kip_solvable();
1392 Stop matching the current solvable and advance to the next
1400 Iterate through the matches. If there is a match, the object
1401 in d will be of type Datamatch.
1405 Objects of this type will be created for every value matched
1410 Pool *pool; /* read only */
1415 Back pointer to pool.
1417 Repo *repo; /* read only */
1422 The repository containing the matched object.
1424 Solvable *solvable; /* read only */
1429 The solvable containing the value that was matched.
1431 Id solvid; /* read only */
1436 The id of the solvable that matched.
1445 const char *key_idstr();
1450 The keyname that matched, either as id or string.
1457 const char *type_idstr();
1462 The key type of the value that was matched, either as id or string.
1474 The Id of the value that was matched (only valid for id types),
1475 either as id or string.
1482 The string value that was matched (only valid for string types).
1484 unsigned long long num();
1489 The numeric value that was matched (only valid for numeric types).
1491 unsigned int num2();
1496 The secondary numeric value that was matched (only valid for types
1497 containing two values).
1500 my $pos = $d->pos();
1504 The position object of the current match. It can be used to do
1505 sub-searches starting at the match (if it is of an array type).
1506 See the Datapos class for more information.
1508 Datapos parentpos();
1509 my $pos = $d->parentpos();
1513 The position object of the array containing the current match.
1514 It can be used to do sub-searches, see the Datapos class for more
1522 Return the stringification of the matched value. Stringification
1523 depends on the search flags, for file list entries it will return
1524 just the base name unless SEARCH_FILES is used, for checksums
1525 it will return an empty string unless SEARCH_CHECKSUMS is used.
1526 Numeric values are currently stringified to an empty string.
1531 Selections are a way to easily deal with sets of packages.
1532 There are multiple constructors to create them, the most useful
1533 is probably the select() method in the Pool class.
1538 Create the selection by matching package names
1540 *SELECTION_PROVIDES*::
1541 Create the selection by matching package provides
1543 *SELECTION_FILELIST*::
1544 Create the selection by matching package files
1547 Create the selection by matching the canonical representation
1548 of the package. This is normally a combination of the name,
1549 the version, and the architecture of a package.
1551 *SELECTION_DOTARCH*::
1552 Allow an ``.<architecture>'' suffix when matching names or
1556 Allow the specification of a relation when matching names
1557 or provides, e.g. "name >= 1.2".
1559 *SELECTION_INSTALLED_ONLY*::
1560 Limit the package search to installed packages.
1562 *SELECTION_SOURCE_ONLY*::
1563 Limit the package search to source packages only.
1565 *SELECTION_WITH_SOURCE*::
1566 Extend the package search to also match source packages. The
1567 default is only to match binary packages.
1570 Allow glob matching for package names, package provides, and
1573 *SELECTION_NOCASE*::
1574 Ignore case when matching package names, package provides,
1578 Return only one selection element describing the selected packages.
1579 The default is to create multiple elements for all globbed packages.
1580 Multiple elements are useful if you want to turn the selection into
1581 an install job, in that case you want an install job for every
1586 Pool *pool; /* read only */
1591 Back pointer to pool.
1596 my $flags = $sel->flags();
1600 Return the result flags of the selection. The flags are a subset
1601 of the ones used when creating the selection, they describe which
1602 method was used to get the result. For example, if you create the
1603 selection with ``SELECTION_NAME | SELECTION_PROVIDES'', the resulting
1604 flags will either be SELECTION_NAME or SELECTION_PROVIDES depending
1605 if there was a package that matched the name or not. If there was
1606 no match at all, the flags will be zero.
1613 Return true if the selection is empty, i.e. no package could be matched.
1615 void filter(Selection *other)
1616 $sel->filter($other);
1620 Intersect two selections. Packages will only stay in the selection if there
1621 are also included in the other selecting. Does an in-place modification.
1623 void add(Selection *other)
1628 Build the union of two selections. All packages of the other selection will
1629 be added to the set of packages of the selection object. Does an in-place
1630 modification. Note that the selection flags are no longer meaningful after the
1633 void add_raw(Id how, Id what)
1634 $sel->add_raw($how, $what);
1635 sel.add_raw(how, what)
1636 sel.add_raw(how, what)
1638 Add a raw element to the selection. Check the Job class for information about
1639 the how and what parameters.
1641 Job *jobs(int action)
1642 my @jobs = $sel->jobs($action);
1643 jobs = sel.jobs(action)
1644 jobs = sel.jobs(action)
1646 Convert a selection into an array of Job objects. The action parameter is or-ed
1647 to the ``how'' part of the job, it describes the type of job (e.g. install,
1648 erase). See the Job class for the action and action modifier constants.
1650 Solvable *solvables()
1651 my @solvables = $sel->solvables();
1652 solvables = sel.solvables()
1653 solvables = sel.solvables()
1655 Convert a selection into an array of Solvable objects.
1658 my $str = $sel->str;
1662 Return a string describing the selection.
1666 Jobs are the way to specify to the dependency solver what to do.
1667 Most of the times jobs will get created by calling the jobs() method
1668 on a Selection object, but there is also a Job() constructor in the
1673 Selection constants:
1676 The ``what'' part is the id of a solvable.
1678 *SOLVER_SOLVABLE_NAME*::
1679 The ``what'' part is the id of a package name.
1681 *SOLVER_SOLVABLE_PROVIDES*::
1682 The ``what'' part is the id of a package provides.
1684 *SOLVER_SOLVABLE_ONE_OF*::
1685 The ``what'' part is an offset into the ``whatprovides'' data, created
1686 by calling the towhatprovides() pool method.
1688 *SOLVER_SOLVABLE_REPO*::
1689 The ``what'' part is the id of a repository.
1691 *SOLVER_SOLVABLE_ALL*::
1692 The ``what'' part is ignored, all packages are selected.
1694 *SOLVER_SOLVABLE_SELECTMASK*::
1695 A mask containing all the above selection bits.
1703 Install a package of the specified set of packages. It tries to install
1704 the best matching package (i.e. the highest version of the packages from
1705 the repositories with the highest priority).
1708 Erase all of the packages from the specified set. If a package is not
1709 installed, erasing it will keep it from getting installed.
1712 Update the matching installed packages to their best version. If none
1713 of the specified packages are installed, try to update the installed
1714 packages to the specified versions. See the section about targeted
1715 updates about more information.
1717 *SOLVER_WEAKENDEPS*::
1718 Allow to break the dependencies of the matching packages. Handle with care.
1720 *SOLVER_MULTIVERSION*::
1721 Mark the matched packages for multiversion install. If they get to be installed
1722 because of some other job, the installation will keep the old version of the
1723 package installed (for rpm by using ``-i'' instead of ``-U'').
1726 Do not change the state of the matched packages, i.e. when they are installed
1727 they stay installed, if not they are not selected for installation.
1729 *SOLVER_DISTUPGRADE*::
1730 Update the matching installed packages to the best version included in one
1731 of the repositories. After this operation, all come from one of the available
1732 repositories except orphaned packages. Orphaned packages are packages that
1733 have no relation to the packages in the repositories, i.e. no package in the
1734 repositories have the same name or obsolete the orphaned package.
1735 This action brings the installed packages in sync with the ones in the
1736 repository. It also turns of arch/vendor/version locking for the affected
1737 packages to simulate a fresh installation. This means that distupgrade can
1738 actually downgrade packages if only lower versions of a package are available
1739 in the repositories.
1741 *SOLVER_DROP_ORPHANED*::
1742 Erase all the matching installed packages if they are orphaned. This only makes
1743 sense if there is a ``distupgrade all packages'' job. The default is to erase
1744 orphaned packages only if they block the installation of other packages.
1747 Fix dependency problems of matching installed packages. The default is to ignore
1748 dependency problems for installed packages.
1750 *SOLVER_USERINSTALLED*::
1751 The matching installed packages are considered to be installed by a user, thus
1752 not installed to fulfill some dependency. This is needed input for the calculation
1753 of unneeded packages for jobs that have the SOLVER_CLEANDEPS flag set.
1756 A mask containing all the above action bits.
1758 Action modifier constants:
1761 Makes the job a weak job. The solver tries to fulfill weak jobs, but does not
1762 report a problem if it is not possible to do so.
1764 *SOLVER_ESSENTIAL*::
1765 Makes the job an essential job. If there is a problem with the job, the solver
1766 will not propose to remove the job as one solution (unless all other solutions
1767 are also to remove essential jobs).
1769 *SOLVER_CLEANDEPS*::
1770 The solver will try to also erase all packages dragged in through dependencies
1771 when erasing the package. This needs SOLVER_USERINSTALLED jobs to maximize user
1774 *SOLVER_FORCEBEST*::
1775 Insist on the best package for install, update, and distupgrade jobs. If this
1776 flag is not used, the solver will use the second-best package if the best
1777 package cannot be installed for some reason. When this flag is used, the solver
1778 will generate a problem instead.
1781 Forces targeted operation update and distupgrade jobs. See the section about
1782 targeted updates about more information.
1787 The job specified the exact epoch and version of the package set.
1790 The job specified the exact epoch, version, and release of the package set.
1793 The job specified the exact architecture of the packages from the set.
1795 *SOLVER_SETVENDOR*::
1796 The job specified the exact vendor of the packages from the set.
1799 The job specified the exact repository of the packages from the set.
1802 The job specified the exact name of the packages from the set.
1804 *SOLVER_NOAUTOSET*::
1805 Turn of automatic set flag generation for SOLVER_SOLVABLE jobs.
1808 A mask containing all the above set bits.
1810 See the section about set bits for more information.
1814 Pool *pool; /* read only */
1819 Back pointer to pool.
1821 Id how; /* read/write */
1826 Union of the selection, action, action modifier, and set flags.
1827 The selection part describes the semantics of the ``what'' Id.
1829 Id what; /* read/write */
1834 Id describing the set of packages, the meaning depends on the
1835 selection part of the ``how'' attribute.
1839 Solvable *solvables()
1840 my @solvables = $job->solvables();
1841 solvables = job.solvables()
1842 solvables = job.solvables()
1844 Return the set of solvables of the job as an array of Solvable
1847 bool isemptyupdate();
1848 $job->isemptyupdate()
1852 Convenience function to find out if the job describes an update
1853 job with no matching packages, i.e. a job that does nothing.
1854 Some package managers like ``zypper'' like to turn those jobs
1855 into install jobs, i.e. an update of a not-installed package
1856 will result into the installation of the package.
1859 my $str = $job->str;
1863 Return a string describing the job.
1870 Two jobs are equal if they belong to the same pool and both the
1871 ``how'' and the ``what'' attributes are the same.
1873 === TARGETED UPDATES ===
1874 Libsolv has two modes for upgrades and distupgrade: targeted and
1875 untargeted. Untargeted mode means that the installed packages from
1876 the specified set will be updated to the best version. Targeted means
1877 that packages that can be updated to a package in the specified set
1878 will be updated to the best package of the set.
1880 Here's an example to explain the subtle difference. Suppose that
1881 you have package A installed in version "1.1", "A-1.2" is available
1882 in one of the repositories and there is also package "B" that
1883 obsoletes package A.
1885 An untargeted update of "A" will update the installed "A-1.1" to
1886 package "B", because that is the newest version (B obsoletes A and
1889 A targeted update of "A" will update "A-1.1" to "A-1.2", as the
1890 set of packages contains both "A-1.1" and "A-1.2", and "A-1.2" is
1893 An untargeted update of "B" will do nothing, as "B" is not installed.
1895 An targeted update of "B" will update "A-1.1" to "B".
1897 Note that the default is to do "auto-targeting", thus if the specified
1898 set of packages does not include an installed package, the solver
1899 will assume targeted operation even if SOLVER_TARGETED is not used.
1901 This mostly matches the intent of the user, with one exception: In
1902 the example above, an update of "A-1.2" will update "A-1.1" to
1903 "A-1.2" (targeted mode), but a second update of "A-1.2" will suddenly
1904 update to "B", as untargeted mode is chosen because "A-1.2" is now
1907 If you want to have full control over when targeting mode is chosen,
1908 turn off auto-targeting with the SOLVER_FLAG_NO_AUTOTARGET solver option.
1909 In that case, all updates are considered to be untargeted unless they
1910 include the SOLVER_TARGETED flag.
1913 Set bits specify which parts of the specified packages where specified
1914 by the user. It is used by the solver when checking if an operation is
1915 allowed or not. For example, the solver will normally not allow the
1916 downgrade of an installed package. But it will not report a problem if
1917 the SOLVER_SETEVR flag is used, as it then assumes that the user specified
1918 the exact version and thus knows what he is doing.
1920 So if a package "screen-1-1" is installed for the x86_64 architecture and
1921 version "2-1" is only available for the i586 architecture, installing
1922 package "screen-2.1" will ask the user for confirmation because of the
1923 different architecture. When using the Selection class to create jobs
1924 the set bits are automatically added, e.g. selecting ``screen.i586'' will
1925 automatically add SOLVER_SETARCH, and thus no problem will be reported.
1929 Dependency solving is what this library is about. A solver object is needed
1930 for solving to store the result of the solver run. The solver object can be
1931 used multiple times for different jobs, reusing it allows the solver to
1932 re-use the dependency rules it already computed.
1936 Flags to modify some of the solver's behavior:
1938 *SOLVER_FLAG_ALLOW_DOWNGRADE*::
1939 Allow the solver to downgrade packages without asking for confirmation
1940 (i.e. reporting a problem).
1942 *SOLVER_FLAG_ALLOW_ARCHCHANGE*::
1943 Allow the solver to change the architecture of an installed package
1944 without asking for confirmation. Note that changes to/from noarch
1945 are always considered to be allowed.
1947 *SOLVER_FLAG_ALLOW_VENDORCHANGE*::
1948 Allow the solver to change the vendor of an installed package
1949 without asking for confirmation. Each vendor is part of one or more
1950 vendor equivalence classes, normally installed packages may only
1951 change their vendor if the new vendor shares at least one equivalence
1954 *SOLVER_FLAG_ALLOW_NAMECHANGE*::
1955 Allow the solver to change the name of an installed package, i.e.
1956 install a package with a different name that obsoletes the installed
1957 package. This option is on by default.
1959 *SOLVER_FLAG_ALLOW_UNINSTALL*::
1960 Allow the solver to erase installed packages to fulfill the jobs.
1961 This flag also includes the above flags. You may want to set this
1962 flag if you only have SOLVER_ERASE jobs, as in that case it's
1963 better for the user to check the transaction overview instead of
1964 approving every single package that needs to be erased.
1966 *SOLVER_FLAG_NO_UPDATEPROVIDE*::
1967 If multiple packages obsolete an installed package, the solver checks
1968 the provides of every such package and ignores all packages that
1969 do not provide the installed package name. Thus, you can have an
1970 official update candidate that provides the old name, and other
1971 packages that also obsolete the package but are not considered for
1972 updating. If you cannot use this feature, you can turn it off
1973 by setting this flag.
1975 *SOLVER_FLAG_SPLITPROVIDES*::
1976 Make the solver aware of special provides of the form
1977 ``<packagename>:<path>'' used in SUSE systems to support package
1980 *SOLVER_FLAG_IGNORE_RECOMMENDED*::
1981 Do not process optional (aka weak) dependencies.
1983 *SOLVER_FLAG_ADD_ALREADY_RECOMMENDED*::
1984 Install recommended or supplemented packages even if they have no
1985 connection to the current transaction. You can use this feature
1986 to implement a simple way for the user to install new recommended
1987 packages that were not available in the past.
1989 *SOLVER_FLAG_NO_INFARCHCHECK*::
1990 Turn off the inferior architecture checking that is normally done
1991 by the solver. Normally, the solver allows only the installation
1992 of packages from the "best" architecture if a package is available
1993 for multiple architectures.
1995 *SOLVER_FLAG_BEST_OBEY_POLICY*::
1996 Make the SOLVER_FORCEBEST job option consider only packages that
1997 meet the policies for installed packages, i.e. no downgrades,
1998 no architecture change, no vendor change (see the first flags
1999 of this section). If the flag is not specified, the solver will
2000 enforce the installation of the best package ignoring the
2001 installed packages, which may conflict with the set policy.
2003 *SOLVER_FLAG_NO_AUTOTARGET*::
2004 Do not enable auto-targeting up update and distupgrade jobs. See
2005 the section on targeted updates for more information.
2009 *SOLVER_RULE_UNKNOWN*::
2010 A rule of an unknown class. You should never encounter those.
2013 A package dependency rule, called rpm rule for historical reasons.
2015 *SOLVER_RULE_UPDATE*::
2016 A rule to implement the update policy of installed packages. Every
2017 installed package has an update rule that consists of the packages
2018 that may replace the installed package.
2020 *SOLVER_RULE_FEATURE*::
2021 Feature rules are fallback rules used when a update rule is disabled.
2022 They include all packages that may replace the installed package
2023 ignoring the update policy, i.e. they contain downgrades, arch
2024 changes and so on. Without them, the solver would simply erase
2025 installed packages if their update rule gets disabled.
2028 Job rules implement the job given to the solver.
2030 *SOLVER_RULE_DISTUPGRADE*::
2031 This are simple negative assertions that make sure that only packages
2032 are kept that are also available in one of the repositories.
2034 *SOLVER_RULE_INFARCH*::
2035 Infarch rules are also negative assertions, they disallow the installation
2036 of packages when there are packages of the same name but with a better
2039 *SOLVER_RULE_CHOICE*::
2040 Choice rules are used to make sure that the solver prefers updating to
2041 installing different packages when some dependency is provided by
2042 multiple packages with different names. The solver may always break
2043 choice rules, so you will not see them when a problem is found.
2045 *SOLVER_RULE_LEARNT*::
2046 These rules are generated by the solver to keep it from running into
2047 the same problem multiple times when it has to backtrack. They are
2048 the main reason why a sat solver is faster then other dependency solver
2051 Special dependency rule types:
2053 *SOLVER_RULE_RPM_NOT_INSTALLABLE*::
2054 This rule was added to prevent the installation of a package of an
2055 architecture that does not work on the system.
2057 *SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP*::
2058 The package contains a required dependency which was not provided by
2061 *SOLVER_RULE_RPM_PACKAGE_REQUIRES*::
2062 Similar to SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, but in this case
2063 some packages provided the dependency but none of them could be
2064 installed due to other dependency issues.
2066 *SOLVER_RULE_RPM_SELF_CONFLICT*::
2067 The package conflicts with itself. This is not allowed by older rpm
2070 *SOLVER_RULE_RPM_PACKAGE_CONFLICT*::
2071 To fulfill the dependencies two packages need to be installed, but
2072 one of the packages contains a conflict with the other one.
2074 *SOLVER_RULE_RPM_SAME_NAME*::
2075 The dependencies can only be fulfilled by multiple versions of
2076 a package, but installing multiple versions of the same package
2079 *SOLVER_RULE_RPM_PACKAGE_OBSOLETES*::
2080 To fulfill the dependencies two packages need to be installed, but
2081 one of the packages obsoletes the other one.
2083 *SOLVER_RULE_RPM_IMPLICIT_OBSOLETES*::
2084 To fulfill the dependencies two packages need to be installed, but
2085 one of the packages has provides a dependency that is obsoleted
2086 by the other one. See the POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES
2089 *SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES*::
2090 To fulfill the dependencies a package needs to be installed that is
2091 obsoleted by an installed package. See the POOL_FLAG_NOINSTALLEDOBSOLETES
2094 *SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP*::
2095 The user asked for installation of a package providing a specific
2096 dependency, but no available package provides it.
2098 *SOLVER_RULE_JOB_UNKNOWN_PACKAGE*::
2099 The user asked for installation of a package with a specific name,
2100 but no available package has that name.
2102 *SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM*::
2103 The user asked for the erasure of a dependency that is provided by the
2104 system (i.e. for special hardware or language dependencies), this
2105 cannot be done with a job.
2107 *SOLVER_RULE_JOB_UNSUPPORTED*::
2108 The user asked for something that is not yet implemented, e.g. the
2109 installation of all packages at once.
2111 Policy error constants
2113 *POLICY_ILLEGAL_DOWNGRADE*::
2114 The solver ask for permission before downgrading packages.
2116 *POLICY_ILLEGAL_ARCHCHANGE*::
2117 The solver ask for permission before changing the architecture of installed
2120 *POLICY_ILLEGAL_VENDORCHANGE*::
2121 The solver ask for permission before changing the vendor of installed
2124 *POLICY_ILLEGAL_NAMECHANGE*::
2125 The solver ask for permission before replacing an installed packages with
2126 a package that has a different name.
2128 Solution element type constants
2130 *SOLVER_SOLUTION_JOB*::
2131 The problem can be solved by removing the specified job.
2133 *SOLVER_SOLUTION_POOLJOB*::
2134 The problem can be solved by removing the specified job that is defined in the pool.
2136 *SOLVER_SOLUTION_INFARCH*::
2137 The problem can be solved by allowing the installation of the specified package
2138 with an inferior architecture.
2140 *SOLVER_SOLUTION_DISTUPGRADE*::
2141 The problem can be solved by allowing to keep the specified package installed.
2143 *SOLVER_SOLUTION_BEST*::
2144 The problem can be solved by allowing to install the specified package that is
2145 not the best available package.
2147 *SOLVER_SOLUTION_ERASE*::
2148 The problem can be solved by allowing to erase the specified package.
2150 *SOLVER_SOLUTION_REPLACE*::
2151 The problem can be solved by allowing to replace the package with some other
2154 *SOLVER_SOLUTION_REPLACE_DOWNGRADE*::
2155 The problem can be solved by allowing to replace the package with some other
2156 package that has a lower version.
2158 *SOLVER_SOLUTION_REPLACE_ARCHCHANGE*::
2159 The problem can be solved by allowing to replace the package with some other
2160 package that has a different architecture.
2162 *SOLVER_SOLUTION_REPLACE_VENDORCHANGE*::
2163 The problem can be solved by allowing to replace the package with some other
2164 package that has a different vendor.
2166 *SOLVER_SOLUTION_REPLACE_NAMECHANGE*::
2167 The problem can be solved by allowing to replace the package with some other
2168 package that has a different name.
2173 Pool *pool; /* read only */
2178 Back pointer to pool.
2182 int set_flag(int flag, int value)
2183 my $oldvalue = $pool->set_flag($flag, $value);
2184 oldvalue = pool.set_flag(flag, value)
2185 oldvalue = pool.set_flag(flag, value)
2187 int get_flag(int flag)
2188 my $value = $pool->get_flag($flag);
2189 value = pool.get_flag(flag)
2190 value = pool.get_flag(flag)
2192 Set/get a solver specific flag. The flags define the policies the solver has
2193 to obey. The flags are explained in the CONSTANTS section of this class.
2195 Problem *solve(Job *jobs)
2196 my @problems = $solver->solve(\@jobs);
2197 problems = solver.solve(jobs)
2198 problems = solver.solve(jobs)
2200 Solve a problem specified in the job list (plus the jobs defined in the pool).
2201 Returns an array of problems that need user interaction, or an empty array
2202 if no problems were encountered. See the Problem class on how to deal with
2205 Transaction transaction()
2206 my $trans = $solver->transaction();
2207 trans = solver.transaction()
2208 trans = solver.transaction()
2210 Return the transaction to implement the calculated package changes. A transaction
2211 is available even if problems were found, this is useful for interactive user
2212 interfaces that show both the job result and the problems.
2216 Problems are the way of the solver to interact with the user. You can simply list
2217 all problems and terminate your program, but a better way is to present solutions to
2218 the user and let him pick the ones he likes.
2222 Solver *solv; /* read only */
2227 Back pointer to solver object.
2229 Id id; /* read only */
2234 Id of the problem. The first problem has Id 1, they are numbered consecutively.
2238 Rule findproblemrule()
2239 my $probrule = $problem->findproblemrule();
2240 probrule = problem.findproblemrule()
2241 probrule = problem.findproblemrule()
2243 Return the rule that caused the problem. Of course in most situations there is no
2244 single responsible rule, but many rules that interconnect with each created the
2245 problem. Nevertheless, the solver uses some heuristic approach to find a rule
2246 that somewhat describes the problem best to the user.
2248 Rule *findallproblemrules(bool unfiltered = 0)
2249 my @probrules = $problem->findallproblemrules();
2250 probrules = problem.findallproblemrule()
2251 probrules = problem.findallproblemrule()
2253 Return all rules responsible for the problem. The returned set of rules contains
2254 all the needed information why there was a problem, but it's hard to present
2255 them to the user in a sensible way. The default is to filter out all update and
2256 job rules (unless the returned rules only consist of those types).
2258 Solution *solutions()
2259 my @solutions = $problem->solutions();
2260 solutions = problem.solutions()
2261 solutions = problem.solutions()
2263 Return an array containing multiple possible solutions to fix the problem. See
2264 the solution class for more information.
2266 int solution_count()
2267 my $cnt = $problem->solution_count();
2268 cnt = problem.solution_count()
2269 cnt = problem.solution_count()
2271 Return the number of solutions without creating solution objects.
2275 Rules are the basic block of sat solving. Each package dependency gets translated
2276 into one or multiple rules.
2280 Solver *solv; /* read only */
2285 Back pointer to solver object.
2287 Id id; /* read only */
2294 int type; /* read only */
2299 The basic type of the rule. See the constant section of the solver class for the type list.
2304 my $ruleinfo = $rule->info();
2305 ruleinfo = rule.info()
2306 ruleinfo = rule.info()
2308 Return a Ruleinfo object that contains information about why the rule was created. But
2309 see the allinfos() method below.
2311 Ruleinfo *allinfos()
2312 my @ruleinfos = $rule->allinfos();
2313 ruleinfos = rule.allinfos()
2314 ruleinfos = rule.allinfos()
2316 As the same dependency rule can get created because of multiple dependencies, one
2317 Ruleinfo is not enough to describe the reason. Thus the allinfos() method returns
2318 an array of all infos about a rule.
2321 if ($rule1 == $rule2)
2325 Two rules are equal if they belong to the same solver and have the same id.
2329 A Ruleinfo describes one reason why a rule was created.
2333 Solver *solv; /* read only */
2338 Back pointer to solver object.
2340 int type; /* read only */
2345 The type of the ruleinfo. See the constant section of the solver class for the
2346 rule type list and the special type list.
2348 Dep *dep; /* read only */
2353 The dependency leading to the creation of the rule.
2355 Dep *dep_id; /* read only */
2356 $ruleinfo->{'dep_id'}
2360 The Id of the dependency leading to the creation of the rule, or zero.
2362 Solvable *solvable; /* read only */
2363 $ruleinfo->{solvable}
2367 The involved Solvable, e.g. the one containing the dependency.
2369 Solvable *othersolvable; /* read only */
2370 $ruleinfo->{othersolvable}
2371 ruleinfo.othersolvable
2372 ruleinfo.othersolvable
2374 The other involved Solvable (if any), e.g. the one containing providing
2375 the dependency for conflicts.
2377 const char *problemstr();
2378 my $str = $ruleinfo->problemstr();
2379 str = ruleinfo.problemstr()
2380 str = ruleinfo.problemstr()
2382 A string describing the ruleinfo from a problem perspective. This probably
2383 only makes sense if the rule is part of a problem.
2387 A solution solves one specific problem. It consists of multiple solution elements
2388 that all need to be executed.
2392 Solver *solv; /* read only */
2397 Back pointer to solver object.
2399 Id problemid; /* read only */
2400 $solution->{problemid}
2404 Id of the problem the solution solves.
2406 Id id; /* read only */
2411 Id of the solution. The first solution has Id 1, they are numbered consecutively.
2415 Solutionelement *elements(bool expandreplaces = 0)
2416 my @solutionelements = $solution->elements();
2417 solutionelements = solution.elements()
2418 solutionelements = solution.elements()
2420 Return an array containing the elements describing what needs to be done to
2421 implement the specific solution. If expandreplaces is true, elements of type
2422 SOLVER_SOLUTION_REPLACE will be replaced by one or more elements replace
2423 elements describing the policy mismatches.
2426 my $cnt = $solution->solution_count();
2427 cnt = solution.element_count()
2428 cnt = solution.element_count()
2430 Return the number of solution elements without creating objects. Note that the
2431 count does not match the number of objects returned by the elements() method
2432 of expandreplaces is set to true.
2435 The Solutionelement Class
2436 -------------------------
2437 A solution element describes a single action of a solution. The action is always
2438 either to remove one specific job or to add a new job that installs or erases
2439 a single specific package.
2443 Solver *solv; /* read only */
2444 $solutionelement->{solv}
2445 solutionelement.solv
2446 solutionelement.solv
2448 Back pointer to solver object.
2450 Id problemid; /* read only */
2451 $solutionelement->{problemid}
2452 solutionelement.problemid
2453 solutionelement.problemid
2455 Id of the problem the element (partly) solves.
2457 Id solutionid; /* read only */
2458 $solutionelement->{solutionid}
2459 solutionelement.solutionid
2460 solutionelement.solutionid
2462 Id of the solution the element is a part of.
2464 Id id; /* read only */
2465 $solutionelement->{id}
2469 Id of the solution element. The first element has Id 1, they are numbered consecutively.
2471 Id type; /* read only */
2472 $solutionelement->{type}
2473 solutionelement.type
2474 solutionelement.type
2476 Type of the solution element. See the constant section of the solver class for the
2479 Solvable *solvable; /* read only */
2480 $solutionelement->{solvable}
2481 solutionelement.solvable
2482 solutionelement.solvable
2484 The installed solvable that needs to be replaced for replacement elements.
2486 Solvable *replacement; /* read only */
2487 $solutionelement->{replacement}
2488 solutionelement.replacement
2489 solutionelement.replacement
2491 The solvable that needs to be installed to fix the problem.
2493 int jobidx; /* read only */
2494 $solutionelement->{jobidx}
2495 solutionelement.jobidx
2496 solutionelement.jobidx
2498 The index of the job that needs to be removed to fix the problem, or -1 if the
2499 element is of another type. Note that it's better to change the job to SOLVER_NOOP
2500 type so that the numbering of other elements does not get disturbed. This
2501 method works both for types SOLVER_SOLUTION_JOB and SOLVER_SOLUTION_POOLJOB.
2505 Solutionelement *replaceelements()
2506 my @solutionelements = $solutionelement->replaceelements();
2507 solutionelements = solutionelement.replaceelements()
2508 solutionelements = solutionelement.replaceelements()
2510 If the solution element is of type SOLVER_SOLUTION_REPLACE, return an array of
2511 elements describing the policy mismatches, otherwise return a copy of the
2512 element. See also the ``expandreplaces'' option in the solution's elements()
2515 int illegalreplace()
2516 my $illegal = $solutionelement->illegalreplace();
2517 illegal = solutionelement.illegalreplace()
2518 illegal = solutionelement.illegalreplace()
2520 Return an integer that contains the policy mismatch bits or-ed together, or
2521 zero if there was no policy mismatch. See the policy error constants in
2525 my $job = $solutionelement->Job();
2526 illegal = solutionelement.Job()
2527 illegal = solutionelement.Job()
2529 Create a job that implements the solution element. Add this job to the array
2530 of jobs for all elements of type different to SOLVER_SOLUTION_JOB and
2531 SOLVER_SOLUTION_POOLJOB. For the later two, a SOLVER_NOOB Job is created,
2532 you should replace the old job with the new one.
2535 my $str = $solutionelement->str();
2536 str = solutionelement.str()
2537 str = solutionelement.str()
2539 A string describing the change the solution element consists of.
2541 The Transaction Class
2542 ---------------------
2543 Transactions describe the output of a solver run. A transaction contains
2544 a number of transaction elements, each either the installation of a new
2545 package or the removal of an already installed package. The Transaction
2546 class supports a classify() method that puts the elements into different
2547 groups so that a transaction can be presented to the user in a meaningful
2552 Transaction element types, both active and passive
2554 *SOLVER_TRANSACTION_IGNORE*::
2555 This element does nothing. Used to map element types that do not
2556 match the view mode.
2558 *SOLVER_TRANSACTION_INSTALL*::
2559 This element installs a package.
2561 *SOLVER_TRANSACTION_ERASE*::
2562 This element erases a package.
2564 *SOLVER_TRANSACTION_MULTIINSTALL*::
2565 This element installs a package with a different version keeping the
2566 other versions installed.
2568 *SOLVER_TRANSACTION_MULTIREINSTALL*::
2569 This element reinstalls a installed package keeping the other versions
2572 Transaction element types, active view
2574 *SOLVER_TRANSACTION_REINSTALL*::
2575 This element re-installs a package, i.e. installs the same package again.
2577 *SOLVER_TRANSACTION_CHANGE*::
2578 This element installs a package with same name, version, architecture but
2581 *SOLVER_TRANSACTION_UPGRADE*::
2582 This element installs a newer version of an installed package.
2584 *SOLVER_TRANSACTION_DOWNGRADE*::
2585 This element installs a older version of an installed package.
2587 *SOLVER_TRANSACTION_OBSOLETES*::
2588 This element installs a package that obsoletes an installed package.
2590 Transaction element types, passive view
2592 *SOLVER_TRANSACTION_REINSTALLED*::
2593 This element re-installs a package, i.e. installs the same package again.
2595 *SOLVER_TRANSACTION_CHANGED*::
2596 This element replaces an installed package with one of the same name,
2597 version, architecture but different content.
2599 *SOLVER_TRANSACTION_UPGRADED*::
2600 This element replaces an installed package with a new version.
2602 *SOLVER_TRANSACTION_DOWNGRADED*::
2603 This element replaces an installed package with an old version.
2605 *SOLVER_TRANSACTION_OBSOLETED*::
2606 This element replaces an installed package with a package that obsoletes
2609 Pseudo element types for showing extra information used by classify()
2611 *SOLVER_TRANSACTION_ARCHCHANGE*::
2612 This element replaces an installed package with a package of a different
2615 *SOLVER_TRANSACTION_VENDORCHANGE*::
2616 This element replaces an installed package with a package of a different
2619 Transaction mode flags
2621 *SOLVER_TRANSACTION_SHOW_ACTIVE*::
2622 Filter for active view types. The default is to return passive view type,
2623 i.e. to show how the installed packages get changed.
2625 *SOLVER_TRANSACTION_SHOW_OBSOLETES*::
2626 Do not map the obsolete view type into INSTALL/ERASE elements.
2628 *SOLVER_TRANSACTION_SHOW_ALL*::
2629 If multiple packages replace an installed package, only the best of them
2630 is kept as OBSOLETE element, the other ones are mapped to INSTALL/ERASE
2631 elements. This is because most applications want to show just one package
2632 replacing the installed one. The SOLVER_TRANSACTION_SHOW_ALL makes the
2633 library keep all OBSOLETE elements.
2635 *SOLVER_TRANSACTION_SHOW_MULTIINSTALL*::
2636 The library maps MULTIINSTALL elements to simple INSTALL elements. This
2637 flag can be used to disable the mapping.
2639 *SOLVER_TRANSACTION_CHANGE_IS_REINSTALL*::
2640 Use this flag if you want to map CHANGE elements to the REINSTALL type.
2642 *SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE*::
2643 Use this flag if you want to map OBSOLETE elements to the UPGRADE type.
2645 *SOLVER_TRANSACTION_MERGE_ARCHCHANGES*::
2646 Do not add extra categories for every architecture change, instead cumulate
2647 them in one category.
2649 *SOLVER_TRANSACTION_MERGE_VENDORCHANGES*::
2650 Do not add extra categories for every vendor change, instead cumulate
2651 them in one category.
2653 *SOLVER_TRANSACTION_RPM_ONLY*::
2654 Special view mode that just returns IGNORE, ERASE, INSTALL, MULTIINSTALL
2655 elements. Useful if you want to find out what to feed to the underlying
2658 Transaction order flags
2660 *SOLVER_TRANSACTION_KEEP_ORDERDATA*::
2661 Do not throw away the dependency graph used for ordering the transaction.
2662 This flag is needed if you want to do manual ordering.
2666 Pool *pool; /* read only */
2671 Back pointer to pool.
2680 Returns true if the transaction does not do anything, i.e. has no elements.
2682 Solvable *newsolvables();
2683 my @newsolvables = $trans->newsolvables();
2684 newsolvables = trans.newsolvables()
2685 newsolvables = trans.newsolvables()
2687 Return all packages that are to be installed by the transaction. This are
2688 the packages that need to be downloaded from the repositories.
2690 Solvable *keptsolvables();
2691 my @keptsolvables = $trans->keptsolvables();
2692 keptsolvables = trans.keptsolvables()
2693 keptsolvables = trans.keptsolvables()
2695 Return all installed packages that the transaction will keep installed.
2698 my @steps = $trans->steps();
2699 steps = trans.steps()
2700 steps = trans.steps()
2702 Return all solvables that need to be installed (if the returned solvable
2703 is not already installed) or erased (if the returned solvable is installed).
2704 A step is also called a transaction element.
2706 int steptype(Solvable *solvable, int mode)
2707 my $type = $trans->steptype($solvable, $mode);
2708 type = trans.steptype(solvable, mode)
2709 type = trans.steptype(solvable, mode)
2711 Return the transaction type of the specified solvable. See the CONSTANTS
2712 sections for the mode argument flags and the list of returned types.
2714 TransactionClass *classify(int mode = 0)
2715 my @classes = $trans->classify();
2716 classes = trans.classify()
2717 classes = trans.classify()
2719 Group the transaction elements into classes so that they can be displayed
2720 in a structured way. You can use various mapping mode flags to tweak
2721 the result to match your preferences, see the mode argument flag in
2722 the CONSTANTS section. See the TransactionClass class for how to deal
2723 with the returned objects.
2725 Solvable othersolvable(Solvable *solvable);
2726 my $other = $trans->othersolvable($solvable);
2727 other = trans.othersolvable(solvable)
2728 other = trans.othersolvable(solvable)
2730 Return the ``other'' solvable for a given solvable. For installed packages
2731 the other solvable is the best package with the same name that replaces
2732 the installed package, or the best package of the obsoleting packages if
2733 the package does not get replaced by one with the same name.
2735 For to be installed packages, the ``other'' solvable is the best installed
2736 package with the same name that will be replaced, or the best packages
2737 of all the packages that are obsoleted if the new package does not replace
2738 a package with the same name.
2740 Thus, the ``other'' solvable is normally the package that is also shown
2741 for a given package.
2743 Solvable *allothersolvables(Solvable *solvable);
2744 my @others = $trans->allothersolvables($solvable);
2745 others = trans.allothersolvables(solvable)
2746 others = trans.allothersolvables(solvable)
2748 For installed packages, returns all of the packages that replace us. For to
2749 be installed packages, returns all of the packages that the new package
2750 replaces. The special ``other'' solvable is always the first entry of the
2753 int calc_installsizechange();
2754 my $change = $trans->calc_installsizechange();
2755 change = trans.calc_installsizechange()
2756 change = trans.calc_installsizechange()
2758 Return the size change of the installed system in kilobytes (kibibytes).
2760 void order(int flags = 0);
2765 Order the steps in the transactions so that dependant packages are updated
2766 before packages that depend on them. For rpm, you can also use rpmlib's
2767 ordering functionality, debian's dpkg does not provide a way to order a
2770 === ACTIVE/PASSIVE VIEW ===
2772 Active view list what new packages get installed, while passive view shows
2773 what happens to the installed packages. Most often there's not much
2774 difference between the two modes, but things get interesting of multiple
2775 package get replaced by one new package. Say you have installed package
2776 A-1-1 and B-1-1, and now install A-2-1 with has a new dependency that
2777 obsoletes B. The transaction elements will be
2779 updated A-1-1 (other: A-2-1)
2780 obsoleted B-1-1 (other: A-2-1)
2782 in passive mode, but
2784 update A-2-1 (other: A-1-1)
2787 in active mode. If the mode contains SOLVER_TRANSACTION_SHOW_ALL, the
2788 passive mode list will be unchanged but the active mode list will just
2791 The Transactionclass Class
2792 --------------------------
2793 Objects of this type are returned by the classify() Transaction method.
2797 Transaction *transaction; /* read only */
2798 $class->{transaction}
2802 Back pointer to transaction object.
2804 int type; /* read only */
2809 The type of the transaction elements in the class.
2811 int count; /* read only */
2816 The number of elements in the class.
2818 const char *fromstr;
2823 The old vendor or architecture.
2830 The new vendor or architecture.
2837 The id of the old vendor or architecture.
2844 The id of the new vendor or architecture.
2849 my @solvables = $class->solvables();
2850 solvables = class.solvables()
2851 solvables = class.solvables()
2853 Return the solvables for all transaction elements in the class.
2857 Checksums (also called hashes) are used to make sure that downloaded data is
2858 not corrupt and also as a fingerprint mechanism to check if data has changed.
2860 === CLASS METHODS ===
2862 Chksum Chksum(Id type)
2863 my $chksum = solv::Chksum->new($type);
2864 chksum = solv.Chksum(type)
2865 chksum = Solv::Chksum.new(type)
2867 Create a checksum object. Currently the following types are supported:
2873 These keys are constants in the *solv* class.
2875 Chksum Chksum(Id type, const char *hex)
2876 my $chksum = solv::Chksum->new($type, $hex);
2877 chksum = solv.Chksum(type, hex)
2878 chksum = Solv::Chksum.new(type, hex)
2880 Create an already finalized checksum object.
2884 Id type; /* read only */
2889 Return the type of the checksum object.
2893 void add(const char *str)
2898 Add a string to the checksum.
2900 void add_fp(FILE *fp)
2901 $chksum->add_fp($file);
2905 Add the contents of a file to the checksum.
2907 void add_stat(const char *filename)
2908 $chksum->add_stat($filename);
2909 chksum.add_stat(filename)
2910 chksum.add_stat(filename)
2912 Stat the file and add the dev/ino/size/mtime member to the checksum. If the
2913 stat fails, the members are zeroed.
2915 void add_fstat(int fd)
2916 $chksum->add_fstat($fd);
2917 chksum.add_fstat(fd)
2918 chksum.add_fstat(fd)
2920 Same as add_stat, but instead of the filename a file descriptor is used.
2922 unsigned char *raw()
2923 my $raw = $chksum->raw();
2927 Finalize the checksum and return the result as raw bytes. This means that the
2928 result can contain NUL bytes or unprintable characters.
2931 my $raw = $chksum->hex();
2935 Finalize the checksum and return the result as hex string.
2938 if ($chksum1 == $chksum2)
2939 if chksum1 == chksum2:
2940 if chksum1 == chksum2
2942 Checksums are equal if they are of the same type and the finalized results are
2946 my $str = $chksum->str;
2950 If the checksum is finished, the checksum is returned as "<type>:<hex>" string.
2951 Otherwise "<type>:unfinished" is returned.
2956 This functions were added because libsolv uses standard *FILE* pointers to
2957 read/write files, but languages like perl have their own implementation of
2958 files. The libsolv functions also support decompression and compression, the
2959 algorithm is selected by looking at the file name extension.
2961 FILE *xfopen(char *fn, char *mode = "r")
2962 my $file = solv::xfopen($path);
2963 file = solv.xfopen(path)
2964 file = Solv::xfopen(path)
2966 Open a file at the specified path. The `mode` argument is passed on to the
2969 FILE *xfopen_fd(char *fn, int fileno)
2970 my $file = solv::xfopen_fd($path, $fileno);
2971 file = solv.xfopen_fd(path, fileno)
2972 file = Solv::xfopen_fd(path, fileno)
2974 Create a file handle from the specified file descriptor. The path argument is
2975 only used to select the correct (de-)compression algorithm, use an empty path
2976 if you want to make sure to read/write raw data.
2981 my $fileno = $file->fileno();
2982 fileno = file.fileno()
2983 fileno = file.fileno()
2985 Return file file descriptor of the file. If the file is not open, `-1` is
2989 my $fileno = $file->dup();
2993 Return a copy of the descriptor of the file. If the file is not open, `-1` is
3001 Flush the file. Returns false if there was an error. Flushing a closed file
3002 always returns true.
3009 Close the file. This is needed for languages like Ruby, that do not destruct
3010 objects right after they are no longer referenced. In that case, it is good
3011 style to close open files so that the file descriptors are freed right away.
3012 Returns false if there was an error.
3017 The Repodata stores attributes for packages and the repository itself, each
3018 repository can have multiple repodata areas. You normally only need to
3019 directly access them if you implement lazy downloading of repository data.
3020 Repodata areas are created by calling the repository's add_repodata() method
3021 or by using repo_add methods without the REPO_REUSE_REPODATA or REPO_USE_LOADING
3026 Repo *repo; /* read only */
3031 Back pointer to repository object.
3033 Id id; /* read only */
3038 The id of the repodata area. Repodata ids of different repositories overlap.
3043 $data->internalize();
3047 Internalize newly added data. The lookup functions will only see the new data
3048 after it has been internalized.
3050 bool write(FILE *fp);
3055 Write the contents of the repodata area as solv file.
3057 bool add_solv(FILE *fp, int flags = 0);
3058 $data->add_solv($fp);
3062 Replace a stub repodata object with the data from a solv file. This method
3063 automatically adds the REPO_USE_LOADING flag. It should only be used from
3066 void create_stubs();
3067 $data->create_stubs()
3071 Create stub repodatas from the information stored in the repodata meta
3074 void extend_to_repo();
3075 $data->extend_to_repo();
3076 data.extend_to_repo()
3077 data.extend_to_repo()
3079 Extend the repodata so that it has the same size as the repo it belongs to.
3080 This method is only needed when switching to a just written repodata extension
3081 to make the repodata match the written extension (which is always of the
3085 if ($data1 == $data2)
3089 Two repodata objects are equal if they belong to the same repository and have
3092 === DATA RETRIEVAL METHODS ===
3094 const char *lookup_str(Id solvid, Id keyname)
3095 my $string = $data->lookup_str($solvid, $keyname);
3096 string = data.lookup_str(solvid, keyname)
3097 string = data.lookup_str(solvid, keyname)
3099 Id *lookup_idarray(Id solvid, Id keyname)
3100 my @ids = $data->lookup_idarray($solvid, $keyname);
3101 ids = data.lookup_idarray(solvid, keyname)
3102 ids = data.lookup_idarray(solvid, keyname)
3104 Chksum lookup_checksum(Id solvid, Id keyname)
3105 my $chksum = $data->lookup_checksum($solvid, $keyname);
3106 chksum = data.lookup_checksum(solvid, keyname)
3107 chksum = data.lookup_checksum(solvid, keyname)
3109 Lookup functions. Return the data element stored in the specified solvable.
3110 The methods probably only make sense to retrieve data from the special
3111 SOLVID_META solvid that stores repodata meta information.
3113 === DATA STORAGE METHODS ===
3115 void set_id(Id solvid, Id keyname, DepId id);
3116 $data->set_id($solvid, $keyname, $id);
3117 data.set_id(solvid, keyname, id)
3118 data.set_id(solvid, keyname, id)
3120 void set_str(Id solvid, Id keyname, const char *str);
3121 $data->set_str($solvid, $keyname, $str);
3122 data.set_str(solvid, keyname, str)
3123 data.set_str(solvid, keyname, str)
3125 void set_poolstr(Id solvid, Id keyname, const char *str);
3126 $data->set_poolstr($solvid, $keyname, $str);
3127 data.set_poolstr(solvid, keyname, str)
3128 data.set_poolstr(solvid, keyname, str)
3130 void set_checksum(Id solvid, Id keyname, Chksum *chksum);
3131 $data->set_checksum($solvid, $keyname, $chksum);
3132 data.set_checksum(solvid, keyname, chksum)
3133 data.set_checksum(solvid, keyname, chksum)
3135 void add_idarray(Id solvid, Id keyname, DepId id);
3136 $data->add_idarray($solvid, $keyname, $id);
3137 data.add_idarray(solvid, keyname, id)
3138 data.add_idarray(solvid, keyname, id)
3141 my $handle = $data->new_handle();
3142 handle = data.new_handle()
3143 handle = data.new_handle()
3145 void add_flexarray(Id solvid, Id keyname, Id handle);
3146 $data->add_flexarray($solvid, $keyname, $handle);
3147 data.add_flexarray(solvid, keyname, handle)
3148 data.add_flexarray(solvid, keyname, handle)
3150 Data storage methods. Probably only useful to store data in the special
3151 SOLVID_META solvid that stores repodata meta information. Note that
3152 repodata areas can have their own Id pool (see the REPO_LOCALPOOL flag),
3153 so be careful if you need to store ids. Arrays are created by calling
3154 the add function for every element. A flexarray is an array of
3155 sub-structures, call new_handle to create a new structure, use the
3156 handle as solvid to fill the structure with data and call add_flexarray
3157 to put the structure in an array.
3162 Datapos objects describe a specific position in the repository data area.
3163 Thus they are only valid until the repository is modified in some way.
3164 Datapos objects can be created by the pos() and parentpos() methods of
3165 a Datamatch object or by accessing the ``meta'' attribute of a repository.
3169 Repo *repo; /* read only */
3174 Back pointer to repository object.
3178 Dataiterator(Id keyname, const char *match, int flags)
3179 my $di = $datapos->Dataiterator($keyname, $match, $flags);
3180 di = datapos.Dataiterator(keyname, match, flags)
3181 di = datapos.Dataiterator(keyname, match, flags)
3183 Create a Dataiterator at the position of the datapos object.
3185 const char *lookup_deltalocation(unsigned int *OUTPUT);
3186 my ($location, $medianr) = $datapos->lookup_deltalocation();
3187 location, medianr = datapos.lookup_deltalocation()
3188 location, medianr = datapos.lookup_deltalocation()
3190 Return a tuple containing the on-media location and an optional media number
3191 for a delta rpm. This obviously only works if the data position points to
3192 structure describing a delta rpm.
3194 const char *lookup_deltaseq();
3195 my $seq = $datapos->lookup_deltaseq();
3196 seq = datapos.lookup_deltaseq();
3197 seq = datapos.lookup_deltaseq();
3199 Return the delta rpm sequence from the structure describing a delta rpm.
3201 === DATA RETRIEVAL METHODS ===
3203 const char *lookup_str(Id keyname)
3204 my $string = $datapos->lookup_str($keyname);
3205 string = datapos.lookup_str(keyname)
3206 string = datapos.lookup_str(keyname)
3208 Id lookup_id(Id solvid, Id keyname)
3209 my $id = $datapos->lookup_id($keyname);
3210 id = datapos.lookup_id(keyname)
3211 id = datapos.lookup_id(keyname)
3213 unsigned long long lookup_num(Id keyname, unsigned long long notfound = 0)
3214 my $num = $datapos->lookup_num($keyname);
3215 num = datapos.lookup_num(keyname)
3216 num = datapos.lookup_num(keyname)
3218 bool lookup_void(Id keyname)
3219 my $bool = $datapos->lookup_void($keyname);
3220 bool = datapos.lookup_void(keyname)
3221 bool = datapos.lookup_void(keyname)
3223 Id *lookup_idarray(Id keyname)
3224 my @ids = $datapos->lookup_idarray($keyname);
3225 ids = datapos.lookup_idarray(keyname)
3226 ids = datapos.lookup_idarray(keyname)
3228 Chksum lookup_checksum(Id keyname)
3229 my $chksum = $datapos->lookup_checksum($keyname);
3230 chksum = datapos.lookup_checksum(keyname)
3231 chksum = datapos.lookup_checksum(keyname)
3233 Lookup functions. Note that the returned Ids are always translated into
3234 the Ids of the global pool even if the repodata area contains its own pool.
3238 Michael Schroeder <mls@suse.de>