Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8024be0f

Von Wulf Coulmann vor fast 13 Jahren hinzugefügt

  • ID 8024be0f4ce99c6062f8e1858ba991f271647cb7
  • Vorgänger 1f7d4ae3
  • Nachfolger e7fdb1da

Prüfung von LaTeX Abhängigkeiten

Unterschiede anzeigen:

SL/InstallationCheck.pm
54 54
  return eval "use $module $version; 1";
55 55
}
56 56

  
57
sub check_kpsewhich {
58
  my $exit = system("which kpsewhich > /dev/null");
59

  
60
  return $exit > 0 ? 0 : 1;
61
}
62

  
63
sub template_dirs {
64
  my ($path) = @_;
65
  opendir my $dh, $path || die "can't open $path";
66
  my @templates = sort grep { !/^\.\.?$/ } readdir $dh;
67
  close $dh;
68

  
69
  return @templates;
70
}
71

  
72
sub classes_from_latex {
73
  my ($path, $class) = @_;
74
  open my $pipe, q#egrep -rs '^[\ \t]*# . "$class' $path". q# | sed 's/ //g' | awk -F '{' '{print $2}' | awk -F '}' '{print $1}' |#;
75
  my @cls = <$pipe>;
76
  close $pipe;
77

  
78
  # can't use uniq here
79
  my %class_hash = map { $_ => 1 } map { s/\n//; $_ } split ',', join ',', @cls;
80
  return sort keys %class_hash;
81
}
82

  
57 83
my %conditional_dependencies;
58 84

  
59 85
sub check_for_conditional_dependencies {
scripts/installation_check.pl
4 4
use Getopt::Long;
5 5
use Pod::Usage;
6 6
use Term::ANSIColor;
7

  
7
our $master_templates;
8 8
BEGIN {
9 9
  unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
10 10
  push    @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
11

  
12
  # this is a default dir. may be wrong in your installation, change it then
13
  $master_templates = './templates/print/';
11 14
}
12 15

  
13 16
use SL::InstallationCheck;
......
19 22
  "a|all"       => \ $check{a},
20 23
  "o|optional!" => \ $check{o},
21 24
  "d|devel!"    => \ $check{d},
25
  "l|latex!"    => \ $check{l},
22 26
  "r|required!" => \ $check{r},
23 27
  "h|help"      => sub { pod2usage(-verbose => 2) },
24 28
  "c|color!"    => \ ( my $c = 1 ),
......
26 30

  
27 31
# if notihing is requested check "required"
28 32
$check{r} = 1 unless defined $check{a} ||
33
                     defined $check{l} ||
29 34
                     defined $check{o} ||
30 35
                     defined $check{d};
31 36

  
......
39 44
$| = 1;
40 45

  
41 46
if ($check{r}) {
47
  print_header('Checking Required Modules');
42 48
  check_module($_, required => 1) for @SL::InstallationCheck::required_modules;
43 49
}
44 50
if ($check{o}) {
51
  print_header('Checking Optional Modules');
45 52
  check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
46 53
}
47 54
if ($check{d}) {
55
  print_header('Checking Developer Modules');
48 56
  check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
49 57
}
58
if ($check{l}) {
59
  check_latex();
60
}
61

  
62
sub check_latex {
63
  my ($res) = check_kpsewhich();
64
  print_result("Looking for LaTeX kpsewhich", $res ? ('ok', 'green') : ('NOT ok', 'red'));
65
  if ($res) {
66
    check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
67
  }
68
}
69

  
70
sub check_template_dir {
71
  my ($dir) = @_;
72
  my $path  = $master_templates . $dir;
73

  
74
  print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
75
  kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
76
  kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
77
}
78

  
79
our $mastertemplate_path = './templates/print/';
80

  
81
sub check_kpsewhich {
82
  return 1 if SL::InstallationCheck::check_kpsewhich();
83

  
84
  print STDERR <<EOL if $v;
85
+------------------------------------------------------------------------------+
86
  Can't find kpsewhich, is there a proper installed LaTeX?
87
  On Debian you may run "aptitude install texlive-base-bin"
88
+------------------------------------------------------------------------------+
89
EOL
90
  return 0;
91
}
92

  
93
sub kpsewhich {
94
  my ($dw, $type, $package) = @_;
95
  $package =~ s/[^-_0-9A-Za-z]//g;
96
  my $type_desc = $type eq 'cls' ? 'document class' : 'package';
97

  
98
  my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $package.$type > /dev/null|);
99
  my $res  = $exit > 0 ? 0 : 1;
100

  
101
  print_result("Looking for LaTeX $type_desc $package", $res);
102
  if (!$res) {
103
    print STDERR <<EOL if $v;
104
+------------------------------------------------------------------------------+
105
  LaTeX $type_desc $package could not be loaded.
106

  
107
  On Debian you may find the needed *.deb package with:
108
    apt-file search $package.$type
109

  
110
  Maybe you need to install apt-file first by:
111
    aptitude install apt-file && apt-file update
112
+------------------------------------------------------------------------------+
113
EOL
114
  }
115
}
50 116

  
51 117
sub check_module {
52 118
  my ($module, %role) = @_;
......
113 179
  return;
114 180
}
115 181

  
182
sub print_header {
183
  print $/;
184
  print "$_[0]:", $/;
185
}
186

  
116 187
1;
117 188

  
118 189
__END__
......
130 201
=head1 DESCRIPTION
131 202

  
132 203
Check dependencys. List all perl modules needed by Lx-Office, probes for them,
133
and warns if one is not available.
204
and warns if one is not available.  List all LaTeX document classes and
205
packages needed by Lx-Office master templates, probes for them, and warns if
206
one is not available.
207

  
134 208

  
135 209
=head1 OPTIONS
136 210

  
......
154 228

  
155 229
=item C<--no-devel>
156 230

  
157
Dont't probe for perl developer dependancies. (Usefull in combination with --all)
231
Don't probe for perl developer dependancies. (Useful in combination with --all)
158 232

  
159 233
=item C<-h, --help>
160 234

  
......
166 240

  
167 241
=item C<--no-optional>
168 242

  
169
Dont't probe for optional perl modules. (Usefull in combination with --all)
243
Don't probe for optional perl modules. (Useful in combination with --all)
170 244

  
171 245
=item C<-r, --required>
172 246

  
......
174 248

  
175 249
=item C<--no-required>
176 250

  
177
Dont't probe for required perl modules. (Usefull in combination with --all)
251
Don't probe for required perl modules. (Useful in combination with --all)
252

  
253
=item C<-l. --latex>
254

  
255
Probe for LaTeX documentclasses and packages in master templates.
256

  
257
=item C<--no-latex>
258

  
259
Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
178 260

  
179 261
=item C<-v. --verbose>
180 262

  

Auch abrufbar als: Unified diff