summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-27 09:45:26 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-27 09:45:26 +0000
commit6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd (patch)
tree48f5fafdb441883b7ea7060ee7fa976c1de8a6bb /urpm
parent7535011851ee81aeb4c3386ad5a515cee8179103 (diff)
downloadurpmi-6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd.tar
urpmi-6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd.tar.gz
urpmi-6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd.tar.bz2
urpmi-6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd.tar.xz
urpmi-6177d90a2ada2717c8d0aed687dbbdc5cad6c5dd.zip
create separate function to mount iso
Diffstat (limited to 'urpm')
-rw-r--r--urpm/media.pm2
-rw-r--r--urpm/removable.pm58
2 files changed, 38 insertions, 22 deletions
diff --git a/urpm/media.pm b/urpm/media.pm
index 2e8abb70..c8397efb 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -740,7 +740,7 @@ sub add_distrib_media {
my $distribconf;
if (my $dir = $url && file_from_local_url($url)) {
- urpm::removable::try_mounting($urpm, $dir)
+ urpm::removable::try_mounting_($urpm, $dir)
or $urpm->{error}(N("unable to mount the distribution medium")), return ();
$distribconf = MDV::Distribconf->new($dir, undef);
$distribconf->load
diff --git a/urpm/removable.pm b/urpm/removable.pm
index 13d3fc70..bb10c14b 100644
--- a/urpm/removable.pm
+++ b/urpm/removable.pm
@@ -18,29 +18,45 @@ sub is_iso {
$removable_dev && $removable_dev =~ /\.iso$/i;
}
-#- side-effects: $urpm->{removable_mounted}, "mount"
+#- side-effects:
+#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
+#- + those of try_mounting_iso ($urpm->{removable_mounted}, "mount")
sub try_mounting {
my ($urpm, $dir, $o_removable) = @_;
- my $is_iso = is_iso($o_removable);
- my $mntpoint = $is_iso
- #- note: for isos, we don't parse the fstab because it might not be declared in it.
- #- so we try to remove suffixes from the dir name until the dir exists
- ? ($dir = urpm::sys::trim_until_d($dir))
- : _non_mounted_mntpoint($dir);
+ is_iso($o_removable) ? try_mounting_iso($urpm, $dir, $o_removable) : try_mounting_($urpm, $dir);
+}
+
+#- side-effects: $urpm->{removable_mounted}, "mount"
+sub try_mounting_iso {
+ my ($urpm, $dir, $iso) = @_;
+
+ #- note: for isos, we don't parse the fstab because it might not be declared in it.
+ #- so we try to remove suffixes from the dir name until the dir exists
+ my $mntpoint = urpm::sys::trim_until_d($dir);
if ($mntpoint) {
$urpm->{log}(N("mounting %s", $mntpoint));
- if ($is_iso) {
- #- to mount an iso image, grab the first loop device
- my $loopdev = urpm::sys::first_free_loopdev();
- sys_log("mount iso $mntpoint on $o_removable");
- $loopdev and system('mount', $o_removable, $mntpoint, '-t', 'iso9660', '-o', "loop=$loopdev");
- $o_removable and $urpm->{removable_mounted}{$mntpoint} = undef;
- } else {
- sys_log("mount $mntpoint");
- system("mount '$mntpoint' 2>/dev/null");
- }
+
+ #- to mount an iso image, grab the first loop device
+ my $loopdev = urpm::sys::first_free_loopdev();
+ sys_log("mount iso $mntpoint on $iso");
+ $loopdev and system('mount', $iso, $mntpoint, '-t', 'iso9660', '-o', "loop=$loopdev");
+ $iso and $urpm->{removable_mounted}{$mntpoint} = undef;
+ }
+ -e $mntpoint;
+}
+
+#- side-effects: $urpm->{removable_mounted}, "mount"
+sub try_mounting_ {
+ my ($urpm, $dir) = @_;
+
+ my $mntpoint = _non_mounted_mntpoint($dir);
+
+ if ($mntpoint) {
+ $urpm->{log}(N("mounting %s", $mntpoint));
+ sys_log("mount $mntpoint");
+ system("mount '$mntpoint' 2>/dev/null");
}
-e $dir;
}
@@ -84,11 +100,11 @@ sub try_umounting_removables {
}
#- side-effects:
-#- + those of try_mounting ($urpm->{removable_mounted}, "mount")
+#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
sub _mount_and_check_notfound {
my ($urpm, $medium_list, $dir, $removable) = @_;
- try_mounting($urpm, $dir, $removable);
+ try_mounting_($urpm, $dir, $removable);
-e $dir or return 2;
_check_notfound($medium_list);
@@ -200,14 +216,14 @@ sub _examine_removable_medium_ {
}
#- side-effects:
-#- + those of try_mounting ($urpm->{removable_mounted}, "mount")
+#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
sub try_mounting_non_removable {
my ($urpm) = @_;
foreach my $medium (grep { !$_->{removable} } @{$urpm->{media}}) {
my $dir = file_from_local_url($medium->{url}) or next;
- -e $dir || try_mounting($urpm, $dir) or
+ -e $dir || try_mounting_($urpm, $dir) or
$urpm->{error}(N("unable to access medium \"%s\"", $medium->{name})), next;
}
}