summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPostActions.pm
blob: 8f148676e151b37aa883e448862f50233d9b43d7 (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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# $Id$
# TeXLive::TLPostActions.pm - collection post install stuff for installation
# Copyright 2008 Norbert Preining
# This file is licensed under the GNU General Public License version 2
# or any later version.

package TeXLive::TLPostActions;

my $svnrev = '$Revision$';
my $_modulerevision;
if ($svnrev =~ m/: ([0-9]+) /) {
  $_modulerevision = $1;
} else {
  $_modulerevision = "unknown";
}
sub module_revision {
  return $_modulerevision;
}

BEGIN {
  use Exporter ();
  use vars qw( @ISA @EXPORT_OK @EXPORT );
  @ISA = qw(Exporter);
  @EXPORT_OK = qw(
    %PostInstall
    %PostRemove
  );
  @EXPORT = @EXPORT_OK;
}

use TeXLive::TLUtils qw(win32 mkdirhier copy conv_to_w32_path log debug info
                        touch tlwarn);
use TeXLive::TLWinGoo;

my $mainmenu = "TeX Live 2008";

our %PostInstall;
our %PostRemove;

# NOT ENABLED !!!!!
# context post install actions
sub do_install_bin_context {
  my ($texdir, $texdirw, $texmfsysvar) = @_;
  # set up texmfcnf.lua
  my $TMF = "$texdirw/texmf/web2c/texmfcnf.lua";
  if (! -r $TMF) {
    open(TMF, ">$TMF") || die "open($TMF) failed: $!\n";
    print TMF 'local conf = {}', "\n";
    print TMF "conf.TEXMFCACHE = \"$texmfsysvar\"\n";
    #print TMP "conf.CACHEINTDS = 't'\n";
    print TMF "return conf\n";
    close(TMF) || warn "close($TMF) failed: $!";
  }
  # update the luatools cache
  system("luatools", "--generate");
  # build the context formats based on luatex
  system("context", "--make", "--compile", "cont-en");
  # update the font cache
  system("mtxrun", "--script", "fonts", "--reload");
}
#
# That has to be sorted out and maybe changed at a later time, so do NOT
# enable that for now.
###$PostInstall{"bin-context"} = \&do_install_bin_context;


# ATM do the same for luatex as for context
sub do_install_luatex {
  do_install_bin_context(@_);
}
#
# SEE ABOVE
# $PostInstall{"luatex"} = \&do_install_luatex;


# xetex
#
sub do_install_xetex {
  my ($texdir, $texdirw, $texmfsysvar) = @_;
  #
  # bin-installs font-config related stuff
  #
  # new version according to Staszek
  if (!defined($texmfsysvar)) {
    $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($texmfsysvar);
  }
  if (-r "$texdir/bin/win32/conf/fonts.conf") {
    # we have installed w32, so put it into texmfsysvar
    mkdirhier("$texmfsysvar/fonts");
    TeXLive::TLUtils::rmtree("$texmfsysvar/fonts/conf");
    TeXLive::TLUtils::rmtree("$texmfsysvar/fonts/cache");
    my @cpycmd;
    if (win32()) {
      push @cpycmd, "xcopy", "/e", "/i", "/q", "/y";
    } else {
      push @cpycmd, "cp", "-R";
    }
    system(@cpycmd,
             (win32() ? conv_to_w32_path("$texdir/bin/win32/conf") :
                       "$texdir/bin/win32/conf"),
             (win32() ? conv_to_w32_path("$texmfsysvar/fonts/conf") :
                       "$texmfsysvar/fonts/conf"));
    system(@cpycmd,
             (win32() ? conv_to_w32_path("$texdir/bin/win32/cache") :
                       "$texdir/bin/win32/cache"),
             (win32() ? conv_to_w32_path("$texmfsysvar/fonts/cache") :
                       "$texmfsysvar/fonts/cache"));
    if (open(FONTSCONF, "<$texdir/bin/win32/conf/fonts.conf")) {
      my @lines = <FONTSCONF>;
      close(FONTSCONF);
      if (open(FONTSCONF, ">$texmfsysvar/fonts/conf/fonts.conf")) {
        my $winfontdir;
        if (win32()) {
          $winfontdir = $ENV{'SystemRoot'}.'/fonts';
          $winfontdir =~ s!\\!/!g;
          #mkdirhier("$texmfsysvar/fonts/cache");

          # fc-cache breaks often on w32 in some strange way
          # there are claims that touching a font file in $winfontdir
          # would solve that problem. So lets touch some of them
          if (opendir (WINFONT, $winfontdir)) {
            my @dirents = readdir (WINFONT);
            closedir (WINFONT) || warn "closedir($winfontdir) failed: $!";
            # do not actually touch anything by now, maybe already the
            # opendir is enough ...

            # for my $dirent (@dirents) {
            #   if ($dirent =~ m/\.(ttf|otf)$/i) {
            #     touch("$winfontdir/$dirent");
            #     tlwarn("touching $dirent in $winfontdir to make fc-cache work\n");
            #     # one file touched should be enough
            #     last;
            #   }
            # }
          }
        }
        foreach (@lines) {
          $_ =~ s!c:/Program Files/texlive/2008!$texdir!;
          $_ =~ s!c:/windows/fonts!$winfontdir! if win32();
          # hack around fc-cache problem in from_dvd case:
          #if (win32() and (uc($texdir) ne uc($texdirw)) and
          #    ($_ =~ m!^<dir>.*texmf-dist.*</dir>!)) { $_ = '<!-- '.$_.' -->'; }
          print FONTSCONF;
        }
        close(FONTSCONF);
      } else {
        warn("Cannot open $texmfsysvar/fonts/conf/fonts.conf for writing\n");
      }
    } else {
      warn("Cannot open $texdir/bin/win32/conf/fonts.conf\n");
    }
  }
  # call fc-cache but only when we install on w32!
  if (win32()) {
    info("Running fc-cache -v -r\n");
    log(`fc-cache -v -r 2>&1`);
    #system("fc-cache","-v", "-r");
  }
}
$PostInstall{"xetex"} = \&do_install_xetex;

#
# dviout.win32
#
sub do_install_bin_dviout_win32 {
  my ($texdir, $texdirw) = @_;
  if (win32()) {
    my $texdir_bsl = conv_to_w32_path($texdir);
    add_menu_shortcut(
      $mainmenu,
      'DVIOUT Dvi Viewer',
      $texdir.'/tlpkg/dviout/dviout.exe', # for the icon
      'wscript',
      $texdir_bsl."\\bin\\win32\\dviout.vbs",
      '',
    );
  }
}
sub do_remove_bin_dviout_win32 {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu, 'DVIOUT Dvi Viewer');
  }
}
$PostInstall{'dviout.win32'} = \&do_install_bin_dviout_win32;
$PostRemove{'dviout.win32'} = \&do_remove_bin_dviout_win32;


