Mailing List Archive

Patch to support inclusion of library files during PAR creation
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;

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Patch to support inclusion of library files during PAR creation [ In reply to ]
Stephen Shorrock wrote:
> 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:

Can you not just require the libraries which you need in your
application class in some way so that par detects them when building the
.par file?

Your patch looks reasonable from a very quick skim, but I don't think it
should be needed.

Cheers
t0m

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Patch to support inclusion of library files during PAR creation [ In reply to ]
Tomas Doran napsal(a):
> Stephen Shorrock wrote:
> > 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:
>
> Can you not just require the libraries which you need in your
> application class in some way so that par detects them when building the
> .par file?
>
> Your patch looks reasonable from a very quick skim, but I don't think it
> should be needed.

That reminds me my patch I have implemented in Catalyst::Devel branche
that is available here:
http://github.com/rafl/catalyst-devel/tree/par_options

The patch is quite simple and provides more general way of passing
additional params to PAR creation process, it takes a string with
parameters in exactly the same syntax as pp utility and push them into
PAR creation process (for more info see short POD doc I have written for
it). All existing commands like catalyst_par_core are still supported - see:
http://github.com/rafl/catalyst-devel/commit/4b26a2f0a32b1e21f27f5f493145bafd6e7dab44

My patch was a part of an idea that I have put aside for a while but
I'll be happy if my code could be useful for anybody.

Anyway, I agree with Stephen that there are situations when you need to
customize options for creating catalyst app PAR packcages.

--
kmx
Re: Re: Patch to support inclusion of library files during PAR creation [ In reply to ]
On 9 Jan 2010, at 08:53, kmx wrote:

> That reminds me my patch I have implemented in Catalyst::Devel
> branche that is available here:
> http://github.com/rafl/catalyst-devel/tree/par_options

I've merged this to master having read it as it looks good. Sorry
about having never got to that before.

However, I believe right now PAR support is broken (as the script
modules aren't included) :(

Does anyone fancy having a crack at this?

Cheers
t0m


_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev