From b17e7c1d02ce811ce6e072157980be24d6fc8749 Mon Sep 17 00:00:00 2001 From: Kiyoshi Aman Date: Tue, 28 Jun 2011 10:51:07 -0400 Subject: apkbuild-cpan: Added 'check' command, which prints latest & packaged versions. --- apkbuild-cpan.in | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in index 96df111..d96a4b7 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 | recreate | upgrade | update]"; + say "Usage: apkbuild-cpan [create | check | recreate | update | upgrade]"; exit; } } -- cgit v1.2.3-60-g2f50