#
# texdoc
#
sub do_install_texdoc {
  my ($texdir, $texdirw) = @_;
  if (win32()) {
    #add_desktop_shortcut(
    #  $texdirw,
    #  'TeXdoc GUI',
    #  '', # $vars{'TEXDIR'}.'/tlpkg/doc/notes.ico', # the icon
    #  $texdir.'/bin/win32/texdoctk.bat',
    #  '', # no args
    #  'batgui', # any non-null value to hide command-prompt
    #);
    add_menu_shortcut(
      $mainmenu,
      'TeXdoc GUI',
      '', # $vars{'TEXDIR'}.'/tlpkg/doc/notes.ico', # the icon
      $texdir.'/bin/win32/texdoctk.bat',
      '', # no args
      'batgui', # any non-null value to hide command-prompt
    );
  }
}
sub do_remove_texdoc {
  my ($texdir) = @_;
  if (win32()) {
    # remove_desktop_shortcut('TeXdoc GUI');
    remove_menu_shortcut($mainmenu, 'TeXdoc GUI');
  }
}
$PostInstall{'texdoc'} = \&do_install_texdoc;
$PostRemove{'texdoc'} = \&do_remove_texdoc;

#
# tlpsv.win32
#
sub do_install_bin_tlpsv_win32 {
  my ($texdir, $texdirw) = @_;
  if (win32()) {
    add_desktop_shortcut(
      $texdirw,
      'PS_View',
      $texdir.'/tlpkg/tlpsv/psv.exe', # icon, not prog!
      $texdir.'/bin/win32/psv.bat',
      '', # no args
      'batgui', # any non-null value to hide command-prompt
    );
    add_menu_shortcut(
      $mainmenu,
      'PS_View',
      $texdir.'/tlpkg/tlpsv/psv.exe', # icon, not prog!
      $texdir.'/bin/win32/psv.bat',
      '', # no args
      'batgui', # any non-null value to hide command-prompt
    );
    #register_extension(".ps", "PostScript");
    #register_extension(".eps", "PostScript");
    ##register_file_type("PostScript", '"'.$texdir.'/bin/win32/psv.bat"');
    #register_file_type("PostScript",
    #  '"'.$texdir.'/tlpkg/tlpsv/gswxlua.exe" -g '.
    #  '"'.$texdir.'/tlpkg/tlgs/bin/gsdll32.dll" -l '.
    #  '"'.$texdir.'/tlpkg/tlpsv/psv.wx.lua" -p '.
    #  '"'.$texdir.'/tlpkg/tlpsv/psv_view.ps" -sINPUT="%1"');
    #update_assocs();
  }
}
sub do_remove_bin_tlpsv_win32 {
  my ($texdir) = @_;
  if (win32()) {
    remove_desktop_shortcut('PS_View');
    remove_menu_shortcut($mainmenu, 'PS_View');
    #unregister_extension(".ps");
    #unregister_extension(".eps");
    #unregister_file_type("PostScript");
    #update_assocs();
  }
}
$PostRemove{'tlpsv.win32'} = \&do_remove_bin_tlpsv_win32;
$PostInstall{'tlpsv.win32'} = \&do_install_bin_tlpsv_win32;

