source: vendor/perl/5.8.8/Porting/manicheck

Last change on this file was 3181, checked in by bird, 18 years ago

perl 5.8.8

File size: 1.4 KB
Line 
1#!/usr/bin/perl -ws
2
3#
4# manicheck - check files against the MANIFEST
5#
6# Without options prints out (possibly) two lines:
7#
8# extra: a b c
9# missing: d
10#
11# With option -x prints out only the missing files (and without the "extra: ")
12# With option -m prints out only the extra files (and without the "missing: ")
13#
14
15BEGIN {
16 $SIG{__WARN__} = sub {
17 help() if $_[0] =~ /"main::\w" used only once: possible typo at /;
18 };
19}
20
21use strict;
22
23sub help {
24 die <<EOF;
25$0: Usage: $0 [-x|-m|-l|-h]
26-x show only the extra files
27-m show only the missing files
28-l show the files one per line instead of one line
29-h show only this help
30EOF
31}
32
33use vars qw($x $m $l $h);
34
35help() if $h;
36
37open(MANIFEST, "MANIFEST") or die "MANIFEST: $!";
38
39my %mani;
40my %mand = qw(. 1);
41use File::Basename qw(dirname);
42
43while (<MANIFEST>) {
44 if (/^(\S+)\t+(.+)$/) {
45 $mani{$1}++;
46 my $d = dirname($1);
47 while($d ne '.') {
48 $mand{$d}++;
49 $d = dirname($d);
50 }
51 } else {
52 warn "MANIFEST:$.:$_";
53 }
54}
55
56close(MANIFEST);
57
58my %find;
59use File::Find;
60find(sub {
61 my $n = $File::Find::name;
62 $n =~ s:^\./::;
63 $find{$n}++;
64 }, '.' );
65
66my @xtra;
67my @miss;
68
69for (sort keys %find) {
70 push @xtra, $_ unless $mani{$_} || $mand{$_};
71}
72
73for (sort keys %mani) {
74 push @miss, $_ unless $find{$_};
75}
76
77$" = "\n" if $l;
78
79unshift @xtra, "extra:" if @xtra;
80unshift @miss, "missing:" if @miss;
81
82print "@xtra\n", if @xtra && !$m;
83print "@miss\n" if @miss && !$x;
84
85exit 0;
86
Note: See TracBrowser for help on using the repository browser.