diff options
Diffstat (limited to 'lib/metas/perl.d')
-rwxr-xr-x | lib/metas/perl.d/perl-dist | 59 | ||||
-rwxr-xr-x | lib/metas/perl.d/scrapecore | 8 |
2 files changed, 46 insertions, 21 deletions
diff --git a/lib/metas/perl.d/perl-dist b/lib/metas/perl.d/perl-dist index cefcaf9..3259fd8 100755 --- a/lib/metas/perl.d/perl-dist +++ b/lib/metas/perl.d/perl-dist @@ -273,42 +273,63 @@ sub _distsofmods my (@mods) = @_; return () if(@mods == 0); + @mods = _nocore(@mods); - my $var = $ENV{'PKGVAR'} - or die "$PROG: PKGVAR env variable is unset\n"; + my $var = _vardir(); open(my $fh, '<', "$var/cpanmods") or die "$PROG: failed to open $var/cpanmods: $!"; - my (@hunted, %dists) = @mods; + my %mods = map { ($_ => 1) } @mods; + my %dists; local $/ = ''; RECLOOP: while(my $rec = <$fh>) { - my ($dist, @modvers) = split(/\n/, $rec); - for (@modvers) { - my ($m) = split; - - CMPLOOP: - for my $i (0 .. $#hunted) { - next CMPLOOP unless($hunted[$i] eq $m); - $dists{$m} = $dist; - splice @hunted, $i, 1; - last RECLOOP if(@hunted == 0); - last CMPLOOP; - } + last RECLOOP unless(keys %mods > 0); + + my($dist, @mvs) = split(/\n/, $rec); + MODLOOP: + for(@mvs){ + my($m) = split; + my $fnd = delete($mods{$m}) or next; + $dists{$m} = $dist; } } - if (@hunted) { - for my $lost (@hunted) { - print STDERR "$PROG: failed to find module $lost\n"; + my @lost = keys %mods; + if(@lost){ + for my $m (@lost){ + print STDERR "$PROG: failed to find module $m\n"; } - exit 2; + exit 1; } return %dists; } +sub _nocore +{ + my (@mods) = @_; + + my $path = _vardir() . '/coremods'; + open(my $if, '<', $path) or die "$PROG: open $path: $!"; + + my %mods = map { ($_ => 1) } @mods; + while(<$if>){ + my ($m) = split; + delete $mods{$m}; + } + + close($if); + return keys %mods; +} + +sub _vardir +{ + return $ENV{'PKGVAR'} + or die "$PROG: PKGVAR env variable is unset\n"; +} + #----------------------------------------------------------------------------- package main; diff --git a/lib/metas/perl.d/scrapecore b/lib/metas/perl.d/scrapecore index eae1b21..2e1aba3 100755 --- a/lib/metas/perl.d/scrapecore +++ b/lib/metas/perl.d/scrapecore @@ -205,8 +205,9 @@ sub _delmatch sub coreonly { - my (%mods) = map { @$_ } @_; - my $path = "$ENV{'PKGVAR'}/cpanmods"; + my %mods = map { @$_ } @_; + my $var = $ENV{'PKGVAR'} || "$ENV{'HOME'}/var"; + my $path = "$var/cpanmods"; open(my $if, '<', $path) or die("open $path: $!"); my @dists; @@ -233,5 +234,8 @@ my @mods = (CoreDist::findmods($perldir), CoreLib::findmods($perldir)); +## Embedded modules without any files... +push @mods, [qw/ Config 1/]; + @mods = coreonly(@mods); for my $mv (@mods){ print "@$mv\n"; } |