summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-08-25 09:41:44 +0000
committerNorbert Preining <preining@logic.at>2009-08-25 09:41:44 +0000
commit16e3c94d7360d4ad8d5106fadc3fabfbc797bf02 (patch)
tree95dcd72b88cccffb280e30a306bd696a06c927ef /Master/tlpkg/TeXLive
parentab85c7eb4fde78db5439fe75ae612246064c77fc (diff)
add progress bars for tlmgr install and tlmgr update,
separate out the time estimation code and reuse it git-svn-id: svn://tug.org/texlive/trunk@14854 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm77
1 files changed, 45 insertions, 32 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 08ab4571272..84c99221002 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -69,6 +69,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure
TeXLive::TLUtils::create_updmap($tlpdb,$dest,$localconf);
TeXLive::TLUtils::create_language_dat($tlpdb,$dest,$localconf);
TeXLive::TLUtils::create_language_def($tlpdb,$dest,$localconf);
+ TeXLive::TLUtils::time_estimate($totalsize, $donesize, $starttime)
TeXLive::TLUtils::install_packages($from_tlpdb,$media,$to_tlpdb,$what,$opt_src, $opt_doc)>);
TeXLive::TLUtils::install_package($what, $filelistref, $target, $platform);
TeXLive::TLUtils::do_postaction($how, $tlpobj, $do_fileassocs, $do_shortcuts, $do_script);
@@ -146,6 +147,7 @@ BEGIN {
&w32_add_to_path
&w32_remove_from_path
&tlcmp
+ &time_estimate
);
@EXPORT = qw(setup_programs download_file process_logging_options
tldie tlwarn info log debug ddebug dddebug debug_hash
@@ -1039,6 +1041,47 @@ sub removed_dirs
return keys %removed_dirs;
}
+=item C<time_estimate($totalsize, $donesize, $starttime)>
+
+Returns the estimated remaining and estimated total time
+based on the total size, the already done size, and the start time.
+
+=cut
+
+sub time_estimate {
+ my ($totalsize, $donesize, $starttime) = @_;
+ if ($donesize <= 0) {
+ return ("??:??", "??:??");
+ }
+ my $curtime = time();
+ my $passedtime = $curtime - $starttime;
+ my $esttotalsecs = int ( ( $passedtime * $totalsize ) / $donesize );
+ my $remsecs = $esttotalsecs - $passedtime;
+ my $min = int($remsecs/60);
+ my $hour;
+ if ($min >= 60) {
+ $hour = int($min/60);
+ $min %= 60;
+ }
+ my $sec = $remsecs % 60;
+ $remtime = sprintf("%02d:%02d", $min, $sec);
+ if ($hour) {
+ $remtime = sprintf("%02d:$remtime", $hour);
+ }
+ my $tmin = int($esttotalsecs/60);
+ my $thour;
+ if ($tmin >= 60) {
+ $thour = int($tmin/60);
+ $tmin %= 60;
+ }
+ my $tsec = $esttotalsecs % 60;
+ $tottime = sprintf("%02d:%02d", $tmin, $tsec);
+ if ($thour) {
+ $tottime = sprintf("%02d:$tottime", $thour);
+ }
+ return($remtime, $tottime);
+}
+
=item C<install_packages($from_tlpdb, $media, $to_tlpdb, $what, $opt_src, $opt_doc)>
@@ -1095,39 +1138,9 @@ sub install_packages {
my $tlpobj = $tlpobjs{$package};
my $reloc = $tlpobj->relocated;
$n++;
- my $remtime = "??:??";
- my $tottime = "??:??";
- if ($donesize > 0) {
- # try to compute the remaining time
- my $curtime = time();
- my $passedtime = $curtime - $starttime;
- my $esttotalsecs = int ( ( $passedtime * $totalsize ) / $donesize );
- my $remsecs = $esttotalsecs - $passedtime;
- my $min = int($remsecs/60);
- my $hour;
- if ($min >= 60) {
- $hour = int($min/60);
- $min %= 60;
- }
- my $sec = $remsecs % 60;
- $remtime = sprintf("%02d:%02d", $min, $sec);
- if ($hour) {
- $remtime = sprintf("%02d:$remtime", $hour);
- }
- my $tmin = int($esttotalsecs/60);
- my $thour;
- if ($tmin >= 60) {
- $thour = int($tmin/60);
- $tmin %= 60;
- }
- my $tsec = $esttotalsecs % 60;
- $tottime = sprintf("%02d:%02d", $tmin, $tsec);
- if ($thour) {
- $tottime = sprintf("%02d:$tottime", $thour);
- }
- }
+ my ($estrem, $esttot) = time_estimate($totalsize, $donesize, $starttime);
my $infostr = sprintf("Installing [%0${td}d/$totalnr, "
- . "time/total: $remtime/$tottime]: $package [%dk]",
+ . "time/total: $estrem/$esttot]: $package [%dk]",
$n, int($tlpsizes{$package}/1024) + 1);
info("$infostr\n");
foreach my $h (@::install_packages_hook) {