1RPM2(3)               User Contributed Perl Documentation              RPM2(3)
2
3
4

NAME

6       RPM2 - Perl bindings for the RPM Package Manager API
7

SYNOPSIS

9         use RPM2;
10
11         my $db = RPM2->open_rpm_db();
12
13         my $i = $db->find_all_iter();
14         print "The following packages are installed (aka, 'rpm -qa'):\n";
15         while (my $pkg = $i->next) {
16           print $pkg->as_nvre, "\n";
17         }
18
19         $i = $db->find_by_name_iter("kernel");
20         print "The following kernels are installed (aka, 'rpm -q kernel'):\n";
21         while (my $pkg = $i->next) {
22           print $pkg->as_nvre, " ", int($pkg->size()/1024), "k\n";
23         }
24
25         $i = $db->find_by_provides_iter("kernel");
26         print "The following packages provide 'kernel' (aka, 'rpm -q --whatprovides kernel'):\n";
27         while (my $pkg = $i->next) {
28           print $pkg->as_nvre, " ", int($pkg->size()/1024), "k\n";
29         }
30
31         print "The following packages are installed (aka, 'rpm -qa' once more):\n";
32         foreach my $pkg ($db->find_by_file("/bin/sh")) {
33           print $pkg->as_nvre, "\n";
34         }
35
36         my $pkg = RPM2->open_package("/tmp/XFree86-4.1.0-15.src.rpm");
37         print "Package opened: ", $pkg->as_nvre(), ", is source: ", $pkg->is_source_package, "\n";
38

DESCRIPTION

40       The RPM2 module provides an object-oriented interface to querying both
41       the installed RPM database as well as files on the filesystem.
42

CLASS METHODS

