From 422199858ca8d134039ff315538f11c9ce522c9d Mon Sep 17 00:00:00 2001 From: Timothy Legge Date: Mon, 26 Nov 2018 03:18:10 +0000 Subject: apkbuild-cpan.in fix issues with update, recreate, etc --- apkbuild-cpan.in | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in index fc84260..92bf2fc 100644 --- a/apkbuild-cpan.in +++ b/apkbuild-cpan.in @@ -110,7 +110,7 @@ sub read_apkbuild { sub write_apkbuild { my ($distdata, $authors, $moddata) = @_; - my $cpanid = $distdata->{releases}[0]->{id}; + my $cpanid = $distdata->{id}; $cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid"; my %repl = ( @@ -323,7 +323,12 @@ sub get_data { my $distdata = $json->decode($response->decoded_content); $distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n"; - return ($apkbuild, $distdata); + $response = $ua->get("https://fastapi.metacpan.org/module/$distdata->{main_module}"); + $response->is_success or die $response->status_line; + my $moddata = $json->decode($response->decoded_content); + $moddata->{error} and die "Error trying to locate $distdata->{main_module}: $moddata->{error}\n"; + + return ($apkbuild, $distdata, $moddata); } my $abuild_conf = read_assignments_from_file("/etc/abuild.conf"); @@ -357,14 +362,14 @@ given ( $ARGV[0] ) { do_depends; } when ("recreate") { - my ($apkbuild, $distdata) = get_data; - write_apkbuild($distdata, $apkbuild->{authors}); + my ($apkbuild, $distdata, $moddata) = get_data; + write_apkbuild($distdata, $apkbuild->{authors}, $moddata); prepare_tree; update_functions; do_depends; } when ("upgrade") { - my ($apkbuild, $distdata) = get_data; + my ($apkbuild, $distdata, $moddata) = get_data; my $pkgver = $distdata->{metadata}{version}; if ($pkgver != $apkbuild->{pkgver}) { @@ -385,8 +390,8 @@ given ( $ARGV[0] ) { } } when ('check') { - my ($apkbuild, $distdata) = get_data; - my $pkgver = $distdata->{releases}[0]->{version}; + my ($apkbuild, $distdata, $moddata) = get_data; + my $pkgver = $distdata->{metadata}{version}; say "$apkbuild->{pkgname}: Latest version: $pkgver Packaged version: $apkbuild->{pkgver}"; if ($pkgver ne $apkbuild->{pkgver}) { exit(1); -- cgit v1.2.3