From: Tomas Doran (t0m) Date: Sat, 23 May 2009 18:31:41 +0000 (+0100) Subject: Hack module install to ensure we _require_ the stuff for the optional tests if you... X-Git-Tag: 0.05~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Engine-STOMP.git;a=commitdiff_plain;h=e946eafd5c7f853cf90d996210d773bdb31cf68c Hack module install to ensure we _require_ the stuff for the optional tests if you're in author mode (i.e. a checkout), but not include them in META.yml. Also protect against broken dists built on Macs before it happens --- diff --git a/Makefile.PL b/Makefile.PL index 6c70f1f..e5ca729 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -20,6 +20,64 @@ test_requires 'Alien::ActiveMQ' => '0.00003'; no_index package => 'StompTestApp'; no_index package => 'StompTestApp::Controller::TestController'; +my @force_build_requires_if_author = qw( + Test::NoTabs + Test::Pod + Test::Pod::Coverage + Pod::Coverage +); + +if ($Module::Install::AUTHOR) { + foreach my $module (@force_build_requires_if_author) { + build_requires $module; + } + darwin_check_no_resource_forks(); +} + +install_script glob('script/*.pl'); auto_install; WriteAll; +if ($Module::Install::AUTHOR) { + + # Strip out the author only build_requires from META.yml + # Need to do this _after_ WriteAll else it looses track of them + strip_author_only_build_requires(@force_build_requires_if_author); + + Meta->{values}{resources} = [ + [ 'license', => 'http://dev.perl.org/licenses/' ], + [ 'repository', => 'git://github.com/chrisa/catalyst-engine-stomp.git' ], + ]; + + Meta->write; +} + +sub darwin_check_no_resource_forks { + if ($^O eq 'darwin') { + my $osx_ver = `/usr/bin/sw_vers -productVersion`; + chomp $osx_ver; + + # TAR on 10.4 wants COPY_EXTENDED_ATTRIBUTES_DISABLE + # On 10.5 (Leopard) it wants COPYFILE_DISABLE + my $attr = $osx_ver eq '10.5' ? 'COPYFILE_DISABLE' : 'COPY_EXTENDED_ATTRIBUTES_DISABLE'; + + makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}. + qq{ echo "You must set the ENV variable $attr to true,"; }. + ' echo "to avoid getting resource forks in your dist."; exit 255; fi' }); + } +} + +sub strip_author_only_build_requires { + my @build_requires_to_strip = @_; + Meta->{values}{build_requires} = [ grep { + my $ok = 1; + foreach my $module (@build_requires_to_strip) { + if ($_->[0] =~ /$module/) { + $ok = 0; + last; + } + } + $ok; + } @{Meta->{values}{build_requires}} ]; +} +