3 ## $Id: mkmanifest 7307 2005-06-11 08:38:15Z eagle $
5 ## Generate a filename-only manifest from an INN tree.
7 ## This script generates a filename-only manifest from an INN tree, excluding
8 ## certain files according to .cvsignore files and several built-in rules.
9 ## It is intended to be used to support make check-manifest from the top
10 ## level of the INN tree.
15 use vars qw(%CVSIGNORE @FILES @IGNORE);
17 use File::Find qw(find);
19 # The following regex patterns match files to be ignored wherever they are
20 # in the tree. This is intended to handle files that CVS ignores by default
21 # or files that are present in the tree and in CVS but which are not included
23 @IGNORE = (qr%(\A|/)\.cvsignore\Z%, qr/\.[ao]\Z/, qr%(\A|/)CVS(/|\Z)%,
24 qr%(\A|/)\.?\#%, qr/\.(old|bak|orig|rej)$/, qr%(\A|/)core\Z%,
25 qr/~$/, qr%(\A|/)\.pure%, qr%(\A|/)\.svn(/|\Z)%);
27 # Build a list of all the files ignored by rules in .cvsignore files. Meant
28 # to be run as the wanted sub of a call to File::Find. Stuff in .cvsignore
29 # that contains wildcards needs to be lifted into the list of @IGNORE regexes.
31 return unless $_ eq '.cvsignore';
36 my $dir = $File::Find::dir;
41 open (CVSIGNORE, $_) or die "Cannot open $File::Find::name: $!\n";
42 @ignored = map { $dir . $_ } map { split (' ', $_) } <CVSIGNORE>;
47 $pattern =~ s/\./\\./g;
48 $pattern =~ s/\*/.*/g;
49 push (@IGNORE, qr/\A$pattern\Z/);
56 # Build a list of all files in the tree that aren't ignored by .cvsignore
57 # files or listed in ignore regexes.
60 my $name = $File::Find::name;
62 if ($CVSIGNORE{$name}) {
63 $File::Find::prune = 1;
66 for my $pattern (@IGNORE) {
67 return if $name =~ /$pattern/;
72 find (\&find_cvsignore, '.');
73 find (\&find_files, '.');
74 print join ("\n", (sort @FILES), '');