Commit b17e7c1d authored by Kiyoshi Aman's avatar Kiyoshi Aman

apkbuild-cpan: Added 'check' command, which prints latest & packaged versions.

parent 014544bc
...@@ -174,7 +174,7 @@ EOF ...@@ -174,7 +174,7 @@ EOF
$build_func = <<'EOF'; $build_func = <<'EOF';
build() { build() {
cd "$_builddir" cd "$_builddir"
export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'` export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'`
./Build && ./Build test ./Build && ./Build test
} }
EOF EOF
...@@ -268,6 +268,16 @@ sub do_depends { ...@@ -268,6 +268,16 @@ sub do_depends {
close $fh; 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"); my $abuild_conf = read_assignments_from_file("/etc/abuild.conf");
$packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER}; $packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER};
...@@ -296,23 +306,14 @@ given ( $ARGV[0] ) { ...@@ -296,23 +306,14 @@ given ( $ARGV[0] ) {
do_depends; do_depends;
} }
when ("recreate") { when ("recreate") {
my $apkbuild = read_apkbuild; my ($apkbuild, $distdata) = get_data;
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";
write_apkbuild($distdata); write_apkbuild($distdata);
prepare_tree; prepare_tree;
update_functions; update_functions;
do_depends; do_depends;
} }
when ("upgrade") { when ("upgrade") {
my $apkbuild = read_apkbuild; my ($apkbuild, $distdata) = get_data;
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 $pkgver = $distdata->{releases}[0]->{version}; my $pkgver = $distdata->{releases}[0]->{version};
if ($pkgver != $apkbuild->{pkgver}) { if ($pkgver != $apkbuild->{pkgver}) {
...@@ -332,12 +333,17 @@ given ( $ARGV[0] ) { ...@@ -332,12 +333,17 @@ given ( $ARGV[0] ) {
say "Up-to-data with CPAN"; 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") { when ("update") {
prepare_tree; prepare_tree;
do_depends; do_depends;
} }
default { default {
say "Usage: apkbuild-cpan [create <Module::Name> | recreate | upgrade | update]"; say "Usage: apkbuild-cpan [create <Module::Name> | check | recreate | update | upgrade]";
exit; exit;
} }
} }
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