From 474da8b0f390c1f0b98d31b06a2b39f788d8dc52 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 4 Feb 2005 14:51:56 +0000 Subject: Add support to copy all RPMs to the hard drive before installation. --- perl-install/install_any.pm | 83 +++++++++++++++---------------- perl-install/install_steps.pm | 2 +- perl-install/install_steps_gtk.pm | 58 +++++++++++++++++++++ perl-install/install_steps_interactive.pm | 5 -- perl-install/pkgs.pm | 6 ++- 5 files changed, 104 insertions(+), 50 deletions(-) diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 46549f9a6..d400c2523 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -79,7 +79,7 @@ sub askChangeMedium($$) { do { 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!!! + } while $@; #- really it is not allowed to die in changeMedium!!! or install will core with rpmlib!!! log::l($allow ? "accepting medium $medium_name" : "refusing medium $medium_name"); $allow; } @@ -369,46 +369,6 @@ sub preConfigureTimezone { add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp }); } -sub deselectFoundMedia { - #- group by CD - my ($o, $hdlists) = @_; - my %cdlist; - my @hdlist2; - my @corresp; - my $i = 0; - foreach (@$hdlists) { - (my $cd) = $_->[3] =~ /\bCD ?(\d+)\b/; - if (!$cd || !@{$cdlist{$cd} || []}) { - push @hdlist2, $_; - $corresp[$i] = [ $i ]; - } else { - $corresp[$i] = []; - push @{$corresp[$cdlist{$cd}[0]]}, $i; - } - if ($cd) { - $cdlist{$1} ||= []; - push @{$cdlist{$1}}, $i; - } - ++$i; - } - my $l = $o->ask_many_from_list('', -N("The following installation media have been found. -If you want to skip some of them, you can unselect them now."), - { - list => \@hdlist2, - value => sub { 1 }, - label => sub { $_[0][3] }, - }, - ); - my @l2; $i = 0; - foreach my $c (@$l) { - ++$i while $hdlists->[$i][3] ne $c->[3]; - push @l2, $hdlists->[$_] foreach @{$corresp[$i]}; - } - log::l("keeping media " . join ',', map { $_->[1] } @l2); - @l2; -} - sub ask_if_suppl_media { my ($o) = @_; our $suppl_already_asked; @@ -613,7 +573,7 @@ sub setPackages { require pkgs; if (!$o->{packages} || is_empty_array_ref($o->{packages}{depslist})) { - ($o->{packages}, my $suppl_method) = pkgs::psUsingHdlists($o, $o->{method}); + ($o->{packages}, my $suppl_method, my $copy_rpms_on_disk) = pkgs::psUsingHdlists($o, $o->{method}); 1 while $suppl_method = $o->selectSupplMedia($suppl_method); @@ -633,6 +593,8 @@ sub setPackages { put_in_hash($o->{rpmsrate_flags_chosen} ||= {}, rpmsrate_always_flags($o)); #- must be done before pkgs::read_rpmsrate() load_rate_files($o); + copy_rpms_on_disk($o) if $copy_rpms_on_disk; + set_rpmsrate_default_category_flags($o, $rpmsrate_flags_was_chosen); push @{$o->{default_packages}}, default_packages($o); @@ -647,6 +609,43 @@ sub setPackages { } } +sub copy_rpms_on_disk { + my ($o) = @_; + use Data::Dumper;log::l("dumper mediums:".Dumper$o->{packages}{mediums}); + mkdir "$o->{prefix}/$_", 0755 for qw(var var/ftp var/ftp/pub var/ftp/pub/Mandrakelinux var/ftp/pub/Mandrakelinux/media); + local *changeMedium = sub { + my ($method, $medium) = @_; + my $name = pkgs::mediumDescr($o->{packages}, $medium); + if (method_allows_medium_change($method)) { + my $r; + if ($method =~ /-iso$/) { + $r = install_any::changeIso($name); + } else { + ejectCdrom(); + $r &&= $o->ask_okcancel('', N("Change your Cd-Rom! +Please insert the Cd-Rom labelled \"%s\" in your drive and press Ok when done.", $name), 1); + } + return $r; + } else { + return 1; + } + }; + for my $k (pkgs::allMediums($o->{packages})) { + my $m = $o->{packages}{mediums}{$k}; + askChangeMedium($o->{method}, $m->{descr}) + or next; + log::l("copying /tmp/image/$m->{rpmsdir} to $o->{prefix}/var/ftp/pub/Mandrakelinux/media"); + my $wait_w = $o->wait_message(N("Please wait"), N("Copying in progress")); + eval { cp_af("/tmp/image/$m->{rpmsdir}", "$o->{prefix}/var/ftp/pub/Mandrakelinux/media") }; + undef $wait_w; + log::l($@) if $@; + $m->{prefix} = "$o->{prefix}/var/ftp/pub/Mandrakelinux"; + $m->{method} = 'disk'; + } + #- now the install will continue as 'disk' + $o->{method} = 'disk'; +} + sub set_rpmsrate_default_category_flags { my ($o, $rpmsrate_flags_was_chosen) = @_; diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 533ee3ef0..59ce89b2a 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -295,7 +295,7 @@ sub setPackages { sub deselectFoundMedia { my (undef, $hdlists) = @_; - @$hdlists; + return ($hdlists, 0); } sub selectSupplMedia { '' } diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index 927686569..e9487b7f5 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -632,4 +632,62 @@ sub summary_prompt { $w->main($check_complete); } +sub deselectFoundMedia { + #- group by CD + my (undef, $hdlists) = @_; + my %cdlist; + my @hdlist2; + my @corresp; + my $i = 0; + foreach (@$hdlists) { + (my $cd) = $_->[3] =~ /\bCD ?(\d+)\b/; + if (!$cd || !@{$cdlist{$cd} || []}) { + push @hdlist2, $_; + $corresp[$i] = [ $i ]; + } else { + $corresp[$i] = []; + push @{$corresp[$cdlist{$cd}[0]]}, $i; + } + if ($cd) { + $cdlist{$1} ||= []; + push @{$cdlist{$1}}, $i; + } + ++$i; + } + my $w = ugtk2->new(""); + my @selection = (1) x @hdlist2; + my $copy_rpms_on_disk = 0; + $i = -1; + $w->sync; + #- TODO check available size for copying rpms from infos in hdlists file + ugtk2::gtkadd( + $w->{window}, + gtkpack( + Gtk2::VBox->new(0, 5), + Gtk2::WrappedLabel->new(N("The following installation media have been found. +If you want to skip some of them, you can unselect them now.")), + (map { ++$i; gtknew('CheckButton', text => $_->[3], active_ref => \$selection[$i]) } @hdlist2), + gtknew('HSeparator'), + Gtk2::WrappedLabel->new(N("You have the possibility to copy the contents of the CDs on the hard drive before installation. +It will then continue from the hard drive and the packages will remain available once the system will be fully installed.")), + gtknew('CheckButton', text => N("Copy whole CDs"), active_ref => \$copy_rpms_on_disk), + gtknew('HSeparator'), + #- TODO only show this for cdrom install method ? + gtknew('HBox', children_tight => [ + gtknew('Button', text => N("Next"), clicked => sub { Gtk2->main_quit }), + ]), + ), + ); + $w->main; + $i = -1; + my $l = [ grep { $selection[++$i] } @hdlist2 ]; + my @l2; $i = 0; + foreach my $c (@$l) { + ++$i while $hdlists->[$i][3] ne $c->[3]; + push @l2, $hdlists->[$_] foreach @{$corresp[$i]}; + } + log::l("keeping media " . join ',', map { $_->[1] } @l2); + (\@l2, $copy_rpms_on_disk); +} + 1; diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index f905030d5..a30ac6c76 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -403,11 +403,6 @@ sub setPackages { } } -sub deselectFoundMedia { - my ($o, $p) = @_; - install_any::deselectFoundMedia($o, $p); -} - sub mirror2text { $crypto::mirrors{$_[0]} ? $crypto::mirrors{$_[0]}[0] . '|' . $_[0] : "-|URL" } sub askSupplMirror { my ($o, $message) = @_; diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 235fc218a..cd6c33f89 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -423,7 +423,9 @@ sub psUsingHdlists { ]; $cdsuppl ? ($medium_name = ($medium_name + 1) . 's') : ++$medium_name; } - @hdlists = $o->deselectFoundMedia(\@hdlists) if $deselectionAllowed && !defined $o_initialmedium; + my ($finalhdlists, $copy_rpms_on_disk); + ($finalhdlists, $copy_rpms_on_disk) = $o->deselectFoundMedia(\@hdlists) if $deselectionAllowed && !defined $o_initialmedium; + @hdlists = @$finalhdlists; foreach my $h (@hdlists) { #- make sure the first medium is always selected! @@ -435,7 +437,7 @@ sub psUsingHdlists { log::l("psUsingHdlists read " . int(@{$o_packages->{depslist}}) . " headers on " . int(keys %{$o_packages->{mediums}}) . " hdlists"); - return $o_packages, $suppl_CDs; + return $o_packages, $suppl_CDs, $copy_rpms_on_disk; } sub psUsingHdlist { -- cgit v1.2.1