From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SGs2Q-0007Y9-Il for garchives@archives.gentoo.org; Sun, 08 Apr 2012 13:20:15 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BE1F1E083C; Sun, 8 Apr 2012 13:20:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 812A6E083B for ; Sun, 8 Apr 2012 13:20:05 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9BB3C1B40A2 for ; Sun, 8 Apr 2012 13:20:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 0B3E5E5402 for ; Sun, 8 Apr 2012 13:20:03 +0000 (UTC) From: "Kent Fredric" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Kent Fredric" Message-ID: <1333890870.86cf3771522cae084ec11a50aa85401504489cfc.kent@gentoo> Subject: [gentoo-commits] proj/perl-overlay:master commit in: scripts/ X-VCS-Repository: proj/perl-overlay X-VCS-Files: scripts/package_map.pl X-VCS-Directories: scripts/ X-VCS-Committer: kent X-VCS-Committer-Name: Kent Fredric X-VCS-Revision: 86cf3771522cae084ec11a50aa85401504489cfc X-VCS-Branch: master Date: Sun, 8 Apr 2012 13:20:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 5a5d7ef0-22f4-439f-8f30-ddb199a2274b X-Archives-Hash: 75c05c5b4840264eea183cf6e27d4570 commit: 86cf3771522cae084ec11a50aa85401504489cfc Author: Kent Fredric gmail com> AuthorDate: Sun Apr 8 13:14:30 2012 +0000 Commit: Kent Fredric gmail com> CommitDate: Sun Apr 8 13:14:30 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/perl-overlay.= git;a=3Dcommit;h=3D86cf3771 [scripts] add scripts/package_map.pl which emits all useful metadata for = all versions of a given distribution --- scripts/package_map.pl | 132 ++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 132 insertions(+), 0 deletions(-) diff --git a/scripts/package_map.pl b/scripts/package_map.pl new file mode 100755 index 0000000..cdc306f --- /dev/null +++ b/scripts/package_map.pl @@ -0,0 +1,132 @@ +#!/usr/bin/env perl + +eval 'echo "Called with something not perl"' && exit 1 # Non-Perl pro= tection. + if 0; + +use 5.14.2; +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/lib"; + +use env::gentoo::perl_experimental; +use metacpan qw( mcpan ); +use Try::Tiny; +use optparse; + +# FILENAME: pvlist.pl +# CREATED: 16/10/11 20:16:03 by Kent Fredric (kentnl) +# ABSTRACT: Show dist metadata for interesting perl dists + +# DEPENDENCIES: +# +# * MetaCPAN::API +# * CHI +# * WWW::Mechanize::Cached +# * HTTP::Tiny::Mech +# * Data::Dump +# * Gentoo::PerlMod::Version +# + +my $optparse =3D optparse->new( + argv =3D> \@ARGV, + help =3D> sub { print help(); }, +); +my $search =3D {}; +$search->{query} =3D { constant_score =3D> { filter =3D> { terms =3D> { = distribution =3D> $optparse->extra_opts } } } }; +$search->{sort} =3D [ { 'date' =3D> 'desc', }, ]; +$search->{size} =3D 5000; +$search->{fields} =3D [qw( + abstract + archive + author + authorized + date + distribution + download_url + license + maturity + name + status + version +)]; + +_log( ['initialized: fetching search results'] ); + +my $results =3D mcpan->post( 'release/_search', $search ); + +_log( [ 'fetched %s results', scalar @{ $results->{hits}->{hits} } ] ); + +my $data =3D {}; + + +for my $result ( @{ $results->{hits}->{hits} } ) { + if ( not $result->{fields} ) { + $result->{fields} =3D $result->{_source}; + } + delete $result->{fields}->{dependency} if exists $result->{fields}->{d= ependency}; + my $fields =3D $result->{fields}; + + my $cversion =3D $fields->{name}; + my $cdistrib =3D $fields->{distribution}; + $cversion =3D~ s/^${cdistrib}-//; + + $fields->{canon_version} =3D $cversion; + $fields->{gentoo_version} =3D scalar try { gv( $cversion , { lax =3D> = 1 } ) }; + $data->{ $cdistrib } =3D [] unless exists $data->{ $cdistrib }; + push @{ $data->{ $cdistrib } }, $fields ; +} + +require JSON; + +my $encode =3D JSON->new->pretty->utf8->canonical; +say $encode->encode( $data ); + +exit 0; + +# Utils + +sub pp { require Data::Dump; goto \&Data::Dump::pp } +sub gv { require Gentoo::PerlMod::Version; goto \&Gentoo::PerlMod::Versi= on::gentooize_version } + +sub _log { + return unless $optparse->long_opts->{trace}; + return *STDERR->print(@_) if ( not ref $_[0] ); + + state $prefix =3D "\e[7m* package_map.pl:\e[0m "; + + my ( $str, @args ) =3D @{ $_[0] }; + $str =3D~ s/\n?$/\n/; + + *STDERR->print($prefix); + *STDERR->printf( $str, @args ); + return; + +} + + + +sub help { + return <<"EOF"; +package_map.pl + +USAGE: + + package_map.pl PACKAGE [PACKAGE*][--help] [--trace] + + ie: + + # Show full metadata for Moose, Catalyst-Runtime and Dist-Zilla + package_log.pl Moose Catalyst-Runtime Dist-Zilla + + # Be verbose about what we're doing + package_log.pl Moose --trace + + --help Show this message + --trace Turn on extra debugging. + +EOF + +} +