diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in index 96df111a67073ebe9c351c7ab63e3fa917846394..d96a4b7d77087433c323de3c592aab7b277344cf 100755 --- a/apkbuild-cpan.in +++ b/apkbuild-cpan.in @@ -174,7 +174,7 @@ EOF $build_func = <<'EOF'; build() { cd "$_builddir" - export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'` + export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'` ./Build && ./Build test } EOF @@ -268,6 +268,16 @@ sub do_depends { close $fh; } +sub get_data { + my $apkbuild = read_apkbuild; + my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}"); + $response->is_success or die $response->status_line; + my $distdata = $json->decode($response->decoded_content); + $distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n"; + + return ($apkbuild, $distdata); +} + my $abuild_conf = read_assignments_from_file("/etc/abuild.conf"); $packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER}; @@ -296,23 +306,14 @@ given ( $ARGV[0] ) { do_depends; } when ("recreate") { - my $apkbuild = read_apkbuild; - my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}"); - $response->is_success or die $response->status_line; - my $distdata = $json->decode($response->decoded_content); - $distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n"; - + my ($apkbuild, $distdata) = get_data; write_apkbuild($distdata); prepare_tree; update_functions; do_depends; } when ("upgrade") { - my $apkbuild = read_apkbuild; - my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}"); - $response->is_success or die $response->status_line; - my $distdata = $json->decode($response->decoded_content); - $distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n"; + my ($apkbuild, $distdata) = get_data; my $pkgver = $distdata->{releases}[0]->{version}; if ($pkgver != $apkbuild->{pkgver}) { @@ -332,12 +333,17 @@ given ( $ARGV[0] ) { say "Up-to-data with CPAN"; } } + when ('check') { + my ($apkbuild, $distdata) = get_data; + my $pkgver = $distdata->{releases}[0]->{version}; + say "Latest version: $pkgver Packaged version: $apkbuild->{pkgver}"; + } when ("update") { prepare_tree; do_depends; } default { - say "Usage: apkbuild-cpan [create <Module::Name> | recreate | upgrade | update]"; + say "Usage: apkbuild-cpan [create <Module::Name> | check | recreate | update | upgrade]"; exit; } }