Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: buildpacked.pl - Pack script and dependencies into self-extracting bash script

by Anonymous Monk
on Aug 21, 2012 at 19:35 UTC ( #988836=note: print w/ replies, xml ) Need Help??


in reply to buildpacked.pl - Pack script and dependencies into self-extracting bash script

Congratulations, you've reinvented shar/ fatpack

Congratulations, pp --perlscript can almost do that too :) provided you use -X coremod to exclude core modules

system qw{ pp -M Data::Dump::FilterContext -M Data::Dump::Filtered -M Data::Dump -X File::Glob -X threads -X Symbol -X subs -X overload -X Exporter -X vars -X utf8 -X strict -X base -X Carp -X Config -X Exporter::Heavy -X feature -X XSLoader -X DynaLoader -X Scalar::Util -X mro -X warnings::register -X integer -X warnings -X MIME::Base64 -X Text::ParseWords -X List::Util -C CACHEFILE --perlscript -o ddvars -e } => 'use Data::Dump; dd\@INC,\%ENV; ';

Sure various lib/unicore/lib/IDC/N.pl get packed as well, but no binary components get packed, no .dll's or .so's


Comment on Re: buildpacked.pl - Pack script and dependencies into self-extracting bash script
Select or Download Code
Re^2: buildpacked.pl - Pack script and dependencies into self-extracting bash script
by Anonymous Monk on Aug 21, 2012 at 20:02 UTC

    So here is my version :)

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump; use Module::Corelist; @ARGV or die "Usage: $0 outfile infile infile infile\n"; my $outfile = shift || 'ddname'; my @script = @ARGV ? @ARGV : qw[ dd-inc.pl ]; my @cache = qw[ -C CACHEFILE ]; my %exclude; # we don't pack core modules available in this perl my %include; for ( qx[scandeps @cache -B -V @script ] ){ /^'([^']+)'/ or next; my $mod = $1; my $first = Module::CoreList->first_release($mod); my $removed = Module::CoreList->removed_from($mod); $exclude{$mod}++ if defined $first and $first < $] ; # core in + this perl $include{$mod}++ if defined $removed and $] >= $removed; # removed + (not core) in this perl } my @exclude = map {; '-X', $_ } keys %exclude; my @include = map {; '-M', $_ } keys %include; #~ my @args = ( qw[ pp --perlscript --output ] => $outfile, @exclude, +@include, @script ); my @args = ( qw[ pp -P -o ] => $outfile, @exclude, @include, @script ) +; dd \@args; system @args; __END__

      Impressive coding and deft manipulation - nicely done. I downloaded it and tweaked it to actually run (a typo and Dump->Dumper, print Dumper instead of dd, etc) - nicely done indeed.

      However, the resulting file from PAR still gives an error when run on another machine:

      Can't locate PAR/Heavy.pm in @INC (@INC contains: ...snip...) at /usr/bin/par.pl line 348.

      I even attempted to force inclusion of PAR::Heavy by adding push @include, qw(-M PAR::Heavy); after my @include (Admittedly, I gave up after a few moments of it not working - I didn't try *too* hard) - unfortunately, that didn't change the error message on the other machine at all.

        Well it does require PAR to be installed on the other machine :/
Re^2: buildpacked.pl - Pack script and dependencies into self-extracting bash script
by jbryan (Acolyte) on Aug 21, 2012 at 20:06 UTC

    Ahh, so is that different than what the following does:

    # From http://search.cpan.org/~rschupp/PAR-Packer-1.013/lib/pp.pm: % pp -P -o out.pl file % pp -B -p -o out.pl file

    Neither of the resulting files would run cross-platform (e.g. when copied from 64bit laptop to 64bit machine, both running CentOS, or the other way around - 32bit to 64bit.) Even though no .so/etc were copied, the header on the file that PAR added require'd DynaLoader, which caused it to fail with an error like Undefined subroutine &DynaLoader::bootstrap called at /usr/lib64/perl5/XSLoader.pm line 111. (This is from a file generated with pp on my 64bit laptop last night and ran on my 32bit desktop here at the office.)

    I spent several hours googling and trying various options, though I admit I didn't try that -X option (must have glossed over that thru my sleep-deprived hazy vision!)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988836]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-08-31 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls