]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - samples/gengentooisms
Use MODULE_{AUTHOR,VERSION} when SRC_URI is not specified in the ebuild
[perl/modules/CPANPLUS-Dist-Gentoo.git] / samples / gengentooisms
index 34d5869fea17a58492a11f0ba268c76641fd3465..980ecbf7dcaf56b8b4418080ad5deb7a6e347853 100755 (executable)
@@ -5,14 +5,14 @@ use warnings;
 
 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 0.11;
 
-use Capture::Tiny qw/capture/;
+use Capture::Tiny qw<capture>;
 use LWP::UserAgent;
 use Parse::CPAN::Packages::Fast;
 
@@ -74,7 +74,7 @@ my (@not_on_cpan, @unfindable, @missing, %name_mismatch, %version);
 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);
@@ -85,10 +85,11 @@ sub parse_portage_tree {
    my $pkg_name = (File::Spec->splitdir($pkg_dir))[-1];
 
    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-*");
+               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/);
+   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')
@@ -111,10 +112,25 @@ sub parse_portage_tree {
      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,