summaryrefslogtreecommitdiffstats
path: root/urpm/removable.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-26 20:32:43 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-26 20:32:43 +0000
commita7c96c5c219dfd89c3d7eb422c431dc4b23717f8 (patch)
tree46a9aac6c6501cbbf698a14d837e05bd154df269 /urpm/removable.pm
parent5c2d545f720487b86403fecafc0a41b08d4e09fb (diff)
downloadurpmi-a7c96c5c219dfd89c3d7eb422c431dc4b23717f8.tar
urpmi-a7c96c5c219dfd89c3d7eb422c431dc4b23717f8.tar.gz
urpmi-a7c96c5c219dfd89c3d7eb422c431dc4b23717f8.tar.bz2
urpmi-a7c96c5c219dfd89c3d7eb422c431dc4b23717f8.tar.xz
urpmi-a7c96c5c219dfd89c3d7eb422c431dc4b23717f8.zip
create _sort_media() out of copy_packages_of_removable_media()
Diffstat (limited to 'urpm/removable.pm')
-rw-r--r--urpm/removable.pm29
1 files changed, 16 insertions, 13 deletions
diff --git a/urpm/removable.pm b/urpm/removable.pm
index c2e8db7a..b0d9d278 100644
--- a/urpm/removable.pm
+++ b/urpm/removable.pm
@@ -207,6 +207,20 @@ sub _create_blists {
map { { medium => $_, list => $list->[$i++] } } @$media ];
}
+sub _sort_media {
+ my ($urpm, @l) = @_;
+
+ if (@l > 1) {
+ @l = sort { values(%{$a->{list}}) <=> values(%{$b->{list}}) } @l;
+
+ #- check if a removable device is already mounted (and files present).
+ if (my ($already_mounted) = grep { !_check_notfound($urpm, $_->{list}) } @l) {
+ @l = ($already_mounted, grep { $_ != $already_mounted } @l);
+ }
+ }
+ @l;
+}
+
#- $list is a [ { pkg_id1 => url1, ... }, { ... }, ... ]
#- where there is one hash for each medium in {media}
sub copy_packages_of_removable_media {
@@ -214,23 +228,12 @@ sub copy_packages_of_removable_media {
my $blists = _create_blists($urpm->{media}, $list);
- my @removables = _get_removables_or_check_mounted($urpm, $blists);
+ foreach my $l (_get_removables_or_check_mounted($urpm, $blists)) {
- foreach my $l (@removables) {
#- Here we have only removable devices.
#- If more than one media uses this device, we have to sort
#- needed packages to copy the needed rpm files.
- my @l = @$l;
-
- if (@l > 1) {
- @l = sort { values(%{$a->{list}}) <=> values(%{$b->{list}}) } @l;
-
- #- check if a removable device is already mounted (and files present).
- if (my ($already_mounted) = grep { !_check_notfound($urpm, $_->{list}) } @l) {
- @l = ($already_mounted, grep { $_ != $already_mounted } @l);
- }
- }
- foreach my $blist (@l) {
+ foreach my $blist (_sort_media($urpm, @$l)) {
_examine_removable_medium($urpm, $blist, $sources, $o_ask_for_medium);
}
}