From 9b533aa6fc530c87435b493a18076de78bc57a74 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Wed, 22 Sep 2004 04:47:11 +0000 Subject: Cope with different cd-rom mountpoints --- perl-install/install_any.pm | 54 ++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'perl-install') 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 { -- cgit v1.2.1