File: manicheck

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (58 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (3)
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
56
57
58
#!/usr/bin/perl

# output a list of:
#  a) files listed in MANIFEST which don't exist
#  b) files which exist but which aren't in MANIFEST

use v5.14;
use warnings;
use File::Find;
use Getopt::Long;
use constant SKIP => 125;

my $exitstatus;
GetOptions('exitstatus!', \$exitstatus)
    or die "$0 [--exitstatus]";

my %files;
my $missing = 0;
my $bonus = 0;

open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
for my $line (<$fh>) {
    my ($file) = $line =~ /^(\S+)/;
    ++$files{$file};
    next if -f $file;
    ++$missing;
    print "$file from MANIFEST doesn't exist\n";
}
close $fh;

find {
    wanted => sub {
        return if -d;
        return if $_ eq '.mailmap';
        return if $_ eq '.gitignore';
        return if $_ eq '.gitattributes';
        return if $_ eq '.git_patch';

        my $x = $File::Find::name =~ s!^\./!!r;
        return if $x =~ /^\.git\b/;
        return if $x =~ m{^\.github/};
        return if $files{$x};
        ++$bonus;
        print "$x\t\tnot in MANIFEST\n";
    },
}, ".";

my $exitcode = $exitstatus ? $missing + $bonus : 0;

# We can't (meaningfully) exit with codes above 255, so we're going to have to
# clamp them to some range whatever we do. So as we need the code anyway, use
# 124 as our maximum instead, and then we can run as a useful git bisect run
# script if needed...

$exitcode = SKIP - 1
    if $exitcode > SKIP;

exit $exitcode;