summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-02-27 14:31:59 +0000
committerFrancois Pons <fpons@mandriva.com>2003-02-27 14:31:59 +0000
commit09cf1622af26d63c1a00d060cb16d670f5b04fbd (patch)
treeda753847915cc96e3c02a7ec661b6c2545285438
parente97c079164e08aa9aceb02f60b5f7c0b1aa4b0d0 (diff)
downloadurpmi-09cf1622af26d63c1a00d060cb16d670f5b04fbd.tar
urpmi-09cf1622af26d63c1a00d060cb16d670f5b04fbd.tar.gz
urpmi-09cf1622af26d63c1a00d060cb16d670f5b04fbd.tar.bz2
urpmi-09cf1622af26d63c1a00d060cb16d670f5b04fbd.tar.xz
urpmi-09cf1622af26d63c1a00d060cb16d670f5b04fbd.zip
4.2-24mdk
-rw-r--r--urpm.pm46
-rwxr-xr-xurpmi.addmedia3
-rw-r--r--urpmi.spec7
-rwxr-xr-xurpmi.update3
4 files changed, 35 insertions, 24 deletions
diff --git a/urpm.pm b/urpm.pm
index dd454f50..a7397d0d 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -684,16 +684,18 @@ sub probe_removable_device {
#- try to find device to open/close for removable medium.
if (exists $medium->{removable}) {
if (my ($dir) = $medium->{url} =~ /(?:file|removable)[^:]*:\/(.*)/) {
- my @mntpoints2devices = $urpm->find_mntpoints($dir, 'device');
- if (@mntpoints2devices > 2) { #- return value is suitable for an hash.
+ my %infos;
+ my @mntpoints = $urpm->find_mntpoints($dir, \%infos);
+ if (@mntpoints > 1) { #- return value is suitable for an hash.
$urpm->{log}(_("too many mount points for removable medium \"%s\"", $medium->{name}));
- $urpm->{log}(_("taking removable device as \"%s\"", $mntpoints2devices[-1])); #- take the last one.
+ $urpm->{log}(_("taking removable device as \"%s\"", join ',', map { $infos{$_}{device} } @mntpoints));
}
- if (@mntpoints2devices) {
- if ($medium->{removable} && $medium->{removable} ne $mntpoints2devices[-1]) {
- $urpm->{log}(_("using different removable device [%s] for \"%s\"", $mntpoints2devices[-1], $medium->{name}));
+ if (@mntpoints) {
+ if ($medium->{removable} && $medium->{removable} ne $infos{$mntpoints[-1]}{device}) {
+ $urpm->{log}(_("using different removable device [%s] for \"%s\"",
+ $infos{$mntpoints[-1]}{device}, $medium->{name}));
}
- $medium->{removable} = $mntpoints2devices[-1];
+ $medium->{removable} = $infos{$mntpoints[-1]}{device};
} else {
$urpm->{error}(_("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
}
@@ -1696,7 +1698,7 @@ sub is_using_supermount {
#- find used mount point from a pathname, use a optional mode to allow
#- filtering according the next operation (mount or umount).
sub find_mntpoints {
- my ($urpm, $dir, $mode) = @_;
+ my ($urpm, $dir, $infos) = @_;
my ($fdir, $pdir, $v, %fstab, @mntpoints) = $dir;
local (*F, $_);
@@ -1706,13 +1708,11 @@ sub find_mntpoints {
my ($device, $mntpoint, $fstype, $options) = /^\s*(\S+)\s+(\/\S+)\s+(\S+)\s+(\S+)/ or next;
$mntpoint =~ s,/+,/,g; $mntpoint =~ s,/$,,;
$fstab{$mntpoint} = 0;
- if ($mode eq 'device') {
+ if (ref $infos) {
if ($fstype eq 'supermount') {
- $options =~ /^(?:.*[\s,])?dev=([^\s,]+)/ and $fstab{$mntpoint} = $1;
- } elsif ($device eq 'none') {
- next;
+ $options =~ /^(?:.*[\s,])?dev=([^\s,]+)/ and $infos->{$mntpoint} = { mounted => 0, device => $1, fs => $fstype };
} else {
- $fstab{$mntpoint} = $device;
+ $infos->{$mntpoint} = { mounted => 0, device => $device, fs => $fstype };
}
}
}
@@ -1721,13 +1721,11 @@ sub find_mntpoints {
my ($device, $mntpoint, $fstype, $options) = /^\s*(\S+)\s+(\/\S+)\s+(\S+)\s+(\S+)/ or next;
$mntpoint =~ s,/+,/,g; $mntpoint =~ s,/$,,;
$fstab{$mntpoint} = 1;
- if ($mode eq 'device') {
+ if (ref $infos) {
if ($fstype eq 'supermount') {
- $options =~ /^(?:.*[\s,])?dev=([^\s,]+)/ and $fstab{$mntpoint} = $1;
- } elsif ($device eq 'none') {
- next;
+ $options =~ /^(?:.*[\s,])?dev=([^\s,]+)/ and $infos->{$mntpoint} = { mounted => 1, device => $1, fs => $fstype };
} else {
- $fstab{$mntpoint} = $device;
+ $infos->{$mntpoint} = { mounted => 1, device => $device, fs => $fstype };
}
}
}
@@ -1753,9 +1751,9 @@ sub find_mntpoints {
$pdir .= "/$_";
$pdir =~ s,/+,/,g; $pdir =~ s,/$,,;
if (exists $fstab{$pdir}) {
- $mode eq 'mount' && ! $fstab{$pdir} and push @mntpoints, $pdir;
- $mode eq 'umount' && $fstab{$pdir} and unshift @mntpoints, $pdir;
- $mode eq 'device' and push @mntpoints, $pdir, $fstab{$pdir};
+ ref $infos and push @mntpoints, $pdir;
+ $infos eq 'mount' && ! $fstab{$pdir} and push @mntpoints, $pdir;
+ $infos eq 'umount' && $fstab{$pdir} and unshift @mntpoints, $pdir;
}
}
@@ -1791,18 +1789,20 @@ sub reduce_pathname {
#- check for necessity of mounting some directory to get access
sub try_mounting {
my ($urpm, $dir, $removable) = @_;
+ my %infos;
$dir = reduce_pathname($dir);
- foreach ($urpm->find_mntpoints($dir, 'mount')) {
+ foreach (grep { ! $infos{$_}{mounted} } $urpm->find_mntpoints($dir, \%infos)) {
$urpm->{log}(_("mounting %s", $_));
`mount '$_' 2>/dev/null`;
- $removable and $urpm->{removable_mounted}{$_} = undef;
+ $removable && $infos{$_}{fs} ne 'supermount' and $urpm->{removable_mounted}{$_} = undef;
}
-e $dir;
}
sub try_umounting {
my ($urpm, $dir) = @_;
+ my %infos;
$dir = reduce_pathname($dir);
foreach ($urpm->find_mntpoints($dir, 'umount')) {
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 2401dfe5..e40f6f1b 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -219,6 +219,9 @@ and [options] are from
$urpm->update_media(%options, callback => \&urpm::sync_logger);
}
}
+
+ #- try to umount removable device which may have been mounted.
+ $urpm->try_umounting_removables;
}
main(@ARGV);
diff --git a/urpmi.spec b/urpmi.spec
index 83c1bee9..5b3eafba 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 4.2
-Release: 23mdk
+Release: 24mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -206,6 +206,11 @@ fi
%changelog
+* Thu Feb 27 2003 François Pons <fpons@mandrakesoft.com> 4.2-24mdk
+- fixed removable devices not needing to be umouting if
+ supermount is used.
+- umount removable devices after adding or updating a medium.
+
* Mon Feb 24 2003 François Pons <fpons@mandrakesoft.com> 4.2-23mdk
- fixed bug 2342 (reported exit code 9 for rpm db access failure)
diff --git a/urpmi.update b/urpmi.update
index 5fb32981..858556ef 100755
--- a/urpmi.update
+++ b/urpmi.update
@@ -98,6 +98,9 @@ where <name> is a medium name to update.
}
$urpm->update_media(%options, callback => \&urpm::sync_logger);
+
+ #- try to umount removable device which may have been mounted.
+ $urpm->try_umounting_removables;
}
main(@ARGV);