use Fatal;
use File::Spec;
-use File::Copy qw/copy/;
-use List::Util qw/max reduce/;
+use File::Copy qw<copy>;
+use List::Util qw<max reduce>;
use Storable ();
use Term::ANSIColor;
-use CPAN::DistnameInfo;
-BEGIN {
- my $old_cdi_new = \&CPAN::DistnameInfo::new;
- die 'CPAN::DistnameInfo is not loaded' unless $old_cdi_new;
- my $new_cdi_new = sub {
- my $dist = $old_cdi_new->(@_);
- $dist->{version} =~ s/-withoutworldwriteables$//;
- $dist;
- };
- no warnings 'redefine';
- *CPAN::DistnameInfo::new = $new_cdi_new;
-}
+use CPAN::DistnameInfo 0.11;
-use Capture::Tiny qw/capture/;
+use Capture::Tiny qw<capture>;
use LWP::UserAgent;
use Parse::CPAN::Packages::Fast;
my %is_on_cpan = (
'Audio-CD-disc-cover' => 0,
+ 'Video-Frequencies' => 0,
+ 'Sphinx-Search' => 1,
'WattsUp-Daemon' => 1,
);
sub parse_portage_tree {
my $pcp = Parse::CPAN::Packages::Fast->new(PACKAGES);
- for my $category (qw/perl-core dev-perl/) {
+ for my $category (qw<perl-core dev-perl>) {
p(0, "Browsing the $category category.\n");
my $cat_dir = File::Spec->catdir(PORTAGE, $category);
my $pkg_name = (File::Spec->splitdir($pkg_dir))[-1];
+ my $last = reduce { $a->[1] > $b->[1] ? $a : $b }
+ grep $_->[1] != 9999,
+ map [ $_, CPANPLUS::Dist::Gentoo::Atom->new_from_ebuild($_) ],
+ glob File::Spec->catfile($pkg_dir, "$pkg_name-*");
+ my ($ebuild, $atom) = @$last;
+ p(1, "%s/%s-%s\n", map $atom->$_, qw<category name version>);
+
if (exists $is_on_cpan{$pkg_name} and not $is_on_cpan{$pkg_name}) {
p(2, colored("$pkg_name is not a CPAN distribution (forced)", 'bright_red')
. "\n");
next;
}
- my $last = reduce { $a->[1] > $b->[1] ? $a : $b }
- map [ $_, CPANPLUS::Dist::Gentoo::Atom->new_from_ebuild($_) ],
- glob File::Spec->catfile($pkg_dir, "$pkg_name-*");
- my ($ebuild, $atom) = @$last;
- p(1, "%s/%s-%s\n", map $atom->$_, qw/category name version/);
-
my $uri;
if (exists $fetched_uri{$ebuild}) {
$uri = $fetched_uri{$ebuild};
die "system(\"@cmd\") returned $ret and/or failed with status $code";
}
- while ($err =~ /SRC_URI=((['"]).*?\2|\S+)/gs) {
- $uri = $1;
- $uri =~ s{^(['"])(.*?)\1$}{$2}s;
+ my %map;
+ while ($err =~ /([a-zA-Z0-9_]+)=((['"]).*?\3|\S+)/gs) {
+ my $key = $1;
+ my $val = $2;
+ $val =~ s{^(['"])(.*?)\1$}{$2}s;
+ $map{$key} = $val;
+ }
+
+ $uri = $map{SRC_URI};
+ unless (defined $uri) {
+ my $author = $map{MODULE_AUTHOR};
+ if (defined $author) {
+ my ($au, $a) = $author =~ /^((.).)/;
+ my $dist_version = $map{MODULE_VERSION};
+ $dist_version = $last->[1] unless defined $dist_version;
+ $uri = "mirror://cpan/$a/$au/$author/$pkg_name/$dist_version.tar.gz";
+ }
}
+
$fetched_uri{$ebuild} = $uri;
Storable::store([
$timestamp,
local $@;
eval { $pcp->latest_distribution($pseudo_dist->dist) };
};
+
+ unless (defined $latest_dist) {
+ print "no\n";
+ p(2, 'is similiar to a module indexed in another distribution of the CPAN... ');
+ (my $mod_name = $pkg_name) =~ s/-/::/g;
+ $latest_dist = do {
+ local $@;
+ eval {
+ my $module = $pcp->package($mod_name);
+ defined $module ? $module->distribution : undef;
+ };
+ };
+ if (defined $latest_dist) {
+ # Re-forge the pseudo dist so that it will pick up the correct dist
+ # name when looking for a mismatch.
+ $pseudo_dist = CPAN::DistnameInfo->new(
+ $latest_dist->dist . '-' . $pseudo_dist->version
+ . '.' . $pseudo_dist->extension
+ );
+ }
+ }
+
my ($latest_file, $latest_author);
if (defined $latest_dist) {
$latest_file = $latest_dist->filename;