[v2 1/3] scancpan: update with MetaCPAN API v1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[v2 1/3] scancpan: update with MetaCPAN API v1

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

Signed-off-by: Francois Perrad <[hidden email]>
---
 support/scripts/scancpan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/scripts/scancpan b/support/scripts/scancpan
index 8d44ed90..f87cdce7 100755
--- a/support/scripts/scancpan
+++ b/support/scripts/scancpan
@@ -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};
 }
--
2.11.0

_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot
Reply | Threaded
Open this post in threaded view
|

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

Francois Perrad
instead of get_manifest()

Signed-off-by: Francois Perrad <[hidden email]>
---
 support/scripts/scancpan | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/support/scripts/scancpan b/support/scripts/scancpan
index f87cdce7..82c77a85 100755
--- a/support/scripts/scancpan
+++ b/support/scripts/scancpan
@@ -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 = ();
--
2.11.0

_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot
Reply | Threaded
Open this post in threaded view
|

[v2 3/3] scancpan: refactor with $mirror

Francois Perrad
In reply to this post by Francois Perrad
Signed-off-by: Francois Perrad <[hidden email]>
---
 support/scripts/scancpan | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/support/scripts/scancpan b/support/scripts/scancpan
index 82c77a85..62df2253 100755
--- a/support/scripts/scancpan
+++ b/support/scripts/scancpan
@@ -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;
--
2.11.0

_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot
Reply | Threaded
Open this post in threaded view
|

Re: [v2 1/3] scancpan: update with MetaCPAN API v1

Thomas Petazzoni-2
In reply to this post by Francois Perrad
Hello,

On Wed, 14 Jun 2017 16:15:29 +0200, Francois Perrad wrote:
> The API v0 is shutdown.
> see https://bugs.busybox.net/show_bug.cgi?id=9951
>
> Signed-off-by: Francois Perrad <[hidden email]>
> ---
>  support/scripts/scancpan | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Series applied. Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot
Reply | Threaded
Open this post in threaded view
|

Re: [v2 1/3] scancpan: update with MetaCPAN API v1

François PERRAD


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

On Wed, 14 Jun 2017 16:15:29 +0200, Francois Perrad wrote:
> The API v0 is shutdown.
> see https://bugs.busybox.net/show_bug.cgi?id=9951
>
> Signed-off-by: Francois Perrad <[hidden email]>
> ---
>  support/scripts/scancpan | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Series applied. Thanks!


must be committed also in maintenance branches.

François


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


_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot
Reply | Threaded
Open this post in threaded view
|

Re: [v2 1/3] scancpan: update with MetaCPAN API v1

Peter Korsgaard-2
>>>>> "François" == François Perrad <[hidden email]> writes:

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

 >> Hello,
 >>
 >> On Wed, 14 Jun 2017 16:15:29 +0200, Francois Perrad wrote:
 >> > The API v0 is shutdown.
 >> > see https://bugs.busybox.net/show_bug.cgi?id=9951
 >> >
 >> > Signed-off-by: Francois Perrad <[hidden email]>
 >> > ---
 >> >  support/scripts/scancpan | 4 ++--
 >> >  1 file changed, 2 insertions(+), 2 deletions(-)
 >>
 >> Series applied. Thanks!
 >>


 > must be committed also in maintenance branches.

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

--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/buildroot