summaryrefslogtreecommitdiffstats
path: root/perl-install/install/pkgs.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-11-16 17:13:45 +0000
committerThierry Vignaud <tv@mageia.org>2012-11-16 17:13:45 +0000
commit82992ae5608f3c745150ea113ae667ed1ae966e6 (patch)
tree3136133bd77e1862720d711277729d8fddacbc8d /perl-install/install/pkgs.pm
parentcb757caf7eaeaeff303e7752f4bd744c34092602 (diff)
downloaddrakx-backup-do-not-use-82992ae5608f3c745150ea113ae667ed1ae966e6.tar
drakx-backup-do-not-use-82992ae5608f3c745150ea113ae667ed1ae966e6.tar.gz
drakx-backup-do-not-use-82992ae5608f3c745150ea113ae667ed1ae966e6.tar.bz2
drakx-backup-do-not-use-82992ae5608f3c745150ea113ae667ed1ae966e6.tar.xz
drakx-backup-do-not-use-82992ae5608f3c745150ea113ae667ed1ae966e6.zip
retrieve package descriptions from XML meta-data instead of from huge hdlists
(fix not displaying packages description in network installs) (mga#549)
Diffstat (limited to 'perl-install/install/pkgs.pm')
-rw-r--r--perl-install/install/pkgs.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/perl-install/install/pkgs.pm b/perl-install/install/pkgs.pm
index e41c6c31c..588aea420 100644
--- a/perl-install/install/pkgs.pm
+++ b/perl-install/install/pkgs.pm
@@ -108,6 +108,44 @@ sub size2time {
}
}
+# Based on Rpmdrake::pkg::extract_header():
+sub get_pkg_info {
+ my ($p) = @_;
+
+ my $urpm = $::o->{packages};
+ my $name = $p->fullname;
+
+ my $medium = URPM::pkg2media($urpm->{media}, $p);
+ my ($local_source, %xml_info_pkgs, $description);
+ my $dir = urpm::file_from_local_url($medium->{url});
+ $local_source = "$dir/" . $p->filename if $dir;
+
+ if (-s $local_source) {
+ log::l("getting information from $dir...");
+ $p->update_header($local_source) and $description = $p->description;
+ log::l("Warning, could not extract header for $name from $medium!") if !$description;
+ }
+ if (!$description) {
+ my $_w = $::o->wait_message(undef, N("Getting package information from XML meta-data..."));
+ if (my $xml_info_file = eval { urpm::media::any_xml_info($urpm, $medium, 'info', undef, urpm::download::sync_logger) }) {
+ require urpm::xml_info;
+ require urpm::xml_info_pkg;
+ log::l("getting information from $xml_info_file");
+ my %nodes = eval { urpm::xml_info::get_nodes('info', $xml_info_file, [ $name ]) };
+ goto header_non_available if $@;
+ put_in_hash($xml_info_pkgs{$name} ||= {}, $nodes{$name});
+ } else {
+ $urpm->{info}(N("No xml info for medium \"%s\", only partial result for package %s", $medium->{name}, $name));
+ }
+ }
+
+ if (!$description && $xml_info_pkgs{$name}) {
+ $description = $xml_info_pkgs{$name}{description};
+ }
+ header_non_available:
+ $description || N("No description");
+}
+
sub packagesProviding {
my ($packages, $name) = @_;
grep { $_->is_arch_compat } URPM::packages_providing($packages, $name);