summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/cdrom.pm6
-rw-r--r--urpm/get_pkgs.pm35
-rw-r--r--urpm/install.pm10
-rw-r--r--urpm/main_loop.pm14
-rw-r--r--urpm/removable.pm19
5 files changed, 41 insertions, 43 deletions
diff --git a/urpm/cdrom.pm b/urpm/cdrom.pm
index 6fcfe9f7..38aabb76 100644
--- a/urpm/cdrom.pm
+++ b/urpm/cdrom.pm
@@ -209,17 +209,13 @@ sub _copy_from_cdrom__if_needed {
}
}
-#- $list is a [ { pkg_id1 => url1, ... }, { ... }, ... ]
-#- where there is one hash for each medium in {media}
-#-
#- side-effects:
#- + those of _may_eject_cdrom ($urpm->{cdrom_mounted}, "hal_umount", "hal_eject")
#- + those of _mount_cdrom ($urpm->{cdrom_mounted}, $blists_url->[_]{medium}{mntpoint}, "hal_mount", "hal_eject")
#- + those of _copy_from_cdrom__if_needed ("copy-move-files")
sub copy_packages_of_removable_media {
- my ($urpm, $list, $sources, $o_ask_for_medium) = @_;
+ my ($urpm, $blists, $sources, $o_ask_for_medium) = @_;
- my $blists = urpm::removable::create_blists($urpm->{media}, $list);
@$blists = grep { urpm::is_cdrom_url($_->{medium}{url}) } @$blists;
# we prompt for CDs used less first, since the last CD will be used directly
diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm
index 71336da0..7be7f33b 100644
--- a/urpm/get_pkgs.pm
+++ b/urpm/get_pkgs.pm
@@ -131,6 +131,28 @@ sub selected2list {
($local_sources, \@list);
}
+#- side-effects: none
+sub _create_blists {
+ my ($media, $list) = @_;
+
+ #- make sure everything is correct on input...
+ $media or return;
+ @$media == @$list or return;
+
+ my $i;
+ [ map {
+ my $list = $list->[$i++];
+ %$list ? { medium => $_, list => $list } : ();
+ } @$media ];
+}
+
+sub selected2local_and_blists {
+ my ($urpm, $selected, %options) = @_;
+
+ my ($local_sources, $list) = selected2local_and_blists($urpm, $selected, %options);
+ ($local_sources, _create_blists($urpm->{media}, $list));
+}
+
sub verify_partial_rpm_and_move {
my ($urpm, $cachedir, $filename) = @_;
@@ -147,19 +169,16 @@ sub verify_partial_rpm_and_move {
# TODO verify that files are downloaded from the right corresponding media
#- options: quiet, callback,
sub download_packages_of_distant_media {
- my ($urpm, $list, $sources, $error_sources, %options) = @_;
+ my ($urpm, $blists, $sources, $error_sources, %options) = @_;
my %errors;
#- get back all ftp and http accessible rpm files into the local cache
- foreach my $n (0..$#$list) {
+ foreach my $blist (@$blists) {
my %distant_sources;
- #- ignore media that contain nothing for the current set of files
- values %{$list->[$n]} or next;
-
#- examine all files to know what can be indexed on multiple media.
- while (my ($i, $url) = each %{$list->[$n]}) {
+ while (my ($i, $url) = each %{$blist->{list}}) {
#- the given URL is trusted, so the file can safely be ignored.
defined $sources->{$i} and next;
my $local_file = file_from_local_url($url);
@@ -189,8 +208,8 @@ sub download_packages_of_distant_media {
#- download files from the current medium.
if (%distant_sources) {
- $urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $urpm->{media}[$n]{name}));
- if (urpm::download::sync($urpm, $urpm->{media}[$n], [ values %distant_sources ],
+ $urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $blist->{media}{name}));
+ if (urpm::download::sync($urpm, $blist->{media}, [ values %distant_sources ],
dir => "$cachedir/partial", quiet => $options{quiet},
resume => $urpm->{options}{resume}, callback => $options{callback})) {
$urpm->{log}(N("...retrieving done"));
diff --git a/urpm/install.pm b/urpm/install.pm
index db15ae09..0df11dce 100644
--- a/urpm/install.pm
+++ b/urpm/install.pm
@@ -27,13 +27,13 @@ sub _hash_intersect_list {
}
sub prepare_transaction {
- my ($_urpm, $set, $list, $sources) = @_;
+ my ($_urpm, $set, $blists, $sources) = @_;
- my @transaction_list = map {
- _hash_intersect_list($_, $set->{upgrade});
- } @$list;
+ my @blists_subset = map {
+ +{ %$_, list => _hash_intersect_list($_->{list}, $set->{upgrade}) };
+ } @$blists;
- \@transaction_list, _hash_intersect_list($sources, $set->{upgrade});
+ \@blists_subset, _hash_intersect_list($sources, $set->{upgrade});
}
sub build_transaction_set_ {
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index 790cdffd..ba3c3879 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -41,22 +41,22 @@ sub run {
urpm::get_pkgs::clean_all_cache($urpm) if $clean;
-my ($local_sources, $list) = urpm::get_pkgs::selected2list($urpm,
+my ($local_sources, $blists) = urpm::get_pkgs::selected2local_and_blists($urpm,
$state->{selected},
clean_other => !$noclean && $urpm->{options}{'pre-clean'},
);
-if (!$local_sources && !$list) {
+if (!$local_sources && !$blists) {
$urpm->{fatal}(3, N("unable to get source packages, aborting"));
}
my %sources = %$local_sources;
-urpm::removable::try_mounting_non_cdroms($urpm, $list);
+urpm::removable::try_mounting_non_cdroms($urpm, $blists);
$callbacks->{pre_removable} and $callbacks->{pre_removable}->();
require urpm::cdrom;
urpm::cdrom::copy_packages_of_removable_media($urpm,
- $list, \%sources,
+ $blists, \%sources,
$callbacks->{copy_removable});
$callbacks->{post_removable} and $callbacks->{post_removable}->();
@@ -87,13 +87,13 @@ foreach my $set (@{$state->{transaction} || []}) {
#- put a blank line to separate with previous transaction or user question.
print "\n" if $options{verbose} >= 0;
- my ($transaction_list, $transaction_sources) =
- urpm::install::prepare_transaction($urpm, $set, $list, \%sources);
+ my ($transaction_blists, $transaction_sources) =
+ urpm::install::prepare_transaction($urpm, $set, $blists, \%sources);
#- first, filter out what is really needed to download for this small transaction.
my @error_sources;
urpm::get_pkgs::download_packages_of_distant_media($urpm,
- $transaction_list,
+ $transaction_blists,
$transaction_sources,
\@error_sources,
quiet => $options{verbose} < 0,
diff --git a/urpm/removable.pm b/urpm/removable.pm
index 558e95a6..57b52f95 100644
--- a/urpm/removable.pm
+++ b/urpm/removable.pm
@@ -136,9 +136,7 @@ sub try_umounting_removables {
#- side-effects:
#- + those of try_mounting_non_cdrom ($urpm->{removable_mounted}, "mount")
sub try_mounting_non_cdroms {
- my ($urpm, $list) = @_;
-
- my $blists = create_blists($urpm->{media}, $list);
+ my ($urpm, $blists) = @_;
foreach my $blist (grep { urpm::file_from_local_url($_->{medium}{url}) } @$blists) {
try_mounting_medium($urpm, $blist->{medium}, _blist_first_url($blist));
@@ -146,21 +144,6 @@ sub try_mounting_non_cdroms {
}
#- side-effects: none
-sub create_blists {
- my ($media, $list) = @_;
-
- #- make sure everything is correct on input...
- $media or return;
- @$media == @$list or return;
-
- my $i;
- [ map {
- my $list = $list->[$i++];
- %$list ? { medium => $_, list => $list } : ();
- } @$media ];
-}
-
-#- side-effects: none
sub _blist_first_url {
my ($blist) = @_;