This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
makerel: use Digest::SHA to print sha256sum
[perl5.git] / Porting / manicheck
CommitLineData
4d1e77f9 1#!/usr/bin/perl
93209f39 2
a7d002a1
DM
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
f73a32e0 7use v5.14;
4d1e77f9 8use warnings;
93209f39 9use File::Find;
a36da35b
NC
10use Getopt::Long;
11use constant SKIP => 125;
12
13my $exitstatus;
14GetOptions('exitstatus!', \$exitstatus)
15 or die "$0 [--exitstatus]";
16
17my %files;
18my $missing = 0;
19my $bonus = 0;
93209f39 20
1ae6ead9 21open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
a36da35b
NC
22for 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";
93209f39 28}
a36da35b
NC
29close $fh;
30
4d1e77f9
RGS
31find {
32 wanted => sub {
4d1e77f9 33 return if -d;
12100751 34 return if $_ eq '.mailmap';
3618011f 35 return if $_ eq '.gitignore';
d42c7c41
GK
36 return if $_ eq '.gitattributes';
37 return if $_ eq '.git_patch';
f73a32e0
NC
38
39 my $x = $File::Find::name =~ s!^\./!!r;
3618011f 40 return if $x =~ /^\.git\b/;
79ff1055 41 return if $x =~ m{^\.github/};
a36da35b
NC
42 return if $files{$x};
43 ++$bonus;
44 print "$x\t\tnot in MANIFEST\n";
4d1e77f9
RGS
45 },
46}, ".";
93209f39 47
a36da35b
NC
48my $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
58exit $exitcode;