#
# texlive-scripts
#
sub do_install_bin_texlive {
  my ($texdir, $texdirw) = @_;
  if (win32()) {
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manager',
      '', # $texdir.'/tlpkg/doc/dummy.ico',
      $texdir.'/bin/win32/tlmgr.bat',
      'gui',
      'batgui',
    );
    add_menu_shortcut(
      $mainmenu,
      'Release notes',
      '',
      'http://tug.org/texlive/windows.html',
      '',
      '',
    );
    if (uc(TeXLive::TLWinGoo::win_which_dir('tex.exe')) ne
          uc($texdir.'/bin/win32') or
        uc(TeXLive::TLWinGoo::win_which_dir('pdftex.exe')) ne
          uc($texdir.'/bin/win32') or
        uc(TeXLive::TLWinGoo::win_which_dir('luatex.exe')) ne
          uc($texdir.'/bin/win32')) {
      my $texbindir = $texdir."\\bin\\win32";
      $texbindir =~ s!/!\\!g;
      add_menu_shortcut(
        $mainmenu,
        'TeX Live Prompt',
        '',
        $ENV{'COMSPEC'},
       "/k \"path $texbindir;%path%\"",
       '',
      );
      add_desktop_shortcut(
        $texdirw,
        'TeX Live Prompt',
        '',
        $ENV{'COMSPEC'},
       "/k \"path $texbindir;%path%\"",
       '',
      );
    }
  }
}
sub do_remove_bin_texlive {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu, 'TeX Live Manager');
    remove_menu_shortcut($mainmenu, 'Release notes');
    remove_menu_shortcut($mainmenu, 'TeX Live Prompt');
    remove_desktop_shortcut('TeX Live Prompt');
  }
}
$PostInstall{'texlive-scripts'} = \&do_install_bin_texlive;
$PostRemove{'texlive-scripts'} = \&do_remove_bin_texlive;

#
# texlive.infra
# ships all the readme.html/readme.XX.html files, and the index of all
# documents
sub do_install_texlive_infra {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_infra: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Toplevel Readme Index',
      '', # default pdf icon
      $texdir.'/index.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_infra {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Toplevel Readme Index');
  }
}
$PostInstall{'texlive.infra'} = \&do_install_texlive_infra;
$PostRemove{'texlive.infra'} = \&do_remove_texlive_infra;

#
# texlive-en
#
sub do_install_texlive_en {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_en: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (en) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/english/texlive-en/texlive-en.html',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (en) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/english/texlive-en/texlive-en.pdf',
      '',
      '',
    );
  }
}
sub do_remove_texlive_en {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (en) (HTML)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (en) (PDF)');
  }
}
$PostInstall{'texlive-en'} = \&do_install_texlive_en;
$PostRemove{'texlive-en'} = \&do_remove_texlive_en;

