9 libsolv-bindings - access libsolv from perl/python/ruby
18 The pool is libsolv's central resource manager. A pool consists of Solvables,
19 Repositories, Dependencies, each indexed by Ids.
24 my $pool = solv::Pool->new();
26 pool = Solv::Pool.new()
28 Create a new pool instance. In most cases you just need
33 void *appdata; /* read/write */
38 Application specific data that may be used in any way by the code using the
41 Solvable solvables[]; /* read only */
42 my $solvable = $pool->{'solvables'}->[$solvid];
43 solvable = pool.solvables[solvid]
44 solvable = pool.solvables[solvid]
46 Look up a Solvable by its id.
48 Repo repos[]; /* read only */
49 my $repo = $pool->{'repos'}->[$repoid];
50 repo = pool.repos[repoid]
51 repo = pool.repos[repoid]
53 Look up a Repository by its id.
55 Repo *installed; /* read/write */
56 $pool->{'installed'} = $repo;
60 Define which repository contains all the installed packages.
69 Free a pool. This is currently done with a method instead of relying on
70 reference counting or garbage collection because it's hard to track every
73 void setdebuglevel(int level)
74 $pool->setdebuglevel($level);
75 pool.setdebuglevel(level)
76 pool.setdebuglevel(level)
78 Set the debug level. A value of zero means no debug output, the higher the
79 value, the more output is generated.
81 int set_flag(int flag, int value)
82 my $oldvalue = $pool->set_flag($flag, $value);
83 oldvalue = pool.set_flag(flag, value)
84 oldvalue = pool.set_flag(flag, value)
86 int get_flag(int flag)
87 my $value = $pool->get_flag($flag);
88 value = pool.get_flag(flag)
89 value = pool.get_flag(flag)
91 Set/get a pool specific flag. The flags define how the system works, e.g. how
92 the package manager treats obsoletes. The default flags should be sane for most
93 applications, but in some cases you may want to tweak a flag, for example if
94 you want to solv package dependencies for some other system than yours.
96 void set_rootdir(const char *rootdir)
97 $pool->set_rootdir(rootdir);
98 pool.set_rootdir(rootdir)
99 pool.set_rootdir(rootdir)
101 const char *get_rootdir()
102 my $rootdir = $pool->get_rootdir();
103 rootdir = pool.get_rootdir()
104 rootdir = pool.get_rootdir()
106 Set/get the rootdir to use. This is useful if you want package management
107 to work only in some directory, for example if you want to setup a chroot
108 jail. Note that the rootdir will only be prepended to file paths if the
109 *REPO_USE_ROOTDIR* flag is used.
111 void setarch(const char *arch = 0)
116 Set the architecture for your system. The architecture is used to determine
117 which packages are installable. It defaults to the result of ``uname -m''.
119 Repo *add_repo(const char *name)
120 $repo = $pool->add_repo($name);
121 repo = pool.add_repo(name)
122 repo = pool.add_repo(name)
124 Add a Repository with the specified name to the pool. The reposiory is empty
125 on creation, use the repository methods to populate it with packages.
127 Repoiterator *repos_iter()
128 for my $repo (@{$pool->repos_iter()})
129 for repo in pool.repos_iter():
130 for repo in pool.repos_iter()
132 Iterate over the existing repositories.
134 Solvableiterator *solvables_iter()
135 for my $solvable (@{$pool->solvables_iter()})
136 for solvable in pool.solvables_iter():
137 for solvable in pool.solvables_iter()
139 Iterate over the existing solvables.
141 Dep *Dep(const char *str, bool create=1)
142 my $dep = $pool->Dep($string);
143 dep = pool.Dep(string)
144 dep = pool.Dep(string)
146 Create an object describing a string or dependency. If the string is currently
147 not in the pool and _create_ is false, *undef*/*None*/*nil* is returned.
149 void addfileprovides()
150 $pool->addfileprovides();
151 pool.addfileprovides()
152 pool.addfileprovides()
154 Queue addfileprovides_queue()
155 my @ids = $pool->addfileprovides_queue();
156 ids = pool.addfileprovides_queue()
157 ids = pool.addfileprovides_queue()
159 Some package managers like rpm allow dependencies on files contained in other
160 packages. To allow libsolv to deal with those dependencies in an efficient way,
161 you need to call the addfileprovides method after creating and reading all
162 repositories. This method will scan all dependency for file names and than scan
163 all packages for matching files. If a filename has been matched, it will be
164 added to the provides list of the corresponding package. The
165 addfileprovides_queue variant works the same way but returns an array
166 containing all file dependencies. This information can be stored with the
167 repository to speed up the next usage of the repository.
169 void createwhatprovides()
170 $pool->createwhatprovides();
171 pool.createwhatprovides()
172 pool.createwhatprovides()
174 Create the internal ``whatprovides'' hash over all of the provides of all
175 packages. This method must be called before doing any lookups on provides.
176 It's encuraged to do it right after all repos are set up, usually right after
177 the call to addfileprovides().
179 Queue whatprovides(DepId dep)
180 my @solvables = $pool->whatprovides($dep);
181 solvables = pool.whatprovides(dep)
182 solvables = pool.whatprovides(dep)
184 Return all solvables that provide the specified dependency. You can use either
185 a Dep object or an simple Id as argument.
187 Queue matchprovidingids(const char *match, int flags)
188 my @ids = $pool->matchprovidingids($match, $flags);
189 ids = pool.matchprovidingids(match, flags)
190 ids = pool.matchprovidingids(match, flags)
192 Search the names of all provides and return the ones matching the specified
193 string. See the Dataiterator class for the allowed flags.
195 Id towhatprovides(Queue ids)
196 my $offset = $pool->towhatprovides(\@ids);
197 offset = pool.towhatprovides(ids)
198 offset = pool.towhatprovides(ids)
200 ``Internalize'' an array containing Ids. The returned value can be used to
201 create solver jobs working on a specific set of packages. See the Solver class
202 for more information.
204 bool isknownarch(DepId id)
205 my $bool = $pool->isknownarch($id);
206 bool = pool.isknownarch(id)
207 bool = pool.isknownarch?(id)
209 Return true if the specified Id describs a known architecture.
212 my $solver = $pool->Solver();
213 solver = pool.Solver()
214 solver = pool.Solver()
216 Create a new solver object.
218 Solver *Job(int how, Id what)
219 my $job = $pool->Job($how, $what);
220 job = pool.Job(how, what)
221 job = pool.Job(how, what)
223 Create a new Job object. Kind of low level, in most cases you would use a
224 Selection or Dep job constructor instead.
226 Selection *Selection()
227 my $sel = $pool->Selection();
228 sel = pool.Selection()
229 sel = pool.Selection()
231 Create an empty selection. Useful as a starting point for merging other
234 Selection *Selection_all()
235 my $sel = $pool->Selection_all();
236 sel = pool.Selection_all()
237 sel = pool.Selection_all()
239 Create a selection containing all packages. Useful as starting point for
240 intersecting other selections or for update/distupgrade jobs.
242 Selection *select(const char *name, int flags)
243 my $sel = $pool->select($name, $flags);
244 sel = pool.select(name, flags)
245 sel = pool.select(name, flags)
247 Create a selection by matching packages against the specified string. See the
248 Selection class for a list of flags and how to create solver jobs from a
251 void setpooljobs(Jobs *jobs)
252 $pool->setpooljobs(\@jobs);
253 pool.setpooljobs(jobs)
254 pool.setpooljobs(jobs)
257 @jobs = $pool->getpooljobs();
258 jobs = pool.getpooljobs()
259 jobs = pool.getpooljobs()
261 Get/Set fixed jobs stored in the pool. Those jobs are automatically appended to
262 all solver jobs, they are meant for fixed configurations like which packages
263 can be multiversion installed, which packages were userinstalled or must not be
266 void set_loadcallback(Callable *callback)
267 $pool->setloadcallback(\&callbackfunction);
268 pool.setloadcallback(callbackfunction)
269 pool.setloadcallback { |repodata| ... }
271 Set the callback function called when repository metadata needs to be loaded on
272 demand. To make use of this feature, you need to create repodata stubs that
273 tell the library which data is available but not loaded. If later on the data
274 needs to be accessed, the callback function is called with a repodata argument.
275 You can then load the data (maybe fetching it first from an remote server).
276 The callback should return true if the data has been made available.
278 === DATA RETRIEVAL METHODS ===
280 In the following functions, the _keyname_ argument describes what to retrive.
281 For the standard cases you can use the available Id constants. For example,
283 $solv::SOLVABLE_SUMMARY
284 solv.SOLVABLE_SUMMARY
285 Solv::SOLVABLE_SUMMARY
287 selects the ``Summary'' entry of a solvable. The _solvid_ argument selects the
288 desired solvable by Id.
290 const char *lookup_str(Id solvid, Id keyname)
291 my $string = $pool->lookup_str($solvid, $keyname);
292 string = pool.lookup_str(solvid, keyname)
293 string = pool.lookup_str(solvid, keyname)
295 Id lookup_id(Id solvid, Id keyname)
296 my $id = $pool->lookup_id($solvid, $keyname);
297 id = pool.lookup_id(solvid, keyname)
298 id = pool.lookup_id(solvid, keyname)
300 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
301 my $num = $pool->lookup_num($solvid, $keyname);
302 num = pool.lookup_num(solvid, keyname)
303 num = pool.lookup_num(solvid, keyname)
305 bool lookup_void(Id solvid, Id keyname)
306 my $bool = $pool->lookup_void($solvid, $keyname);
307 bool = pool.lookup_void(solvid, keyname)
308 bool = pool.lookup_void(solvid, keyname)
310 Queue lookup_idarray(Id solvid, Id keyname)
311 my @ids = $pool->lookup_idarray($solvid, $keyname);
312 ids = pool.lookup_idarray(solvid, keyname)
313 ids = pool.lookup_idarray(solvid, keyname)
315 Chksum *lookup_checksum(Id solvid, Id keyname)
316 my $chksum = $pool->lookup_checksum($solvid, $keyname);
317 chksum = pool.lookup_checksum(solvid, keyname)
318 chksum = pool.lookup_checksum(solvid, keyname)
320 Lookup functions. Return the data element stored in the specified solvable.
321 You should probably use the methods of the Solvable class instead.
323 Dataiterator *Dataiterator(Id solvid, Id keyname, const char *match, int flags)
324 my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags);
325 di = pool.Dataiterator(solvid, keyname, match, flags)
326 di = pool.Dataiterator(solvid, keyname, match, flags)
332 Iterate over the matching data elements. See the Dataiterator class for more
337 The following methods deal with Ids, i.e. integers representing objects in the
338 pool. They are considered ``low level'', in most cases you would not use them
339 but instead the object orientated methods.
342 $repo = $pool->id2repo($id);
343 repo = pool.id2repo(id)
344 repo = pool.id2repo(id)
346 Lookup an existing Repository by id. You can also do this by using the *repos*
349 Solvable *id2solvable(Id id)
350 $solvable = $pool->id2solvable($id);
351 solvable = pool.id2solvable(id)
352 solvable = pool.id2solvable(id)
354 Lookup an existing Repository by id. You can also do this by using the
355 *solvables* attribute.
357 const char *solvid2str(Id id)
358 my $str = $pool->solvid2str($id);
359 str = pool.solvid2str(id)
360 str = pool.solvid2str(id)
362 Return a string describing the Solvable with the specified id. The string
363 consists of the name, version, and architecture of the Solvable.
365 Id str2id(const char *str, bool create=1)
366 my $id = pool->str2id($string);
367 id = pool.str2id(string)
368 id = pool.str2id(string)
370 const char *id2str(Id id)
371 $string = pool->id2str($id);
372 string = pool.id2str(id)
373 string = pool.id2str(id)
375 Convert a string into an Id and back. If the string is currently not in the
376 pool and _create_ is false, zero is returned.
378 Id rel2id(Id name, Id evr, int flags, bool create=1)
379 my $id = pool->rel2id($nameid, $evrid, $flags);
380 id = pool.rel2id(nameid, evrid, flags)
381 id = pool.rel2id(nameid, evrid, flags)
383 Create a ``relational'' dependency. Such dependencies consist of a name part,
384 the _flags_ describing the relation, and a version part. The flags are:
386 $solv::REL_EQ | $solv::REL_GT | $solv::REL_LT
387 solv.REL_EQ | solv.REL_GT | solv.REL_LT
388 Solv::REL_EQ | Solv::REL_GT | Solv::REL_LT
390 Thus, if you want a ``\<='' relation, you would use *REL_LT | REL_EQ*.
392 Id id2langid(Id id, const char *lang, bool create=1)
393 my $id = $pool->id2langid($id, $language);
394 id = pool.id2langid(id, language)
395 id = pool.id2langid(id, language)
397 Create a language specific Id from some other id. This function simply converts
398 the id into a string, appends a dot and the specified language to the string
399 and converts the result back into an Id.
401 const char *dep2str(Id id)
402 $string = pool->dep2str($id);
403 string = pool.dep2str(id)
404 string = pool.dep2str(id)
406 Convert a dependency id into a string. If the id is just a string, this
407 function has the same effect as id2str(). For relational dependencies, the
408 result is the correct ``name relation evr'' string.
413 The dependency class is an object orientated way to work with strings and
414 dependencies. Internally, dependencies are represented as Ids, i.e. simple
415 numbers. Dependency objects can be constructed by using the Pool's Dep()
420 Pool *pool; /* read only */
425 Back reference to the pool this dependency belongs to.
427 Id id; /* read only */
432 The id of this dependency.
436 Dep *Rel(int flags, DepId evrid, bool create=1)
437 my $reldep = $dep->Rel($flags, $evrdep);
438 reldep = dep.Rel(flags, evrdep)
439 reldep = dep.Rel(flags, evrdep)
441 Create a relational dependency from to string dependencies and a flags
442 argument. See the pool's rel2id method for a description of the flags.
444 Selection *Selection_name(int setflags = 0)
445 my $sel = $dep->Selection_name();
446 sel = dep.Selection_name()
447 sel = dep.Selection_name()
449 Create a Selection from a dependency. The selection consists of all packages
450 that have a name equal to the dependency. If the dependency is of a relational
451 type, the packages version must also fulfill the dependency.
453 Selection *Selection_provides(int setflags = 0)
454 my $sel = $dep->Selection_provides();
455 sel = dep.Selection_provides()
456 sel = dep.Selection_provides()
458 Create a Selection from a dependency. The selection consists of all packages
459 that have at least one provides matching the dependency.
462 my $str = $dep->str();
466 Return a string describing the dependency.
473 Same as calling the str() method.
480 The dependencies are equal if they are part of the same pool and have the same
485 A Repository describes a group of packages, normally comming from the same
486 source. Repositories are created by the Pool's add_repo() method.
490 Pool *pool; /* read only */
495 Back reference to the pool this dependency belongs to.
497 Id id; /* read only */
502 Return the id of the repository.
504 const char *name; /* read/write */
509 The repositories name. To libsolv, the name is just a string with no specific
512 int prioprity; /* read/write */
517 The priority of the repository. A higher number means that packages of this
518 repository will be chosen over other repositories, even if they have a greater
521 int subprioprity; /* read/write */
522 $repo->{'subpriority'}
526 The sub-priority of the repository. This value is compared when the priorities
527 of two repositories are the same. It is useful to make the library prefer
528 on-disk repositories to remote ones.
530 int nsolvables; /* read only */
531 $repo->{'nsolvables'}
535 The number of solvables in this repository.
537 void *appdata; /* read/write */
542 Application specific data that may be used in any way by the code using the
545 Datapos *meta; /* read only */
550 Return a Datapos object of the repodata's metadata. You can use the lookup
551 methods of the Datapos class to lookup metadata attributes, like the repository
556 *REPO_REUSE_REPODATA*::
557 Reuse the last repository data aera (``repodata'') instead of creating a new
560 *REPO_NO_INTERNALIZE*::
561 Do not internalize the added repository data. This is useful if
562 you plan to add more data because internalization is a costly
566 Use the repodata's pool for Id storage instead of the global pool. Useful
567 if you don't want to pollute the global pool with many unneeded ids, like
568 when storing the filelist.
571 Use the repodata that is currently being loaded instead of creating a new one.
572 This only makes sense if used in a load callback.
574 *REPO_EXTEND_SOLVABLES*::
575 Do not create new solvables for the new data, but match existing solvables and
576 add the data to them. Repository metadata is often split into multiple parts,
577 with one primary file describing all packages and other parts holding
578 information that is normally not needed, like the changelog.
581 Prepend the pool's rootdir to the path when doing file operations.
584 Do not add a location element to the solvables. Useful if the solvables are
585 not in the final position, so you can add the correct location later in your code.
587 *SOLV_ADD_NO_STUBS*::
588 Do not create stubs for repository parts that can be downloaded on demand.
590 *SUSETAGS_RECORD_SHARES*::
591 This is specific to the add_susetags() method. Susetags allows to refer to already
592 read packages to save disk space. If this data sharing needs to work over multiple
593 calls to add_susetags, you need to specify this flag so that the share information
594 is made available to subsequent calls.
598 void free(bool reuseids = 0)
603 Free the repository and all solvables it contains. If _reuseids_ is set to
604 true, the solvable ids and the repository id may be reused by the library when
605 added new solvables. Thus you should leave it false if you are not sure that
606 somebody holds a reference.
608 void empty(bool reuseids = 0)
613 Free all the solvables in a repository. The repository will be empty after this
614 call. See the free() method for the meaning of _reuseids_.
621 Return true if there are no solvables in this repository.
624 $repo->internalize();
628 Internalize added data. Data must be internalized before it is available to the
629 lookup and data iterator functions.
636 Write a repo as a ``solv'' file. These files can be read very fast and thus are
637 a good way to cache repository data. Returns false if there was some error
640 Solvableiterator *solvables_iter()
641 for my $solvable (@{$repo->solvables_iter()})
642 for solvable in repo.solvables_iter():
643 for solvable in repo.solvables_iter()
645 Iterate over all solvables in a repository.
647 Repodata *add_repodata(int flags = 0)
648 my $repodata = $repo->add_repodata();
649 repodata = repo.add_repodata()
650 repodata = repo.add_repodata()
652 Add a new repodata area to the repository. This is normally automatically
653 done by the repo_add methods, so you need this method only in very
657 $repo->create_stubs();
661 Calls the create_stubs() repodata method for the last repodata of the
665 $repo->iscontiguous()
669 Return true if the solvables of this repository are all in a single block with
670 no holes, i.e. they have consecutive ids.
672 Repodata *first_repodata()
673 my $repodata = $repo->first_repodata();
674 repodata = repo.first_repodata()
675 repodata = repo.first_repodata()
677 Checks if all repodatas but the first repodata are extensions, and return the
678 first repodata if this is the case. Useful if you want to do a store/retrive
679 sequence on the repository to reduce the memory using and enable paging, as
680 this does not work if the rpository contains multiple non-extension repodata
683 Selection *Selection(int setflags = 0)
684 my $sel = $repo->Selection();
685 sel = repo.Selection()
686 sel = repo.Selection()
688 Create a Selection consisting of all packages in the repository.
690 Dataiterator *Dataiterator(Id p, Id key, const char *match, int flags)
691 my $di = $repo->Dataiterator($solvid, $keyname, $match, $flags);
692 di = repo.Dataiterator(solvid, keyname, match, flags)
693 di = repo.Dataiterator(solvid, keyname, match, flags)
699 Iterate over the matching data elements in this repository. See the
700 Dataiterator class for more information.
707 Return the name of the repository, or "Repo#<id>" if no name is set.
710 if ($repo1 == $repo2)
714 Two repositories are equal if they belong to the same pool and have the same id.
716 === DATA ADD METHODS ===
718 Solvable *add_solvable()
719 $repo->add_solvable();
723 Add a single empty solvable to the repository. Returns a Solvable object, see
724 the Solvable class for more information.
726 bool add_solv(const char *name, int flags = 0)
727 $repo->add_solv($name, $flags);
728 repo.add_solv(name, flags)
729 repo.add_solv(name, flags)
731 bool add_solv(FILE *fp, int flags = 0)
732 $repo->add_solv($fp, $flags);
733 repo.add_solv(fp, flags)
734 repo.add_solv(fp, flags)
736 Read a ``solv'' file and add its contents to the repository. These files can be
737 written with the write() method and are normally used as fast cache for
740 bool add_rpmdb(int flags = 0)
741 $repo->add_rpmdb($flags);
742 repo.add_rpmdb(flags)
743 repo.add_rpmdb(flags)
745 bool add_rpmdb_reffp(FILE *reffp, int flags = 0)
746 $repo->add_rpmdb_reffp($reffp, $flags);
747 repo.add_rpmdb_reffp($reffp, flags)
748 repo.add_rpmdb_reffp($reffp, flags)
750 Add the contents of the rpm database to the repository. If a solv file
751 containing an old version of the database is available, it can be passed as
752 reffp to speed up reading.
754 bool add_rpm(const char *name, int flags = 0)
755 $repo->add_rpm($name, $flags);
756 repo.add_rpm(name, flags)
757 repo.add_rpm(name, flags)
759 Add the metadata of a single rpm package to the repository.
761 bool add_rpmdb_pubkeys(int flags = 0)
762 $repo->add_rpmdb_pubkeys();
763 repo.add_rpmdb_pubkeys()
764 repo.add_rpmdb_pubkeys()
766 Add all pubkeys contained in the rpm database to the repository. Note that
767 newer rpm versions also allow to store the pubkeys in some directory instead
770 bool add_pubkey(const char *keyfile, int flags = 0)
771 $repo->add_pubkey($keyfile);
772 repo.add_pubkey($keyfile)
773 repo.add_pubkey($keyfile)
775 Add a pubkey from a file to the repository.
777 bool add_rpmmd(FILE *fp, const char *language, int flags = 0)
778 $repo->add_rpmmd($fp, $language);
779 repo.add_rpmmd(fp, language)
780 repo.add_rpmmd(fp, language)
782 Add metadata stored in the "rpm-md" format (i.e. from files in the ``repodata''
783 directory) to a repository. Supported files are "primary", "filelists",
784 "other", "suseinfo". Do not forget to specify the *REPO_EXTEND_SOLVABLES* for
785 extension files like "filelists" and "other". Use the _language_ parameter if
786 you have language extension files, otherwise simply use a *undef*/*None*/*nil*
789 bool add_repomdxml(FILE *fp, int flags = 0)
790 $repo->add_repomdxml($fp);
791 repo.add_repomdxml(fp)
792 repo.add_repomdxml(fp)
794 Add the repomd.xml meta description from the "rpm-md" format to the repository.
795 This file contains information about the repository like keywords, and also a
796 list of all database files with checksums. The data is added the the "meta"
797 section of the repository, i.e. no package gets created.
799 bool add_updateinfoxml(FILE *fp, int flags = 0)
800 $repo->add_updateinfoxml($fp);
801 repo.add_updateinfoxml(fp)
802 repo.add_updateinfoxml(fp)
804 Add the updateinfo.xml file containing available maintenance updates to the
805 repository. All updates are created as special packages that have a "patch:"
806 prefix in their name.
808 bool add_deltainfoxml(FILE *fp, int flags = 0)
809 $repo->add_deltainfoxml($fp);
810 repo.add_deltainfoxml(fp)
811 repo.add_deltainfoxml(fp)
813 Add the deltainfo.xml file (also called prestodelta.xml) containing available
814 delta-rpms to the repository. The data is added to the "meta" section, i.e. no
815 package gets created.
817 bool add_debdb(int flags = 0)
822 Add the contents of the debian installed package database to the repository.
824 bool add_debpackages(FILE *fp, int flags = 0)
825 $repo->add_debpackages($fp);
826 repo.add_debpackages($fp)
827 repo.add_debpackages($fp)
829 Add the contents of the debian repository metadata (the "packages" file)
832 bool add_deb(const char *filename, int flags = 0)
833 $repo->add_deb($filename);
834 repo.add_deb(filename)
835 repo.add_deb(filename)
837 Add the metadata of a single deb package to the repository.
839 bool add_mdk(FILE *fp, int flags = 0)
844 Add the contents of the mageia/mandriva repository metadata (the
845 "synthesis.hdlist" file) to the repository.
847 bool add_mdk_info(FILE *fp, int flags = 0)
852 Extend the packages from the synthesis file with the info.xml and files.xml
853 data. Do not forget to specify *REPO_EXTEND_SOLVABLES*.
855 bool add_arch_repo(FILE *fp, int flags = 0)
856 $repo->add_arch_repo($fp);
857 repo.add_arch_repo($fp)
858 repo.add_arch_repo($fp)
860 Add the contents of the archlinux repository metadata (the ".db.tar" file) to
863 bool add_arch_local(const char *dir, int flags = 0)
864 $repo->add_arch_local($dir);
865 repo.add_arch_local($dir)
866 repo.add_arch_local($dir)
868 Add the contents of the archlinux installed package database to the repository.
869 The _dir_ parameter is usually set to "/var/lib/pacman/local".
871 bool add_content(FILE *fp, int flags = 0)
872 $repo->add_content($fp);
876 Add the ``content'' meta description from the susetags format to the repository.
877 This file contains information about the repository like keywords, and also
878 a list of all database files with checksums. The data is added the the "meta"
879 section of the repository, i.e. no package gets created.
881 bool add_susetags(FILE *fp, Id defvendor, const char *language, int flags = 0)
882 $repo->add_susetags($fp, $defvendor, $language);
883 repo.add_susetags(fp, defvendor, language)
884 repo.add_susetags(fp, defvendor, language)
886 Add repository metadata in the susetags format to the repository. Like with
887 add_rpmmd, you can specify a language if you have language extension files. The
888 _defvendor_ parameter provides a default vendor for packages with missing
889 vendors, it is usually provided in the content file.
891 bool add_products(const char *dir, int flags = 0)
892 $repo->add_products($dir);
893 repo.add_products(dir)
894 repo.add_products(dir)
896 Add the installed SUSE products database to the repository. The _dir_ parameter
897 is usually "/etc/products.d".
902 A solvable describes all the information of one package. Each solvable belongs to
903 one repository, it can be added and filled manually but in most cases solvables
904 will get created by the repo_add methods.
908 Repo *repo; /* read only */
913 The repository this solvable belongs to.
915 Pool *pool; /* read only */
920 The pool this solvable belongs to, same as the pool of the repo.
922 Id id; /* read only */
927 The specific id of the solvable.
929 char *name; /* read/write */
934 char *evr; /* read/write */
939 char *arch; /* read/write */
944 char *vendor; /* read/write */
945 $solvable->{'vendor'}
949 Easy access to often used attributes of solvables. They are
950 internally stored as Ids.
952 Id nameid; /* read/write */
953 $solvable->{'nameid'}
957 Id evrid; /* read/write */
962 Id archid; /* read/write */
963 $solvable->{'archid'}
967 Id vendorid; /* read/write */
968 $solvable->{'vendorid'}
972 Raw interface to the ids. Useful if you want to search for
973 a specific id and want to avoid the string compare overhead.
977 const char *lookup_str(Id keyname)
978 my $string = $solvable->lookup_str($keyname);
979 string = solvable.lookup_str(keyname)
980 string = solvable.lookup_str(keyname)
982 Id lookup_id(Id keyname)
983 my $id = $solvable->lookup_id($keyname);
984 id = solvable.lookup_id(solvid)
985 id = solvable.lookup_id(solvid)
987 unsigned long long lookup_num(Id solvid, Id keyname, unsigned long long notfound = 0)
988 my $num = $solvable->lookup_num($keyname);
989 num = solvable.lookup_num(keyname)
990 num = solvable.lookup_num(keyname)
992 bool lookup_void(Id keyname)
993 my $bool = $solvable->lookup_void($keyname);
994 bool = solvable.lookup_void(keyname)
995 bool = solvable.lookup_void(keyname)
997 Chksum *lookup_checksum(Id keyname)
998 my $chksum = $solvable->lookup_checksum($keyname);
999 chksum = solvable.lookup_checksum(keyname)
1000 chksum = solvable.lookup_checksum(keyname)
1002 Queue lookup_idarray(Id keyname, Id marker = -1)
1003 my @ids = $solvable->lookup_idarray($keyname);
1004 ids = solvable.lookup_idarray(keyname)
1005 ids = solvable.lookup_idarray(keyname)
1007 Queue lookup_deparray(Id keyname, Id marker = -1)
1008 my @deps = $solvable->lookup_deparray($keyname);
1009 ids = solvable.lookup_deparray(keyname)
1010 ids = solvable.lookup_deparray(keyname)
1012 Generic lookup methods. Retrieve data stored for the specific keyname.
1013 The lookup_idarray() method will return an array of Ids, use
1014 lookup_deparray if you want an array of Dependency objects instead.
1015 Some Id arrays contain two parts of data divided by a specific marker,
1016 for example the provides array uses the SOLVABLE_FILEMARKER id to
1017 store both the ids provided by the package and the ids added by
1018 the addfileprovides method. The default, -1, translates to the
1019 correct marker for the keyname and returns the first part of the
1020 array, use 1 to select the second part or 0 to retrive all ids
1021 including the marker.
1023 const char *lookup_location(unsigned int *OUTPUT);
1024 my ($location, $medianr) = $solvable->lookup_location();
1025 location, medianr = solvable.lookup_location()
1026 location, medianr = solvable.lookup_location()
1028 Return a tuple containing the on-media location and an optional
1029 media number for multi-part repositories (e.g. repositories
1030 spawning multiple DVDs).
1032 void add_deparray(Id keyname, DepId id, Id marker = -1);
1033 $solvable->add_deparray($keyname, $depid);
1034 solvable.add_deparray(keyname, depid)
1035 solvable.add_deparray(keyname, depid)
1037 Add a new dependency to the attributes stored in keyname.
1040 $solvable->installable()
1041 solvable.installable()
1042 solvable.installable?
1044 Return true if the solvable is installable on the system. Solvables
1045 are not installable if the system does not support their architecture.
1048 $solvable->isinstalled()
1049 solvable.isinstalled()
1050 solvable.isinstalled?
1052 Return true if the solvable is installed on the system.
1054 Selection *Selection(int setflags = 0)
1055 my $sel = $solvable->Selection();
1056 sel = solvable.Selection()
1057 sel = solvable.Selection()
1059 Create a Selection containing just the single solvable.
1062 my $str = $solvable->str();
1063 str = $solvable.str()
1064 str = $solvable.str()
1066 Return a string describing the solvable. The string consists of the name,
1067 version, and architecture of the Solvable.
1070 my $str = "$solvable";
1074 Same as calling the str() method.
1077 if ($solvable1 == $solvable2)
1078 if solvable1 == solvable2:
1079 if solvable1 == solvable2
1081 Two solvables are equal if they are part of the same pool and have the same
1084 THE DATAITERATOR CLASS
1085 ----------------------
1100 THE TRANSACTION CLASS
1101 ---------------------
1106 Checksums (also called hashes) are used to make sure that downloaded data is
1107 not corrupt and also as a fingerprint mechanism to check if data has changed.
1109 === CLASS METHODS ===
1111 Chksum *Chksum(Id type)
1112 my $chksum = solv::Chksum->new($type);
1113 chksum = solv.Chksum(type)
1114 chksum = Solv::Chksum.new(type)
1116 Create a checksum object. Currently the following types are supported:
1122 These keys are constants in the *solv* class.
1124 Chksum *Chksum(Id type, const char *hex)
1125 my $chksum = solv::Chksum->new($type, $hex);
1126 chksum = solv.Chksum(type, hex)
1127 chksum = Solv::Chksum.new(type, hex)
1129 Create an already finalized checksum object.
1133 Id type; /* read only */
1138 Return the type of the checksum object.
1142 void add(const char *str)
1147 Add a string to the checksum.
1149 void add_fp(FILE *fp)
1150 $chksum->add_fp($file);
1154 Add the contents of a file to the checksum.
1156 void add_stat(const char *filename)
1157 $chksum->add_stat($filename);
1158 chksum.add_stat(filename)
1159 chksum.add_stat(filename)
1161 Stat the file and add the dev/ino/size/mtime member to the checksum. If the
1162 stat fails, the members are zeroed.
1164 void add_fstat(int fd)
1165 $chksum->add_fstat($fd);
1166 chksum.add_fstat(fd)
1167 chksum.add_fstat(fd)
1169 Same as add_stat, but instead of the filename a file descriptor is used.
1171 unsigned char *raw()
1172 my $raw = $chksum->raw();
1176 Finalize the checksum and return the result as raw bytes. This means that the
1177 result can contain zero bytes or unprintable characters.
1179 unsigned char *hex()
1180 my $raw = $chksum->hex();
1184 Finalize the checksum and return the result as hex string.
1187 if ($chksum1 == $chksum2)
1188 if chksum1 == chksum2:
1189 if chksum1 == chksum2
1191 Checksums are equal if they are of the same type and the finalized results are
1195 my $str = "$chksum";
1199 If the checksum is finished, the checksum is returned as "<type>:<hex>" string.
1200 Otherwise "<type>:unfinished" is returned.
1205 This functions were added because libsolv uses standard *FILE* pointers to
1206 read/write files, but languages like perl have their own implementation of
1207 files. The libsolv functions also support decompression and compression, the
1208 algorithm is selected by looking at the file name extension.
1210 FILE *xfopen(char *fn, char *mode = "r")
1211 my $file = solv::xfopen($path);
1212 file = solv.xfopen(path)
1213 file = Solv::xfopen(path)
1215 Open a file at the specified path. The `mode` argument is passed on to the
1218 FILE *xfopen_fd(char *fn, int fileno)
1219 my $file = solv::xfopen_fd($path, $fileno);
1220 file = solv.xfopen_fd(path, fileno)
1221 file = Solv::xfopen_fd(path, fileno)
1223 Create a file handle from the specified file descriptor. The path argument is
1224 only used to select the correct (de-)compression algorithm, use an empty path
1225 if you want to make sure to read/write raw data.
1230 my $fileno = $file->fileno();
1231 fileno = file.fileno()
1232 fileno = file.fileno()
1234 Return file file descriptor of the file. If the file is not open, `-1` is
1238 my $fileno = $file->dup();
1242 Return a copy of the descriptor of the file. If the file is not open, `-1` is
1250 Flush the file. Returns false if there was an error. Flushing a closed file
1251 always returns true.
1258 Close the file. This is needed for languages like Ruby, that do not destruct
1259 objects right after they are no longer referenced. In that case, it is good
1260 style to close open files so that the file descriptors are freed right away.
1261 Returns false if there was an error.
1269 Michael Schroeder <mls@suse.de>