From: "Kent Fredric" <kentfredric@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/perl-overlay:master commit in: scripts/
Date: Sun, 8 Apr 2012 13:20:03 +0000 (UTC) [thread overview]
Message-ID: <1333890870.86cf3771522cae084ec11a50aa85401504489cfc.kent@gentoo> (raw)
commit: 86cf3771522cae084ec11a50aa85401504489cfc
Author: Kent Fredric <kentfredric <AT> gmail <DOT> com>
AuthorDate: Sun Apr 8 13:14:30 2012 +0000
Commit: Kent Fredric <kentfredric <AT> gmail <DOT> com>
CommitDate: Sun Apr 8 13:14:30 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/perl-overlay.git;a=commit;h=86cf3771
[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 protection.
+ 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) <kentfredric@gmail.com>
+# 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 = optparse->new(
+ argv => \@ARGV,
+ help => sub { print help(); },
+);
+my $search = {};
+$search->{query} = { constant_score => { filter => { terms => { distribution => $optparse->extra_opts } } } };
+$search->{sort} = [ { 'date' => 'desc', }, ];
+$search->{size} = 5000;
+$search->{fields} = [qw(
+ abstract
+ archive
+ author
+ authorized
+ date
+ distribution
+ download_url
+ license
+ maturity
+ name
+ status
+ version
+)];
+
+_log( ['initialized: fetching search results'] );
+
+my $results = mcpan->post( 'release/_search', $search );
+
+_log( [ 'fetched %s results', scalar @{ $results->{hits}->{hits} } ] );
+
+my $data = {};
+
+
+for my $result ( @{ $results->{hits}->{hits} } ) {
+ if ( not $result->{fields} ) {
+ $result->{fields} = $result->{_source};
+ }
+ delete $result->{fields}->{dependency} if exists $result->{fields}->{dependency};
+ my $fields = $result->{fields};
+
+ my $cversion = $fields->{name};
+ my $cdistrib = $fields->{distribution};
+ $cversion =~ s/^${cdistrib}-//;
+
+ $fields->{canon_version} = $cversion;
+ $fields->{gentoo_version} = scalar try { gv( $cversion , { lax => 1 } ) };
+ $data->{ $cdistrib } = [] unless exists $data->{ $cdistrib };
+ push @{ $data->{ $cdistrib } }, $fields ;
+}
+
+require JSON;
+
+my $encode = 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::Version::gentooize_version }
+
+sub _log {
+ return unless $optparse->long_opts->{trace};
+ return *STDERR->print(@_) if ( not ref $_[0] );
+
+ state $prefix = "\e[7m* package_map.pl:\e[0m ";
+
+ my ( $str, @args ) = @{ $_[0] };
+ $str =~ 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
+
+}
+
next reply other threads:[~2012-04-08 13:20 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-08 13:20 Kent Fredric [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-09-16 22:36 [gentoo-commits] proj/perl-overlay:master commit in: scripts/ Kent Fredric
2015-02-28 23:17 Kent Fredric
2015-02-28 23:17 Kent Fredric
2013-12-23 15:28 Kent Fredric
2013-05-01 23:03 Kent Fredric
2013-05-01 23:03 Kent Fredric
2012-10-24 15:49 Kent Fredric
2012-09-15 23:19 Kent Fredric
2012-08-02 11:46 Kent Fredric
2012-08-02 11:46 Kent Fredric
2012-07-31 3:04 Kent Fredric
2012-07-12 19:23 Torsten Veller
2012-06-22 7:34 Kent Fredric
2012-06-08 17:14 Kent Fredric
2012-05-27 2:30 Kent Fredric
2012-04-28 10:40 Kent Fredric
2012-04-18 3:32 Kent Fredric
2012-04-18 3:32 Kent Fredric
2012-04-18 3:32 Kent Fredric
2012-04-12 19:46 Kent Fredric
2012-04-09 16:05 Kent Fredric
2012-04-08 13:20 Kent Fredric
2012-04-05 10:02 Kent Fredric
2012-03-27 1:26 Kent Fredric
2012-03-27 1:26 Kent Fredric
2012-03-27 1:26 Kent Fredric
2012-03-01 11:38 Kent Fredric
2012-02-29 12:22 Kent Fredric
2012-02-29 12:22 Kent Fredric
2012-02-29 12:06 Kent Fredric
2012-02-28 21:55 Kent Fredric
2012-02-28 21:55 Kent Fredric
2012-02-28 21:55 Kent Fredric
2012-02-24 7:13 Kent Fredric
2012-02-24 7:13 Kent Fredric
2012-02-12 7:22 Kent Fredric
2012-02-12 7:22 Kent Fredric
2011-12-05 21:45 Kent Fredric
2011-11-14 2:57 Kent Fredric
2011-11-14 2:57 Kent Fredric
2011-11-11 14:38 Kent Fredric
2011-10-31 18:05 Kent Fredric
2011-10-31 18:05 Kent Fredric
2011-10-31 8:46 Kent Fredric
2011-10-31 7:10 Kent Fredric
2011-10-31 4:52 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-31 2:48 Kent Fredric
2011-10-25 19:46 Kent Fredric
2011-10-25 19:46 Kent Fredric
2011-10-25 19:46 Kent Fredric
2011-10-24 21:17 Kent Fredric
2011-10-24 18:26 Kent Fredric
2011-10-24 9:09 Kent Fredric
2011-09-23 6:17 Kent Fredric
2011-08-29 5:44 Kent Fredric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1333890870.86cf3771522cae084ec11a50aa85401504489cfc.kent@gentoo \
--to=kentfredric@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox