1 |
package URPM; |
2 |
|
3 |
use strict; |
4 |
use warnings; |
5 |
use DynaLoader; |
6 |
|
7 |
# different files, but same package |
8 |
# require them here to avoid dependencies |
9 |
use URPM::Build; |
10 |
use URPM::Resolve; |
11 |
use URPM::Signature; |
12 |
|
13 |
our @ISA = qw(DynaLoader); |
14 |
our $VERSION = '4.23'; |
15 |
|
16 |
URPM->bootstrap($VERSION); |
17 |
|
18 |
sub new { |
19 |
my ($class, %options) = @_; |
20 |
my $self = bless { |
21 |
depslist => [], |
22 |
provides => {}, |
23 |
obsoletes => {}, |
24 |
}, $class; |
25 |
$self->{nofatal} = 1 if $options{nofatal}; |
26 |
$self; |
27 |
} |
28 |
|
29 |
sub set_nofatal { |
30 |
my ($urpm, $bool) = @_; |
31 |
$urpm->{nofatal} = $bool } |
32 |
|
33 |
sub packages_providing { |
34 |
my ($urpm, $name) = @_; |
35 |
grep { $_ } map { $urpm->{depslist}[$_] } sort { $a <=> $b } keys %{$urpm->{provides}{$name} || {}}; |
36 |
} |
37 |
|
38 |
sub packages_obsoleting { |
39 |
my ($urpm, $name) = @_; |
40 |
map { $urpm->{depslist}[$_] } keys %{$urpm->{obsoletes}{$name} || {}}; |
41 |
} |
42 |
|
43 |
sub packages_by_name { |
44 |
my ($urpm, $name) = @_; |
45 |
grep { $name eq $_->name } packages_providing($urpm, $name); |
46 |
} |
47 |
|
48 |
sub search { |
49 |
my ($urpm, $name, %options) = @_; |
50 |
my $best; |
51 |
|
52 |
#- tries other alternative if no strict searching. |
53 |
unless ($options{strict_name}) { |
54 |
if ($name =~ /^(.*)-([^\-]*)-([^\-]*)\.([^\.\-]*)$/) { |
55 |
foreach my $pkg (packages_providing($urpm, $1)) { |
56 |
$pkg->fullname eq $name and return $pkg; |
57 |
} |
58 |
} |
59 |
unless ($options{strict_fullname}) { |
60 |
if ($name =~ /^(.*)-([^\-]*)-([^\-]*)$/) { |
61 |
foreach my $pkg (packages_providing($urpm, $1)) { |
62 |
my ($n, $v, $r, $a) = $pkg->fullname; |
63 |
$options{src} && $a eq 'src' || $pkg->is_arch_compat or next; |
64 |
"$n-$v-$r" eq $name or next; |
65 |
!$best || $pkg->compare_pkg($best) > 0 and $best = $pkg; |
66 |
} |
67 |
$best and return $best; |
68 |
} |
69 |
if ($name =~ /^(.*)-([^\-]*)$/) { |
70 |
foreach my $pkg (packages_providing($urpm, $1)) { |
71 |
my ($n, $v, undef, $a) = $pkg->fullname; |
72 |
$options{src} && $a eq 'src' || $pkg->is_arch_compat or next; |
73 |
"$n-$v" eq $name or next; |
74 |
!$best || $pkg->compare_pkg($best) > 0 and $best = $pkg; |
75 |
} |
76 |
$best and return $best; |
77 |
} |
78 |
} |
79 |
} |
80 |
|
81 |
unless ($options{strict_fullname}) { |
82 |
foreach my $pkg (packages_providing($urpm, $name)) { |
83 |
my ($n, undef, undef, $a) = $pkg->fullname; |
84 |
$options{src} && $a eq 'src' || $pkg->is_arch_compat or next; |
85 |
$n eq $name or next; |
86 |
!$best || $pkg->compare_pkg($best) > 0 and $best = $pkg; |
87 |
} |
88 |
} |
89 |
|
90 |
return $best; |
91 |
} |
92 |
|
93 |
#- Olivier Thauvin: |
94 |
#- Returns @$listid, $start .. $end or the whole deplist id |
95 |
#- according to the given args |
96 |
sub build_listid { |
97 |
my ($urpm, $start, $end, $listid) = @_; |
98 |
|
99 |
@{$listid || []} > 0 ? @$listid : |
100 |
(($start || 0) .. (defined($end) ? $end : $#{$urpm->{depslist}})); |
101 |
} |
102 |
|
103 |
#- this is used when faking a URPM::DB: $urpm can be used as-a $db |
104 |
#- (used for urpmi --env) |
105 |
sub traverse { |
106 |
my ($urpm, $callback) = @_; |
107 |
|
108 |
if ($callback) { |
109 |
foreach my $p (@{$urpm->{depslist} || []}) { |
110 |
$callback->($p); |
111 |
} |
112 |
} |
113 |
|
114 |
scalar @{$urpm->{depslist} || []}; |
115 |
} |
116 |
|
117 |
|
118 |
#- this is used when faking a URPM::DB: $urpm can be used as-a $db |
119 |
#- (used for urpmi --env) |
120 |
sub traverse_tag { |
121 |
my ($urpm, $tag, $names, $callback) = @_; |
122 |
my $count = 0; |
123 |
my %names; |
124 |
|
125 |
if (@{$names || []}) { |
126 |
if ($tag eq 'name') { |
127 |
foreach my $n (@$names) { |
128 |
foreach my $p (packages_providing($urpm, $n)) { |
129 |
$p->name eq $n or next; |
130 |
$callback and $callback->($p); |
131 |
++$count; |
132 |
} |
133 |
} |
134 |
} elsif ($tag eq 'whatprovides') { |
135 |
foreach (@$names) { |
136 |
foreach (keys %{$urpm->{provides}{$_} || {}}) { |
137 |
$callback and $callback->($urpm->{depslist}[$_]); |
138 |
++$count; |
139 |
} |
140 |
} |
141 |
} else { |
142 |
@names{@$names} = (); |
143 |
if ($tag eq 'whatrequires') { |
144 |
foreach (@{$urpm->{depslist} || []}) { |
145 |
if (grep { exists $names{$_} } $_->requires_nosense) { |
146 |
$callback and $callback->($_); |
147 |
++$count; |
148 |
} |
149 |
} |
150 |
} elsif ($tag eq 'whatconflicts') { |
151 |
foreach (@{$urpm->{depslist} || []}) { |
152 |
if (grep { exists $names{$_} } $_->conflicts_nosense) { |
153 |
$callback and $callback->($_); |
154 |
++$count; |
155 |
} |
156 |
} |
157 |
} elsif ($tag eq 'group') { |
158 |
foreach (@{$urpm->{depslist} || []}) { |
159 |
if (exists $names{$_->group}) { |
160 |
$callback and $callback->($_); |
161 |
++$count; |
162 |
} |
163 |
} |
164 |
} elsif ($tag eq 'triggeredby' || $tag eq 'path') { |
165 |
foreach (@{$urpm->{depslist} || []}) { |
166 |
if (grep { exists $names{$_} } $_->files, grep { m!^/! } $_->provides_nosense) { |
167 |
$callback and $callback->($_); |
168 |
++$count; |
169 |
} |
170 |
} |
171 |
} else { |
172 |
die "unknown tag"; |
173 |
} |
174 |
} |
175 |
} |
176 |
|
177 |
$count; |
178 |
} |
179 |
|
180 |
#- this is used when faking a URPM::DB: $urpm can be used as-a $db |
181 |
#- (used for urpmi --env) |
182 |
sub traverse_tag_find { |
183 |
my ($urpm, $tag, $name, $callback) = @_; |
184 |
$urpm->traverse_tag($tag, [ $name ], $callback); |
185 |
} |
186 |
|
187 |
# wrapper around XS functions |
188 |
# it handles error cases |
189 |
sub _parse_hdlist_or_synthesis { |
190 |
my ($parse_func, $urpm, $file, %options) = @_; |
191 |
|
192 |
my $previous_indice = @{$urpm->{depslist}}; |
193 |
if (my ($start, $end) = $parse_func->($urpm, $file, %options)) { |
194 |
($start, $end); |
195 |
} elsif (!$options{callback}) { |
196 |
#- parse_hdlist__XS may have added some pkgs to {depslist}, |
197 |
#- but we don't want those pkgs since reading hdlist failed later. |
198 |
#- so we need to drop them |
199 |
#- FIXME: {provides} would need to be reverted too! |
200 |
splice(@{$urpm->{depslist}}, $previous_indice); |
201 |
(); |
202 |
} else { |
203 |
#- we need to keep them since the callback has been used |
204 |
#- and we can't pretend we didn't parse anything |
205 |
#- (needed for genhdlist2) |
206 |
(); |
207 |
} |
208 |
} |
209 |
sub parse_synthesis { _parse_hdlist_or_synthesis(\&parse_synthesis__XS, @_) } |
210 |
sub parse_hdlist { _parse_hdlist_or_synthesis(\&parse_hdlist__XS, @_) } |
211 |
|
212 |
sub add_macro { |
213 |
my ($s) = @_; |
214 |
#- quote for rpmlib, *sigh* |
215 |
$s =~ s/\n/\\\n/g; |
216 |
add_macro_noexpand($s); |
217 |
} |
218 |
|
219 |
package URPM::Package; |
220 |
our @ISA = qw(); # help perl_checker |
221 |
|
222 |
#- debug help for urpmi |
223 |
sub dump_flags { |
224 |
my ($pkg) = @_; |
225 |
<<EODUMP; |
226 |
available: ${\($pkg->flag_available)} |
227 |
base: ${\($pkg->flag_base)} |
228 |
disable_obsolete: ${\($pkg->flag_disable_obsolete)} |
229 |
installed: ${\($pkg->flag_installed)} |
230 |
requested: ${\($pkg->flag_requested)} |
231 |
required: ${\($pkg->flag_required)} |
232 |
selected: ${\($pkg->flag_selected)} |
233 |
skip: ${\($pkg->flag_skip)} |
234 |
upgrade: ${\($pkg->flag_upgrade)} |
235 |
EODUMP |
236 |
} |
237 |
|
238 |
my %arch_cache; |
239 |
sub is_arch_compat { |
240 |
my ($pkg) = @_; |
241 |
my $arch = $pkg->arch; |
242 |
exists $arch_cache{$arch} and return $arch_cache{$arch}; |
243 |
|
244 |
$arch_cache{$arch} = is_arch_compat__XS($pkg); |
245 |
} |
246 |
|
247 |
sub changelogs { |
248 |
my ($pkg) = @_; |
249 |
|
250 |
my @ti = $pkg->changelog_time or return; |
251 |
my @na = $pkg->changelog_name or return; |
252 |
my @tx = $pkg->changelog_text or return; |
253 |
map { |
254 |
{ time => $ti[$_], name => $na[$_], text => $tx[$_] }; |
255 |
} 0 .. $#ti; |
256 |
} |
257 |
|
258 |
package URPM::Transaction; |
259 |
our @ISA = qw(); # help perl_checker |
260 |
|
261 |
package URPM::DB; |
262 |
our @ISA = qw(); # help perl_checker |
263 |
|
264 |
1; |
265 |
|
266 |
__END__ |
267 |
|
268 |
=head1 NAME |
269 |
|
270 |
URPM - Manipulate RPM files and headers |
271 |
|
272 |
=head1 SYNOPSIS |
273 |
|
274 |
use URPM; |
275 |
|
276 |
# using the local RPM database |
277 |
my $db = URPM::DB::open(); |
278 |
$db->traverse(sub { |
279 |
my ($package) = @_; # this is a URPM::Package object |
280 |
print $package->name, "\n"; |
281 |
# ... |
282 |
}); |
283 |
|
284 |
# loading and parsing a synthesis file |
285 |
my $urpm = new URPM; |
286 |
$urpm->parse_synthesis("synthesis.sample.cz"); |
287 |
$urpm->traverse(sub { |
288 |
# retrieve all packages from the dependency list |
289 |
# ... |
290 |
}); |
291 |
|
292 |
=head1 DESCRIPTION |
293 |
|
294 |
The URPM module allows you to manipulate RPM files, RPM header files and |
295 |
hdlist files and manage them in memory. It is notably used by the L<urpmi> |
296 |
utility. It provides four classes : C<URPM>, C<URPM::DB>, C<URPM::Package>, |
297 |
and C<URPM::Transaction>. |
298 |
|
299 |
=head2 The URPM class |
300 |
|
301 |
=over 4 |
302 |
|
303 |
=item URPM->new() |
304 |
|
305 |
The constructor creates a new, empty URPM object. It's a blessed hash that |
306 |
contains two fields: |
307 |
|
308 |
B<depslist> is an arrayref containing the list of depending packages (which are |
309 |
C<URPM::Package> objects). |
310 |
|
311 |
B<provides> is an hashref containing as keys the list of property names |
312 |
provided by the URPM object. The associated value is true if the property is |
313 |
versioned. |
314 |
|
315 |
If the constructor is called with the arguments C<< nofatal => 1 >>, various |
316 |
fatal error messages are suppressed (file not found in parse_hdlist() and |
317 |
parse_synthesis()). |
318 |
|
319 |
=item URPM::read_config_files() |
320 |
|
321 |
Force the re-reading of the RPM configuration files. |
322 |
|
323 |
=item URPM::ranges_overlap($range1, $range2) |
324 |
|
325 |
This utility function compares two version ranges, in order to calculate |
326 |
dependencies properly. The ranges have roughly the form |
327 |
|
328 |
[<|<=|==|=>|>] [epoch:]version[-release] |
329 |
|
330 |
where epoch, version and release are RPM-style version numbers. |
331 |
|
332 |
=item $urpm->parse_synthesis($file [, callback => sub {...} ]) |
333 |
|
334 |
This method gets the B<depslist> and the B<provides> from a synthesis file |
335 |
and adds them to the URPM object. |
336 |
|
337 |
=item $urpm->parse_hdlist($file, %options) |
338 |
|
339 |
This method loads rpm informations from rpm headers contained in an hdlist |
340 |
file and adds them to the URPM object. Allowed options are |
341 |
|
342 |
packing => 0 / 1 |
343 |
callback => sub { ... } |
344 |
keep_all_tags => 0 / 1 |
345 |
|
346 |
The return value is a two-element array containing the first and the last id |
347 |
parsed. |
348 |
|
349 |
=item $urpm->parse_rpm($file, %options) |
350 |
|
351 |
This method gets the B<depslist> and the B<provides> from an RPM file |
352 |
and adds them to the URPM object. Allowed options are |
353 |
|
354 |
packing => 0 / 1 |
355 |
keep_all_tags => 0 / 1 |
356 |
callback => sub { ... } |
357 |
|
358 |
If C<keep_all_tags> isn't specified, URPM will drop all memory-consuming tags |
359 |
(notably changelogs, filelists, scriptlets). |
360 |
|
361 |
=item $urpm->packages_providing($name) |
362 |
|
363 |
Returns a list of C<URPM::Package> providing <$name> |
364 |
|
365 |
=item $urpm->packages_by_name($name) |
366 |
|
367 |
Returns a list of C<URPM::Package> corresponding to the wanted <$name> |
368 |
|
369 |
=item $urpm->search($name, %options) |
370 |
|
371 |
Search an RPM by name or by part of name in the list of RPMs represented by |
372 |
this $urpm. The behaviour of the search is influenced by several options: |
373 |
|
374 |
strict_name => 0 / 1 |
375 |
strict_fullname => 0 / 1 |
376 |
src => 0 / 1 |
377 |
|
378 |
=item $urpm->traverse($callback) |
379 |
|
380 |
Executes the callback for each package in the depslist, passing a |
381 |
C<URPM::Package> object as argument the callback. |
382 |
|
383 |
This is used when faking a URPM::DB: $urpm can be used as-a $db |
384 |
|
385 |
=item $urpm->traverse_tag($tag, $names, $callback) |
386 |
|
387 |
$tag may be one of C<name>, C<whatprovides>, C<whatrequires>, C<whatconflicts>, |
388 |
C<group>, C<triggeredby>, or C<path>. |
389 |
$names is a reference to an array, holding the acceptable values of the said |
390 |
tag for the searched variables. |
391 |
Then, $callback is called for each matching package in the depslist. |
392 |
|
393 |
This is used when faking a URPM::DB: $urpm can be used as-a $db |
394 |
|
395 |
=item $urpm->traverse_tag_find($tag,$name,$callback) |
396 |
|
397 |
Quite similar to C<traverse_tag>, but stops when $callback returns true. |
398 |
|
399 |
(also note that only one $name is handled) |
400 |
|
401 |
This is used when faking a URPM::DB: $urpm can be used as-a $db |
402 |
|
403 |
=item URPM::verify_rpm($file, %options) |
404 |
|
405 |
Verifies an RPM file. |
406 |
Returns 0 on failure, 1 on success. |
407 |
Recognized options are: |
408 |
|
409 |
nodigests => 0 / 1 |
410 |
nosignatures => 0 / 1 |
411 |
|
412 |
=item URPM::verify_signature($file) |
413 |
|
414 |
Verifies the signature of an RPM file. Returns a string that will contain "OK" |
415 |
or "NOT OK" as well as a description of the found key (if successful) or of the |
416 |
error (if signature verification failed.) |
417 |
|
418 |
=item $urpm->import_pubkey(%options) |
419 |
|
420 |
Imports a key in the RPM database. |
421 |
|
422 |
db => $urpm_db |
423 |
root => '...' |
424 |
block => '...' |
425 |
filename => '...' |
426 |
|
427 |
=item URPM::spec2srcheader($specfile) |
428 |
|
429 |
Returns a URPM::Package object containing the header of the source rpm produced |
430 |
by the evaluation of the specfile whose path is given as argument. All |
431 |
dependencies stored in this header are exactly the one needed to build the |
432 |
specfile. |
433 |
|
434 |
=back |
435 |
|
436 |
=head2 The URPM::DB class |
437 |
|
438 |
=over 4 |
439 |
|
440 |
=item open($prefix, $write_perm) |
441 |
|
442 |
Returns a new C<URPM::DB> object pointing on the local RPM database (or |
443 |
C<undef> on failure). |
444 |
|
445 |
$prefix defaults to C<""> and indicates the RPM DB root directory prefix if |
446 |
any. (See the B<--root> option to rpm(1)). |
447 |
|
448 |
$write_perm is a boolean that defaults to false, and that indicates whether |
449 |
the RPM DB should be open in read/write mode. |
450 |
|
451 |
=item rebuild($prefix) |
452 |
|
453 |
Rebuilds the RPM database (like C<rpm --rebuilddb>). $prefix defaults to C<"">. |
454 |
|
455 |
=item $db->traverse($callback) |
456 |
|
457 |
Executes the specified callback (a code reference) for each package |
458 |
in the DB, passing a C<URPM::Package> object as argument the callback. |
459 |
|
460 |
Returns the number of packages seen (all). |
461 |
|
462 |
=item $db->traverse_tag($tag,$names,$callback) |
463 |
|
464 |
$tag may be one of C<name>, C<whatprovides>, C<whatrequires>, C<whatconflicts>, |
465 |
C<group>, C<triggeredby>, or C<path>. |
466 |
$names is a reference to an array, holding the acceptable values of the said |
467 |
tag for the searched variables. |
468 |
Then, $callback is called for each matching package in the DB. |
469 |
|
470 |
Returns the number of packages seen (all those that matched provided names). |
471 |
|
472 |
=item $db->traverse_tag_find($tag,$name,$callback) |
473 |
|
474 |
Quite similar to C<traverse_tag>, but stops when $callback returns true. |
475 |
|
476 |
(also note that only one $name is handled) |
477 |
|
478 |
Returns whether callback returned true once. |
479 |
|
480 |
=item $db->create_transaction() |
481 |
|
482 |
Creates and returns a new transaction (an C<URPM::Transaction> object) on the |
483 |
specified DB. |
484 |
|
485 |
=back |
486 |
|
487 |
=head2 The URPM::Package class |
488 |
|
489 |
Most methods of C<URPM::Package> are accessors for the various properties |
490 |
of an RPM package. |
491 |
|
492 |
=over 4 |
493 |
|
494 |
=item $package->arch() |
495 |
|
496 |
Gives the package architecture |
497 |
|
498 |
=item $package->build_header($fileno) |
499 |
|
500 |
Writes the rpm header to the specified file ($fileno being an integer). |
501 |
|
502 |
=item $package->build_info($fileno, [$provides_files]) |
503 |
|
504 |
Writes a line of information in a synthesis file. |
505 |
|
506 |
=item $package->buildarchs() |
507 |
|
508 |
=item $package->buildhost() |
509 |
|
510 |
=item $package->buildtime() |
511 |
|
512 |
=item $package->changelog_name() |
513 |
|
514 |
=item $package->changelog_text() |
515 |
|
516 |
=item $package->changelog_time() |
517 |
|
518 |
=item $package->compare($evr) |
519 |
|
520 |
=item $package->compare_pkg($other_pkg) |
521 |
|
522 |
=item $package->conf_files() |
523 |
|
524 |
=item $package->conflicts() |
525 |
|
526 |
Full conflicts tags |
527 |
|
528 |
=item $package->conflicts_nosense() |
529 |
|
530 |
Just the conflicted package name. |
531 |
This is only used when faking a URPM::DB: $urpm can be used as-a $db |
532 |
|
533 |
=item $package->description() |
534 |
|
535 |
=item $package->dirnames() |
536 |
|
537 |
=item $package->distribution() |
538 |
|
539 |
=item $package->epoch() |
540 |
|
541 |
=item $package->EVR() |
542 |
|
543 |
=item $package->excludearchs() |
544 |
|
545 |
=item $package->exclusivearchs() |
546 |
|
547 |
=item $package->filelinktos() |
548 |
|
549 |
=item $package->files() |
550 |
|
551 |
List of files in this rpm. |
552 |
|
553 |
=item $package->files_flags() |
554 |
|
555 |
=item $package->files_gid() |
556 |
|
557 |
=item $package->files_group() |
558 |
|
559 |
=item $package->files_md5sum() |
560 |
|
561 |
=item $package->files_mode() |
562 |
|
563 |
=item $package->files_mtime() |
564 |
|
565 |
=item $package->files_owner() |
566 |
|
567 |
=item $package->files_size() |
568 |
|
569 |
=item $package->files_uid() |
570 |
|
571 |
=item $package->flag($name) |
572 |
|
573 |
=item $package->flag_available() |
574 |
|
575 |
=item $package->flag_base() |
576 |
|
577 |
=item $package->flag_disable_obsolete() |
578 |
|
579 |
=item $package->flag_installed() |
580 |
|
581 |
=item $package->flag_requested() |
582 |
|
583 |
=item $package->flag_required() |
584 |
|
585 |
=item $package->flag_selected() |
586 |
|
587 |
=item $package->flag_skip() |
588 |
|
589 |
=item $package->flag_upgrade() |
590 |
|
591 |
=item $package->free_header() |
592 |
|
593 |
=item $package->fullname() |
594 |
|
595 |
Returns a 4 element list: name, version, release and architecture in an array |
596 |
context. Returns a string NAME-VERSION-RELEASE.ARCH in scalar context. |
597 |
|
598 |
=item $package->get_tag($tagid) |
599 |
|
600 |
Returns an array containing values of $tagid. $tagid is the numerical value of |
601 |
rpm tags. See rpmlib.h. |
602 |
|
603 |
=item $package->queryformat($format) |
604 |
|
605 |
Querying the package like rpm --queryformat do. |
606 |
|
607 |
The function calls directly the rpmlib, then use header informations, so it |
608 |
silently failed if you use synthesis instead of hdlist/rpm/header files or rpmdb. |
609 |
|
610 |
=item $package->get_tag_modifiers($tagid) |
611 |
|
612 |
Return an array of human readable view of tag values. $tagid is the numerical value of rpm tags. |
613 |
|
614 |
=item $package->group() |
615 |
|
616 |
=item $package->id() |
617 |
|
618 |
=item $package->installtid() |
619 |
|
620 |
=item $package->is_arch_compat() |
621 |
|
622 |
Returns whether this package is compatible with the current machine's |
623 |
architecture. 0 means not compatible. The lower the result is, the preferred |
624 |
the package is. |
625 |
|
626 |
=item $package->license() |
627 |
|
628 |
=item $package->name() |
629 |
|
630 |
The rpm's bare name. |
631 |
|
632 |
=item $package->obsoletes() |
633 |
|
634 |
Full obsoletes tags |
635 |
|
636 |
=item $package->obsoletes_nosense() |
637 |
|
638 |
Just the obsoleted package name. |
639 |
|
640 |
=item $package->obsoletes_overlap($s) |
641 |
|
642 |
=item $package->os() |
643 |
|
644 |
=item $package->pack_header() |
645 |
|
646 |
=item $package->packager() |
647 |
|
648 |
=item $package->payload_format() |
649 |
|
650 |
=item $package->provides() |
651 |
|
652 |
Full provides tags |
653 |
|
654 |
=item $package->provides_nosense() |
655 |
|
656 |
Just the provided package name. |
657 |
|
658 |
=item $package->provides_overlap($s) |
659 |
|
660 |
=item $package->rate() |
661 |
|
662 |
=item $package->release() |
663 |
|
664 |
=item $package->requires() |
665 |
|
666 |
Full requires tags |
667 |
|
668 |
=item $package->requires_nosense() |
669 |
|
670 |
Just the required package name. |
671 |
|
672 |
=item $package->rflags() |
673 |
|
674 |
=item $package->filesize() |
675 |
|
676 |
Size of the rpm file (ie the rpm header + cpio body) |
677 |
|
678 |
=item $package->set_flag($name, $value) |
679 |
|
680 |
=item $package->set_flag_base($value) |
681 |
|
682 |
=item $package->set_flag_disable_obsolete($value) |
683 |
|
684 |
=item $package->set_flag_installed($value) |
685 |
|
686 |
=item $package->set_flag_requested($value) |
687 |
|
688 |
=item $package->set_flag_required($value) |
689 |
|
690 |
=item $package->set_flag_skip($value) |
691 |
|
692 |
=item $package->set_flag_upgrade($value) |
693 |
|
694 |
=item $package->set_id($id) |
695 |
|
696 |
=item $package->set_rate($rate) |
697 |
|
698 |
=item $package->set_rflags(...) |
699 |
|
700 |
=item $package->size() |
701 |
|
702 |
=item $package->sourcerpm() |
703 |
|
704 |
=item $package->summary() |
705 |
|
706 |
=item $package->update_header($filename, ...) |
707 |
|
708 |
=item $package->url() |
709 |
|
710 |
=item $package->vendor() |
711 |
|
712 |
=item $package->version() |
713 |
|
714 |
=back |
715 |
|
716 |
=head2 The URPM::Transaction class |
717 |
|
718 |
=over 4 |
719 |
|
720 |
=item $trans->set_script_fd($fileno) |
721 |
|
722 |
Sets the transaction output filehandle. |
723 |
|
724 |
=item $trans->add($pkg, %options) |
725 |
|
726 |
Adds a package to be installed to the transaction represented by $trans. |
727 |
$pkg is an C<URPM::Package> object. |
728 |
|
729 |
Options are: |
730 |
|
731 |
update => 0 / 1 : indicates whether this is an upgrade |
732 |
excludepath => [ ... ] |
733 |
|
734 |
=item $trans->remove($name) |
735 |
|
736 |
Adds a package to be erased to the transaction represented by $trans. |
737 |
$name is the name of the package. |
738 |
|
739 |
=item $trans->check(%options) |
740 |
|
741 |
Checks that all dependencies can be resolved in this transaction. |
742 |
|
743 |
Options are: |
744 |
|
745 |
translate_message => 0 / 1 (currently ignored.) |
746 |
|
747 |
In list context, returns an array of problems (an empty array indicates |
748 |
success). |
749 |
|
750 |
=item $trans->order() |
751 |
|
752 |
Determines package order in a transaction set according to dependencies. In |
753 |
list context, returns an array of problems (an empty array indicates success). |
754 |
|
755 |
=item $trans->run($data, %options) |
756 |
|
757 |
Runs the transaction. |
758 |
|
759 |
$data is an arbitrary user-provided piece of data to be passed to callbacks. |
760 |
|
761 |
Recognized options are: |
762 |
|
763 |
callback_close => sub { ... } |
764 |
callback_inst => sub { ... } |
765 |
callback_open => sub { ... } |
766 |
callback_trans => sub { ... } |
767 |
callback_uninst => sub { ... } |
768 |
delta => used for progress callbacks (trans, uninst, inst) |
769 |
excludedocs => 0 / 1 |
770 |
force => 0 / 1 |
771 |
ignorearch => 0 / 1 |
772 |
nosize => 0 / 1 |
773 |
noscripts => 0 / 1 |
774 |
oldpackage => 0 / 1 |
775 |
test => 0 / 1 |
776 |
translate_message => 1 |
777 |
|
778 |
They roughly correspond to command-line options to rpm(1). |
779 |
|
780 |
=item $trans->traverse($callback) |
781 |
|
782 |
Executes the specified callback (a code reference) for each package in the |
783 |
transaction, passing a C<URPM::Package> object as argument the callback. |
784 |
|
785 |
=back |
786 |
|
787 |
=head2 Macro handling functions |
788 |
|
789 |
=over |
790 |
|
791 |
=item loadmacrosfile($filename) |
792 |
|
793 |
Load the specified macro file. Sets $! if the file can't be read. |
794 |
|
795 |
=item expand($name) |
796 |
|
797 |
Expands the specified macro. |
798 |
|
799 |
=item add_macro($macro_definition) |
800 |
|
801 |
=item add_macro_noexpand($macro_definition) |
802 |
|
803 |
Define a macro. For example, |
804 |
|
805 |
URPM::add_macro("vendor Mageia"); |
806 |
my $vendor = URPM::expand("%vendor"); |
807 |
|
808 |
The 'noexpand' version doesn't expand literal newline characters in the |
809 |
macro definition. |
810 |
|
811 |
=item del_macro($name) |
812 |
|
813 |
Delete a macro. |
814 |
|
815 |
=item resetmacros() |
816 |
|
817 |
Destroys macros. |
818 |
|
819 |
=back |
820 |
|
821 |
=head2 Misc other functions |
822 |
|
823 |
=over |
824 |
|
825 |
=item setVerbosity($level) |
826 |
|
827 |
Sets rpm verbosity level. $level is an integer between 2 (RPMMESS_CRIT) and 7 |
828 |
(RPMMESS_DEBUG). |
829 |
|
830 |
=item rpmErrorString() |
831 |
|
832 |
=item rpmErrorWriteTo($fd) |
833 |
|
834 |
=item archscore($arch) |
835 |
|
836 |
Return the score of the given arch. 0 mean not compatible, |
837 |
lower is prefered. |
838 |
|
839 |
=item osscore($os) |
840 |
|
841 |
Return the score of the given os. 0 mean not compatible, |
842 |
lower is prefered. |
843 |
|
844 |
=back |
845 |
|
846 |
=head2 The $state object |
847 |
|
848 |
It has the following fields: |
849 |
|
850 |
B<backtrack>: { |
851 |
selected => { id => undef }, |
852 |
deadlock => { id|property => undef }, |
853 |
} |
854 |
|
855 |
B<cached_installed>: { property_name => { fullname => undef } } |
856 |
|
857 |
B<oldpackage>: int |
858 |
# will be passed to $trans->run to set RPMPROB_FILTER_OLDPACKAGE |
859 |
|
860 |
B<selected>: { id => { |
861 |
requested => bool, install => bool, |
862 |
from => pkg, psel => pkg, |
863 |
promote => name, unsatisfied => [ id|property ] |
864 |
} } |
865 |
|
866 |
B<rejected>: { fullname => { |
867 |
size => int, removed => { fullname|"asked" => undef }, |
868 |
obsoleted => { fullname|"asked" => undef }, |
869 |
backtrack => { # those info are only used to display why package is unselected |
870 |
promote => [ name ], keep => [ fullname ], |
871 |
unsatisfied => [ id|property ], |
872 |
conflicts => [ fullname ], |
873 |
}, |
874 |
closure => { fullname => { old_requested => bool, |
875 |
unsatisfied => [ id|property ], |
876 |
conflicts => property }, |
877 |
avoid => bool }, |
878 |
}, |
879 |
} } |
880 |
|
881 |
B<rejected_already_installed>: { id => pkg } |
882 |
|
883 |
B<orphans_to_remove>: [ pkg ] |
884 |
|
885 |
B<whatrequires>: { name => { id => undef } } |
886 |
# reversed requires_nosense for selected packages |
887 |
|
888 |
B<unselected_uninstalled>: [ pkg ] |
889 |
# (old) packages which are needed, but installed package is newer |
890 |
|
891 |
more fields only used in build_transaction_set and its callers): |
892 |
|
893 |
B<transaction>: [ { upgrade => [ id ], remove => [ fullname ] } ] |
894 |
|
895 |
B<transaction_state>: $state object |
896 |
|
897 |
=head1 COPYRIGHT |
898 |
|
899 |
Copyright 2002, 2003, 2004, 2005 MandrakeSoft SA |
900 |
|
901 |
Copyright 2005, 2006, 2007, 2008 Mandriva SA |
902 |
|
903 |
Copyright 2011, 2012, Mageia |
904 |
|
905 |
FranE<ccedil>ois Pons (original author), Rafael Garcia-Suarez, Pixel, Thierry Vignaud <tv@mageia.org> (current maintainer) |
906 |
|
907 |
This library is free software; you can redistribute it and/or modify it under |
908 |
the same terms as Perl itself. |
909 |
|
910 |
=cut |