summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/dev.installer-gui-rework.diff
blob: 438a95cc570e197873a0c8b25d09fdf68e93689c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
Index: install-tl
===================================================================
--- install-tl	(revision 11304)
+++ install-tl	(working copy)
@@ -268,10 +268,7 @@
 
 # $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 @@
 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 @@
     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 @@
     }
   }
   $localtlpdb->save unless $vars{'from_dvd'};
-  foreach $h (@::end_install_hook) {
-    &$h();
-  }
 }
 
 sub dump_vars {
Index: tlpkg/TeXLive/TLMedia.pm
===================================================================
--- tlpkg/TeXLive/TLMedia.pm	(revision 11304)
+++ tlpkg/TeXLive/TLMedia.pm	(working copy)
@@ -117,9 +117,6 @@
       # 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;
Index: tlpkg/TeXLive/TLUtils.pm
===================================================================
--- tlpkg/TeXLive/TLUtils.pm	(revision 11304)
+++ tlpkg/TeXLive/TLUtils.pm	(working copy)
@@ -794,19 +794,56 @@
   my $totalnr = $#packs + 1;
   my $td = length("$totalnr");
   my $n = 0;
+  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=$fromtlpdb->get_package($package);
-    if (!defined($tlpobj)) {
-      die "STRANGE: $package not to be found in ", $fromtlpdb->root;
+    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);
     }
-    $n++;
     # 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 @@
       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 @@
 =cut
 
 sub info {
-  logit(\*STDOUT, 0, @_);
+  my $str = shift;
+  logit(\*STDOUT, 0, $str);
+  chomp($str);
+  for my $i (@::info_hook) {
+    &{$i}($str);
+  }
 }
 
 =pod
Index: tlpkg/installer/install-menu-perltk.pl
===================================================================
--- tlpkg/installer/install-menu-perltk.pl	(revision 11304)
+++ tlpkg/installer/install-menu-perltk.pl	(working copy)
@@ -36,6 +36,9 @@
 require Tk::Dialog;
 require Tk::DialogBox;
 require Tk::PNG;
+require Tk::ROText;
+require Tk::ProgressBar;
+
 if ($::alternative_selector) {
   require Tk::DirTree;
 }
@@ -100,29 +103,26 @@
 my $optsrcstate;
 my $optdocstate;
 
-push @::start_install_hook, 
-  sub { 
-    update_statusbar("Starting installation");
+push @::info_hook,
+  sub {
+    update_status(join(" ",@_));
     $mainwindow->update;
   };
-push @::start_postinst_hook, 
-  sub { 
-    update_statusbar("Starting post-installation Jobs");
-    $mainwindow->update;
-  };
-push @::end_install_hook, 
-  sub { 
-    update_statusbar("Installation finished");
-    $mainwindow->update;
-  };
+push @::install_packages_hook, \&update_progressbar;
+push @::install_packages_hook, 
+  sub { $mainwindow->update; $::sww->update; };
 
-push @::install_packages_hook, \&update_statusbar;
-push @::install_packages_hook, sub { $mainwindow->update; };
-
-sub update_statusbar {
-  my $p = shift;
-  $::statusbar->configure(-text => "$p");
+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',
              basicinfo  => 'Basic Information',
@@ -369,32 +369,15 @@
   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 @@
   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;