-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.PL
115 lines (104 loc) · 3.09 KB
/
Makefile.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
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long; # Technique inspired by IO::Lambda
use ExtUtils::MakeMaker 6.64; # 6.64 for TEST_REQUIRES
use IO::Socket::INET;
my $online_tests;
if($ENV{RELEASE_TESTING}) {
$online_tests = are_online();
} elsif($ENV{NO_NETWORK_TESTING}) {
$online_tests = 0;
} else {
Getopt::Long::GetOptions('online-tests!' => \$online_tests);
if(!defined($online_tests)) {
$online_tests = are_online();
}
}
if($online_tests) {
open(my $enabled, '>', 't/online.enabled') || die "Can't touch t/online.enabled $!";
close($enabled) || die "Can't touch t/online.enabled $!";
} else {
unlink('t/online.enabled');
print STDERR "NA: Genealogy::ChroniclingAmerica needs a permanent connexion to the Internet\n";
exit(0);
}
WriteMakefile(
NAME => 'Genealogy::ChroniclingAmerica',
AUTHOR => q{Nigel Horne <njh@bandsman.co.uk>},
VERSION_FROM => 'lib/Genealogy/ChroniclingAmerica.pm',
ABSTRACT_FROM => 'lib/Genealogy/ChroniclingAmerica.pm',
((defined($ExtUtils::MakeMaker::VERSION) &&
($ExtUtils::MakeMaker::VERSION >= 6.3002))
? ('LICENSE'=> 'GPL')
: ()),
PL_FILES => {},
TEST_REQUIRES => {
'Test::Most' => 0,
'Test::NoWarnings' => 0,
'Test::URI' => 0,
# 'Test::Kwalitee' => 0,
}, PREREQ_PM => {
'Carp' => 0,
'JSON::MaybeXS' => 0,
'LWP::Protocol::https' => 0,
'LWP::UserAgent' => 0,
'URI' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Genealogy-ChroniclingAmerica-*' },
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'git://github.com/nigelhorne/Genealogy-ChroniclingAmerica.git',
web => 'https://github.com/nigelhorne/Genealogy-ChroniclingAmerica',
}, bugtracker => {
# web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Genealogy-ChroniclingAmerica',
web => 'https://github.com/nigelhorne/Genealogy-ChroniclingAmerica/issues',
mailto => 'bug-Genealogy-ChroniclingAmerica@rt.cpan.org'
}, homepage => 'https://chroniclingamerica.loc.gov',
},
},
MIN_PERL_VERSION => '5.6.2' # Probably would work, but never tested on earlier versions than this
);
sub are_online
{
my $host = 'chroniclingamerica.loc.gov:80';
if($ENV{'http_proxy'} && ($ENV{'http_proxy'} =~ /^.+\/\/(\w+:\d+)$/)) {
$host = $1;
} elsif($ENV{'HTTP_PROXY'} && ($ENV{'HTTP_PROXY'} =~ /^.+\/\/(\w+:\d+)$/)) {
$host = $1;
}
my $s = IO::Socket::INET->new(
PeerAddr => $host,
Timeout => 5
);
if($s) {
if($ENV{'AUTOMATED_TESTING'}) {
close($s);
return 1;
}
print <<EOF;
You appear to be directly connected to the Internet. I have some tests
that connect to chroniclingamerica.loc.gov.
EOF
close($s);
# Timeout inspired by Mail::IMAPClient
my $rc;
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(60);
$rc = prompt('Do you want to enable these tests?', 'y') =~ /^y/i ? 1 : 0;
alarm(0);
};
if($@) {
print "\n";
return 1; # The default is 'y'
}
return $rc;
}
print "On-line tests disabled because I couldn't detect an Internet connexion\n";
return 0;
}