3 # This scrit is meant to guess gentooisms by looking into the portage tree.
4 # A really good one would use the CPANPLUS API to check if the dist name
5 # candidates are really on CPAN.
11 use List::Util qw/max/;
13 use constant PORTAGE => '/usr/portage';
18 'Audio-CD-disc-cover' => 1,
28 for my $category (qw/perl-core dev-perl/) {
29 my $dir = PORTAGE . '/' . $category;
33 my $eb = (sort glob "$dir/$name/$name-*")[-1];
34 open my $fh, '<', $eb;
36 $on_cpan = $where{$name} if exists $where{$name};
38 $on_cpan = 1 if not defined $on_cpan
39 and /(?:MODULE_AUTHOR|SRC_URI=.*?(?i:cpan))/;
40 if (not defined $pn and /_PN?=(.*)/) {
42 if ($pn =~ /^\s*["']?\s*\$\{PN?\}/) {
46 $pn =~ s!\$[{(][^/]*?[})]!!g;
47 $pn =~ s!\$\{P?V.*?\}!!g;
48 $pn =~ s/^\s*["']?\s*-*\s*//;
49 $pn =~ s/\s*-*\s*["']?\s*$//;
51 if ($pn =~ m!\$\{PN?(/.*?/(?:.*/?)?)\}!) {
53 $s .= '/' if $s =~ tr!/!! <= 2;
54 eval "(\$pn = \$name) =~ s$s";
58 if ($pn and $pn ne $name) {
60 $gentooism{$pn} = $name;
61 } elsif (not defined $on_cpan) {
62 print STDERR "'$pn' => '$name' may not be on CPAN\n";
68 my $max = max map length, keys %gentooism;
70 print STDERR +(keys %gentooism) . " gentooisms found\n";
72 print "our %gentooism = (\n";
73 printf " '%s'%s => '%s',\n", $_, (' ' x ($max - length)), $gentooism{$_}
74 for sort keys %gentooism;