summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texlive/uninstall-win32.pl
blob: 3aa3434a358801ab35dd20c2827cfeefe97735ff (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
#!/usr/bin/env perl
#
# $Id$
#
# Copyright 2008 Norbert Preining
#
# GUI for tlmgr
#

my $Master;

BEGIN {
  $^W = 1;
  $Master = `%COMSPEC% /c kpsewhich -var-value=SELFAUTOPARENT`;
  chomp($Master);
  unshift (@INC, "$Master/tlpkg");
}

use TeXLive::TLWinGoo;
use TeXLive::TLPDB;
use TeXLive::TLPOBJ;
use TeXLive::TLPackageConfigurations;
use TeXLive::TLConfig;
use TeXLive::TLUtils;
use Tk;
use Tk::Dialog;

my $mw = MainWindow->new(-title => "remove tlmgr 2008");

my $lab = $mw->Label(-justify    => 'left',
                     -text => "Do you really want to remove TeX Live 2008?");

$lab->pack(-padx => "10m", -pady => "5m");

my $f = $mw->Frame;
$f->pack(-padx => "10m", -pady => "5m");

my $ok = $f->Button(-text => "Ok",
                    -command => sub { $mw->destroy; doit(); exit(0); });
my $cancel = $f->Button(-text => "Cancel",
                        -command => sub { $mw->destroy; exit(1); });

$ok->pack(-side => 'left', -padx => "3m");
$cancel->pack(-side => 'left' , -padx => "3m");

sub doit {
  # first we remove the whole bunch of shortcuts and menu entries
  # by calling all the post action codes for the installed packages
  my $localtlpdb = TeXLive::TLPDB->new ("root" => $Master);
  if (!defined($localtlpdb)) {
    tlwarn("Cannot load the TLPDB from $Master, are you sure there is an installation?\n");
  } else {
    for my $pkg ($localtlpdb->list_packages) {
      if (defined($PackageConfigRemove{$pkg})) {
        info("running post remove action for $pkg\n");
        &{$PackageConfigRemove{$pkg}}($Master);
      }
    }
    &TeXLive::TLUtils::do_postaction("remove", $pkg);
  }
  my $menupath = &TeXLive::TLWinGoo::menu_path();
  $menupath =~ s!/!\\!g;
  `rmdir /s /q "$menupath\\$TeXLive::TLConfig::WindowsMainMenuName" 2>nul`;
  remove_texbindirs_from_path();
  unsetenv_reg("TEXBINDIR");
  # from_dvd case:
  unsetenv_reg("TEXMFSYSVAR");
  unsetenv_reg("TEXMFCNF");
  unregister_uninstaller();
  exit if is_vista();
  broadcast_env();
  update_assocs();
}

Tk::MainLoop();

__END__


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