Commit 27c430cc authored by Timothy Legge's avatar Timothy Legge Committed by Natanael Copa

Updates for metacpan

parent 0126fbdf
...@@ -31,7 +31,7 @@ _pkgreal=[% pkgreal %] ...@@ -31,7 +31,7 @@ _pkgreal=[% pkgreal %]
pkgver=[% pkgver %] pkgver=[% pkgver %]
pkgrel=0 pkgrel=0
pkgdesc="Perl module for [% pkgreal %]" pkgdesc="Perl module for [% pkgreal %]"
url="http://search.cpan.org/dist/[% pkgreal %]/" url="https://metacpan.org/release/[% pkgreal %]/"
arch="noarch" arch="noarch"
license="GPL PerlArtistic" license="GPL PerlArtistic"
cpandepends="" cpandepends=""
...@@ -110,15 +110,15 @@ sub read_apkbuild { ...@@ -110,15 +110,15 @@ sub read_apkbuild {
sub write_apkbuild { sub write_apkbuild {
my ($distdata, $authors) = @_; my ($distdata, $authors) = @_;
my $cpanid = $distdata->{releases}[0]->{cpanid}; my $cpanid = $distdata->{releases}[0]->{id};
$cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid"; $cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid";
my %repl = ( my %repl = (
authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"), authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
pkgname => map_cpan_to_apk($distdata->{name}), pkgname => map_cpan_to_apk($distdata->{metadata}{name}),
pkgreal => $distdata->{name}, pkgreal => $distdata->{metadata}{name},
pkgver => $distdata->{releases}[0]->{version}, pkgver => $distdata->{version},
source => "http://search.cpan.org/CPAN/authors/id/$cpanid/\$_pkgreal-\$pkgver.tar.gz", source => $distdata->{download_url},
); );
$template =~ s/\[% (.*?) %\]/$repl{$1}/g; $template =~ s/\[% (.*?) %\]/$repl{$1}/g;
...@@ -143,16 +143,16 @@ sub parse_deps { ...@@ -143,16 +143,16 @@ sub parse_deps {
next if $module eq 'perl'; next if $module eq 'perl';
# map module name to package name # map module name to package name
$response = $ua->get("http://search.cpan.org/api/module/$module"); $response = $ua->get("https://fastapi.metacpan.org/module/$module");
$response->is_success or die $response->status_line; $response->is_success or die $response->status_line;
my $moddata = $json->decode($response->decoded_content); my $moddata = $json->decode($response->decoded_content);
$moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n"; $moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n";
$distfiles->{$moddata->{distvname}} = $moddata; $distfiles->{$moddata->{distribution}} = $moddata;
} }
# map package names to alpine packages # map package names to alpine packages
foreach ( keys %{ $distfiles } ) { foreach ( keys %{ $distfiles } ) {
$response = $ua->get("http://search.cpan.org/api/dist/$_"); $response = $ua->get("https://fastapi.metacpan.org/releases/$_");
$response->is_success or die $response->status_line; $response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content); my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $_: $distdata->{error}\n"; $distdata->{error} and die "Error trying to locate $_: $distdata->{error}\n";
...@@ -317,7 +317,7 @@ sub do_depends { ...@@ -317,7 +317,7 @@ sub do_depends {
sub get_data { sub get_data {
my $apkbuild = read_apkbuild; my $apkbuild = read_apkbuild;
$apkbuild->{_pkgreal} or die "Not apkbuild-cpan generated APKBUILD"; $apkbuild->{_pkgreal} or die "Not apkbuild-cpan generated APKBUILD";
my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}"); my $response = $ua->get("https://fastapi.metacpan.org/release/$apkbuild->{_pkgreal}");
$response->is_success or die $response->status_line; $response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content); my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n"; $distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n";
...@@ -337,17 +337,17 @@ given ( $ARGV[0] ) { ...@@ -337,17 +337,17 @@ given ( $ARGV[0] ) {
my $response; my $response;
$module or die "Module name is a mandatory argument"; $module or die "Module name is a mandatory argument";
$response = $ua->get("http://search.cpan.org/api/module/$module"); $response = $ua->get("https://fastapi.metacpan.org/module/$module");
$response->is_success or die $response->status_line; $response->is_success or die $response->status_line;
my $moddata = $json->decode($response->decoded_content); my $moddata = $json->decode($response->decoded_content);
$moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n"; $moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n";
$response = $ua->get("http://search.cpan.org/api/dist/$moddata->{distvname}"); $response = $ua->get("https://fastapi.metacpan.org/release/$moddata->{distribution}");
$response->is_success or die $response->status_line; $response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content); my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $module: $distdata->{error}\n"; $distdata->{error} and die "Error trying to locate $module: $distdata->{error}\n";
my $apkname = map_cpan_to_apk $distdata->{name}; my $apkname = map_cpan_to_apk $distdata->{metadata}{name};
mkdir $apkname; mkdir $apkname;
chdir $apkname; chdir $apkname;
write_apkbuild($distdata); write_apkbuild($distdata);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment