Skip to content

Commit

Permalink
add a script to build a portable copy of perl
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Apr 25, 2015
1 parent 0f2c558 commit 7684356
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
/kryonet*
/IO-Async-*
/cpanfile.snapshot
/perl
/Logfile.CSV
50 changes: 50 additions & 0 deletions build_perl.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use strictures;

# this builds a portable copy of a windows system perl by scanning a
# procmon log file and copying all files read by perl.exe in the capture

use 5.010;
use Text::CSV_XS 'csv';
use IO::All -binary, -utf8;

run();

sub run {
my $base_path = $ARGV[0] || "c:\\perl";
$base_path .= "\\";
my $base_path_q = quotemeta $base_path;
my $target_base = $ARGV[1] || "perl";

my @log = do {
my $data = io( "Logfile.CSV" )->all;
$data =~ s/^.*?\n//;
@{ csv in => \$data };
};
for my $filter (
sub { $_->[1] eq "perl.exe" }, #
sub { $_->[4] eq "CreateFile" },
sub { $_->[7] eq "SUCCESS" },
sub { $_->[6] =~ /^$base_path_q/i },
sub { $_->[6] !~ /\.bs$/ },
sub { -f $_->[6] },
)
{
@log = grep $filter->( $_ ), @log;
}

my %files = map { $_->[6] => 1 } @log;
my @files = sort keys %files;

for my $file ( @files ) {
say $file;
my $io = io( $file )->file;
my $path = $io->filepath;
$path =~ s/^$base_path_q//i;
my $target_dir = io->catdir( $target_base, $path );
$target_dir->mkpath if !$target_dir->exists;
my $target_file = io->catfile( $target_dir->pathname, $io->filename )->name;
$io->copy( $target_file );
}

return;
}
1 change: 1 addition & 0 deletions client_local.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perl\bin\perl bin\microidium
4 changes: 3 additions & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ copyright_holder = Christian Walde
copyright_year = 2014

[@MITHALDU]
exclude_match = ^(scratch|nytprof|kryonet|IO-Async-|local)
exclude_match = ^(scratch|nytprof|kryonet|IO-Async-|local|perl|Logfile.CSV)
gitignore = /local*
gitignore = /nytprof*
gitignore = /kryonet*
gitignore = /IO-Async-*
gitignore = /cpanfile.snapshot
gitignore = /perl
gitignore = /Logfile.CSV
skip_prereq = ^Microidium::Client$
skip_prereq = ^IO::Async::Internals::Connector$

Expand Down
1 change: 1 addition & 0 deletions server_local.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perl\bin\perl bin\microidium_server

0 comments on commit 7684356

Please sign in to comment.