summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tlprm
blob: d137cdaacd3de1235379f78dcd84f392cfb8371b (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
#!/usr/bin/env perl
# $Id$
# Copyright 2007, 2008, 2009 TeX Users Group
# This file is licensed under the GNU General Public License version 2
# or any later version.
# 
# Remove a package from the TeX Live source repository.  We use this on
# the source tree when a package becomes obsolete, gets merged, or
# whatever.  It doesn't handle package removals from an installed tree.

our $mydir;

BEGIN {
  $^W = 1;
  ($mydir = $0) =~ s,/[^/]*$,,;
  unshift (@INC, "$mydir/..");
}

use strict;

use TeXLive::TLConfig;
use TeXLive::TLPDB;
use TeXLive::TLPSRC;
use TeXLive::TLUtils;
use Pod::Usage;
use Getopt::Long;

my $opt_help = 0;

TeXLive::TLUtils::process_logging_options();
GetOptions("help|?" => \$opt_help) or pod2usage(1);
pod2usage("-exitstatus" => 0, "-verbose" => 2) if $opt_help;

exit (&main ());


sub main
{
  my $failure_count = 0;

  chomp (my $Master = `cd $mydir/../.. && pwd`);
  my $tlpdb = TeXLive::TLPDB->new ("root" => $Master);

  foreach my $f (@ARGV) {
    my $obj = $tlpdb->get_package ($f);
    if (! $obj) {
      warn "$0: no TeX Live package named $f.\n";
      $failure_count++;
      next;
    }

    my @files = $obj->all_files;
    my $tlpsrc = new TeXLive::TLPSRC;
    $tlpsrc->from_file ($f);
    push (@files, $tlpsrc->_srcfile); # also want to remove the tlpsrc file.

    # The paths in tlpdb are relative to Master, so we chdir there so
    # that Cwd::abs_path can work.
    chdir ($Master) || die "chdir($Master) failed: $!";

    # Commonly, we want to remove entire directories, not just all the
    # files in the directory.
    my @removals = TeXLive::TLUtils::collapse_dirs (@files);
    my $removals = join ("", map { "$_\n" } @removals);

    my $TMPDIR = $ENV{"TMPDIR"} || "/tmp";
    my $rm_file = "$TMPDIR/tlprm.rm";
    unlink ($rm_file);
    `printf "$removals" >$rm_file`;

    my $commit_file = "$TMPDIR/tlprm.commit";
    unlink ($commit_file);
    `printf "$removals" >$commit_file`;

    print "if license in Catalogue is still free, "
          . "tell Robin.Fairbairns@cl.cam.ac.uk.\n";

    my $tsrc = "$Master/tlpkg/tlpsrc";
    my @lines = `grep -l 'depend.* $f\$' $tsrc/collection-* $tsrc/scheme-*`;
    print "first edit collections:\n", @lines if @lines;
    `printf "@lines" >>$commit_file`;
    
    my $check_script = "$Master/tlpkg/bin/tlpkg-ctan-check";
    @lines = `egrep '( |^)$f( |\$)' $check_script`;
    if (@lines) {
      print "no future checks: $check_script\n";
      `echo $check_script >>$commit_file`;
    }

    # e.g., insert a die.
    print "no resurrection:  $Master/tlpkg/libexec/ctan2tds\n";
    `echo $Master/tlpkg/libexec/ctan2tds >>$commit_file`;

    print "then:\nsvn remove `cat $rm_file`\n";
    print "svn commit -m'rm $f, REASON' `cat $commit_file`\n";

    if (1) {  # maybe only if debugging?
      print "\n\f ", @removals + 0, " removals ($rm_file):\n";
      print `cat $rm_file`;
      #
      chomp (my $ncommits = `wc -l <$commit_file`);
      print "\n\f ", $ncommits, " commits ($commit_file):\n";
      print `cat $commit_file`;
      #
      print "\n\f ", @files + 0, " files being removed:\n";
      print "$_\n" foreach @files;
    }
  }

  # Instead of rewriting the database here, I think we're better off
  # just doing it nightly or whatever.

  return $failure_count;
}

__END__

=head1 NAME

tlprm - remove a TeX Live package

=head1 SYNOPSIS

tlprm [OPTION]... [TLPKG]...

=head1 OPTIONS

The standard options B<-q>, B<-v>, and B<-logfile>=I<file> are
accepted; see the C<process_logging_options> function in
L<TeXLive::TLUtils> for details.

=head1 DESCRIPTION

B<tlprm> merely prints Subversion commands to remove TeX Live packages
from the source repository, e.g., when a package becomes obsolete or
merged.  It does not actually run any commands, remove anything, or
change the TeX Live package database or anything else.

No dependency or other checking is done.  It also does not remove the
given package from any collection(s) where it is present, although it
reports any collections and schemes that have dependencies on the package.

=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: #