diff --git a/lib/Simba/Build.pm b/lib/Simba/Build.pm new file mode 100644 index 0000000..0e60734 --- /dev/null +++ b/lib/Simba/Build.pm @@ -0,0 +1,33 @@ +package Simba::Build; +use strict; +use warnings; + +use Module::Build; +use Data::Dumper; + +our @ISA = ('Module::Build'); + +sub ACTION_install { + my $self = shift; + # print STDERR Dumper($self), "\n"; + print STDERR $self->install_path->{lib}, "\n"; + print STDERR Dumper($self->install_map), "\n"; + my $lib = $self->install_map->{'blib/lib'}; + for my $script (glob('blib/script/*')) { + open (my $in, '<', $script) or die "cannot open $script: $!"; + open (my $out, '>', "$script.$$") or die "cannot open $script.$$: $!"; + while (<$in>) { + if (m{^use lib 'blib/lib'}) { + print $out "use lib '$lib';\n"; + } else { + print $out $_ or die "cannot write to $script.$$: $!"; + } + } + close $in or die "cannot close $script: $!"; + close $out or die "cannot close $script.$$: $!"; + rename "$script.$$", $script or die "cannot rename $script.$$ to $script: $!"; + } + $self->SUPER::ACTION_install; +} + +