Revision a7973589
Von Sven Schöling vor fast 13 Jahren hinzugefügt
scripts/installation_check.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl -w |
2 | 2 |
|
3 | 3 |
use strict; |
4 |
use Getopt::Long; |
|
5 |
use Pod::Usage; |
|
6 |
use Term::ANSIColor; |
|
4 | 7 |
|
5 | 8 |
BEGIN { |
6 | 9 |
unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). |
... | ... | |
9 | 12 |
|
10 | 13 |
use SL::InstallationCheck; |
11 | 14 |
|
15 |
GetOptions( |
|
16 |
"verbose" => \ my $v, |
|
17 |
"all" => \ my $a, |
|
18 |
"optional!" => \ my $o, |
|
19 |
"devel!" => \ my $d, |
|
20 |
"required!" => \ ( my $r = 1 ), |
|
21 |
"help" => sub { pod2usage(-verbose => 2) }, |
|
22 |
"color" => \ ( my $c = 1 ), |
|
23 |
); |
|
24 |
|
|
25 |
$d = $r = $o = 1 if $a; |
|
26 |
|
|
12 | 27 |
$| = 1; |
13 | 28 |
|
14 |
check($_, 0) for @SL::InstallationCheck::required_modules; |
|
15 |
check($_, 1) for @SL::InstallationCheck::optional_modules; |
|
29 |
if ($r) { |
|
30 |
check($_, required => 1) for @SL::InstallationCheck::required_modules; |
|
31 |
} |
|
32 |
if ($o) { |
|
33 |
check($_, optional => 1) for @SL::InstallationCheck::optional_modules; |
|
34 |
} |
|
35 |
if ($d) { |
|
36 |
check($_, devel => 1) for @SL::InstallationCheck::developer_modules; |
|
37 |
} |
|
16 | 38 |
|
17 | 39 |
sub check { |
18 |
my ($module, $optional) = @_;
|
|
40 |
my ($module, %role) = @_;
|
|
19 | 41 |
|
20 |
print "Looking for $module->{fullname}..."; |
|
42 |
my $line = "Looking for $module->{fullname}"; |
|
43 |
print $line; |
|
21 | 44 |
my $res = SL::InstallationCheck::module_available($module->{"name"}, $module->{version}); |
22 |
print $res ? '' : " NOT", " ok\n";
|
|
45 |
print dot_pad(length $line, $res ? 2 : 6, $res ? mycolor("ok", 'green') : mycolor("NOT ok", 'red')), $/;
|
|
23 | 46 |
|
24 | 47 |
return if $res; |
25 | 48 |
|
26 |
my $needed_text = $optional |
|
27 |
? 'It is OPTIONAL for Lx-Office but recommended for improved functionality.' |
|
28 |
: 'It is NEEDED by Lx-Office and must be installed.'; |
|
49 |
my $needed_text = |
|
50 |
$role{optional} ? 'It is OPTIONAL for Lx-Office but RECOMMENDED for improved functionality.' |
|
51 |
: $role{required} ? 'It is NEEDED by Lx-Office and must be installed.' |
|
52 |
: $role{devel} ? 'It is OPTIONAL for Lx-Office and only useful for developers.' |
|
53 |
: 'It is not listed as a dependancy yet. Please tell this the developers.'; |
|
29 | 54 |
|
30 | 55 |
my @source_texts = source_texts($module); |
31 | 56 |
local $" = $/; |
32 |
print STDERR <<EOL; |
|
33 |
+-----------------------------------------------------------------------------+ |
|
57 |
print STDERR <<EOL if $v;
|
|
58 |
+------------------------------------------------------------------------------+
|
|
34 | 59 |
$module->{fullname} could not be loaded. |
35 | 60 |
|
36 | 61 |
This module is either too old or not available on your system. |
... | ... | |
39 | 64 |
Here are some ideas how to get it: |
40 | 65 |
|
41 | 66 |
@source_texts |
42 |
+-----------------------------------------------------------------------------+ |
|
67 |
+------------------------------------------------------------------------------+
|
|
43 | 68 |
EOL |
44 | 69 |
} |
45 | 70 |
|
... | ... | |
63 | 88 |
|
64 | 89 |
return @texts; |
65 | 90 |
} |
91 |
|
|
92 |
sub mycolor { |
|
93 |
return $_[0] unless $c; |
|
94 |
return colored(@_); |
|
95 |
} |
|
96 |
|
|
97 |
sub dot_pad { |
|
98 |
my ($s, $l, $text) = @_; |
|
99 |
print " "; |
|
100 |
print '.' x (80 - $s - 2 - $l); |
|
101 |
print " "; |
|
102 |
return $text; |
|
103 |
} |
|
104 |
|
|
105 |
1; |
|
106 |
|
|
107 |
__END__ |
|
108 |
|
|
109 |
=encoding UTF-8 |
|
110 |
|
|
111 |
=head1 NAME |
|
112 |
|
|
113 |
scripts/installation_check.pl - check Lx-Office dependancies |
|
114 |
|
|
115 |
=head1 SYNOPSIS |
|
116 |
|
|
117 |
scripts/installation_check.pl [OPTION] |
|
118 |
|
|
119 |
=head1 DESCRIPTION |
|
120 |
|
|
121 |
List all modules needed by Lx-Office, probes for them, and warns if one is not available. |
|
122 |
|
|
123 |
=over 4 |
|
124 |
|
|
125 |
=item C<-a, --all> |
|
126 |
|
|
127 |
Probe for all modules. |
|
128 |
|
|
129 |
=item C<-c, --color> |
|
130 |
|
|
131 |
Color output. Default on. |
|
132 |
|
|
133 |
=item C<-d, --devel> |
|
134 |
|
|
135 |
Probe for developer dependancies. (Used for console and tags file) |
|
136 |
|
|
137 |
=item C<-h, --help> |
|
138 |
|
|
139 |
Display this help. |
|
140 |
|
|
141 |
=item C<-o, --optional> |
|
142 |
|
|
143 |
Probe for optional modules. |
|
144 |
|
|
145 |
=item C<-r, --required> |
|
146 |
|
|
147 |
Probe for required modules (default). |
|
148 |
|
|
149 |
=item C<-v. --verbose> |
|
150 |
|
|
151 |
Print additional info for modules that are missing |
|
152 |
|
|
153 |
=back |
|
154 |
|
|
155 |
=head1 BUGS, CAVEATS and TODO |
|
156 |
|
|
157 |
=over 4 |
|
158 |
|
|
159 |
=item * |
|
160 |
|
|
161 |
Fedora packages not listed yet. |
|
162 |
|
|
163 |
=item * |
|
164 |
|
|
165 |
Not possible yet to generate a combined cpan/apt-get string to install all needed. |
|
166 |
|
|
167 |
=item * |
|
168 |
|
|
169 |
Not able to handle devel cpan modules yet. |
|
170 |
|
|
171 |
=item * |
|
172 |
|
|
173 |
Version requirements not fully tested yet. |
|
174 |
|
|
175 |
=back |
|
176 |
|
|
177 |
=head1 AUTHOR |
|
178 |
|
|
179 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
180 |
Sven Schöling E<lt>s.schoeling@linet-services.deE<gt> |
|
181 |
|
|
182 |
=cut |
Auch abrufbar als: Unified diff
Installationcheck: Mehr Optionen
- wahlweise required, optional, developer
- Hilfe
- verbose mode
- farbe