summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-03-03 15:41:24 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-03-03 15:41:24 +0000
commitdcaffff668e66be0958f276f2b3f141c503caa9a (patch)
tree9871a1f3bfac5c51a170456fe3b30ee444858900 /perl-install
parent6d18753bdad1720d94f576d629b52a8d7f47736d (diff)
downloaddrakx-dcaffff668e66be0958f276f2b3f141c503caa9a.tar
drakx-dcaffff668e66be0958f276f2b3f141c503caa9a.tar.gz
drakx-dcaffff668e66be0958f276f2b3f141c503caa9a.tar.bz2
drakx-dcaffff668e66be0958f276f2b3f141c503caa9a.tar.xz
drakx-dcaffff668e66be0958f276f2b3f141c503caa9a.zip
Add a progress bar when copying rpms from the media to the hard disk
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_any.pm31
-rw-r--r--perl-install/install_steps_gtk.pm4
2 files changed, 30 insertions, 5 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index bac605449..69a2b553a 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -17,6 +17,7 @@ use MDK::Common::System;
use common;
use run_program;
use fs::type;
+use fs::format;
use partition_table;
use devices;
use fsedit;
@@ -638,6 +639,29 @@ Please insert the Cd-Rom labelled \"%s\" in your drive and press Ok when done.",
return 1;
}
};
+ my $total = $o->{mediumsize};
+ log::l("totalsize=$total");
+ my $pid = fork();
+ if (!$pid && defined $pid) { #- child
+ my ($wait_w, $wait_message) = fs::format::wait_message($o); #- nb, this is only called when interactive
+ $wait_message->(N("Copying in progress"));
+ my $du = 0;
+ #- from commands.pm. TODO: factorize, possibly in MDK::Common.
+ my $f; $f = sub {
+ my ($e) = @_;
+ my $s = (lstat($e))[12];
+ $s += sum(map { &$f($_) } glob_("$e/*")) if !-l _ && -d _;
+ $s;
+ };
+ while (1) {
+ my $s = $f->("$o->{prefix}/var/ftp/pub/Mandrakelinux/media") / 1024;
+ $wait_message->('', $s, $total);
+ sleep 1;
+ last if $s > $total - 100;
+ }
+ undef $wait_w;
+ c::_exit(0);
+ }
foreach my $k (pkgs::allMediums($o->{packages})) {
my $m = $o->{packages}{mediums}{$k};
if ($k != $current_medium) {
@@ -649,14 +673,15 @@ Please insert the Cd-Rom labelled \"%s\" in your drive and press Ok when done.",
$current_medium = $k;
}
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;
+ eval {
+ cp_af("/tmp/image/$m->{rpmsdir}", "$o->{prefix}/var/ftp/pub/Mandrakelinux/media");
+ };
log::l($@) if $@;
$m->{prefix} = "$o->{prefix}/var/ftp/pub/Mandrakelinux";
$m->{method} = 'disk';
$m->{with_hdlist} = 'media_info/hdlist.cz'; #- for install_urpmi
}
+ kill 15, $pid;
#- now the install will continue as 'disk'
$o->{method} = 'disk';
#- shoud be enough to fool errorOpeningFile
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index 6c9fe0e66..6cdd6136e 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -653,10 +653,10 @@ sub deselectFoundMedia {
$cdlist{$1} ||= [];
push @{$cdlist{$1}}, $i;
}
- $mediumsize->{$_->[0]} == 0 and $totalsize = -1; #- don't check size, total medium size unknown
$totalsize >= 0 and $totalsize += $mediumsize->{$_->[0]};
++$i;
}
+ $totalsize or $totalsize = -1; #- don't check size, total medium size unknown
my @selection = (1) x @hdlist2;
my $copy_rpms_on_disk = 0;
my $ask_copy_rpms_on_disk = $o->{method} !~ /iso/i;
@@ -664,7 +664,6 @@ sub deselectFoundMedia {
if ($ask_copy_rpms_on_disk && $totalsize >= 0) {
my (undef, $availvar) = install_any::getAvailableSpace_mounted('/var');
$availvar /= 1024; #- Mo
- log::l("rpms totalsize=$totalsize");
$ask_copy_rpms_on_disk = $totalsize > $availvar * 0.6;
}
if ($ask_copy_rpms_on_disk) {
@@ -700,6 +699,7 @@ It will then continue from the hard drive and the packages will remain available
push @l2, $hdlists->[$_] foreach @{$corresp[$i]};
}
log::l("keeping media " . join ',', map { $_->[1] } @l2);
+ $o->{mediumsize} = $totalsize;
(\@l2, $copy_rpms_on_disk);
}