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