This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make spelling of values for 'FILES' consistent
[perl5.git] / Porting / manicheck
1 #!/usr/bin/perl
2
3 # output a list of:
4 #  a) files listed in MANIFEST which don't exist
5 #  b) files which exist but which aren't in MANIFEST
6
7 use v5.14;
8 use warnings;
9 use File::Find;
10 use Getopt::Long;
11 use constant SKIP => 125;
12
13 my $exitstatus;
14 GetOptions('exitstatus!', \$exitstatus)
15     or die "$0 [--exitstatus]";
16
17 my %files;
18 my $missing = 0;
19 my $bonus = 0;
20
21 open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
22 for my $line (<$fh>) {
23     my ($file) = $line =~ /^(\S+)/;
24     ++$files{$file};
25     next if -f $file;
26     ++$missing;
27     print "$file from MANIFEST doesn't exist\n";
28 }
29 close $fh;
30
31 find {
32     wanted => sub {
33         return if -d;
34         return if $_ eq '.mailmap';
35         return if $_ eq '.gitignore';
36         return if $_ eq '.gitattributes';
37         return if $_ eq '.git_patch';
38
39         my $x = $File::Find::name =~ s!^\./!!r;
40         return if $x =~ /^\.git\b/;
41         return if $x =~ m{^\.github/};
42         return if $files{$x};
43         ++$bonus;
44         print "$x\t\tnot in MANIFEST\n";
45     },
46 }, ".";
47
48 my $exitcode = $exitstatus ? $missing + $bonus : 0;
49
50 # We can't (meaningfully) exit with codes above 255, so we're going to have to
51 # clamp them to some range whatever we do. So as we need the code anyway, use
52 # 124 as our maximum instead, and then we can run as a useful git bisect run
53 # script if needed...
54
55 $exitcode = SKIP - 1
56     if $exitcode > SKIP;
57
58 exit $exitcode;