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
|
#!/usr/bin/env perl
# $Id$
# Public domain. Originally written by Karl Berry, 2022.
#
# Top-level script to update from CTAN to TL.
#
# First (unless placing was explicitly specified with [-]p),
# run a test import with c2l.
# Then, if no files were added or removed (and it was an existing
# package), or if placing was explicitly specified, automatically run
# c2l p to "place" the new package in svn with adds/removes.
# Do not run svn commit.
#
# By the way, we accept "p" as well as "-p" because it's convenient for
# word deletion on the command line not to have a - lying around. For
# the same reason, the [-]p is given after the package, so we can
# add/remove it without having to edit the package name. Since we run
# this command multiple times a day, must optimize every keystroke.
use strict; use warnings;
(my $prg = $0) =~ s,.*/,,;
exit (&main ());
sub main {
die "Usage: $0 PKGNAME [-][p]\n" if (@ARGV == 0 || @ARGV > 2); # USTL
my $status = 1; # default to failure
my $place = 0;
if ($ARGV[$#ARGV] =~ /^-?p$/) {
pop (@ARGV);
$place = 1;
}
if ($place) {
$status = &do_place ("$prg: p(lace) explicitly given");
exit $status;
}
# no explicit place, run c2l to check if we can do it implicitly.
printf "$prg: running c2l...";
my @lines;
($status,@lines) = &run_c2l ("");
if ($status) {
print "first c2l failed, exiting.\n";
print @lines;
exit $status;
}
my $i;
for ($i = 0; $i < @lines; $i++) {
if ($lines[$i] =~ /^current vs.\ new/) {
my $nextline = $lines[$i+1];
if ($nextline =~ /^[0-9]+ common files, ([0-9]+) changed/) {
if ($1 == 0) {
print "seems nothing has changed, done.\n";
print @lines;
$status = 0;
last;
} else {
$status = &do_place ("no new or removed files");
last;
}
} elsif ($place) {
$status = &do_place ("new/removed files, but p(lace) given");
last;
} else {
print "have new/removed files, exiting.\n";
print @lines;
last;
}
}
}
if ($i == @lines) {
print "no current vs. new, exiting.\n"; # new package, presumably
print @lines;
}
return $status;
}
# Run c2l to "place" (svn add/remove, but not commit) file.
# Return exit status.
#
sub do_place {
my ($desc) = @_;
print "$desc, running for svn.\n";
my ($status,@placelines) = &run_c2l ("p");
print @placelines;
if ($status) {
print "$prg: *** do_place failed, exiting.\n";
}
return $status;
}
# Run c2l, specifying ARG. Return a list with the exit status
# and then all output lines.
#
sub run_c2l {
my ($arg) = @_;
my $tmpfile = "/tmp/c2l$arg.out";
# don't bother with svn update unless we are doing place.
if ($arg eq "p") {
delete $ENV{"TLPKGINFO_CATALOGUE_NO_UPDATE"};
} else {
$ENV{"TLPKGINFO_CATALOGUE_NO_UPDATE"} = 1;
}
my @ret = `set -o pipefail; c2l $arg @ARGV </dev/null 2>&1 | tee $tmpfile`;
return ($?, @ret);
}
|