From: Tatsuhiko Miyagawa Date: Wed, 3 Apr 2013 21:39:53 +0000 (-0700) Subject: Stop chdir when finding packlist. Absolutify %INC path in case there's a relative... X-Git-Tag: v0.009018~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0612cca16821f328d0e9c2ea4c18d307ee6dc2fc;p=p5sagit%2FApp-FatPacker.git Stop chdir when finding packlist. Absolutify %INC path in case there's a relative path in @INC. 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 --- diff --git a/lib/App/FatPacker.pm b/lib/App/FatPacker.pm index 2ae6f3a..c35aa25 100644 --- a/lib/App/FatPacker.pm +++ b/lib/App/FatPacker.pm @@ -147,13 +147,14 @@ sub packlists_containing { } 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; }