When there's a relative path in @INC (e.g. with -Mlib=./local/lib/perl5),
FatPacker died with `Can't open local/lib/perl5/.../.packlist` even if the
file exists, because of File::Find's chdir, and $File::Find::name is yet
relative.
This patch adds 'no_chdir' option to File::Find to stop chdir'ing to
the directories, and then expand the %INC entries to fullpath with
Cwd::abs_path, so that it will hopefully match with what you have in
.packlist content.
Reproduce:
cpanm -l local Plack
perl -Mlib=local/lib/perl5 -S fatpack packlists-for Plack.pm
}
my @search = grep -d $_, map catdir($_, 'auto'), @INC;
my %pack_rev;
- my $cwd = cwd;
- find(sub {
- return unless $_ eq '.packlist' && -f $_;
- $pack_rev{$_} = $File::Find::name for lines_of $File::Find::name;
+ find({
+ no_chdir => 1,
+ wanted => sub {
+ return unless /[\\\/]\.packlist$/ && -f $_;
+ $pack_rev{$_} = $File::Find::name for lines_of $File::Find::name;
+ },
}, @search);
- chdir($cwd) or die "Couldn't chdir back to ${cwd} after find: $!";
- my %found; @found{map +($pack_rev{$INC{$_}}||()), @targets} = ();
+ my %found; @found{map +($pack_rev{Cwd::abs_path($INC{$_})}||()), @targets} = ();
sort keys %found;
}