44       Pretty much all use of the class starts here.  There are three main
45       entrypoints into the package -- either through the database of
46       installed rpms (aka the rpmdb),  through a file on the filesystem (such
47       as kernel-2.4.9-31.src.rpm or kernel-2.4.9-31.i386.rpm, or via an rpm
48       transaction.
49
50       You can have multiple RPM databases open at once, as well as running
51       multiple queries on each.  That being said if you expect to run a
52       transaction to install or erase some rpms, you will need to cause any
53       RPM2::DB and RPM2::PackageIterator objects to go out of scope.  For
54       instance:
55
56               $db = RPM2->open_rpm_db();
57               $i  = $db->find_by_name("vim");
58               $t  = create_transaction();
59               while($pkg = $i->next()) {
60                  $t->add_erase($pkg);
61               }
62               $t->run();
63
64       Would end up in a dead lock waiting for $db, and $i (the RPM2::DB and
65       RPM2::PackageIterator) objects to releaase their read lock on the
66       database.  The correct way of handling this then would be to do the
67       following before running the transaction:
68
69               $db = undef;
70               $i  = undef;
71
72       That is to explicitly cause the RPM2::DB and RPM2::PackageIterator
73       objects to go out of scope.
74
75       open_rpm_db(-path => "/path/to/db")
76           As it sounds, it opens the RPM database, and returns it as an
77           object.  The path to the database (i.e. "-path") is optional.
78
79       open_package("foo-1.1-14.noarch.rpm")
80           Opens a specific package (RPM or SRPM).  Returns a Header object.
81
82       create_transaction(RPM2->vsf_default)
83           Creates an RPM2::Transaction.  This can be used to install and
84           remove packages.  It, also, exposes the dependency ordering
85           functionality.  It takes as an optional argument verify signature
86           flags.  The following flags are available:
87
88       RPM2->vsf_default
89           You don't ever have to specify this, but you could if you wanted to
90           do so.  This will check headers, not require a files payload, and
91           support all the various hash and signature formats that rpm
92           supports.
93
94       RPM2->vsf_nohdrchk
95           Don't check the header.
96
97       RPM2->vsf_needpayload
98           Require that a files payload be part of the RPM (Chip is this
99           right?).
100
101       RPM2->vsf_nosha1header
102       RPM2->vsf_nomd5header
103       RPM2->vsf_nodsaheader
104       RPM2->vsf_norsaheader
105       RPM2->vsf_nosha1
106       RPM2->vsf_nomd5
107       RPM2->vsf_nodsa
108       RPM2->vsf_norsa
109

RPM DB object methods

111       find_all_iter()
112           Returns an iterator object that iterates over the entire database.
113
114       find_all()
115           Returns an list of all of the results of the find_all_iter()
116           method.
117
118       find_by_file_iter($filename)
119           Returns an iterator that returns all packages that contain a given
120           file.
121
122       find_by_file($filename)
123           Ditto, except it just returns the list
124
125       find_by_name_iter($package_name)
126           You get the idea.  This one is for iterating by package name.
127
128       find_by_name($package_name)
129           Ditto, except it returns a list.
130
131       find_by_provides_iter($provides_string)
132           This one iterates over provides.
133
134       find_by_provides($provides_string)
135           Ditto, except it returns a list.
136
137       find_by_requires_iter($requires_string)
138           This one iterates over requires.
139
140       find_by_requires($requires_string)
141           Ditto, except it returns a list.
142

RPM Database Iterator Methods

144       Once you have a a database iterator, then you simply need to step
145       through all the different package headers in the result set via the
146       iterator.
147
148       next()
149           Return the next package header in the result set.
150
151       expand_iter()
152           Return the list of all the package headers in the result set of the
153           iterator.
154

RPM Header object methods

156       In addition to the following methods, all tags have simple accessors;
157       $hdr->epoch() is equivalent to $hdr->tag('epoch').
158
159       The <=> and cmp operators can be used to compare versions of two
160       packages.
161
162       $hdr->tag($tagname)
163           Returns the value of the tag $tagname.
164
165       $hdr->tagformat($format)
166           TODO.
167
168       $hdr->is_source_package()
169           Returns a true value if the package is a source package, false
170           otherwise.
171
172       $hdr->filename()
173           Returns the filename of the package.
174
175       $hdr->offset()
176           Returns the rpm database offset for the package.
177
178       $hdr->as_nvre()
179           Returns a string formatted like:
180
181              epoch:name-version-release
182
183           If epoch is undefined for this package, it and the leading colon
184           are omitted.
185
186       $hdr->files()
187           TODO.
188
189       $hdr->changelog()
190           Returns a list of hash refs containing the change log data of the
191           package.  The hash keys represent individual change log entries,
192           and their keys are: "time" (the time of the changelog entry),
193           "name" (the "name", ie. often the email address of the author of
194           the entry), and "text" (the text of the entry).
195

Transaction object methods

197       Transactions are what allow you to install, upgrade, and remove rpms.
198       Transactions are created, have elements added to them (i.e. package
199       headers) and are ran.  When run the updates to the system and the rpm
200       database are treated as on "transaction" which is assigned a
201       transaction id.  This can be queried in install packages as the
202       INSTALLTID, and for repackaged packages they have the REMOVETID set.
203
204       add_install($pkg, $upgrade)
205           Adds a package to a transaction for installation.  If you want this
206           to be done as a package upgrade, then be sure to set the second
207           optional parameter to 1.  It will return 0 on failure and 1 on
208           success.  Note, this should be obvious, but the package header must
209           come from an rpm file, not from the RPM database.
210
211       add_erase($pkg)
212           Adds a package to a transaction for erasure.  The package header
213           should come from the database (i.e. via an iterator) and not an rpm
214           file.
215
216       element_count()
217           Returns the number of elements in a transaction (this is the sum of
218           the install and erase elements.
219
220       close_db()
221           Closes the rpm database.  This is needed for some ordering of
222           transactions for non-install purposes.
223
224       check()
225           Verify that the dependencies for this transaction are met.  Returns
226           0 on failure and 1 on success.
227
228       order()
229           Order the elements in dependency order.
230
231       elements()
232           Return a list of elements as they are presently ordered.  Note,
233           this returns the NEVR's not the package headers.
234
235       run()
236           Run the transaction.  This will automatically check for dependency
237           satisfaction, and order the transaction.
238

TODO

240       Make package installation and removal better (-;.
241
242       Signature validation.
243

HISTORY

245       0.01 Initial release.
246       0.68 RPM 4.6 Support.
247       0.69 RPM 4.9 Support.
248

AUTHORS

250       RPM2 was originally written by Chip Turner <cturner@pattern.net> and
251       contributions were made by numerous authors. It is currently maintained
252       by Lubomir Rintel <lkundrak@v3.sk>.
253
254       The source code is kept in a Git repository at
255       <https://github.com/lkundrak/perl-RPM2.git>.
256

BUGS

258       Report the bugs (and feature requests) at
259       <http://rt.cpan.org/Public/Bug/Report.html?Queue=RPM2>.  Alternatively,
260       you can report a bug by sending mail to <bug-RPM2@rt.cpan.org>.
261

LICENSE

263       This module is free software and is licensed under the same terms as
264       Perl itself.
265

SEE ALSO

267       perl.  The original RPM module.
268
269
270
271perl v5.32.0                      2020-07-28                           RPM2(3)
Impressum