summaryrefslogtreecommitdiff
path: root/Porting/makemeta
blob: e1a95adccddca043da231a809aba9a28464bf942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!./perl -w
# this script must be run by the current perl to get perl's version right

use strict;
use warnings;
use lib "Porting";

use File::Basename qw( dirname );

my $file = "META.yml";
die "$0: will not override $file, delete it first.\n" if -e $file;

use Maintainers qw(%Modules get_module_files get_module_pat);

my @CPAN  = grep { $Modules{$_}{CPAN} } keys %Modules;
my @files = map { get_module_files($_) } @CPAN;
my @dirs  = grep { -d $_ } map { get_module_pat($_) } @CPAN;

my %dirs;
@dirs{@dirs} = ();

my $files = join '', map { "    - $_\n" }
  grep {
    my $d = $_;
    while(($d = dirname($d)) ne "."){
      last if exists $dirs{$d};
    }

    # if $d is "." it means we tried every parent dir of the file and none
    # of them were in the private list
    
    $d eq "."; 
  }
  sort { lc $a cmp lc $b } @files;

my $dirs  = join '', map { "    - $_\n" } sort { lc $a cmp lc $b } @dirs;

open my $fh, ">$file" or die "Can't open $file: $!";

print $fh <<"EOI";
name: perl
version: $]
abstract: Practical Extraction and Reporting Language
author: perl5-porters\@perl.org
license: perl
distribution_type: core
private:
  directory:
$dirs
  file:
$files
EOI

close $fh;