diff options
-rw-r--r-- | urpm/cdrom.pm | 34 | ||||
-rw-r--r-- | urpm/removable.pm | 18 |
2 files changed, 25 insertions, 27 deletions
diff --git a/urpm/cdrom.pm b/urpm/cdrom.pm index 625200f7..329aaec9 100644 --- a/urpm/cdrom.pm +++ b/urpm/cdrom.pm @@ -11,12 +11,12 @@ use urpm 'file_from_local_medium'; -#- side-effects: $blists_url->[_]{medium}{mntpoint} -sub _find_blist_url_matching { - my ($urpm, $blists_url, $mntpoint) = @_; +#- side-effects: $blists->[_]{medium}{mntpoint} +sub _find_blist_matching { + my ($urpm, $blists, $mntpoint) = @_; my @l; - foreach my $blist (@$blists_url) { + foreach my $blist (@$blists) { $blist->{medium}{mntpoint} and next; # set it, then verify @@ -40,21 +40,21 @@ sub _look_for_mounted_cdrom_in_mtab() { #- side-effects: #- + those of _try_mounting_cdrom_using_hal ($urpm->{cdrom_mounted}, "hal_mount") -#- + those of _find_blist_url_matching ($blists_url->[_]{medium}{mntpoint}) +#- + those of _find_blist_matching ($blists->[_]{medium}{mntpoint}) sub try_mounting_cdrom { - my ($urpm, $blists_url) = @_; + my ($urpm, $blists) = @_; - my @blists_url; + my @blists; # first try without hal, it allows users where hal fails to work (with one CD only) my @mntpoints = _look_for_mounted_cdrom_in_mtab(); - @blists_url = map { _find_blist_url_matching($urpm, $blists_url, $_) } @mntpoints; + @blists = map { _find_blist_matching($urpm, $blists, $_) } @mntpoints; - if (!@blists_url) { + if (!@blists) { @mntpoints = _try_mounting_cdrom_using_hal($urpm); - @blists_url = map { _find_blist_url_matching($urpm, $blists_url, $_) } @mntpoints; + @blists = map { _find_blist_matching($urpm, $blists, $_) } @mntpoints; } - @blists_url; + @blists; } #- side-effects: $urpm->{cdrom_mounted}, "hal_mount" @@ -81,7 +81,7 @@ sub _try_mounting_cdrom_using_hal { } #- side-effects: -#- + those of try_mounting_cdrom ($urpm->{cdrom_mounted}, $blists_url->[_]{medium}{mntpoint}, "hal_mount") +#- + those of try_mounting_cdrom ($urpm->{cdrom_mounted}, $blists->[_]{medium}{mntpoint}, "hal_mount") sub _mount_cdrom_and_check { my ($urpm, $blists) = @_; @@ -136,7 +136,7 @@ sub _eject_cdrom { } #- side-effects: "eject" -#- + those of _mount_cdrom_and_check ($urpm->{cdrom_mounted}, $blists_url->[_]{medium}{mntpoint}, "hal_mount") +#- + those of _mount_cdrom_and_check ($urpm->{cdrom_mounted}, $blists->[_]{medium}{mntpoint}, "hal_mount") #- + those of _may_eject_cdrom ($urpm->{cdrom_mounted}, "hal_umount", "hal_eject") sub _mount_cdrom { my ($urpm, $blists, $ask_for_medium) = @_; @@ -171,10 +171,8 @@ sub _mount_cdrom { sub _filepath { my ($blist, $pkg) = @_; - my $url = urpm::blist_pkg_to_url($blist, $pkg); - my $filepath = file_from_local_medium($blist->{medium}, $url) or return; - $filepath =~ m!/.*/! or return; #- is this really needed?? - $filepath; + my $filepath = file_from_local_medium($blist->{medium}) or return; + $filepath . '/' . $pkg->filename; } #- side-effects: "copy-move-files" @@ -211,7 +209,7 @@ sub _copy_from_cdrom__if_needed { #- 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 _mount_cdrom ($urpm->{cdrom_mounted}, $blists->[_]{medium}{mntpoint}, "hal_mount", "hal_eject") #- + those of _copy_from_cdrom__if_needed ("copy-move-files") sub copy_packages_of_removable_media { my ($urpm, $blists, $sources, $o_ask_for_medium) = @_; diff --git a/urpm/removable.pm b/urpm/removable.pm index f4892bc0..f6d97983 100644 --- a/urpm/removable.pm +++ b/urpm/removable.pm @@ -26,9 +26,9 @@ sub file_or_synthesis_dir_from_blist { #- side-effects: #- + those of try_mounting_medium_ ($medium->{mntpoint}) sub try_mounting_medium { - my ($urpm, $medium, $o_url) = @_; + my ($urpm, $medium, $o_blist) = @_; - my $rc = try_mounting_medium_($urpm, $medium, $o_url); + my $rc = try_mounting_medium_($urpm, $medium, $o_blist); $rc or $urpm->{error}(N("unable to access medium \"%s\".", $medium->{name})); $rc; } @@ -37,13 +37,13 @@ sub try_mounting_medium { #- + those of urpm::cdrom::try_mounting_cdrom ($urpm->{cdrom_mounted}, $medium->{mntpoint}, "hal_mount") #- + those of _try_mounting_local ($urpm->{removable_mounted}, "mount") sub try_mounting_medium_ { - my ($urpm, $medium, $o_url) = @_; + my ($urpm, $medium, $o_blist) = @_; if (urpm::is_cdrom_url($medium->{url})) { require urpm::cdrom; - urpm::cdrom::try_mounting_cdrom($urpm, [ { medium => $medium, url => $o_url } ]); + urpm::cdrom::try_mounting_cdrom($urpm, [ { medium => $medium, pkgs => $o_blist && $o_blist->{pkgs} } ]); } else { - _try_mounting_local($urpm, $medium, $o_url); + _try_mounting_local($urpm, $medium, $o_blist); } } @@ -51,9 +51,9 @@ sub try_mounting_medium_ { #- + those of _try_mounting_using_fstab ($urpm->{removable_mounted}, "mount") #- + those of _try_mounting_iso ($urpm->{removable_mounted}, "mount") sub _try_mounting_local { - my ($urpm, $medium, $o_url) = @_; + my ($urpm, $medium, $o_blist) = @_; - my $dir = file_or_synthesis_dir($medium, $o_url); + my $dir = file_or_synthesis_dir($medium, $o_blist && _blist_first_url($o_blist)); -e $dir and return 1; $medium->{iso} ? _try_mounting_iso($urpm, $dir, $medium->{iso}) : _try_mounting_using_fstab($urpm, $dir); @@ -139,7 +139,7 @@ sub try_mounting_non_cdroms { 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)); + try_mounting_medium($urpm, $blist->{medium}, $blist); } } @@ -147,7 +147,7 @@ sub try_mounting_non_cdroms { sub _blist_first_url { my ($blist) = @_; - my ($pkg) = values %{$blist->{pkgs}}; + my ($pkg) = values %{$blist->{pkgs}} or return; urpm::blist_pkg_to_url($blist, $pkg); } |