X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FModule%2FInstall%2FCatalyst.pm;h=d081c339c2b9b30d9dc66e91acca8d7e178483d4;hb=ad4ffd74b803f5187f9ee2b07d76d4bd206af74a;hp=ccfdf01729da3f0e363cdf67e73e32ad0c99a9c9;hpb=d99c87182ba2050eb7a6354291e665b5cd35b96b;p=catagits%2FCatalyst-Devel.git diff --git a/lib/Module/Install/Catalyst.pm b/lib/Module/Install/Catalyst.pm index ccfdf01..d081c33 100644 --- a/lib/Module/Install/Catalyst.pm +++ b/lib/Module/Install/Catalyst.pm @@ -8,8 +8,10 @@ require Module::Install::Base; use File::Find; use FindBin; -use File::Copy::Recursive 'rcopy'; +use File::Copy::Recursive; use File::Spec (); +use Getopt::Long (); +use Data::Dumper; my $SAFETY = 0; @@ -19,24 +21,23 @@ our @IGNORE = debian build-stamp install-stamp configure-stamp/; our @CLASSES = (); our $ENGINE = 'CGI'; -our $CORE = 0; -our $MULTIARCH = 0; our $SCRIPT = ''; our $USAGE = ''; +our %PAROPTS = (); =head1 NAME Module::Install::Catalyst - Module::Install extension for Catalyst - + =head1 SYNOPSIS - + use inc::Module::Install; - + name 'MyApp'; all_from 'lib/MyApp.pm'; - + requires 'Catalyst::Runtime' => '5.7014'; - + catalyst_ignore('.*temp'); catalyst_ignore('.*tmp'); catalyst; @@ -57,6 +58,14 @@ command called in C. sub catalyst { my $self = shift; + + if($Module::Install::AUTHOR) { + $self->admin->copy_package( + 'File::Copy::Recursive', + $INC{"File/Copy/Recursive.pm"}, + ); + } + print < and L). =cut @@ -134,9 +143,13 @@ sub catalyst_par { $usage =~ s/"/\\"/g; my $class_string = join "', '", @CLASSES; $class_string = "'$class_string'" if $class_string; + local $Data::Dumper::Indent = 0; + local $Data::Dumper::Terse = 1; + local $Data::Dumper::Pad = ' '; + my $paropts_string = Dumper(\%PAROPTS) || "{ }"; $self->postamble(< [$class_string], CORE => $CORE, ENGINE => '$ENGINE', MULTIARCH => $MULTIARCH, SCRIPT => '$SCRIPT', USAGE => q#$usage# } )" +\t\$(NOECHO) \$(PERL) -Ilib -Minc::Module::Install -MModule::Install::Catalyst -e"Catalyst::Module::Install::_catalyst_par( '$par', '$name', { CLASSES => [$class_string], PAROPTS => $paropts_string, ENGINE => '$ENGINE', SCRIPT => '$SCRIPT', USAGE => q#$usage# } )" EOF print < command from L package. + +Example: + + # part of your Makefile.PL + + catalyst_par_options("--verbose=2 -f Bleach -z 9"); + # verbose mode; use filter 'Bleach'; zip with compression level 9 + catalyst; + +Note1: There is no reason to use catalyst_par_options() command multiple times +as you can spacify in "$optstring" as many options as you want. Still, it +is supported to call catalyst_par_options() more than once. In that case the +specified options are merged (collisions are handled on principle "later wins"). +BEWARE: you are discouraged from using parameters -a -A -X -f -F -I -l -M in +multiple catalyst_par_options() as they are not merged but replaced as you would +expected. + +Note2: By default the options "-x -p -o=.par" are set and option "-n" +is unset. This default always overrides whatever you specify by +catalyst_par_options(). + +=cut + +sub catalyst_par_options { + my ( $self, $optstring ) = @_; + eval "use PAR::Packer ()"; + if ($@) { + warn "WARNING: catalyst_par_options ignored - you need PAR::Packer\n" + } + else { + my $p = Getopt::Long::Parser->new(config => ['no_ignore_case']); + my %o; + require Text::ParseWords; + { + local @ARGV = Text::ParseWords::shellwords($optstring); + $p->getoptions(\%o, PAR::Packer->options); + } + %PAROPTS = ( %PAROPTS, %o); + } } =head2 catalyst_par_script($script) @@ -211,8 +270,7 @@ sub _catalyst_par { my $CLASSES = $opts->{CLASSES} || []; my $USAGE = $opts->{USAGE}; my $SCRIPT = $opts->{SCRIPT}; - my $MULTIARCH = $opts->{MULTIARCH}; - my $CORE = $opts->{CORE}; + my $PAROPTS = $opts->{PAROPTS}; my $name = $class_name; $name =~ s/::/_/g; @@ -318,14 +376,16 @@ EOF open my $olderr, '>&STDERR'; open STDERR, '>', File::Spec->devnull; my %opt = ( + %{$PAROPTS}, + # take user defined options first and override them with harcoded defaults 'x' => 1, 'n' => 0, 'o' => $par, - 'a' => [ grep( !/par.pl/, glob '.' ) ], 'p' => 1, - 'B' => $CORE, - 'm' => $MULTIARCH ); + # do not replace the whole $opt{'a'} array; just push required default value + push @{$opt{'a'}}, grep( !/par.pl/, glob '.' ); + App::Packer::PAR->new( frontend => 'Module::ScanDeps', backend => 'PAR::Packer',