File: Build.PL

package info (click to toggle)
librrd-simple-perl 1.44-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,012 kB
  • ctags: 192
  • sloc: perl: 4,480; sh: 42; makefile: 3
file content (133 lines) | stat: -rw-r--r-- 3,658 bytes parent folder | download
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
# vim:ts=4:sw=4:tw=78
# $Id: Build.PL 965 2007-03-01 19:11:23Z nicolaw $

use strict;
use Module::Build;
use vars qw($build);

BEGIN {
	eval "use RRDs";
	if ($@) {
		warn qq{
+-----------------------------------------------------------------------------+
| ERROR! -- Could not load RRDs.pm                                            |
|                                                                             |
| RRD::Simple requires RRDs.pm (a part of RRDtool) in order to function. You  |
| can download a copy of RRDtool from http://www.rrdtool.org. See the INSTALL |
| document for more details.                                                  |
+-----------------------------------------------------------------------------+

} unless $ENV{AUTOMATED_TESTING};
	}
}

my $module = 'RRD::Simple';
$build = Module::Build->new(
		module_name        => $module,
		license            => 'open_source',
		create_makefile_pl => 'passthrough',
		create_readme      => 1,
		create_packlist    => 1,
		sign               => 0,

		requires => {
			'File::Spec'     => 0, # 3.15
			'File::Basename' => 0, # 2.73
			'File::Temp'     => 0, # 0.16
			'File::Copy'     => 0, # 2.08
			'RRDs'           => 0, # 1.2013
			'Carp'           => 0, # 1.04
			'POSIX'          => 0,
		},

		build_requires => {
			'Test'                => 0, # 1.25
			'Test::More'          => 0, # 0.60
		},

		recommends => {
			'Test::Pod'           => 1.20,
			'Test::Pod::Coverage' => 1.06,
			'Test::Deep'          => 0.093,
		},

		conflicts => {
			'RRDTool::Managed' => 0,
		},

		add_to_cleanup => [ qw(
			t/21test.rrd t/22test.rrd t/23test.rrd t/24test.rrd t/25test.rrd
			t/26test.rrd t/30assume_rrd_filename.rrd t/34test.rrd
			t/31create_assume_rrd_filename.rrd t/32test.rrd t/33test.rrd
			t/21test-daily.png t/21test-weekly.png t/21test-monthly.png
			t/21test-annual.png t/27test.rrd t/35test-daily.png
		) ],
	);

$build->create_build_script;


# Send perl and module version information home if we've been given
# permission to do so by a human being - default to not send for automated
# testing environments, of if the user does not respond within 20 seconds.

my $url = $ENV{AUTOMATED_TESTING} ? undef : may_send_version_information();
if ($url) {
	my @resp = ();
	eval {
		local $SIG{ALRM} = sub { die; };
		alarm 10;
		my $ua = LWP::UserAgent->new(
				agent => 'Build.PL $Revision: 965 $',
				timeout => 9,
				max_size => 500,
			);
		$ua->env_proxy;
		my $response = $ua->get($url);
		if ($response->is_success()) {
			for (split(/\s*\n+\s*/, $response->content())) {
				push @resp, $_ if $_;
			}
		}
		alarm 0;
	};
	print substr($resp[0],0,79) || "Thank you for sending this information.";
	print "\n\n";
}

sub may_send_version_information {
	eval {
		require Config;
		require LWP::UserAgent;
	};
	return undef if $@;

	my $str = sprintf('%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s',
			'http://perlgirl.org.uk/lib/usage.cgi',
			'name',     $module,
			'version',  $build->dist_version(),
			'osname',   $Config::Config{osname},
			'archname', $Config::Config{archname},
			'osver',    $^O,
			'perlver',  $]
		);

	print "\nThank you for downloading ".$build->dist_name()."\n\n";
	print "I would like to find out how many people are using this software,\n";
	print "and on what operating systems and Perl versions. If you have an\n";
	print "internet connection, may I transmit the following information:\n\n";
	print "$str\n\n";

	my $send = 0;
	eval {
		local $SIG{ALRM} = sub { die; };
		alarm 20;
		$send = $build->y_n('Send this anonymous information?','n');
		alarm 0;
	};

	return defined $send && !ref($send) && "$send" eq "1" ? $str : undef;
}

1;