added timeout to sqlite health check because some buggy versions of sqlite just hang
[dbsrgits/DBIx-Class.git] / Makefile.PL
CommitLineData
737416a4 1use inc::Module::Install 0.67;
fe650234 2use strict;
3use warnings;
76607ac8 4use POSIX ();
fe650234 5
6use 5.006001; # delete this line if you want to send patches for earlier.
ce4c07df 7
8name 'DBIx-Class';
ce4c07df 9perl_version '5.006001';
8e0f16f1 10all_from 'lib/DBIx/Class.pm';
ce4c07df 11
ce4c07df 12requires 'Data::Page' => 2.00;
13requires 'Scalar::Util' => 0;
87e75121 14requires 'SQL::Abstract' => 1.24;
15requires 'SQL::Abstract::Limit' => 0.13;
16requires 'Class::C3' => 0.20;
1680d317 17requires 'Class::C3::Componentised' => 0;
ce4c07df 18requires 'Storable' => 0;
ce4c07df 19requires 'Carp::Clan' => 0;
20requires 'DBI' => 1.40;
21requires 'Module::Find' => 0;
22requires 'Class::Inspector' => 0;
87e75121 23requires 'Class::Accessor::Grouped' => 0.08002;
f1b99b9e 24requires 'JSON::Any' => 1.17;
9c6d6d93 25requires 'Scope::Guard' => 0.03;
8026d0eb 26requires 'Path::Class' => 0;
26ab719a 27requires 'List::Util' => 1.19;
ddc0a6c8 28requires 'Sub::Name' => 0.04;
ce4c07df 29
30# Perl 5.8.0 doesn't have utf8::is_utf8()
31requires 'Encode' => 0 if ($] <= 5.008000);
32
d9a898ca 33configure_requires 'DBD::SQLite' => 1.14;
34
f947585b 35test_requires 'Test::Builder' => 0.33;
97aca715 36test_requires 'Test::Warn' => 0.11;
f947585b 37test_requires 'Test::Exception' => 0;
ce3b4eb9 38test_requires 'Test::Deep' => 0;
ce4c07df 39
40install_script 'script/dbicadmin';
41
50891152 42tests_recursive 't';
ce4c07df 43
1543db24 44# re-build README and require CDBI modules for testing if we're in a checkout
fe650234 45
46my @force_build_requires_if_author = qw(
47 DBIx::ContextualFetch
48 Class::Trigger
49 Time::Piece
a8e7500d 50 Clone
51 Test::Pod::Coverage
52 Test::Memory::Cycle
fe650234 53);
54
55if ($Module::Install::AUTHOR) {
56
57 foreach my $module (@force_build_requires_if_author) {
58 build_requires $module;
59 }
09d46657 60
1543db24 61 system('pod2text lib/DBIx/Class.pm > README');
ff132c6f 62}
63
64auto_provides;
65
3e110410 66auto_install;
67
e0b438fb 68# Have all prerequisites, check DBD::SQLite sanity
269228af 69if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ) {
70
e0b438fb 71 my $pid = fork();
72 if (not defined $pid) {
73 die "Unable to fork(): $!";
74 }
75 elsif (! $pid) {
269228af 76
77 # Win32 does not have real fork()s so a segfault will bring
78 # everything down. Warn about it.
79 if ($^O eq 'MSWin32') {
80 print <<'EOW';
81
82######################################################################
83# #
84# A short stress-testing of DBD::SQLite will follow. If you have a #
85# buggy library this might very well be the last text you will see #
86# before the installation silently terminates. If this happens it #
87# would mean that you are running a buggy version of DBD::SQLite #
88# known to randomly segfault on errors. Even if you have the latest #
3951a291 89# CPAN module version, the system sqlite3 dynamic library might have #
90# been compiled against an older buggy sqlite3 dev library (oddly #
91# DBD::SQLite will prefer the system library against the one bundled #
92# with it). You are strongly advised to resolve this issue before #
93# proceeding. #
269228af 94# #
95# If this happens to you (this text is the last thing you see), and #
96# you just want to install this module without worrying about the #
97# tests (which will almost certainly fail) - set the environment #
98# variable DBICTEST_NO_SQLITE_CHECK to a true value and try again. #
99# #
100######################################################################
101
102EOW
103 }
104
e0b438fb 105 require DBI;
269228af 106 for (1 .. 100) {
e0b438fb 107 my $dbh;
108 $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
109 AutoCommit => 1,
110 RaiseError => 0,
111 PrintError => 0,
112 })
113 or die "Unable to connect to database: $@";
114 $dbh->do ('CREATE TABLE name_with_no_columns'); # a subtle syntax error
115 $dbh->do ('COMMIT'); # followed by commit
116 $dbh->disconnect;
117 }
118
119 exit 0;
120 }
121 else {
76607ac8 122 eval {
123 local $SIG{ALRM} = sub { die "timeout\n" };
124 alarm 5;
125 wait();
126 alarm 0;
127 };
e0b438fb 128 my $sig = $? & 127;
76607ac8 129 if ($@ || $sig == POSIX::SIGSEGV) {
e0b438fb 130 warn (<<EOE);
131
3951a291 132############################### WARNING #################################
133# #
134# You are running a buggy version of DBD::SQLite known to randomly #
135# segfault on errors. Even if you have the latest CPAN module version, #
136# the sqlite3 dynamic library on this system might have been compiled #
137# against an older buggy sqlite3 dev library (oddly DBD::SQLite will #
138# prefer the system library against the one bundled with it). You are #
139# strongly advised to resolve this issue before proceeding. #
140# #
141#########################################################################
e0b438fb 142
143EOE
144 my $ans = prompt (
145 "The test suite of this module is almost certain to fail.\n"
146 . 'Do you really want to continue?',
147 'no',
148 );
149 exit 0 unless ($ans =~ /^y(es)?$/i);
150 }
151 }
152}
153
154
43944e47 155WriteAll();
09d46657 156
157
158if ($Module::Install::AUTHOR) {
159 # Need to do this _after_ WriteAll else it looses track of them
160 Meta->{values}{build_requires} = [ grep {
fe650234 161 my $ok = 1;
162 foreach my $module (@force_build_requires_if_author) {
163 if ($_->[0] =~ /$module/) {
164 $ok = 0;
165 last;
166 }
167 }
168 $ok;
09d46657 169 } @{Meta->{values}{build_requires}} ];
170
171 my @scalar_keys = Module::Install::Metadata::Meta_TupleKeys();
fe650234 172 my $cr = Module::Install::Metadata->can("Meta_TupleKeys");
173 {
174 no warnings 'redefine';
175 *Module::Install::Metadata::Meta_TupleKeys = sub {
176 return $cr->(@_), 'resources';
177 };
09d46657 178 }
179 Meta->{values}{resources} = [
180 [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
181 [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
100dd0a8 182 [ 'license', 'http://dev.perl.org/licenses/' ],
183 [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
09d46657 184 ];
185 Meta->write;
186}