diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/metas/perl | 12 | ||||
-rwxr-xr-x | lib/metas/perl.d/perl-dist | 59 | ||||
-rwxr-xr-x | lib/metas/perl.d/scrapecore | 8 |
3 files changed, 54 insertions, 25 deletions
diff --git a/lib/metas/perl b/lib/metas/perl index adb3b08..961084d 100755 --- a/lib/metas/perl +++ b/lib/metas/perl @@ -25,7 +25,7 @@ sub matchdist or err("$PROG: PKGVAR env variable is unset\n"); if(!-f "$var/cpandists" || -M "$var/cpandists" > 1) { - print STDERR "Refreshing local CPAN distribution list..."; + print STDERR "$PROG: Refreshing local CPAN data..."; my $cwd = getcwd(); chdir($var) or die "chdir: $!"; system('fetchcpan'); @@ -37,7 +37,8 @@ sub matchdist open(DISTS, '<', "$var/cpandists") or err("$PROG: open: $!"); while(<DISTS>) { my @f = split; - next unless(lc($f[0]) eq lc($dist)); + my $d = lc $f[0]; $d =~ tr/-_/--/s; + next unless($d eq lc($dist)); close(DISTS); return ($f[0], $f[2]); } @@ -76,8 +77,11 @@ sub main STDERR->autoflush(1); my ($realname, $cpath) = matchdist($dist); unless($realname){ - print STDERR "$PROG: failed to find perl dist similar to $dist\n"; - exit 1; + unless($forcechk){ + ## Don't print errors unless perl- package was requested. + print STDERR qq{$PROG: failed to find perl dist similar to '$dist'\n}; + } + return 2; } fetchdist($cpath); 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"; } |