Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

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


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

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__


Comment on Re^2: buildpacked.pl - Pack script and dependencies into self-extracting bash script
Download Code
Re^3: buildpacked.pl - Pack script and dependencies into self-extracting bash script
by jbryan (Acolyte) on Aug 21, 2012 at 20:21 UTC

    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 :/

        Well, I guess that's my nitch use case for this script then :-) I want to generate a portable file that doesn't require any dependencies on the other machine other than the core modules of Perl itself (for some version of perl.) Or is that an unreasonable goal? Or a goal already covered by some other script/program I'm as yet unaware of? Cheers!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2014-12-21 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (103 votes), past polls