xref: /openbsd/gnu/usr.bin/perl/Porting/manicheck (revision 256a93a4)
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
7use v5.14;
8use warnings;
9use File::Find;
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;
20
21open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
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";
28}
29close $fh;
30
31find {
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
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;
59