summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-11-17 08:29:06 +0000
committerNorbert Preining <preining@logic.at>2008-11-17 08:29:06 +0000
commit639f245ee7565e2ccb5d261ea1b382c502ac277e (patch)
tree64a57a5d08a1bd51e3cbeeb0104bc5871675d733 /Master
parent9d6afc59622c9ae2797be582216b34b80dd8b5f0 (diff)
new installer features: est. remaining time, GUI progress bar
git-svn-id: svn://tug.org/texlive/trunk@11328 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/install-tl14
-rw-r--r--Master/tlpkg/TeXLive/TLMedia.pm3
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm62
-rw-r--r--Master/tlpkg/installer/install-menu-perltk.pl105
4 files changed, 121 insertions, 63 deletions
diff --git a/Master/install-tl b/Master/install-tl
index f09d80f128b..ed438e7f8aa 100755
--- a/Master/install-tl
+++ b/Master/install-tl
@@ -268,10 +268,7 @@ my $location;
# $finished == 1 if the menu call already did the installation
my $finished = 0;
-@::start_install_hook = ();
-@::end_install_hook = ();
-@::start_postinst_hook = ();
-@::start_install_hook = ();
+@::info_hook = ();
my $system_tmpdir=get_system_tmpdir();
my $media;
@@ -481,9 +478,6 @@ exit(0);
sub do_installation {
# do the actual installation
my $h;
- foreach $h (@::start_install_hook) {
- &$h();
- }
prepare_installation();
if (!$vars{'from_dvd'}) {
calc_depends();
@@ -518,9 +512,6 @@ sub do_installation {
create_uninstaller($vars{'TEXDIR'}, $vars{'TEXDIRW'},
$vars{'TEXMFSYSVAR'}, $vars{'TEXMFSYSCONFIG'});
}
- foreach $h (@::start_postinst_hook) {
- &$h();
- }
do_postinst_stuff();
# now we save every scheme that is fully covered by the stuff we have
# installed to the $localtlpdb
@@ -539,9 +530,6 @@ sub do_installation {
}
}
$localtlpdb->save unless $vars{'from_dvd'};
- foreach $h (@::end_install_hook) {
- &$h();
- }
}
sub dump_vars {
diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm
index 7102bbf2766..276fa70509f 100644
--- a/Master/tlpkg/TeXLive/TLMedia.pm
+++ b/Master/tlpkg/TeXLive/TLMedia.pm
@@ -117,9 +117,6 @@ sub install_package {
# even if opt_doc is false
$real_opt_doc = 1;
}
- foreach my $h (@::install_packages_hook) {
- &$h("install: $pkg");
- }
my $container;
my @installfiles;
my $location = $self->location;
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 2482964cafd..a0e92931998 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -794,19 +794,56 @@ sub install_packages {
my $totalnr = $#packs + 1;
my $td = length("$totalnr");
my $n = 0;
- foreach my $package (@packs) {
- my $tlpobj=$fromtlpdb->get_package($package);
- if (!defined($tlpobj)) {
- die "STRANGE: $package not to be found in ", $fromtlpdb->root;
+ my %tlpobjs;
+ my $totalsize = 0;
+ my $donesize = 0;
+ my %tlpsizes;
+ foreach my $p (@packs) {
+ $tlpobjs{$p} = $fromtlpdb->get_package($p);
+ if (!defined($tlpobjs{$p})) {
+ die "STRANGE: $p not to be found in ", $fromtlpdb->root;
+ }
+ if ($media ne 'DVD') {
+ # we use the container size as the measuring unit since probably
+ # downloading will be the limiting factor
+ $tlpsizes{$p} = $tlpobjs{$p}->containersize;
+ } else {
+ # we have to add the respective sizes, that is checking for
+ # installation of src and doc file
+ $tlpsizes{$p} = $tlpobjs{$p}->runsize;
+ $tlpsizes{$p} += $tlpobjs{$p}->srcsize if $opt_src;
+ $tlpsizes{$p} += $tlpobjs{$p}->docsize if $opt_doc;
+ my %foo = %{$tlpobjs{$p}->binsize};
+ for my $k (keys %foo) { $tlpsizes{$p} += $foo{$k}; }
}
+ $totalsize += $tlpsizes{$p};
+ }
+ my $starttime = time();
+ foreach my $package (@packs) {
+ my $tlpobj = $tlpobjs{$package};
$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 $sec = $remsecs % 60;
+ $remtime = sprintf("%02d:%02d", $min, $sec);
+ my $tmin = int($esttotalsecs/60);
+ my $tsec = $esttotalsecs % 60;
+ $tottime = sprintf("%02d:%02d", $tmin, $tsec);
+ }
# here we could add more information, eg about timing and number
# of bytes etc etc.
# the size of the containers is present
- my $infostr = sprintf("Installing [%0${td}d/$totalnr]: $package",$n);
+ my $infostr = sprintf("Installing [%0${td}d/$totalnr, est. time remain/total: $remtime/$tottime]: $package",$n);
info("$infostr\n");
foreach my $h (@::install_packages_hook) {
- &$h($infostr);
+ &$h($n,$totalnr);
}
my $real_opt_doc = $opt_doc;
# if we install a package from the Documentation class we
@@ -877,7 +914,13 @@ sub install_packages {
die("Cannot open tlpobj file for ".$tlpobj->name);
$tlpobj->writeout(\*TMP);
close(TMP);
+ $donesize += $tlpsizes{$package};
}
+ my $totaltime = time() - $starttime;
+ my $totmin = int ($totaltime/60);
+ my $totsec = $totaltime % 60;
+ info(sprintf("Time used for installing the packages: %02d:%02d\n",
+ $totmin, $totsec));
$totlpdb->save;
}
@@ -1523,7 +1566,12 @@ operations.
=cut
sub info {
- logit(\*STDOUT, 0, @_);
+ my $str = shift;
+ logit(\*STDOUT, 0, $str);
+ chomp($str);
+ for my $i (@::info_hook) {
+ &{$i}($str);
+ }
}
=pod
diff --git a/Master/tlpkg/installer/install-menu-perltk.pl b/Master/tlpkg/installer/install-menu-perltk.pl
index 5d6f101b58d..1cfd987f9ee 100644
--- a/Master/tlpkg/installer/install-menu-perltk.pl
+++ b/Master/tlpkg/installer/install-menu-perltk.pl
@@ -36,6 +36,9 @@ require Tk;
require Tk::Dialog;
require Tk::DialogBox;
require Tk::PNG;
+require Tk::ROText;
+require Tk::ProgressBar;
+
if ($::alternative_selector) {
require Tk::DirTree;
}
@@ -100,28 +103,25 @@ my $optfmtstate;
my $optsrcstate;
my $optdocstate;
-push @::start_install_hook,
- sub {
- update_statusbar("Starting installation");
- $mainwindow->update;
- };
-push @::start_postinst_hook,
- sub {
- update_statusbar("Starting post-installation Jobs");
- $mainwindow->update;
- };
-push @::end_install_hook,
- sub {
- update_statusbar("Installation finished");
+push @::info_hook,
+ sub {
+ update_status(join(" ",@_));
$mainwindow->update;
};
-
-push @::install_packages_hook, \&update_statusbar;
-push @::install_packages_hook, sub { $mainwindow->update; };
-
-sub update_statusbar {
- my $p = shift;
- $::statusbar->configure(-text => "$p");
+push @::install_packages_hook, \&update_progressbar;
+push @::install_packages_hook,
+ sub { $mainwindow->update; $::sww->update; };
+
+sub update_status {
+ my ($p) = @_;
+ $::progressw->insert("end", "$p\n");
+ $::progressw->see("end");
+}
+sub update_progressbar {
+ my ($n,$total) = @_;
+ if (defined($n) && defined($total)) {
+ $::progress->value(int($n*100/$total));
+ }
}
my %text = ( title => 'TeX Live 2008 Installation',
@@ -369,32 +369,15 @@ sub run_menu {
my $f3 = $fr->Frame;
$f3->Button(
-text => $text{'install'},
- -command => sub { do_installation();
- $return = $MENU_ALREADYDONE;
- my $t = $text{'finished'};
- if (!win32()) {
- $t .= "\n\n$text{'finishedpath'}";
- }
- $t .= "\n\n$text{'welcome'}";
- $t =~ s/TEXDIR/$::vars{'TEXDIR'}/g;
- $t =~ s/PLATFORM/$::vars{'this_platform'}/g;
- $t =~ s/\\n/\n/g;
- my $sw = $mainwindow->DialogBox(-title => $text{'finbut'}, -buttons => [ $text{'finbut'} ]);
- $sw->add("Label", -text => $t)->pack;
- $sw->Show;
- #$fr->Dialog(-text => $t, -buttons => [ $text{'finbut'} ])->Show;
- $mainwindow->destroy },
- )->pack(-side => 'left');
+ -command => sub { installation_window(); }
+ )->pack(-side => 'left', -padx => "2m", -pady => "2m");
my $quitbutton = $f3->Button(
-text => $text{'quit'},
-command => sub { $return = $MENU_ABORT; $mainwindow->destroy }
- )->pack(-side => 'right');
+ )->pack(-side => 'right', -padx => "2m", -pady => "2m");
$mw->bind('<Escape>', [ $quitbutton, 'Invoke' ]);
$row++;
$f3->grid(-row => $row, -column => 1, -columnspan => 3);
- $::statusbar = $fr->Label(-text => $text{'status'});
- $row++;
- $::statusbar->grid(-row => $row, -column => 1, -columnspan => 3);
menu_update_texts();
$fr->gridColumnconfigure(2, -minsize => 300);
$mw->pack(-expand => 1, -fill => "both");
@@ -415,6 +398,48 @@ sub run_menu {
return($return);
}
+sub installation_window {
+ # create a progress bar window
+ $::sww = $mainwindow->Toplevel(-title => "installation process",
+ -width => 400);
+ $::sww->transient($mainwindow);
+ $::sww->grab();
+ $::sww->Label(-text => "Installation process")->pack;
+ $::progressw = $::sww->Scrolled("ROText", -scrollbars => "e", -height => 16);
+ $::progressw->pack(-expand => 1, -fill => "both");
+ my $percent_done = 0;
+ $::progress = $::sww->ProgressBar(-variable => \$percent_done,
+ -width => 20, -length => 400, -from => 0, -to => 100, -blocks => 10,
+ -colors => [ 0, '#0078b8' ]);
+ $::progress->pack(-fill => "x");
+ my $f = $::sww->Frame;
+ my $b = $f->Button(-text => $text{'cancel'},
+ -command => sub { $::sww->destroy; $mainwindow->destroy;
+ do_cleanup(); exit(1); }
+ )->pack(-pady => "2m");
+ $f->pack;
+ do_installation();
+ $return = $MENU_ALREADYDONE;
+ my $t = $text{'finished'};
+ if (!win32()) {
+ $t .= "\n\n$text{'finishedpath'}";
+ }
+ $t .= "\n\n$text{'welcome'}";
+ $t =~ s/TEXDIR/$::vars{'TEXDIR'}/g;
+ $t =~ s/PLATFORM/$::vars{'this_platform'}/g;
+ $t =~ s/\\n/\n/g;
+ $::progressw->insert("end", "\n");
+ my $linechar = $::progressw->index("end");
+ $::progressw->markSet("finaltext", $linechar);
+ $::progressw->markGravity("finaltext", "left");
+ $::progressw->insert("end", "\n$t");
+ $::progressw->see("end");
+ $::progressw->tagAdd("centered", $linechar, "end");
+ $::progressw->tagConfigure("centered", -justify => "center");
+ $b->configure(-text => $text{'finbut'},
+ -command => sub { $mainwindow->destroy; });
+}
+
sub menu_edit_texdir {
my $key = shift;
our $addyear = 1;