#
# texlive-cz
#
sub do_install_texlive_cz {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_cz: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (cz) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/czechslovak/texlive-cz/texlive-cz.pdf',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (cz) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/czechslovak/texlive-cz/texlive-cz.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_cz {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (cz) (PDF)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (cz) (HTML)');
  }
}
$PostInstall{'texlive-cz'} = \&do_install_texlive_cz;
$PostRemove{'texlive-cz'} = \&do_remove_texlive_cz;

#
# texlive-fr
#
sub do_install_texlive_fr {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_fr: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (fr) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/french/texlive-fr/texlive-fr.pdf',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (fr) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/french/texlive-fr/texlive-fr.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_fr {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (fr) (HTML)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (fr) (PDF)');
  }
}
$PostInstall{'texlive-fr'} = \&do_install_texlive_fr;
$PostRemove{'texlive-fr'} = \&do_remove_texlive_fr;

#
# texlive-de
#
sub do_install_texlive_de {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_de: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (de) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/german/texlive-de/texlive-de.pdf',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (de) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/german/texlive-de/texlive-de.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_de {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (de) (PDF)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (de) (HTML)');
  }
}
$PostInstall{'texlive-de'} = \&do_install_texlive_de;
$PostRemove{'texlive-de'} = \&do_remove_texlive_de;

#
# texlive-pl
#
sub do_install_texlive_pl {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_pl: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (pl) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/polish/texlive-pl/texlive-pl.pdf',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (pl) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/polish/texlive-pl/texlive-pl.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_pl {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (pl) (PDF)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (pl) (HTML)');
  }
}
$PostInstall{'texlive-pl'} = \&do_install_texlive_pl;
$PostRemove{'texlive-pl'} = \&do_remove_texlive_pl;

#
# texlive-ru
#
sub do_install_texlive_ru {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_ru: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (ru) (PDF)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/russian/texlive-ru/texlive-ru.pdf',
      '',
      '',
    );
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (ru) (HTML)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/russian/texlive-ru/texlive-ru.html',
      '',
      '',
    );
  }
}
sub do_remove_texlive_ru {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (ru) (HTML)');
    remove_menu_shortcut($mainmenu,'TeX Live Manual (ru) (PDF)');
  }
}
$PostInstall{'texlive-ru'} = \&do_install_texlive_ru;
$PostRemove{'texlive-ru'} = \&do_remove_texlive_ru;

#
# texlive-zh-cn
#
sub do_install_texlive_zh_cn {
  my ($texdir) = @_;
  if (win32()) {
    if (!defined($texdir)) {
      tlwarn("do_install_texlive_zh_cn: texdir not defined, returning\n");
      return;
    }
    add_menu_shortcut(
      $mainmenu,
      'TeX Live Manual (zh-cn)',
      '', # default pdf icon
      $texdir.'/texmf-doc/doc/chinese/texlive-zh-cn/texlive-zh-cn.pdf',
      '',
      '',
    );
  }
}
sub do_remove_texlive_zh_cn {
  my ($texdir) = @_;
  if (win32()) {
    remove_menu_shortcut($mainmenu,'TeX Live Manual (zh-cn)');
  }
}
$PostInstall{'texlive-zh-cn'} = \&do_install_texlive_zh_cn;
$PostRemove{'texlive-zh-cn'} = \&do_remove_texlive_zh_cn;


#
# FROM HERE ON ONLY DISABLED POST INSTALL AND REMOVE ACTIONS!!!!!!!
#

# disabled
sub do_bin_xdvi {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  copy ("$TEXDIR/texmf/xdvi/XDvi", "$TEXMFSYSVAR/xdvi");
}
# $PostInstall{"xdvi"} = \&do_bin_xdvi;


# disabled
sub do_plain {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # install some copies from texmf(-dist) into texmf-var
  copy ("$TEXDIR/texmf-dist/tex/generic/config/language.def",
        "$TEXMFSYSVAR/tex/generic/config");
}
# $PostInstall{"plain"} = \&do_plain;


# disabled
sub do_bin_dvipsk {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # those files must exist
  copy ("$TEXDIR/texmf/dvips/config/config.ps",
        "$TEXMFSYSVAR/dvips/config");
}
# $PostInstall{"dvipsk"} = \&do_bin_dvipsk;

