diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-03-03 15:41:24 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-03-03 15:41:24 +0000 |
commit | dcaffff668e66be0958f276f2b3f141c503caa9a (patch) | |
tree | 9871a1f3bfac5c51a170456fe3b30ee444858900 /perl-install/install_any.pm | |
parent | 6d18753bdad1720d94f576d629b52a8d7f47736d (diff) | |
download | drakx-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/install_any.pm')
-rw-r--r-- | perl-install/install_any.pm | 31 |
1 files changed, 28 insertions, 3 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 |