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
$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;
}
}
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