Skip to contentSkip to conversation

scancpan: update with MetaCPAN API v1

PATCH New Francois Perrad 4 participants 6 messages Jun 14, 2017 – Jun 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 scancpan: update with MetaCPAN API v1

The API v0 is shutdown.
see https://bugs.busybox.net/show_bug.cgi?id=9951

---
 support/scripts/scancpan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
support/scripts/scancpan +2 -2
index 8d44ed90..f87cdce7 100755
@@ -521,7 +521,7 @@ my %deps_runtime;       # name -> list of target dependencies
 my %deps_optional;      # name -> list of optional target dependencies
 my %license_files;      # name -> list of license files
 my %checksum;           # author -> list of checksum
-my $mcpan = MetaCPAN::API::Tiny->new();
+my $mcpan = MetaCPAN::API::Tiny->new(base_url => 'http://fastapi.metacpan.org/v1');
 my $ua = HTTP::Tiny->new();
 
 sub get_checksum {
@@ -538,7 +538,7 @@ sub get_checksum {
 
 sub get_manifest {
     my ($author, $distname, $version) = @_;
-    my $url = qq{http://api.metacpan.org/source/${author}/${distname}-${version}/MANIFEST};
+    my $url = qq{http://fastapi.metacpan.org/source/${author}/${distname}-${version}/MANIFEST};
     my $response = $ua->get($url);
     return $response->{content};
 }
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 2/3 scancpan: refactor with MetaCPAN::API source()

instead of get_manifest()

---
 support/scripts/scancpan | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
support/scripts/scancpan +3 -8
index f87cdce7..82c77a85 100755
@@ -536,13 +536,6 @@ sub get_checksum {
     return $chksum->{$basename}, $basename;
 }
 
-sub get_manifest {
-    my ($author, $distname, $version) = @_;
-    my $url = qq{http://fastapi.metacpan.org/source/${author}/${distname}-${version}/MANIFEST};
-    my $response = $ua->get($url);
-    return $response->{content};
-}
-
 sub is_xs {
     my ($manifest) = @_;
     # This heuristic determines if a module is a native extension, by searching
@@ -572,7 +565,9 @@ sub fetch {
         say qq{fetch ${name}} unless $quiet;
         my $result = $mcpan->release( distribution => $name );
         $dist{$name} = $result;
-        my $manifest = get_manifest( $result->{author}, $name, $result->{version} );
+        my $manifest = $mcpan->source( author => $result->{author},
+                                       release => $name . q{-} . $result->{version},
+                                       path => 'MANIFEST' );
         $need_dlopen{$name} = is_xs( $manifest );
         $license_files{$name} = find_license_files( $manifest );
         my %build = ();
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 3/3 scancpan: refactor with $mirror

In reply to Francois Perrad
---
 support/scripts/scancpan | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
support/scripts/scancpan +4 -2
index 82c77a85..62df2253 100755
@@ -521,6 +521,7 @@ my %deps_runtime;       # name -> list of target dependencies
 my %deps_optional;      # name -> list of optional target dependencies
 my %license_files;      # name -> list of license files
 my %checksum;           # author -> list of checksum
+my $mirror = 'http://cpan.metacpan.org';        # a CPAN mirror
 my $mcpan = MetaCPAN::API::Tiny->new(base_url => 'http://fastapi.metacpan.org/v1');
 my $ua = HTTP::Tiny->new();
 
@@ -529,7 +530,8 @@ sub get_checksum {
     my($path) = $url =~ m|^[^:/?#]+://[^/?#]*([^?#]*)|;
     my($basename, $dirname) = fileparse( $path );
     unless ($checksum{$dirname}) {
-        my $response = $ua->get(qq{http://cpan.metacpan.org${dirname}CHECKSUMS});
+        my $url = $mirror . $dirname . q{CHECKSUMS};
+        my $response = $ua->get($url);
         $checksum{$dirname} = $response->{content};
     }
     my $chksum = Safe->new->reval($checksum{$dirname});
@@ -720,7 +722,7 @@ while (my ($distname, $dist) = each %dist) {
         my $sha256 = $checksum->{sha256};
         say qq{write ${hashname}} unless $quiet;
         open my $fh, q{>}, $hashname;
-        say {$fh} qq{# retrieved by scancpan from http://cpan.metacpan.org/};
+        say {$fh} qq{# retrieved by scancpan from ${mirror}/};
         say {$fh} qq{md5    ${md5} ${filename}};
         say {$fh} qq{sha256 ${sha256} ${filename}};
         close $fh;
Signature · 1 line
2.11.0
#3 lore raw

PATCH v2 1/3 scancpan: update with MetaCPAN API v1

In reply to Francois Perrad

Hello,

Quoted 7 lines · Francois Perrad

The API v0 is shutdown.
see https://bugs.busybox.net/show_bug.cgi?id=9951

---
 support/scripts/scancpan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Series applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH v2 1/3 scancpan: update with MetaCPAN API v1

2017-06-15 22:36 GMT+02:00 Thomas Petazzoni <
[email protected]>:

Quoted 6 lines

Hello,

Quoted 3 lines · Francois Perrad

The API v0 is shutdown.
see https://bugs.busybox.net/show_bug.cgi?id=9951

Quoted 7 lines
Quoted 4 lines
---
 support/scripts/scancpan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Series applied. Thanks!

must be committed also in maintenance branches.

Fran?ois

Quoted 10 lines

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170618/81569a47/attachment-0001.html>

#5 lore raw

PATCH v2 1/3 scancpan: update with MetaCPAN API v1

Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fran?ois" == Fran?ois Perrad <[email protected]> writes:

2017-06-15 22:36 GMT+02:00 Thomas Petazzoni <
thomas.petazzoni at free-electrons.com>:

Quoted 11 lines

Hello,

Quoted 7 lines · Francois Perrad

The API v0 is shutdown.
see https://bugs.busybox.net/show_bug.cgi?id=9951

---
 support/scripts/scancpan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

Series applied. Thanks!

must be committed also in maintenance branches.

Committed to 2017.02.x and 2017.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard