| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package TeX::AutoTeX; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: AutoTeX.pm,v 1.20.2.7 2011/01/27 18:56:29 thorstens Exp $ |
|
5
|
|
|
|
|
|
|
# $Revision: 1.20.2.7 $ |
|
6
|
|
|
|
|
|
|
# $Source: /cvsroot/arxivlib/arXivLib/lib/TeX/AutoTeX.pm,v $ |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# $Date: 2011/01/27 18:56:29 $ |
|
9
|
|
|
|
|
|
|
# $Author: thorstens $ |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
32751
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
77
|
|
|
13
|
|
|
|
|
|
|
### use warnings; |
|
14
|
2
|
|
|
2
|
|
13
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
181
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# our ($VERSION) = '$Revision: 1.20.2.7 $' =~ m{ \$Revision: \s+ (\S+) }x; |
|
17
|
|
|
|
|
|
|
our $VERSION = 'v0.906.0'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
330
|
use TeX::AutoTeX::Config qw( |
|
20
|
|
|
|
|
|
|
$AUTOTEX_ENV_PATH |
|
21
|
|
|
|
|
|
|
$DEFAULTPSRESOLUTION |
|
22
|
|
|
|
|
|
|
$DEFAULT_BRANCH |
|
23
|
|
|
|
|
|
|
$DEFAULT_TEX_BIN_PATH |
|
24
|
2
|
|
|
2
|
|
1081
|
); |
|
|
2
|
|
|
|
|
6
|
|
|
25
|
2
|
|
|
2
|
|
1066
|
use TeX::AutoTeX::Fileset; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
72
|
|
|
26
|
2
|
|
|
2
|
|
29
|
use TeX::AutoTeX::File; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
41
|
|
|
27
|
2
|
|
|
2
|
|
1461
|
use TeX::AutoTeX::Log; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
60
|
|
|
28
|
2
|
|
|
2
|
|
1270
|
use TeX::AutoTeX::Process; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
55
|
|
|
29
|
2
|
|
|
2
|
|
1062
|
use TeX::AutoTeX::Mail; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
52
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
11
|
use parent qw(Class::Accessor::Fast); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
14
|
|
|
32
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice(); |
|
33
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
|
34
|
|
|
|
|
|
|
qw( |
|
35
|
|
|
|
|
|
|
workdir |
|
36
|
|
|
|
|
|
|
branch |
|
37
|
|
|
|
|
|
|
use_stamp |
|
38
|
|
|
|
|
|
|
stampref |
|
39
|
|
|
|
|
|
|
log |
|
40
|
|
|
|
|
|
|
verbose |
|
41
|
|
|
|
|
|
|
send_email |
|
42
|
|
|
|
|
|
|
dvips_paper_type |
|
43
|
|
|
|
|
|
|
dvips_resolution |
|
44
|
|
|
|
|
|
|
dvips_printer |
|
45
|
|
|
|
|
|
|
dvips_mapfile |
|
46
|
|
|
|
|
|
|
output_format |
|
47
|
|
|
|
|
|
|
is_pdftex |
|
48
|
|
|
|
|
|
|
tex_env_path |
|
49
|
|
|
|
|
|
|
) |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
|
53
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
54
|
0
|
|
|
|
|
|
my $self = { |
|
55
|
|
|
|
|
|
|
workdir => undef, |
|
56
|
|
|
|
|
|
|
branch => undef, |
|
57
|
|
|
|
|
|
|
use_stamp => 1, |
|
58
|
|
|
|
|
|
|
stampref => undef, |
|
59
|
|
|
|
|
|
|
log => undef, |
|
60
|
|
|
|
|
|
|
send_email => 0, |
|
61
|
|
|
|
|
|
|
verbose => undef, |
|
62
|
|
|
|
|
|
|
dvips_paper_type => undef, |
|
63
|
|
|
|
|
|
|
dvips_resolution => $DEFAULTPSRESOLUTION, |
|
64
|
|
|
|
|
|
|
dvips_printer => undef, |
|
65
|
|
|
|
|
|
|
dvips_mapfile => undef, |
|
66
|
|
|
|
|
|
|
@_, |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
0
|
0
|
|
|
|
|
if (!defined $self->{workdir}) { |
|
69
|
0
|
|
|
|
|
|
croak 'no directory holding the unpacked source material defined'; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
0
|
0
|
|
|
|
if ($self->{workdir} ne 'will be derived from paper id' |
|
|
|
|
0
|
|
|
|
|
|
72
|
|
|
|
|
|
|
&& (stat $self->{workdir})[2] != oct(40777) |
|
73
|
|
|
|
|
|
|
&& (stat(_))[2] != oct(40775)) { |
|
74
|
0
|
|
|
|
|
|
croak "workdir '$self->{workdir}' is not a directory or doesn't have mode 0777 or 0775"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
bless $self, $class; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub process { |
|
81
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
local ($?, $!, $@); |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if (!$self->{branch}) { # use the latest branch, unless specified otherwise |
|
86
|
0
|
|
|
|
|
|
$self->{branch} = $DEFAULT_BRANCH; |
|
87
|
0
|
|
|
|
|
|
$self->{tex_env_path} = $DEFAULT_TEX_BIN_PATH; |
|
88
|
0
|
|
|
|
|
|
local $ENV{TEXMFCNF} = q{}; # prevent inadvertent problems due to user settings |
|
89
|
|
|
|
|
|
|
} |
|
90
|
0
|
0
|
|
|
|
|
if (ref $self->{log} ne 'TeX::AutoTeX::Log') { |
|
91
|
0
|
0
|
|
|
|
|
$self->{log} = TeX::AutoTeX::Log->new( |
|
92
|
|
|
|
|
|
|
dir => $self->{workdir}, |
|
93
|
|
|
|
|
|
|
verbose => $self->{verbose}, |
|
94
|
|
|
|
|
|
|
dupefh => $self->{verbose} ? \*STDOUT : undef, |
|
95
|
|
|
|
|
|
|
); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
my $p = $self->{process} = |
|
99
|
|
|
|
|
|
|
TeX::AutoTeX::Process->new( |
|
100
|
|
|
|
|
|
|
log => $self->{log}, |
|
101
|
|
|
|
|
|
|
fileset => $self->{fileset}, |
|
102
|
|
|
|
|
|
|
temp_dir => $self->{workdir}, |
|
103
|
|
|
|
|
|
|
branch => $self->{branch}, |
|
104
|
|
|
|
|
|
|
stampref => $self->{stampref}, |
|
105
|
|
|
|
|
|
|
use_stamp => $self->{use_stamp}, |
|
106
|
|
|
|
|
|
|
decryption_key => $self->{decryption_key}, |
|
107
|
|
|
|
|
|
|
tex_env_path => $self->{tex_env_path}? $self->{tex_env_path} |
|
108
|
|
|
|
|
|
|
: "/$self->{branch}/bin:/bin", |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ($self->__combine_dvips_flags()) { |
|
112
|
0
|
|
|
|
|
|
$p->set_dvi_flags(@{$self->{dvi_flags}}) |
|
|
0
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if (ref $self->{stampref} ne 'ARRAY') { |
|
116
|
0
|
|
|
|
|
|
$p->{use_stamp} = 0; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
local $ENV{PATH} = $AUTOTEX_ENV_PATH; # also untaints path |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if ($p->{error} = $p->go()) { |
|
122
|
0
|
|
|
|
|
|
$self->{log}->verbose("AutoTeX returned error: $p->{error}"); |
|
123
|
|
|
|
|
|
|
# optionally send failure notification email to admin |
|
124
|
0
|
0
|
|
|
|
|
if ($self->{send_email}) { |
|
125
|
0
|
|
|
|
|
|
$self->email(); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
0
|
0
|
|
|
|
|
if (@{$p->{made_pdf}}) { |
|
|
0
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
$self->{log}->verbose('PDFTEX paper, check "' |
|
131
|
|
|
|
|
|
|
. ($self->{paper} ? $self->{paper} : $self->{workdir}) |
|
132
|
|
|
|
|
|
|
. qq{".\n}); |
|
133
|
0
|
|
|
|
|
|
$self->set_is_pdftex(1); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
$self->{log}->verbose("All done.\n"); |
|
137
|
0
|
|
|
|
|
|
return 1; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub __combine_dvips_flags { |
|
141
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
142
|
0
|
|
|
|
|
|
$self->{dvi_flags} = []; |
|
143
|
0
|
0
|
0
|
|
|
|
if ($self->{dvips_paper_type} && $self->{dvips_paper_type} =~ /^([a-z0-9]+)$/i) { |
|
144
|
0
|
|
|
|
|
|
push @{$self->{dvi_flags}}, "-t $1"; |
|
|
0
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
0
|
|
|
|
|
if (defined $self->{dvips_printer}) { |
|
147
|
0
|
0
|
|
|
|
|
if ($self->{dvips_printer} =~ /(?:type1|pdf)/i) { |
|
|
|
0
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
push @{$self->{dvi_flags}}, '-P type1'; |
|
|
0
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$self->{output_format} = 'fInm'; |
|
150
|
|
|
|
|
|
|
} elsif ($self->{dvips_printer} eq 'pk') { |
|
151
|
|
|
|
|
|
|
# TS: new for texlive 12/2009 |
|
152
|
0
|
|
|
|
|
|
push @{$self->{dvi_flags}}, '-P pk'; |
|
|
0
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
0
|
0
|
0
|
|
|
|
if ($self->{dvips_resolution} && $self->{dvips_resolution} =~ /^([346]00)$/) { |
|
156
|
0
|
0
|
|
|
|
|
if ($1 != $DEFAULTPSRESOLUTION) { |
|
157
|
0
|
|
|
|
|
|
push @{$self->{dvi_flags}}, "-D $1"; |
|
|
0
|
|
|
|
|
|
|
|
158
|
0
|
|
0
|
|
|
|
$self->{output_format} ||= "d$1"; # don't overwrite 'fInm' |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
0
|
0
|
0
|
|
|
|
if ($self->{dvips_mapfile} && $self->{dvips_mapfile} =~ /^\+?([a-z]+\.map)$/i) { |
|
162
|
0
|
|
|
|
|
|
push @{$self->{dvi_flags}}, "-u +$1"; |
|
|
0
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
|
164
|
0
|
0
|
|
|
|
|
return wantarray ? @{$self->{dvi_flags}} : scalar @{$self->{dvi_flags}}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub email { |
|
168
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my $dvips_options = $self->{process}->dvi_flags_tostring(); |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $mailer = TeX::AutoTeX::Mail->new($self->{workdir}); |
|
173
|
0
|
0
|
|
|
|
|
if (my $msg = $mailer->send_failure("Failure for $self->{workdir}", <<"EOM") |
|
174
|
|
|
|
|
|
|
$self->{workdir} failed autotex, |
|
175
|
|
|
|
|
|
|
dvips run with options '$dvips_options'. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$self->{process}->{error} |
|
178
|
|
|
|
|
|
|
EOM |
|
179
|
|
|
|
|
|
|
) { |
|
180
|
0
|
|
|
|
|
|
$self->{log}->verbose("send_failure error: $msg"); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
0
|
|
|
|
|
|
return; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |