public

Based in SHARYANTO's script, but adds version numbers to the output.

  • Download Gist
debian-unstable-module-versions.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#!/usr/bin/env perl
 
use 5.010;
use strict;
use warnings;
 
use Data::Dump qw(dump);
use File::Slurp;
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
use JSON;
use LWP::Simple;
 
my $cachef = "/tmp/allpackages.cache";
 
my $json = JSON->new->allow_nonref;
my $debug = $ENV{DEBUG};
my $res;
 
sub dist2deb {
my ($dist) = @_;
"lib".lc($dist)."-perl";
}
 
die "Usage: $0 <CPANID> ...\n" unless @ARGV;
 
binmode STDOUT, ":utf8";
 
my %pkgs;
unless ((-f $cachef) && (-M _) < 7) {
say "DBG: Downloading Debian packages list to $cachef ..." if $debug;
$res = get "http://packages.debian.org/unstable/allpackages?format=txt.gz";
gunzip(\$res => $cachef) or die "gunzip failed: $GunzipError\n";
}
for (read_file $cachef) {
next unless /^(lib\S+-perl) \((.+?)\)/;
$pkgs{$1} = $2;
}
 
say "DBG: Querying MetaCPAN ..." if $debug;
$res = get "http://api.metacpan.org/v0/release/_search?q=author:".
uc($ARGV[0])."%20AND%20status:latest&fields=name&size=5000";
$res = $json->decode($res);
die "MetaCPAN timed out" if $res->{timed_out};
my %dists;
for my $hit (@{ $res->{hits}{hits} }) {
my $dist = $hit->{fields}{name};
$dist =~ s/-(\d.+)//;
$dists{$dist} = $1;
}
 
for my $dist (sort keys %dists) {
my $pkg = dist2deb($dist);
next unless $pkg ~~ %pkgs;
(my $pkg_ver = $pkgs{$pkg}) =~ s/[-].+//;
printf(
"%-40s%15s%15s %s\n",
$dist,
$dists{$dist},
$pkgs{$pkg},
($pkg_ver eq $dists{$dist} ? ' ' : '!'),
);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.