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
|
#!/usr/bin/env perl
# $Id$
# Public domain. Originally written by Karl Berry, 2022.
#
# Update from CTAN to TL. First, run the test import with c2l; then, if
# no files were added or removed (and it was an existing package),
# automatically run c2l -p to "place" the new package in svn.
# Do not run svn commit. (Code needs to be refactored for common calls.)
use strict; use warnings;
(my $prg = $0) =~ s,.*/,,;
my $place_branch = 0;
#my $chicken = "";
my $chicken = "-p";
exit (&main ());
sub main {
my $place = 0;
if ($ARGV[$#ARGV] =~ /^-?p$/) {
pop (@ARGV);
$place = 1;
}
printf "$prg: running c2l...";
my @lines = `set -o pipefail; c2l @ARGV </dev/null 2>&1 | tee /tmp/c2l.out`;
if ($?) {
print "first c2l failed, exiting.\n";
print @lines;
exit $?;
}
my $status = 1;
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 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) {
if ($place) {
$status = &do_place ("no current vs. new, but p(lace) given");
} else {
print "no current vs. new, exiting.\n"; # new package, presumably
print @lines;
}
}
return $status;
}
sub do_place {
my ($desc,$c2cmd) = @_;
my $msg;
if ($c2cmd && $c2cmd eq "c2b") {
$msg = "$prg: $desc"; # place on branch
} else {
$c2cmd = "c2l";
my $branch_msg = $place_branch ? "(+branch)" : "";
$msg = "$desc, rerunning for svn$branch_msg...";
}
print "$msg\n";
my $cmd = "set -o pipefail;"
. "$c2cmd $chicken @ARGV </dev/null 2>&1 | tee /tmp/$c2cmd.out";
my @placelines = `$cmd`;
my $status = $?;
print @placelines;
if ($status) {
print "$prg: *** do_place($c2cmd) failed, exiting.\n";
} elsif ($c2cmd ne "c2b" && $place_branch) {
$status = &do_place ("running c2b for svn branch", "c2b");
}
return $status;
}
|