#!/usr/bin/perl -w # This script reads the CVS/Entries files recursively and writes # their entries to STDOUT. # This is mainly to create the 'MANIFEST' File # # Author: Marek Rouchal use strict; use Getopt::Long; my %opt; unless(GetOptions(\%opt,qw(exclude|x=s@))) { die "Usage: $0 [-x exclude-item]\n"; } unless(defined($opt{exclude})) { @{$opt{exclude}} = (); } my @items = &read_entries('.'); my $item; foreach $item (@items) { print "$item\n" unless(grep($item eq $_, @{$opt{exclude}})); } exit 0; sub read_entries { my ($relpath) = @_; warn "Reading CVS/Entries in '$relpath'\n"; my $file = "$relpath/CVS/Entries"; unless(open(ENTRIES, "<$file")) { warn "Warning: Cannot read '$file': $!\n"; return (); } my @subdirs = (); my @files = (); while() { chomp; if(m:^(D?)/([^/]+):) { if($1) { push(@subdirs, ($relpath eq '.' ? $2 : "$relpath/$2")); } else { push(@files, ($relpath eq '.' ? $2 : "$relpath/$2")); } } else { warn "Warning: Garbled line $. in '$file'\n" unless(/^D$/); } } close(ENTRIES); my @list = (); push(@list, $relpath) if($relpath ne '.'); push(@list, sort @files); foreach(sort @subdirs) { push(@list, &read_entries($_)); } @list; }