Commit 42219985 authored by Timothy Legge's avatar Timothy Legge Committed by Natanael Copa

apkbuild-cpan.in fix issues with update, recreate, etc

parent f98db143
......@@ -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);
......
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