[Catalyst-dev] Patch to support inclusion of library files during PAR creation

Stephen Shorrock stephen.shorrock at googlemail.com
Fri Jan 8 15:40:27 GMT 2010


Hi I wasn't sure whether to contact the 'catalyst' or 'catalyst-dev',
but here goes.

I was wanting to bundle my catalyst app into an PAR /executable with
some lib files so that the target machine didn't require these
installed.  I was unable to achieve this after the applications PAR
had been produced (ie after 'make catalyst_par') and it seemed
necessary to supply the -l option when initially creating the PAR.
The following patch adds the ability to supply a list of libraries to
be bundled into the PAR file by adding a call to
calalyst_par_sharedlibs in Makefile.PL.

I appreciate that there might be a way to add the libraries to the
archive after 'make catalyst_par' but I was unable to find it or
reference. I would be interested in hearing about an alternative
solution if the following is seen as a bad idea:

Regards
Stephen

--- /opt/web-world/lib/perl5/site_perl/5.8.8/Module/Install/Catalyst.pm
+++ /opt/web-world/lib/perl5/site_perl/5.8.8/Module/Install/Catalyst.pm
@@ -23,6 +23,7 @@
 our $MULTIARCH = 0;
 our $SCRIPT    = '';
 our $USAGE     = '';
+our @SHAREDLIBS = ();

 =head1 NAME

@@ -134,15 +135,26 @@
     $usage =~ s/"/\\"/g;
     my $class_string = join "', '", @CLASSES;
     $class_string = "'$class_string'" if $class_string;
+    my $sharedlibs_string = join "', '", @SHAREDLIBS;
+    $sharedlibs_string = "'$sharedlibs_string'" if $sharedlibs_string;
     $self->postamble(<<EOF);
 catalyst_par :: all
-\t\$(NOECHO) \$(PERL) -Ilib -Minc::Module::Install
-MModule::Install::Catalyst
-e"Catalyst::Module::Install::_catalyst_par( '$par', '$name', {
CLASSES => [$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], CORE => $CORE, ENGINE => '$ENGINE',
MULTIARCH => $MULTIARCH, SCRIPT => '$SCRIPT', USAGE => q#$usage#,
SHAREDLIBS=>[$sharedlibs_string] } )"
 EOF
     print <<EOF;
 Please run "make catalyst_par" to create the PAR package!
 EOF
 }

+=head2 calalyst_par_sharedlibs(@libs)
+
+=cut
+
+sub catalyst_par_sharedlibs{
+    my ( $self, @libs ) = @_;
+    push @SHAREDLIBS, @libs;
+}
+
 =head2 catalyst_par_core($core)

 =cut
@@ -213,6 +225,7 @@
     my $SCRIPT    = $opts->{SCRIPT};
     my $MULTIARCH = $opts->{MULTIARCH};
     my $CORE      = $opts->{CORE};
+    my $SHAREDLIBS = $opts->{SHAREDLIBS} || [];

     my $name = $class_name;
     $name =~ s/::/_/g;
@@ -324,7 +337,8 @@
         'a' => [ grep( !/par.pl/, glob '.' ) ],
         'p' => 1,
         'B' => $CORE,
-        'm' => $MULTIARCH
+        'm' => $MULTIARCH,
+        'l' => $SHAREDLIBS
     );
     App::Packer::PAR->new(
         frontend  => 'Module::ScanDeps',
@@ -354,4 +368,3 @@
 =cut

 1;



More information about the Catalyst-dev mailing list