forked from munin-monitoring/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.PL
executable file
·339 lines (269 loc) · 9.59 KB
/
Build.PL
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/usr/bin/env perl
=head1 NAME
Build - Build, test and install Munin
=head1 SYNOPSIS
perl Build.PL [options]
./Build test
./Build install
=head1 DESCRIPTION
Installs Munin and its components, using Module::Build. Some files are generated using templates.
=head1 OPTIONS
Note: options are "sticky". Options set at C<perl Build.PL> are re-used for calls to C<./Build>
later.
=over
=item --debug
Enables debugging
=item --installpaths, --install_base, --install_path
Configures how munin is installed.
=back
=head1 EXAMPLES
=over
=item Set base install location
Handled by Module::Build standard. Overall options
* C<--installpaths site>, installs under /usr/local (this is the default)
* C<--installpaths vendor>, installs under /usr (used for packaging)
* C<--installbase /opt/munin>, installs under the named directory. You are responsible for making
sure the perl library path is set.
=item Override etcdir
Override install path with C<--install_path etc=/path/to/etc>
=item Override vardir
Override install path with C<--install_path var=/path/to/var>
=item Override sharedir
Override install path with C<--install_path share=/path/to/share>
Note: This affects plugins. Available plugins are installed to C</path/to/share/plugins/>, and
C<>munin-node-configure> will look in this directory.
=back
=head1 PLUGINS
Plugins are installed from:
* plugins/node.d/ - Generic plugins for common applications, which should work on all platforms.
* plugins/node.d.$^O/ - Specific plugins for the platform where Munin is built. (for the value of
$^O for your platform, see http://perldoc.perl.org/perlport.html)
=cut
use strict;
use warnings;
use Module::Build;
use File::Find;
use Config;
my ( $version, $release_status );
my $plugins_files = {};
my $web_files = {};
$version = qx{./getversion};
chomp $version;
if ( $version =~ m/^\d+\.\d+\.\d+$/ ) {
$release_status = 'stable';
}
else {
$release_status = 'unstable';
}
my $build = Module::Build->new(
module_name => 'Munin',
dist_version => $version,
release_status => $release_status,
dist_author => 'The Munin Project <[email protected]>',
dist_abstract => 'networked resource monitoring tool with plugins',
license => 'GPL2',
configure_requires => { 'Module::Build' => '0.21', },
requires => {
'perl' => '5.10.0',
'DBD::SQLite' => '1.42',
'DBI' => '1.631',
'HTML::Template::Pro' => '0',
'HTTP::Server::Simple::CGI' => '0',
'CGI::Cookie' => '0',
'IO::Socket::INET6' => '2.69',
'LWP::UserAgent' => '6.06',
'List::Util' => '0',
'List::MoreUtils' => '0.33',
'Log::Dispatch' => '2.41',
'Net::SNMP' => 'v6.0.1',
'Net::SSLeay' => '1.65',
'Net::Server::Daemonize' => '0.06',
'Net::Server::Fork' => '0',
'Params::Validate' => '1.13',
'Alien::RRDtool' => '0',
'URI' => '1.64',
'XML::Dumper' => '0',
},
PL_files => {
'etc/munin-node.conf.PL' => 'etc/munin-node.conf.sample',
'etc/munin.conf.PL' => 'etc/munin.conf.sample',
'lib/Munin.pm.PL' => 'lib/Munin.pm',
'lib/Munin/Common/Defaults.pm.PL' => 'lib/Munin/Common/Defaults.pm',
'script/munin-cron.PL' => 'script/munin-cron',
},
etc_files => {
'etc/munin.conf.sample' => 'etc/munin.conf.sample',
'etc/munin-node.conf.sample' => 'etc/munin-node.conf.sample',
},
plugins_files => $plugins_files,
web_files => $web_files,
script_files => [
qw(
script/munin-async
script/munin-asyncd
script/munin-cron
script/munin-doc
script/munin-httpd
script/munin-limits
script/munin-node
script/munin-node-configure
script/munin-run
script/munin-update
)
],
test_requires => {
'IO::Scalar' => '0',
'Test::Class' => '0',
'Test::Differences' => '0.62',
'Test::MockModule' => '0',
'Test::MockObject' => '0',
'Test::Deep' => '0',
'Test::LongString' => '0',
'Test::Perl::Critic' => '0',
'File::Slurp' => '9999.19',
'File::ReadBackwards' => '0',
'XML::Parser' => '0',
'DBD::Pg' => '0',
'Net::DNS' => '0',
'Net::IP' => '0',
'XML::LibXML' => '0',
},
);
##############################
## Build element "etc"
#
# Contains generated configuration files
$build->add_build_element('etc');
if ( not $build->install_path('etc') ) {
if ( $build->install_base ) {
$build->install_path( 'etc' => $build->install_base . '/etc' );
}
elsif ( $build->installdirs eq 'site' ) {
$build->install_path( 'etc' => '/usr/local/etc/munin' );
}
elsif ( $build->installdirs eq 'vendor' ) {
$build->install_path( 'etc' => '/etc/munin' );
}
}
##############################
## Path "share"
#
# Used as root for other parts of munin, like "plugins"
if ( not $build->install_path('share') ) {
if ( $build->install_base ) {
$build->install_path( 'share' => $build->install_base . '/share' );
}
elsif ( $build->installdirs eq 'site' ) {
$build->install_path( 'share' => '/usr/local/share/munin' );
}
elsif ( $build->installdirs eq 'vendor' ) {
$build->install_path( 'share' => '/usr/share/munin' );
}
}
##############################
## Path "var"
if ( not $build->install_path('var') ) {
if ( $build->install_base ) {
$build->install_path( 'var' => $build->install_base . '/var' );
}
else {
$build->install_path( 'var' => '/var' );
}
}
##############################
## Build element "plugins"
#
# Contains munin plugins. Installed under the "share" path by default.
$build->add_build_element('plugins');
if ( not $build->install_path('plugins') ) {
$build->install_path(
'plugins' => $build->install_path('share') . '/plugins' );
}
$plugins_files->{'plugins/plugin.sh'} = 'plugins/plugin.sh';
File::Find::find( { wanted => \&_find_plugins_wanted },
'plugins/node.d', "plugins/node.d.$^O" );
sub _find_plugins_wanted {
# Assume all plugins are located on the same directory level
my $dirlevel = scalar( split( '/', $File::Find::dir ) );
return unless $dirlevel == 2;
if ( ( lstat($_) ) && -f _ && -x _ ) {
my $src = $File::Find::name;
my $dst = join( '/', 'plugins', $_ );
$plugins_files->{$src} = $dst;
}
}
##############################
## Build element "web"
#
# Contains static files and templates. Installed under the "etc" path by default.
$build->add_build_element('web');
if ( not $build->install_path('web') ) {
$build->install_path( 'web' => $build->install_path('etc') );
}
File::Find::find( { wanted => \&_find_web_wanted }, 'web' );
sub _find_web_wanted {
if ( lstat && -f _ ) {
my $file = $File::Find::name;
$web_files->{$file} = $file;
}
}
##############################
# Add generated variables to be used from .PL files
# sharedir (aka libdir)
$build->install_path( 'MUNIN_SHAREDIR' => $build->install_path('share') );
# etc
$build->install_path( 'MUNIN_CONFDIR' => $build->install_path('etc') );
# runstate
# var
if ( $build->install_base ) {
$build->install_path(
'MUNIN_BINDIR' => $build->install_base . '/bin' );
$build->install_path(
'MUNIN_RUNDIR' => $build->install_path('var') . '/run' );
$build->install_path(
'MUNIN_LOGDIR' => $build->install_path('var') . '/log' );
$build->install_path(
'MUNIN_HTMLDIR' => $build->install_path('var') . '/www' );
$build->install_path(
'MUNIN_DBDIR' => $build->install_path('var') . '/lib' );
$build->install_path(
'MUNIN_CGITMPDIR' => $build->install_path('var') . '/cache' );
$build->install_path(
'MUNIN_SPOOLDIR' => $build->install_path('var') . '/spool' );
$build->install_path(
'MUNIN_PLUGSTATE' => $build->install_path('var') . '/plugin-state' );
}
else {
if ($build->installdirs eq 'site') {
$build->install_path( 'MUNIN_BINDIR' => $Config{installsitebin} );
}
else {
$build->install_path( 'MUNIN_BINDIR' => $Config{installvendorbin} );
}
$build->install_path(
'MUNIN_RUNDIR' => $build->install_path('var') . '/run/munin' );
$build->install_path(
'MUNIN_LOGDIR' => $build->install_path('var') . '/log/munin' );
$build->install_path(
'MUNIN_HTMLDIR' => $build->install_path('var') . '/www/munin' );
$build->install_path(
'MUNIN_DBDIR' => $build->install_path('var') . '/lib/munin' );
$build->install_path(
'MUNIN_CGITMPDIR' => $build->install_path('var') . '/cache/munin' );
$build->install_path(
'MUNIN_SPOOLDIR' => $build->install_path('var') . '/spool/munin' );
$build->install_path( 'MUNIN_PLUGSTATE' => $build->install_path('var')
. '/lib/munin-node/plugin-state' );
}
# Aliases, kept for as long as code uses these
$build->install_path(
'MUNIN_STATEDIR' => $build->install_path('MUNIN_RUNDIR') );
$build->install_path(
'MUNIN_LIBDIR' => $build->install_path('MUNIN_SHAREDIR') );
$build->dispatch('manifest');
$build->dispatch('distmeta');
$build->create_build_script;
if ( $build->debug ) {
use Data::Dumper;
print Dumper $build->install_path();
}