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__