summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-13 11:38:11 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-13 11:38:11 +0000
commit7488d786aac5d572d34c69f30c8b6aad7fdb4848 (patch)
treed4748b5b1752cd174fdb69a095f57c0104bec85d /urpm.pm
parentdc956f1076850b895e14d77b3ac590839cc162c3 (diff)
downloadurpmi-7488d786aac5d572d34c69f30c8b6aad7fdb4848.tar
urpmi-7488d786aac5d572d34c69f30c8b6aad7fdb4848.tar.gz
urpmi-7488d786aac5d572d34c69f30c8b6aad7fdb4848.tar.bz2
urpmi-7488d786aac5d572d34c69f30c8b6aad7fdb4848.tar.xz
urpmi-7488d786aac5d572d34c69f30c8b6aad7fdb4848.zip
simplify probe_removable_device()
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm40
1 files changed, 19 insertions, 21 deletions
diff --git a/urpm.pm b/urpm.pm
index c3d8c7be..50a63a4b 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -363,31 +363,30 @@ sub probe_removable_device {
$medium->{removable} ||= $1 && "/dev/$1";
} else {
delete $medium->{removable};
+ return;
}
#- try to find device to open/close for removable medium.
- if (exists($medium->{removable})) {
- if (my ($dir) = $medium->{url} =~ m!^(?:(?:file|removable)[^:]*:/)?(/.*)!) {
- my %infos;
- my @mntpoints = urpm::sys::find_mntpoints($dir, \%infos);
- if (@mntpoints > 1) { #- return value is suitable for an hash.
- $urpm->{log}(N("too many mount points for removable medium \"%s\"", $medium->{name}));
- $urpm->{log}(N("taking removable device as \"%s\"", join ',', map { $infos{$_}{device} } @mntpoints));
- }
- if (is_iso($medium->{removable})) {
- $urpm->{log}(N("Medium \"%s\" is an ISO image, will be mounted on-the-fly", $medium->{name}));
- } elsif (@mntpoints) {
- if ($medium->{removable} && $medium->{removable} ne $infos{$mntpoints[-1]}{device}) {
- $urpm->{log}(N("using different removable device [%s] for \"%s\"",
- $infos{$mntpoints[-1]}{device}, $medium->{name}));
- }
- $medium->{removable} = $infos{$mntpoints[-1]}{device};
- } else {
- $urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
- }
+ if (my $dir = analyse_url__file_if_local($medium->{url})) {
+ my %infos;
+ my @mntpoints = urpm::sys::find_mntpoints($dir, \%infos);
+ if (@mntpoints > 1) { #- return value is suitable for an hash.
+ $urpm->{log}(N("too many mount points for removable medium \"%s\"", $medium->{name}));
+ $urpm->{log}(N("taking removable device as \"%s\"", join ',', map { $infos{$_}{device} } @mntpoints));
+ }
+ if (is_iso($medium->{removable})) {
+ $urpm->{log}(N("Medium \"%s\" is an ISO image, will be mounted on-the-fly", $medium->{name}));
+ } elsif (@mntpoints) {
+ if ($medium->{removable} && $medium->{removable} ne $infos{$mntpoints[-1]}{device}) {
+ $urpm->{log}(N("using different removable device [%s] for \"%s\"",
+ $infos{$mntpoints[-1]}{device}, $medium->{name}));
+ }
+ $medium->{removable} = $infos{$mntpoints[-1]}{device};
} else {
$urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
}
+ } else {
+ $urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
}
}
@@ -709,8 +708,7 @@ sub add_medium {
} else {
$medium->{hdlist} = "hdlist.$name.cz";
$medium->{list} = "list.$name";
- #- check if the medium is using a local or a removable medium.
- $url =~ m!^(?:(removable[^:]*|file):/)?(/.*)! and $urpm->probe_removable_device($medium);
+ $urpm->probe_removable_device($medium);
}
#- local media have priority, other are added at the end.