# disabled
sub do_bin_dvipdfm {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # fix up dvipdfm config file to contain the right # piping command
  mkdirhier("$TEXMFSYSVAR/dvipdfm/config");
  open(DVIPDFMCONFIGDIST, "<$TEXDIR/texmf/dvipdfm/config/config")
    or die("Cannot open $TEXDIR/texmf/dvipdfm/config/config");
  open(DVIPDFMCONFIGINST, ">$TEXMFSYSVAR/dvipdfm/config/config")
    or die("Cannot open $TEXMFSYSVAR/dvipdfm/config/config");
  while (<DVIPDFMCONFIGDIST>) {
    if (m/^D /) {
      print DVIPDFMCONFIGINST 'D "epstopdf --outfile=%o --nocompress %i"', "\n";
    } else {
      print DVIPDFMCONFIGINST;
    }
  }
  close(DVIPDFMCONFIGDIST);
  close(DVIPDFMCONFIGINST);
}
# $PostInstall{"dvipdfm"} = \&do_bin_dvipdfm;

# disabled
sub do_bin_dvipdfmx {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # dvipdfmx.cfg
  open(DVIPDFMCONFIGDIST, "<$TEXDIR/texmf/dvipdfmx/dvipdfmx.cfg")
    or die("Cannot open $TEXDIR/texmf/dvipdfmx/dvipdfmx.cfg");
  open(DVIPDFMCONFIGINST, ">$TEXMFSYSVAR/dvipdfmx/dvipdfmx.cfg")
    or die("Cannot open $TEXMFSYSVAR/dvipdfmx/dvipdfmx.cfg");
  while (<DVIPDFMCONFIGDIST>) {
    # current dvipdfmx.cfg already contains the right rungs incantation
    # so do just copy the file to texmf-var
    #if (m/^D /) {
    #  print DVIPDFMCONFIGINST "%$_";
    #  print DVIPDFMCONFIGINST "\n%% GhostScript (TeX Live (Unix and Win32)):\n";
    #  print DVIPDFMCONFIGINST 'D  "rungs -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dUseFlateCompression=true -sOutputFile=%o %i -c quit"', "\n\n";
    #} else {
      print DVIPDFMCONFIGINST;
    #}
  }
  close(DVIPDFMCONFIGDIST);
  close(DVIPDFMCONFIGINST);
}
# $PostInstall{"dvipdfmx"} = \&do_bin_dvipdfmx;


# disabled
sub do_bin_kpathsea {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  copy ("$TEXDIR/texmf/web2c/mktex.cnf",
        "$TEXMFSYSVAR/web2c");
}
# $PostInstall{"kpathsea"} = \&do_bin_kpathsea;

# disabled
sub do_bin_pdftex {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # the old installer copied from CDDIR, but shouldn't this be installed
  # in ANY case since it is in pdftex???
  copy ("$TEXDIR/texmf/tex/generic/config/pdftexconfig.tex",
        "$TEXMFSYSVAR/tex/generic/config");
}
# $PostInstall{"pdftex"} = \&do_bin_pdftex;

# disabled
sub do_context {
  my ($TEXDIR, $TEXMFSYSVAR) = @_;
  if (!defined($TEXMFSYSVAR)) {
    $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
    chomp($TEXMFSYSVAR);
  }
  # old installer did this, should we do this, TOO????
  copy ("$TEXDIR/texmf-dist/tex/context/config/cont-usr.tex",
        "$TEXMFSYSVAR/tex/context/config");
}
# $PostInstall{"context"} = \&do_context;


1;


=head1 NAME

C<TeXLive::TLPostActions> -- TeX Live Post Installation and Removal Routines

=head1 SYNOPSIS

  use TeXLive::TLPostActions;

=head1 DESCRIPTION

The L<TeXLive::TLPostActions> module exports the C<%PostInstall> and
the C<%PostRemove> hash indexed by package names providing code references.

These code references are called with the root of the installation as
argument (C<$SELFAUTOPARENT>). Additional arguments, but not necessarily
present, are the value of C<TEXMFSYSVAR> and C<TEXMFLOCAL>.

=head1 SEE ALSO

The modules L<TeXLive::TLUtils>, L<TeXLive::TLPSRC>,
L<TeXLive::TLPDB>, L<TeXLive::TLTREE>, L<TeXLive::TeXCatalogue>.

=head1 AUTHORS AND COPYRIGHT

This script and its documentation were written for the TeX Live
distribution (L<http://tug.org/texlive>) and both are licensed under the
GNU General Public License Version 2 or later.

=cut

### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #