-
-
Save jjatria/5d50d47c53fe77ab3c63dbc4c9de5641 to your computer and use it in GitHub Desktop.
Generate a comprehensive list to map CPAN distribution names and versions to authors and releases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use v5.36; | |
| use MetaCPAN::Client; | |
| use Time::HiRes 'sleep'; | |
| use DateTime::Format::ISO8601; | |
| use Getopt::Long; | |
| GetOptions \my %opt => qw( | |
| help | |
| limit|n=i | |
| wait=f | |
| agent=s | |
| from=s | |
| to=s | |
| ); | |
| usage() and exit 0 if $opt{help}; | |
| # Attempt to be well-behaved | |
| $opt{wait} //= 0.01; | |
| # Normalise dates | |
| for (qw( from to )) { | |
| next unless my $date = delete $opt{$_}; | |
| $opt{$_} = DateTime::Format::ISO8601 | |
| ->parse_datetime($date) | |
| ->stringify; | |
| } | |
| my $cpan = MetaCPAN::Client->new( | |
| ua => HTTP::Tiny->new( | |
| agent => $opt{agent} // 'CPAN Sec pURL Maker', | |
| ), | |
| ); | |
| my %filter = ( es_filter => { and => [ { term => { authorized => !!1 } } ] } ); | |
| if ($opt{from} || $opt{to}) { | |
| my %range; | |
| $range{range}{date}{gte} = $opt{from} if $opt{from}; | |
| $range{range}{date}{lt} = $opt{to} if $opt{to}; | |
| push @{ $filter{es_filter}{and} }, \%range; | |
| } | |
| use DDP; | |
| p %filter; | |
| my $set = $cpan->all( releases => { | |
| %filter, | |
| fields => [qw( | |
| author | |
| date | |
| distribution | |
| download_url | |
| version | |
| checksum_sha256 | |
| )], | |
| sort => [ | |
| { date => { order => 'asc' } }, | |
| { distribution => { order => 'asc' } }, | |
| ], | |
| }); | |
| my $n; | |
| while ( my $release = $set->next ) { | |
| last if $opt{limit} && $n++ >= $opt{limit}; | |
| say join "\t", | |
| $release->distribution // '', | |
| $release->version // '', | |
| $release->date // '', | |
| $release->author // '', | |
| $release->download_url // '', | |
| $release->checksum_sha256 // ''; | |
| sleep $opt{wait}; | |
| } | |
| sub usage { | |
| print <<"USAGE"; | |
| $0 - Generate and maintain a mapping of CPAN distributions to releases | |
| $0 [OPTIONS] | |
| This program will connect to a MetaCPAN API server and fetch data on | |
| all relevant releases to generate a tab-separated list with the following | |
| columns: | |
| * Distribution name | |
| * Version | |
| * Release date | |
| * Author | |
| * Tarball link | |
| * SHA-256 checksum | |
| This list will be printed to STDOUT sorted by release date, with older | |
| releases appearing first. | |
| Options: | |
| --help, -? Print this help message | |
| --limit NUMBER Do not process more than NUMBER results. | |
| --wait SECONDS Wait SECONDS after each result. Set to 0 | |
| for no waiting. | |
| (Default: 0.01) | |
| --agent STRING The value of the "Agent" header to use when | |
| connecting to the API server | |
| (Default: "CPAN Sec pURL Maker") | |
| --from DATE Only process results from after DATE. The | |
| value of DATE must be a valid ISO-8601 string. | |
| This date is inclusive. | |
| --to DATE Only process results from before DATE. The | |
| value of DATE must be a valid ISO-8601 string. | |
| This date is exclusive. | |
| USAGE | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Symdump 1.20 1995-08-16T14:12:18 ANDK https://cpan.metacpan.org/authors/id/A/AN/ANDK/Symdump-1.20.tar.gz 1f0f331e3da3c7c0099fa2d937fe23f282fbe26d60ec5cee06de6db301fe5ad2 | |
| Text-Trie 0.2 1995-08-19T22:00:00 ILYAZ https://cpan.metacpan.org/authors/id/I/IL/ILYAZ/modules/Text-Trie-0.2.tar.gz 82778317728839dc67b84ce397ae262b02511780e2cfd15204394af1713fc00a | |
| MD5 1.1 1995-08-20T07:13:34 NWINT https://cpan.metacpan.org/authors/id/N/NW/NWINT/MD5-1.1.tar.gz 584a65239f860cb1f2bd6142cb5ab79d4972521d454868d9ae3ae50f7ecebabb | |
| Ioctl 0.5 1995-08-20T07:26:09 KJALB https://cpan.metacpan.org/authors/id/K/KJ/KJALB/Ioctl-0.5.tar.gz a79624a1f3233a9d568af4fb15e86b5d3931916326e07f7b3b910638116228ea | |
| FileKGlob 0 1995-08-20T07:27:16 TYEMQ https://cpan.metacpan.org/authors/id/T/TY/TYEMQ/FileKGlob.tar.gz d643158c973573aadbb97db0194997c18543b0c0ef2eea29126380ce422233da | |
| Curses 0 1995-08-20T07:27:27 WPS https://cpan.metacpan.org/authors/id/W/WP/WPS/Curses-a8.tar.gz 2cfdbc2a5130d256861431d02ce656544a8dc77f0be3b5448562bc0c4234322c | |
| Term-Info 1.0 1995-08-20T07:29:08 KJALB https://cpan.metacpan.org/authors/id/K/KJ/KJALB/Term-Info-1.0.tar.gz 52606e15499436d0d4f10ce3aa07cbdd43aa2808b14d1ee94077b3480bc22eb1 | |
| SGI-FM 0.1 1995-08-20T07:29:54 AMOSS https://cpan.metacpan.org/authors/id/A/AM/AMOSS/SGI-FM-0.1.tar.gz 2701530cd5d3b1c41b3bfb82456b28af85e20db2e3bed1122b6d63ecdb78cf1c | |
| SGI-GL 0.2 1995-08-20T07:30:34 AMOSS https://cpan.metacpan.org/authors/id/A/AM/AMOSS/SGI-GL-0.2.tar.gz a5eacd87f873d559e87b786ace8a476221393e424d516eae5c7ccea7b870265f | |
| SGI-SysCalls 0.1 1995-08-20T07:31:05 AMOSS https://cpan.metacpan.org/authors/id/A/AM/AMOSS/SGI-SysCalls-0.1.tar.gz 07dfdc95646eb85980a99bca4140ed57e77f462ce8e0d04f9eaecbdefe9a6faf | |
| TclTk 0 1995-08-20T09:19:39 MICB https://cpan.metacpan.org/authors/id/M/MI/MICB/TclTk-b1.tar.gz 76343e042b41233247273dedeb3871351f377b0b439c786162169ca567d9420e | |
| Tcl 0 1995-08-20T09:21:54 MICB https://cpan.metacpan.org/authors/id/M/MI/MICB/Tcl-b1.tar.gz f4456bd94e721c86fc5b835eb1be8466fe35ad95f92d4f9f89a21566f2b7ad04 | |
| Term-Gnuplot 0.2 1995-08-20T14:05:30 ILYAZ https://cpan.metacpan.org/authors/id/I/IL/ILYAZ/modules/Term-Gnuplot-0.2.tar.gz 8f3c36f2c202ed90eb3e0201be39217945c5bd1caac32beb4740814a8f6e1ef0 | |
| perl_archie 1.5 1995-08-20T14:48:11 GBOSS https://cpan.metacpan.org/authors/id/G/GB/GBOSS/perl_archie.1.5.tar.gz e235f4b730985b277c6f898afd2d837cac3f185be194e3e8418d61c632655acf | |
| Sx 2.1 1995-08-20T15:38:05 FMC https://cpan.metacpan.org/authors/id/F/FM/FMC/Sx-2.1.tar.gz ff15817b4c8f69543eb08129c850fb16727c0525aaedd921b51289bd0b4e618d | |
| InitializeServer 1.0 1995-08-20T17:19:41 JACKS https://cpan.metacpan.org/authors/id/J/JA/JACKS/InitializeServer-1.0.tar.gz 4e7d1c00dc818c0889a8a1e19bea28c7c7acfb592341a1b465435f2c60be15ad | |
| Prolog-alpha 0 1995-08-20T17:24:24 JACKS https://cpan.metacpan.org/authors/id/J/JA/JACKS/Prolog-alpha.tar.gz 802e084a455662faf7f31acdc47f3271e31b0fafa1c4242581f010303a2cafd4 | |
| AlarmCall 1.1 1995-08-20T20:07:36 JACKS https://cpan.metacpan.org/authors/id/J/JA/JACKS/AlarmCall-1.1.tar.gz e982b72436c37442caa956b1290f20fb8bf12a2528cdf40fc5464e66c9005cfa | |
| CallerItem 1.0 1995-08-20T20:09:52 JACKS https://cpan.metacpan.org/authors/id/J/JA/JACKS/CallerItem-1.0.tar.gz 7962010e526b5bc2a25aa0b384180f7d41aec68058f92859010f4660d125e2ea | |
| Date-GetDate 0.01 1995-08-20T20:16:23 GBARR https://cpan.metacpan.org/authors/id/G/GB/GBARR/Date-GetDate-0.01a.tar.gz d7cf11e015e696d81120dac46288a26868cf0d3e3a92036d950315793e3f6188 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment