Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added script to find all dynamic_config dists on local CPAN mirror

  • Loading branch information...
commit 7be5142cd4b9dc1d6fdaa24ecb4dec915173ebbe 1 parent 4252c7a
Chris Williams authored May 14, 2012

Showing 1 changed file with 47 additions and 0 deletions. Show diff stats Hide diff stats

  1. 47  cpanmeta.pl
47  cpanmeta.pl
... ...
@@ -0,0 +1,47 @@
  1
+use 5.010;
  2
+use strict;
  3
+use warnings;
  4
+use CPAN::Meta;
  5
+use File::Spec;
  6
+
  7
+my $cpan = '/home/ftp/CPAN';
  8
+
  9
+
  10
+my %packages;
  11
+
  12
+{
  13
+  my $packages = File::Spec->catfile( $cpan, 'modules', '02packages.details.txt' );
  14
+  open my $fh, '<', $packages or die "$!\n";
  15
+
  16
+  while (<$fh>) {
  17
+    last if /^\s*$/;
  18
+  }
  19
+  while (<$fh>) {
  20
+    chomp;
  21
+    my ($module,$version,$package_path) = split ' ', $_;
  22
+    next unless $version eq 'undef' or !$version;
  23
+    $packages{ $package_path } = undef;
  24
+  }
  25
+}
  26
+
  27
+foreach my $package ( sort keys %packages ) {
  28
+  ( my $meta = $package ) =~ s!\.(zip|tgz|tar\.gz|tar\.bz2)!!;
  29
+  $meta .= '.meta';
  30
+  my $metafile = File::Spec->catfile( $cpan, 'authors', 'id', $meta );
  31
+  next unless -e $metafile;
  32
+  my $metastr = do { local $/; open my $fh, '<', $metafile or die "$!\n"; <$fh> };
  33
+  my $data;
  34
+  if ( $metastr =~ m!^\{! ) {
  35
+    $data = eval { CPAN::Meta->load_json_string( $metastr ) };
  36
+    next unless $data;
  37
+  }
  38
+  else {
  39
+    # assume yml
  40
+    $data = eval { CPAN::Meta->load_yaml_string( $metastr ) };
  41
+    next unless $data;
  42
+  }
  43
+  $packages{ $package } = $data->dynamic_config;
  44
+}
  45
+
  46
+say "Total indexed dists: " . scalar keys %packages;
  47
+say "Total dynamic: " . scalar grep { $packages{$_} } keys %packages;

0 notes on commit 7be5142

Please sign in to comment.
Something went wrong with that request. Please try again.