summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/c2l
blob: 91047a7bca590f11fa17f4ec3a4585996f5ea204 (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
#!/usr/bin/env perl
# $Id$
# Originally written by Karl Berry. Public domain.
# 
# Convenience front-end script to run ctan2tl. It rearranges the output
# so error messages come first, then the list of changed files. Also
# accepts platform abbreviations to run tl-update-bindir, etc. Don't
# take it too seriously; it surely need generalizing for use by anyone
# else. Uses various personal environment variables, etc.

$| = 1;
exit (&main ());

sub main {
  # platform abbrev
  my $arg = $ARGV[0];
  if ($arg eq "asy") {
    exec ("tl-update-asy --build");
  } elsif ($arg eq "aarch") {
    $arg = "aarch64-linux";
  } elsif ($arg eq "alpha") {
    $arg = "alpha-linux";
  } elsif ($arg eq "armel") {
    $arg = "armel-linux";
  } elsif ($arg eq "armhf") {
    $arg = "armhf-linux";
  } elsif ($arg eq "cygwin") {
    $arg = "i386-cygwin";
  } elsif ($arg eq "dar32") {
    $arg = "i386-darwin";
  } elsif ($arg eq "darwin" || $arg eq "dar" || $arg eq "mac") {
    $arg = "x86_64-darwin";
  } elsif ($arg eq "darleg") {
    $arg = "x86_64-darwinlegacy";
  } elsif ($arg eq "irix") {
    $arg = "mips-irix";
  } elsif ($arg eq "kfreebsd") {
    exec ("tl-update-bindir i386-kfreebsd && tl-update-bindir amd64-kfreebsd");
  } elsif ($arg eq "linux32" || $arg eq "lin32") {
    $arg = "i386-linux";
  } elsif ($arg eq "mipsel") {
    $arg = "mipsel-linux";
  } elsif ($arg eq "netbsd") {
    exec ("tl-update-bindir i386-netbsd && tl-update-bindir amd64-netbsd");
  } elsif ($arg eq "powdar") {
    $arg = "powerpc-darwin";
  } elsif ($arg eq "powlin") {
    $arg = "powerpc-linux";
  } elsif ($arg eq "sol") {
    exec ("tl-update-bindir i386-solaris && tl-update-bindir x86_64-solaris");
  } elsif ($arg eq "sparc") {
    $arg = "sparc-solaris";
  } elsif ($arg eq "linux64" || $arg eq "lin64") {
    $arg = "x86_64-linux";
  } elsif ($arg eq "musl") {
    $arg = "x86_64-linuxmusl";

  } elsif ($arg eq "norbert" || $arg eq "nor") {
    for my $p (qw(i386-linux x86_64-linux x86_64-linuxmusl)) {
      system ("$0 $p") && die "norbert/$p failed";
    }
    print "$0: norbert updates done.\n";
    exit 0;
  
  } elsif ($arg eq "cg" || $arg eq "moj" || $arg eq "mojca") {
    for my $p (qw(i386-freebsd amd64-freebsd
                  x86_64-darwinlegacy
                  i386-solaris x86_64-solaris)) {
      system ("$0 $p") && die "cg/$p failed";
    }
    print "$0: cg (contextgarden) updates done.\n";
    exit 0;

  } elsif ($arg eq "all") {
    for my $p (qw(aarch dar cg norbert armhf)) {
      system ("$0 $p") && die "all/$p failed";
    }
    print "$0: all updates done.\n";
    exit 0;
  }
  
  if (-d "$ENV{xb}/$arg") {
    print ("tl-update-bindir $arg\n");
    exec ("tl-update-bindir", $arg);
  }

  $ARGV[0] = "-p" if $ARGV[0] eq "p";
  
  print "$0: running ctan2tl @ARGV\n";
  # we want our exit status to be from ctan2tl, not tee, hence the
  # pipefail bash-ism.
  my @lines = `set -o pipefail; ctan2tl @ARGV </dev/null 2>&1 | tee /tmp/cl.out`;
  my $status = $?;

  -d "$ENV{B}/tmp.cooked"
  && system ("cp /tmp/cl.out $ENV{B}/tmp.cooked/$ARGV[$#ARGV].out");
  
  # *** and other notable messages.
  my @msgs = grep { /^\*\*\*.* \S/
                    && ! /\* Generating /
                  } @lines;
  push (@msgs, grep { /at \/.* line / } @lines);        # perl errors
  push (@msgs, grep { /^svn: E/ } @lines);              # svn errors
  push (@msgs, grep { /: no hit for pattern/ } @lines); # tlpsrc updates
  # map file changes; should do better, check .tlpsrc for existing ...
  push (@msgs, grep { /(svn .*|^	)[A-z]*\.map/ } @lines);
  print map { (/^\*/ ? "" : "*** ") . $_ } @msgs;
  
  if ($status != 0) {
    warn "*** ctan2tl exit status: $status\n";
    print STDERR @lines;
    return 1;
  }
  
  my $whole_string = join ("", @lines);
  my @page = split (/\f */, $whole_string);
  
  my $diff_list
    = `test -s /tmp/$<.tlplace.diff && sed -n -e 's/^--- //' \\
              -e 's/[ \\t].*//' \\
              -e 's,/home/texlive/karl/, ,p' \\
           /tmp/$<.tlplace.diff`;
  $diff_list = "";

  # page 0: build stuff.
  # page 1: cooked hierarchy.
  # page 2: new vs. present.
  # page 3: place output.
  print "$page[2]$diff_list\n\f$page[1]\n\f$page[0]\n\f$page[3]\n";
  return 0;
}