Commit | Line | Data |
fc4b0448 |
1 | my ($optdep_msg, $opt_testdeps); |
2 | |
3 | if ($args->{skip_author_deps}) { |
4 | $optdep_msg = <<'EOW'; |
5 | |
6 | ****************************************************************************** |
7 | ****************************************************************************** |
8 | *** *** |
9 | *** IGNORING AUTHOR MODE: no optional test dependencies will be forced. *** |
10 | *** *** |
11 | *** If you are using this checkout with the intention of submitting a DBIC *** |
12 | *** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so *** |
13 | *** that every possible unit-test will run. *** |
14 | *** *** |
15 | ****************************************************************************** |
16 | ****************************************************************************** |
17 | |
18 | EOW |
19 | } |
20 | else { |
21 | $optdep_msg = <<'EOW'; |
22 | |
23 | ****************************************************************************** |
24 | ****************************************************************************** |
25 | *** *** |
26 | *** AUTHOR MODE: all optional test dependencies converted to hard requires *** |
df65d4da |
27 | *** ( to disable re-run Makefile.PL with --skip-author-deps ) *** |
fc4b0448 |
28 | *** *** |
29 | ****************************************************************************** |
30 | ****************************************************************************** |
31 | |
32 | EOW |
33 | |
34 | require DBIx::Class::Optional::Dependencies; |
35 | my %reqs_for_group = %{DBIx::Class::Optional::Dependencies->req_group_list}; |
36 | |
37 | # exclude the rdbms_* groups which are for DBIC users |
4841171c |
38 | # and the moose-related stuff iff we are under 5.8.3 |
fc4b0448 |
39 | $opt_testdeps = { |
4841171c |
40 | map { %{$reqs_for_group{$_}} } grep { |
41 | !/^rdbms_|^dist_/ |
42 | and |
43 | ($] > 5.008002 or !/^ (?: test_ )? (?: admin | admin_script | replicated ) $/x ) |
44 | } keys %reqs_for_group |
fc4b0448 |
45 | }; |
46 | |
47 | print "Including all optional deps\n"; |
48 | $reqs->{test_requires} = { |
49 | %{$reqs->{test_requires}}, |
50 | %$opt_testdeps |
51 | }; |
52 | } |
53 | |
54 | # nasty hook into both M::AI init and the prompter, so that the optdep message |
55 | # comes at the right places (on top and then right above the prompt) |
56 | { |
57 | require Module::AutoInstall; |
58 | no warnings 'redefine'; |
59 | no strict 'refs'; |
60 | |
61 | for (qw/_prompt import/) { |
62 | my $meth = "Module::AutoInstall::$_"; |
63 | my $orig = \&{$meth}; |
64 | *{$meth} = sub { |
65 | print $optdep_msg; |
66 | goto $orig; |
67 | }; |
68 | } |
69 | } |
70 | |
71 | # this will run after the Makefile is written and the main Makefile.PL terminates |
72 | # |
73 | END { |
745b54f5 |
74 | # shit already hit the fan |
75 | return if $?; |
76 | |
fc4b0448 |
77 | # Re-write META.yml at the end to _exclude_ all forced build-requires (we do not |
78 | # want to ship this) We are also not using M::I::AuthorRequires as this will be |
79 | # an extra dep, and deps in Makefile.PL still suck |
80 | # Also always test the result so we stop shipping borked dependency lists to CPAN |
81 | |
82 | # FIXME test_requires is not yet part of META |
83 | my %original_build_requires = ( %$build_requires, %$test_requires ); |
84 | my @all_build_requires = @{delete Meta->{values}{build_requires}||[]}; |
85 | my %removed_build_requires; |
86 | |
87 | for (@all_build_requires) { |
88 | if ($original_build_requires{$_->[0]}) { |
89 | push @{Meta->{values}{build_requires}}, $_; |
90 | } |
91 | else { |
92 | $removed_build_requires{$_->[0]} = $_->[1] |
93 | unless $_->[0] eq 'ExtUtils::MakeMaker'; |
94 | } |
95 | } |
96 | |
97 | if (keys %removed_build_requires) { |
98 | print "Regenerating META with author requires excluded\n"; |
3440100b |
99 | # M::I understands unicode in meta but does not write with the right |
100 | # layers - fhtagn!!! |
101 | local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /Wide character in print/ }; |
fc4b0448 |
102 | Meta->write; |
103 | } |
104 | |
204f57da |
105 | # strip possible crlf from META |
106 | if ($^O eq 'MSWin32' or $^O eq 'cygwin') { |
107 | local $ENV{PERLIO} = 'unix'; |
108 | system( $^X, qw( -MExtUtils::Command -e dos2unix -- META.yml), ); |
109 | } |
110 | |
fc4b0448 |
111 | # test that we really took things away (just in case, happened twice somehow) |
112 | if (! -f 'META.yml') { |
113 | warn "No META.yml generated?! aborting...\n"; |
114 | unlink 'Makefile'; |
115 | exit 1; |
116 | } |
117 | my $meta = do { local @ARGV = 'META.yml'; local $/; <> }; |
118 | |
90d4cbcc |
119 | $meta =~ /^\Qname: DBIx-Class\E$/m or do { |
120 | warn "Seemingly malformed META.yml...?\n"; |
121 | unlink 'Makefile'; |
122 | exit 1; |
123 | }; |
124 | |
fc4b0448 |
125 | # this is safe as there is a fatal check earlier in the main Makefile.PL |
65a231a8 |
126 | # to make sure there are no duplicates (i.e. $opt_testdeps does not contain |
fc4b0448 |
127 | # any real dependencies) |
128 | my @illegal_leftovers = grep |
129 | { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx } |
130 | ( sort keys %$opt_testdeps ) |
131 | ; |
132 | |
133 | if (@illegal_leftovers) { |
134 | warn join ("\n", |
135 | "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n", |
136 | map { "\t$_" } @illegal_leftovers |
137 | ) . "\n\n"; |
138 | unlink 'Makefile'; |
139 | exit 1; |
140 | } |
141 | } |
142 | |
143 | # keep the Makefile.PL eval happy |
144 | 1; |