diff options
Diffstat (limited to 'perl-install/install_any.pm')
-rw-r--r-- | perl-install/install_any.pm | 83 |
1 files changed, 72 insertions, 11 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index d88b23901..b251cd8b9 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -1,6 +1,5 @@ package install_any; # $Id$ -use diagnostics; use strict; use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $boot_medium $current_medium $asked_medium @advertising_images); @@ -38,6 +37,13 @@ $asked_medium = $boot_medium; #-###################################################################################### my $postinstall_rpms = ''; my $cdrom; + +sub mountCdrom($;$) { + my ($mountpoint, $cdrom_) = @_; + $cdrom_ = $cdrom if !defined $cdrom_; + eval { fs::mount($cdrom_, $mountpoint, "iso9660", 'readonly') }; +} + sub useMedium($) { #- before ejecting the first CD, there are some files to copy! #- does nothing if the function has already been called. @@ -63,6 +69,7 @@ sub askChangeMedium($$) { my ($method, $medium) = @_; my $allow; do { + local $::o->{method} = $method = 'cdrom' if $medium =~ /^\d+s$/; #- Suppl CD eval { $allow = changeMedium($method, $medium) }; } 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"); @@ -81,7 +88,7 @@ sub errorOpeningFile($) { ejectCdrom($cdrom); while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) { $current_medium = $asked_medium; - eval { fs::mount($cdrom, "/tmp/image", "iso9660", 'readonly') }; + mountCdrom("/tmp/image"); my $getFile = getFile($file); $getFile && @advertising_images and copy_advertising($::o); $getFile and return $getFile; @@ -98,6 +105,9 @@ sub errorOpeningFile($) { } } + #- Don't unselect supplementary CDs. + return if $asked_medium =~ /^\d+s$/; + #- keep in mind the asked medium has been refused on this way. #- this means it is no more selected. $::o->{packages}{mediums}{$asked_medium}{selected} = undef; @@ -109,7 +119,7 @@ sub errorOpeningFile($) { return; } sub getFile { - my ($f, $o_method) = @_; + my ($f, $o_method, $altroot) = @_; log::l("getFile $f:$o_method"); my $rel = relGetFile($f); do { @@ -126,11 +136,13 @@ sub getFile { require http; http::getFile("$ENV{URLPREFIX}/$rel"); } else { - #- try to open the file, but examine if it is present in the repository, this allow - #- handling changing a media when some of the file on the first CD has been copied - #- to other to avoid media change... + #- try to open the file, but examine if it is present in the repository, + #- this allows handling changing a media when some of the files on the + #- first CD have been copied to other to avoid media change... my $f2 = "$postinstall_rpms/$f"; - $f2 = "/tmp/image/$rel" if !$postinstall_rpms || !-e $f2; + $altroot = '/tmp/image' unless $altroot; + $f2 = "$altroot/$rel" if !$postinstall_rpms || !-e $f2; + $f2 = $rel if $rel =~ m!^/! && !-e $f2; #- not a relative path my $F; open($F, $f2) && $F; } } || errorOpeningFile($f); @@ -287,7 +299,52 @@ sub setPackages { require pkgs; if (!$o->{packages} || is_empty_array_ref($o->{packages}{depslist})) { - $o->{packages} = pkgs::psUsingHdlists($o->{prefix}, $o->{method}); + ($o->{packages}, my $suppl_CDs) = pkgs::psUsingHdlists($o->{prefix}, $o->{method}); + + #- ask whether there are supplementary CDs + SUPPL: { + #- TODO don't ask this for an upgrade: the suppl.CD should aldready be listed in the media + if ($suppl_CDs && $o->ask_yesorno('', N("Do you have a supplementary CD to install?"), 0)) { + #- by convention, the media names for suppl. CDs match /^\d+s$/ + my $medium = '1s'; #- supplement 1 + local $::isWizard = 0; + local $::o->{method} = 'cdrom'; + (my $cdromdev) = detect_devices::cdroms(); + last SUPPL if !$cdromdev; + my $cdrom = $cdromdev->{device}; + my $dev = devices::make($cdrom); + ejectCdrom($cdrom); + if ($o->ask_okcancel('', N("Insert the CD"), 1)) { + mountCdrom("/mnt/cdrom", $cdrom); + log::l($@) if $@; + useMedium($medium); + my $supplmedium = pkgs::psUsingHdlist( + $o->{prefix}, # /mnt + 'cdrom', + $o->{packages}, + "hdlist$medium.cz", + $medium, + 'Mandrake/RPMS', + "Supplementary CD $medium", + 1, # selected + "/mnt/cdrom/Mandrake/base/hdlist$medium.cz", + #'/mnt/cdrom/Mandrake/base/pubkey', + ); + if ($supplmedium) { + log::l("read suppl hdlist"); + $supplmedium->{prefix} = "removable://mnt/cdrom"; #- pour install_urpmi + $supplmedium->{selected} = 1; + $supplmedium->{method} = 'cdrom'; + } else { + log::l("no suppl hdlist"); + } + #- TODO loop if there are several supplementary CDs + # ++$medium; $medium .= "s"; + } + } else { + $suppl_CDs = 0; + } + } #- open rpm db according to right mode needed. $o->{packages}{rpmdb} ||= pkgs::rpmDbOpen($o->{prefix}, $rebuild_needed); @@ -307,6 +364,9 @@ sub setPackages { #- preselect default_packages and compssUsersChoices. setDefaultPackages($o); pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || next) foreach @{$o->{default_packages}}; + + #- umount supplementary CD. Will re-ask for it later + eval { fs::umount("/mnt/cdrom") } if $suppl_CDs; } else { #- this has to be done to make sure necessary files for urpmi are #- present. @@ -528,7 +588,8 @@ sub install_urpmi { cdrom => "removable://mnt/cdrom" }}{$method} || #- for live_update or live_install script. readlink("/tmp/image/Mandrake") =~ m,^(/.*)/Mandrake/*$, && "removable:/$1") . "/$_->{rpmsdir}"; - my $need_list = $dir =~ m,^(?:[^:]*://[^/:\@]*:[^/:\@]+\@|.*%{),; #- use list file only if visible password or macro. + #- use list file only if visible password or macro. + my $need_list = $dir =~ m,^(?:[^:]*://[^/:\@]*:[^/:\@]+\@|.*%{),; #- } #- build a list file if needed. if ($need_list) { @@ -536,7 +597,7 @@ sub install_urpmi { open(my $LIST, ">$prefix/var/lib/urpmi/list.$name") or log::l("failed to write list.$name"); umask $mask; - #- build list file using internal data, synthesis file should exists. + #- build list file using internal data, synthesis file should exist. if ($_->{end} > $_->{start}) { #- WARNING this method of build only works because synthesis (or hdlist) #- has been read. @@ -580,7 +641,7 @@ sub install_urpmi { } else { $with = $_->{rpmsdir}; $with =~ s|/[^/]*%{ARCH}.*||; - $with =~ s|/+|/|g; $with =~ s|/$||; $with =~ s|[^/]||g; $with =~ s|/|../|g; + $with =~ s|/+|/|g; $with =~ s|/$||; $with =~ s|[^/]||g; $with =~ s!/!../!g; $with .= "../Mandrake/base/$_->{hdlist}"; } |