Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created July 18, 2015 01:47
Show Gist options
  • Save dagolden/a28501321da265e94e40 to your computer and use it in GitHub Desktop.
Save dagolden/a28501321da265e94e40 to your computer and use it in GitHub Desktop.
Find my dists where latest upload is an alpha
#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use CPAN::DistnameInfo;
use HTTP::Tiny;
use Parse::CPAN::Packages::Fast;
my $local_mirror = "/srv/cpan";
my $author = shift || "dagolden";
$author = uc $author;
my $author_path = $author =~ s{^((.).)}{$2/$1/$1}r;
my (@files) = qx{rsync -avn cpan-rsync.perl.org::CPAN/authors/id/$author_path .};
my %latest;
for my $f (@files) {
chomp $f;
next unless $f =~ /\A$author.*tar\.gz\z/;
my $info = CPAN::DistnameInfo->new($f);
my ( $dist, $version ) = map { $info->$_ } qw/dist version/;
next if $dist eq 'perl';
$version =~ s/-TRIAL//;
$version = eval { version->new($version) };
$latest{$dist} ||= { version => 0 };
if ( !defined $version ) {
printf( "$dist: Bad version '%s'\n", $info->version );
next;
}
if ( $version > $latest{$dist}{version} ) {
$latest{$dist}{version} = $version;
$latest{$dist}{maturity} = $info->maturity;
$latest{$dist}{tarball} = $info->filename;
}
}
my $p =
Parse::CPAN::Packages::Fast->new(
"$local_mirror/modules/02packages.details.txt.gz");
my $ht = HTTP::Tiny->new;
for my $d ( sort keys %latest ) {
my $mod = $d =~ s{-}{::}gr;
next if $p->package($mod) && $p->package($mod)->version > $latest{$d}{version};
next if $latest{$d}{maturity} eq 'released';
my $tarball = $latest{$d}{tarball} =~ s{^$author/}{}r;
my $res = $ht->head("http://www.cpan.org/authors/id/$author_path/$tarball");
my $date = $res->{success} ? $res->{headers}{'last-modified'} : "unknown date";
printf( "%29s -- %s\n", $date, $latest{$d}{tarball} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment