summaryrefslogtreecommitdiffstats
path: root/urpmf
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-01-11 17:26:52 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-01-11 17:26:52 +0000
commitd8314d9dd12f1bc40960ee9a498ded4ed9e917a3 (patch)
tree7c21d95e48ce824e36707cede847a1e014488306 /urpmf
parent8d2124bcbfd6f1d206035c95b2c88054bfae8612 (diff)
downloadurpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.gz
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.bz2
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.xz
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.zip
- 5.0
- urpmf, urpmq: o use xml info instead of hdlist when possible o "urpmq -l" is faster (3x) o "urpmf -l" is slower (1.5x) o "urpmf --sourcerpm" is much faster o see "xml-info" option in urpmi.cfg(5) to see when those files are downloaded o new require: perl module XML::LibXML - urpmq: o use rpm file instead of hdlist/xml-info when file is local o use URPM::Package->changelogs (need perl-URPM 3.06) - urpmi.update, urpmi.addmedia, urpmi.removemedia: o drop hdlist support replaced with xml media_info (this imply file-deps are correctly handled, see genhdlist2(1)) - urpmi.addmedia o new --xml-info option
Diffstat (limited to 'urpmf')
-rwxr-xr-xurpmf93
1 files changed, 79 insertions, 14 deletions
diff --git a/urpmf b/urpmf
index 3893f7d5..68f5581e 100755
--- a/urpmf
+++ b/urpmf
@@ -88,12 +88,17 @@ usage: urpmf [options] pattern-expression
}
my %tags_per_media_info = (
-
- synthesis => [ qw(
+ everywhere => [ qw(
arch
- conflicts
epoch
filename
+ name
+ release
+ version
+ ) ],
+
+ synthesis => [ qw(
+ conflicts
group
obsoletes
provides
@@ -103,17 +108,23 @@ my %tags_per_media_info = (
summary
) ],
+ xml_info__info => [ qw(
+ description
+ license
+ sourcerpm
+ url
+ ) ],
+
+ xml_info__files => [ qw(
+ files
+ ) ],
+
hdlist => [ qw(
buildhost
buildtime
conf_files
- description
distribution
- files
- license
packager
- sourcerpm
- url
vendor
) ],
);
@@ -165,7 +176,7 @@ my %usedtags;
my $sprintfargs = join(', ', map {
$usedtags{$_} = 1;
if ($_ eq 'media') {
- '$urpm::media::currentmedia->{name}';
+ '$medium->{name}';
} elsif ($_ eq 'fullname') {
'scalar($pkg->fullname)';
} elsif ($_ eq 'description') {
@@ -213,6 +224,7 @@ my $callback = join("\n",
"}");
$urpm->{debug}("qf:[$qf]\ncallback:\n$callback") if $urpm->{debug};
+our $medium;
$callback = eval $callback;
if ($@) {
warn "Internal error: $@\n";
@@ -229,7 +241,19 @@ if ($env) {
}
my $_lock = urpm::lock::urpmi_db($urpm, '', nofatal => 1, wait => $options{wait_lock});
-my $need_xml = grep { $usedtags{$_} } @{$tags_per_media_info{hdlist}};
+
+my %needed_media_info = map { $_ => 1 } grep {
+ my $l = $tags_per_media_info{$_};
+ int(grep { $usedtags{$_} } @$l);
+} keys %tags_per_media_info;
+
+my @needed_xml_info = map { s/xml_info__// ? $_ : () } keys %needed_media_info;
+if (@needed_xml_info > 1) {
+ # we don't handle parallel parsing of xml files, default to hdlist
+ $needed_media_info{hdlist} = 1;
+}
+
+my %fullname2pkg;
urpm::media::configure($urpm,
nocheck_access => 1,
no_skiplist => 1,
@@ -239,10 +263,51 @@ urpm::media::configure($urpm,
synthesis => $synthesis,
usedistrib => $urpm::args::options{usedistrib},
update => $update,
- callback => $callback,
- need_xml => $need_xml,
+ @needed_xml_info && $needed_media_info{synthesis} && !$needed_media_info{hdlist} ?
+ # in that case, we need to have both synthesis and xml_info
+ (callback => sub {
+ my ($_urpm, $pkg) = @_;
+ $fullname2pkg{$pkg->fullname} = $pkg;
+ 1;
+ }) : (nodepslist => 1)
);
-if ($need_xml) {
- # TODO
+# nb: we don't "my" $medium since it is used for $callback
+if ($needed_media_info{hdlist}) {
+ foreach $medium (grep { !$_->{ignore} } @{$urpm->{media}}) {
+ my $hdlist = urpm::media::any_hdlist($urpm, $medium, $options{verbose} < 0) or
+ $urpm->{error}(N("no hdlist available for medium \"%s\"", $medium->{name})), next;
+ $urpm->{log}("getting information from $hdlist");
+ $urpm->parse_hdlist($hdlist, callback => $callback);
+ }
+} elsif (!@needed_xml_info) {
+ foreach $medium (grep { !$_->{ignore} } @{$urpm->{media}}) {
+ my $synthesis = urpm::media::any_synthesis($urpm, $medium) or
+ $urpm->{error}(N("no synthesis available for medium \"%s\"", $medium->{name})), next;
+ $urpm->{log}("getting information from $synthesis");
+ $urpm->parse_synthesis($synthesis, callback => $callback);
+ }
+} elsif (my ($xml_info) = @needed_xml_info) {
+ foreach $medium (grep { !$_->{ignore} } @{$urpm->{media}}) {
+ my $xml_info_file = urpm::media::any_xml_info($urpm, $medium, $xml_info, $options{verbose} < 0) or
+ $urpm->{error}(N("no xml-info available for medium \"%s\"", $medium->{name})), next;
+ require urpm::xml_info;
+ require urpm::xml_info_pkg;
+
+ my $cooked_callback = $needed_media_info{synthesis} ?
+ sub {
+ my ($node) = @_;
+ my $pkg = $fullname2pkg{$node->{fn}} or warn "can't find $node->{fn} in synthesis\n";
+ $pkg and $callback->($urpm, urpm::xml_info_pkg->new($node, $pkg));
+ } : sub {
+ my ($node) = @_;
+ $callback->($urpm, urpm::xml_info_pkg->new($node, undef));
+ };
+ $urpm->{log}("getting information from $xml_info_file");
+ urpm::xml_info::do_something_with_nodes(
+ $xml_info,
+ $xml_info_file,
+ $cooked_callback,
+ );
+ }
}