summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-09-22 04:47:11 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-09-22 04:47:11 +0000
commit9b533aa6fc530c87435b493a18076de78bc57a74 (patch)
treee6be91447e44d89217fbcebfe415fee8bb45a09b /perl-install
parentf3dd1600ffce42ff0e3446fd5e482d5b5f9ec4d2 (diff)
downloaddrakx-backup-do-not-use-9b533aa6fc530c87435b493a18076de78bc57a74.tar
drakx-backup-do-not-use-9b533aa6fc530c87435b493a18076de78bc57a74.tar.gz
drakx-backup-do-not-use-9b533aa6fc530c87435b493a18076de78bc57a74.tar.bz2
drakx-backup-do-not-use-9b533aa6fc530c87435b493a18076de78bc57a74.tar.xz
drakx-backup-do-not-use-9b533aa6fc530c87435b493a18076de78bc57a74.zip
Cope with different cd-rom mountpoints
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_any.pm54
1 files changed, 29 insertions, 25 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 9e2543780..476526b97 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -66,38 +66,41 @@ sub relGetFile($) {
$_;
}
sub askChangeMedium($$) {
- my ($method, $medium) = @_;
+ my ($method, $medium_name) = @_;
my $allow;
do {
- local $::o->{method} = $method = 'cdrom' if $medium =~ /^\d+s$/; #- Suppl CD
- eval { $allow = changeMedium($method, $medium) };
+ local $::o->{method} = $method = 'cdrom' if $medium_name =~ /^\d+s$/; #- Suppl CD
+ eval { $allow = changeMedium($method, $medium_name) };
} while $@; #- really it is not allowed to die in changeMedium!!! or install will cores with rpmlib!!!
- log::l($allow ? "accepting medium $medium" : "refusing medium $medium");
+ log::l($allow ? "accepting medium $medium_name" : "refusing medium $medium_name");
$allow;
}
+
sub errorOpeningFile($) {
my ($file) = @_;
$file eq 'XXX' and return; #- special case to force closing file after rpmlib transaction.
$current_medium eq $asked_medium and log::l("errorOpeningFile $file"), return; #- nothing to do in such case.
- $::o->{packages}{mediums}{$asked_medium}{selected} or return; #- not selected means no need for worying about.
+ $::o->{packages}{mediums}{$asked_medium}{selected} or return; #- not selected means no need to worry about.
+ my $current_method = $::o->{packages}{mediums}{$asked_medium}{method} || $::o->{method};
my $max = 32; #- always refuse after $max tries.
- if ($::o->{method} eq "cdrom") {
- cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image), and $cdrom = $1;
+ if ($current_method eq "cdrom") {
+ cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(/mnt/cdrom|/tmp/image),
+ and ($cdrom, my $mountpoint) = ($1, $2);
return unless $cdrom;
- ejectCdrom($cdrom);
- while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
+ ejectCdrom($cdrom, $mountpoint);
+ while ($max > 0 && askChangeMedium($current_method, $asked_medium)) {
$current_medium = $asked_medium;
mountCdrom("/tmp/image");
my $getFile = getFile($file);
$getFile && @advertising_images and copy_advertising($::o);
$getFile and return $getFile;
$current_medium = 'unknown'; #- don't know what CD is inserted now.
- ejectCdrom($cdrom);
+ ejectCdrom($cdrom, $mountpoint);
--$max;
}
} else {
- while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
+ while ($max > 0 && askChangeMedium($current_method, $asked_medium)) {
$current_medium = $asked_medium;
my $getFile = getFile($file); $getFile and return $getFile;
$current_medium = 'unknown'; #- don't know what CD image has been copied.
@@ -113,11 +116,12 @@ sub errorOpeningFile($) {
$::o->{packages}{mediums}{$asked_medium}{selected} = undef;
#- on cancel, we can expect the current medium to be undefined too,
- #- this enable remounting if selecting a package back.
+ #- this enables remounting if selecting a package back.
$current_medium = 'unknown';
return;
}
+
sub getFile {
my ($f, $o_method, $altroot) = @_;
log::l("getFile $f:$o_method");
@@ -545,20 +549,20 @@ sub unlockCdrom(;$) {
$cdrom or cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image), and $cdrom = $1;
eval { $cdrom and ioctl detect_devices::tryOpen($1), c::CDROM_LOCKDOOR(), 0 };
}
-sub ejectCdrom(;$) {
- my ($cdrom) = @_;
+sub ejectCdrom {
+ my ($o_cdrom, $o_mountpoint) = @_;
getFile("XXX"); #- close still opened filehandle
- $cdrom ||= $1 if cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image),;
- if ($cdrom) {
- #- umount BEFORE opening the cdrom device otherwise the umount will
- #- D state if the cdrom is already removed
- eval { fs::umount("/tmp/image") };
- if ($@) { log::l("files still open: ", readlink($_)) foreach map { glob_("$_/fd/*") } glob_("/proc/*") }
- eval {
- my $dev = detect_devices::tryOpen($cdrom);
- ioctl($dev, c::CDROMEJECT(), 1) if ioctl($dev, c::CDROM_DRIVE_STATUS(), 0) == c::CDS_DISC_OK();
- };
- }
+ my $cdrom = $o_cdrom || cat_("/proc/mounts") =~ m!(/(?:dev|tmp)/\S+)\s+(/mnt/cdrom|/tmp/image)! && $1 or return;
+ $o_mountpoint ||= $2 || '/tmp/image';
+
+ #- umount BEFORE opening the cdrom device otherwise the umount will
+ #- D state if the cdrom is already removed
+ eval { fs::umount($o_mountpoint) };
+ if ($@) { log::l("files still open: ", readlink($_)) foreach map { glob_("$_/fd/*") } glob_("/proc/*") }
+ eval {
+ my $dev = detect_devices::tryOpen($cdrom);
+ ioctl($dev, c::CDROMEJECT(), 1) if ioctl($dev, c::CDROM_DRIVE_STATUS(), 0) == c::CDS_DISC_OK();
+ };
}
sub setupFB {