Commit | Line | Data |
47a4aa51 |
1 | use inc::Module::Install 1.00; |
fe650234 |
2 | use strict; |
3 | use warnings; |
4 | |
55087b99 |
5 | use 5.008001; |
ce4c07df |
6 | |
8057ed01 |
7 | use FindBin; |
8 | use lib "$FindBin::Bin/lib"; |
2f5a6e87 |
9 | use DBIx::Class::Optional::Dependencies; |
93c50889 |
10 | |
d1dc7a98 |
11 | # get cpanX --installdeps . to behave in a checkout (most users do not need |
12 | # the deps for a full test suite run, and if they do - there's MI::AutoInstall |
13 | # for that) |
14 | ## |
15 | ## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad) |
16 | ## |
17 | $Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) ); |
18 | |
4b5544ad |
19 | ### |
20 | ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends() |
21 | ### All of them should go to DBIx::Class::Optional::Dependencies |
22 | ### |
23 | |
ce4c07df |
24 | name 'DBIx-Class'; |
b50d0dd3 |
25 | perl_version '5.008001'; |
8e0f16f1 |
26 | all_from 'lib/DBIx/Class.pm'; |
ce4c07df |
27 | |
8057ed01 |
28 | my $build_requires = { |
79680fc0 |
29 | # needed for testing only, not for operation |
b9df8e39 |
30 | 'DBD::SQLite' => '1.29', |
8057ed01 |
31 | }; |
32 | |
33 | my $test_requires = { |
30da8374 |
34 | 'File::Temp' => '0.22', |
35 | 'Test::Builder' => '0.33', |
0007aedf |
36 | 'Test::Exception' => '0.31', |
30da8374 |
37 | 'Test::More' => '0.92', |
38 | 'Test::Warn' => '0.21', |
90cfe42b |
39 | |
40 | # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t |
41 | # remove and do a manual glob-collection if n::c is no longer a dep |
42 | 'Package::Stash' => '0.28', |
8057ed01 |
43 | }; |
44 | |
45 | my $runtime_requires = { |
b8d22f13 |
46 | 'Class::Accessor::Grouped' => '0.10002', |
9c1700e3 |
47 | 'Class::C3::Componentised' => '1.0009', |
8057ed01 |
48 | 'Class::Inspector' => '1.24', |
79680fc0 |
49 | 'Config::Any' => '0.20', |
50 | 'Context::Preserve' => '0.01', |
2b8cc2f2 |
51 | 'Data::Dumper::Concise' => '2.020', |
8057ed01 |
52 | 'Data::Page' => '2.00', |
b8d22f13 |
53 | 'Hash::Merge' => '0.12', |
8057ed01 |
54 | 'MRO::Compat' => '0.09', |
55 | 'Module::Find' => '0.06', |
f4d7449c |
56 | 'Path::Class' => '0.18', |
b7b18f32 |
57 | 'Scope::Guard' => '0.03', |
bf51641f |
58 | 'SQL::Abstract' => '1.72', |
20674fcd |
59 | 'Try::Tiny' => '0.04', |
9859bf7a |
60 | 'Data::Compare' => '1.22', |
79680fc0 |
61 | |
62 | # XS (or XS-dependent) libs |
997a3638 |
63 | 'DBI' => '1.57', |
4549ba49 |
64 | 'namespace::clean' => '0.20', |
79680fc0 |
65 | 'Sub::Name' => '0.04', |
66 | 'Variable::Magic' => '0.44', |
67 | |
c7d50a7d |
68 | # dual-life corelibs needing a specific bugfixed version |
79680fc0 |
69 | 'File::Path' => '2.07', |
8057ed01 |
70 | }; |
71 | |
bb7950c0 |
72 | |
73 | # Bail out on parallel testing |
74 | if ( |
75 | ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x |
76 | and |
77 | $1 > 1 |
78 | ) { die <<EOP } |
79 | |
80 | ****************************************************************************** |
81 | ****************************************************************************** |
82 | *** *** |
83 | *** PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' ) *** |
84 | *** *** |
85 | *** DBIC tests will fail. It is harder to make them parallel-friendly than *** |
86 | *** it should be (though work is underway). In the meantime you will have *** |
87 | *** to adjust your environment and re-run the installation. Sorry! *** |
88 | *** *** |
89 | ****************************************************************************** |
90 | ****************************************************************************** |
91 | |
92 | EOP |
93 | |
94 | require Getopt::Long; |
95 | my $getopt = Getopt::Long::Parser->new( |
96 | config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/] |
97 | ); |
98 | my $args = { |
99 | skip_author_deps => undef, |
100 | }; |
101 | $getopt->getoptions($args, 'skip_author_deps'); |
102 | if (@ARGV) { |
103 | warn "\nIgnoring unrecognized option(s): @ARGV\n\n"; |
104 | } |
105 | |
8057ed01 |
106 | # this is so we can order requires alphabetically |
107 | # copies are needed for author requires injection |
108 | my $reqs = { |
109 | build_requires => { %$build_requires }, |
110 | requires => { %$runtime_requires }, |
111 | test_requires => { %$test_requires }, |
112 | }; |
3a4251e2 |
113 | |
be68095d |
114 | my %reqs_for_group = %{DBIx::Class::Optional::Dependencies->req_group_list}; |
115 | |
116 | # exclude the rdbms_* groups which are for DBIC users |
2f5a6e87 |
117 | my $opt_testdeps = { |
be68095d |
118 | map { %{$reqs_for_group{$_}} } grep { !/^rdbms_/ } keys %reqs_for_group |
2f5a6e87 |
119 | }; |
8057ed01 |
120 | |
92f8f62a |
121 | # require extra modules for testing if we're in a checkout |
0424d17a |
122 | my $optdep_msg; |
92f8f62a |
123 | if ($Module::Install::AUTHOR) { |
0424d17a |
124 | if ($args->{skip_author_deps}) { |
125 | $optdep_msg = <<'EOW'; |
126 | |
127 | ****************************************************************************** |
128 | ****************************************************************************** |
129 | *** *** |
130 | *** IGNORING AUTHOR MODE: no optional test dependencies will be forced. *** |
131 | *** *** |
132 | *** If you are using this checkout with the intention of submitting a DBIC *** |
133 | *** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so *** |
134 | *** that every possible unit-test will run. *** |
135 | *** *** |
136 | ****************************************************************************** |
137 | ****************************************************************************** |
138 | |
139 | EOW |
140 | } |
141 | else { |
142 | $optdep_msg = <<'EOW'; |
143 | |
8057ed01 |
144 | ****************************************************************************** |
145 | ****************************************************************************** |
146 | *** *** |
147 | *** AUTHOR MODE: all optional test dependencies converted to hard requires *** |
7adae31a |
148 | *** ( to disable re-run Makefile.PL with --skip_author_deps ) *** |
8057ed01 |
149 | *** *** |
150 | ****************************************************************************** |
151 | ****************************************************************************** |
152 | |
153 | EOW |
154 | |
0424d17a |
155 | $reqs->{test_requires} = { |
156 | %{$reqs->{test_requires}}, |
2f5a6e87 |
157 | %$opt_testdeps |
0424d17a |
158 | }; |
159 | } |
8057ed01 |
160 | } |
161 | |
162 | # compose final req list, for alphabetical ordering |
163 | my %final_req; |
164 | for my $rtype (keys %$reqs) { |
165 | for my $mod (keys %{$reqs->{$rtype}} ) { |
166 | |
167 | # sanity check req duplications |
168 | if ($final_req{$mod}) { |
b718fd0a |
169 | die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n"; |
8057ed01 |
170 | } |
171 | |
172 | $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ], |
173 | } |
174 | } |
175 | |
176 | # actual require |
177 | for my $mod (sort keys %final_req) { |
178 | my ($rtype, $ver) = @{$final_req{$mod}}; |
179 | no strict 'refs'; |
180 | $rtype->($mod, $ver); |
181 | } |
a410299d |
182 | |
0424d17a |
183 | # output twice since the deplist is > 70 lines |
f90896ae |
184 | warn $optdep_msg if $Module::Install::AUTHOR; |
92f8f62a |
185 | auto_install(); |
f90896ae |
186 | warn $optdep_msg if $Module::Install::AUTHOR; |
92f8f62a |
187 | |
4557be61 |
188 | |
92f8f62a |
189 | # re-create various autogenerated documentation bits |
190 | if ($Module::Install::AUTHOR) { |
191 | |
bb7950c0 |
192 | # adjust ENV for $AUTHOR system() calls |
193 | require Config; |
194 | $ENV{PERL5LIB} = join ($Config::Config{path_sep}, @INC); |
195 | |
92f8f62a |
196 | print "Regenerating README\n"; |
197 | system('pod2text lib/DBIx/Class.pm > README'); |
198 | |
199 | if (-f 'MANIFEST') { |
200 | print "Removing MANIFEST\n"; |
201 | unlink 'MANIFEST'; |
202 | } |
203 | |
92f8f62a |
204 | print "Regenerating Optional/Dependencies.pod\n"; |
205 | require DBIx::Class::Optional::Dependencies; |
ccebe1f1 |
206 | DBIx::Class::Optional::Dependencies->_gen_pod (Meta->version); |
92f8f62a |
207 | |
208 | # FIXME Disabled due to unsolved issues, ask theorbtwo |
209 | # require Module::Install::Pod::Inherit; |
210 | # PodInherit(); |
211 | } |
212 | |
f90896ae |
213 | |
7eaae8db |
214 | tests_recursive (qw| |
215 | t |
216 | |); |
217 | |
f90896ae |
218 | # temporary(?) until I get around to fix M::I wrt xt/ |
219 | # needs Module::Install::AuthorTests |
c1fdb460 |
220 | eval { |
c5e9d46d |
221 | # this should not be necessary since the autoloader is supposed |
222 | # to work, but there were reports of it failing |
223 | require Module::Install::AuthorTests; |
7f2c37b8 |
224 | recursive_author_tests (qw/xt/); |
225 | 1; |
226 | } || do { |
d1dc7a98 |
227 | if ($Module::Install::AUTHOR && ! $args->{skip_author_deps}) { |
22a2062e |
228 | my $err = $@; |
c5e9d46d |
229 | |
230 | # better error message in case of missing dep |
22a2062e |
231 | eval { require Module::Install::AuthorTests } |
eeaf8701 |
232 | || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or supply --skip_author_deps):\n\n$@\n"; |
c5e9d46d |
233 | |
234 | die $err; |
22a2062e |
235 | } |
7f2c37b8 |
236 | }; |
f90896ae |
237 | |
238 | |
a410299d |
239 | install_script (qw| |
240 | script/dbicadmin |
241 | |); |
242 | |
7eaae8db |
243 | |
244 | ### Mangle makefile - read the comments for more info |
245 | # |
246 | postamble <<"EOP"; |
247 | |
248 | # This will add an extra dep-spec for the distdir target, |
249 | # which `make` will fold together in a first-come first-serve |
250 | # fashion. What we do here is essentially adding extra |
251 | # commands to execute once the distdir is assembled (via |
252 | # create_distdir), but before control is returned to a higher |
253 | # calling rule. |
254 | distdir : dbicadmin_pod_inject |
255 | |
256 | # The pod self-injection code is in fact a hidden option in |
257 | # dbicadmin itself |
258 | dbicadmin_pod_inject : |
259 | \tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod |
260 | |
261 | # Regenerate manifest before running create_distdir. |
262 | create_distdir : manifest |
263 | |
264 | EOP |
265 | |
f90896ae |
266 | homepage 'http://www.dbix-class.org/'; |
a410299d |
267 | resources 'IRC' => 'irc://irc.perl.org/#dbix-class'; |
268 | resources 'license' => 'http://dev.perl.org/licenses/'; |
aeb669b8 |
269 | resources 'repository' => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git'; |
a410299d |
270 | resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class'; |
70fbb0b8 |
271 | resources 'bugtracker' => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class'; |
a410299d |
272 | |
974fe5e8 |
273 | # Deprecated/internal modules need no exposure |
274 | no_index directory => $_ for (qw| |
bc6f129c |
275 | lib/DBIx/Class/Admin |
281738a4 |
276 | lib/DBIx/Class/PK/Auto |
bc6f129c |
277 | lib/DBIx/Class/CDBICompat |
974fe5e8 |
278 | |); |
279 | no_index package => $_ for (qw/ |
d5dedbd6 |
280 | DBIx::Class::Storage::DBIHacks |
70c28808 |
281 | DBIx::Class::Carp |
974fe5e8 |
282 | /); |
a410299d |
283 | |
713cc98e |
284 | WriteAll(); |
09d46657 |
285 | |
2f5a6e87 |
286 | # Re-write META.yml to _exclude_ all forced build-requires (we do not want to ship |
287 | # this) We are also not using M::I::AuthorRequires as this will be an extra dep, |
288 | # and deps in Makefile.PL still suck |
289 | # Also always test the result so we stop shipping borked dependency lists to CPAN |
713cc98e |
290 | |
2f5a6e87 |
291 | # FIXME test_requires is not yet part of META |
292 | my %original_build_requires = ( %$build_requires, %$test_requires ); |
293 | my @all_build_requires = @{delete Meta->{values}{build_requires}}; |
294 | my %removed_build_requires; |
8057ed01 |
295 | |
2f5a6e87 |
296 | for (@all_build_requires) { |
297 | if ($original_build_requires{$_->[0]}) { |
298 | push @{Meta->{values}{build_requires}}, $_; |
299 | } |
300 | else { |
301 | $removed_build_requires{$_->[0]} = $_->[1] |
302 | unless $_->[0] eq 'ExtUtils::MakeMaker'; |
1278e5f0 |
303 | } |
2f5a6e87 |
304 | } |
713cc98e |
305 | |
2f5a6e87 |
306 | # Rewrite only in author mode, the original META should not contain anything anyway |
307 | # if we executed as non-author |
308 | if ($Module::Install::AUTHOR && keys %removed_build_requires) { |
1278e5f0 |
309 | print "Regenerating META with author requires excluded\n"; |
713cc98e |
310 | Meta->write; |
2f5a6e87 |
311 | } |
1278e5f0 |
312 | |
2f5a6e87 |
313 | # test that we really took things away (just in case, happened twice somehow) |
b8d22f13 |
314 | if (! -f 'META.yml') { |
315 | warn "No META.yml generated?! aborting...\n"; |
316 | exit 1; |
317 | } |
2f5a6e87 |
318 | my $meta = do { local @ARGV = 'META.yml'; local $/; <> }; |
319 | |
320 | # this is safe as there is a fatal check earlier to make sure $opt_testdeps does |
321 | # not contain any real dependencies |
322 | my @illegal_leftovers = grep |
323 | { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx } |
324 | ( sort keys %$opt_testdeps ) |
325 | ; |
326 | |
327 | if (@illegal_leftovers) { |
328 | die join ("\n", |
329 | "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n", |
330 | map { "\t$_" } @illegal_leftovers |
331 | ) . "\n\n"; |
09d46657 |
332 | } |