new ticket from slaven
[andk-cpan-tools.git] / bin / parse-all-meta.pl
blob3ca9a2c1bb7cd31f2afb2fdc841d68b99c632498
1 #!/usr/bin/perl
3 # use 5.010;
4 use strict;
5 use warnings;
7 =head1 NAME
11 =head1 SYNOPSIS
15 =head1 OPTIONS
17 =over 8
19 =cut
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--cpan=s>
25 CPAN mirror root directory. Defaults to /home/ftp/pub/PAUSE
27 =item B<--help|h!>
29 This help
31 =item B<--parser=s>
33 defaults to Parse::CPAN::Meta. Also supported: YAML::Syck
35 =back
37 =head1 DESCRIPTION
41 =cut
43 use File::Basename qw(dirname);
44 use File::Path qw(mkpath);
45 use File::Spec;
46 use File::Temp;
47 use Getopt::Long;
48 use Hash::Util qw(lock_keys);
50 our %Opt;
51 lock_keys %Opt, map { /([^=]+)/ } @opt;
52 GetOptions(\%Opt,
53 @opt,
54 ) or pod2usage(1);
56 $Opt{cpan} ||= "/home/ftp/pub/PAUSE";
57 my $counter = 0;
58 use File::Find;
59 find
61 wanted => sub {
62 return unless /\.meta$/;
63 my $ok;
64 if ($Opt{parser} eq "Parse::CPAN::Meta") {
65 require Parse::CPAN::Meta;
66 unlink "/tmp/meta.yaml" or die $! if -e "/tmp/meta.yaml";
67 symlink $File::Find::name, "/tmp/meta.yaml";
68 $ok = eval { Parse::CPAN::Meta->load_file("/tmp/meta.yaml"); };
69 unlink "/tmp/meta.yaml" or die $!;
70 } elsif ($Opt{parser} eq "YAML::Syck") {
71 require YAML::Syck;
72 $ok = eval { YAML::Syck::LoadFile($File::Find::name); };
73 } elsif ($Opt{parser} eq "YAML::XS") {
74 require YAML::XS;
75 $ok = eval { YAML::XS::LoadFile($File::Find::name); };
77 return if $ok;
78 $counter++;
79 warn "$Opt{parser} could not parse $counter\: $File::Find::name\:\n$@\n";
81 no_chdir => 1,
83 $Opt{cpan} . "/authors/id"