Release diogenes-0.9.22
[diogenes.git] / config / checkspool.pl
1 #!/usr/bin/perl
2
3 use strict;
4 my $revision = '$Revision: 1.1 $';
5
6
7 # compare two directories recursively
8 sub scandir {
9 my ($rRoot,$oRoot,$rPat,$oPat,$curdir) = @_;
10
11 opendir(SPOOL,"$rRoot/$curdir") || die "can't open '$rRoot/$curdir'";
12 my @entries = grep { ! /^\.{1,2}$/ } readdir SPOOL;
13 closedir SPOOL;
14
15 my @children;
16
17 # process entries
18 foreach my $entry(@entries) {
19 my $fentry = $curdir ? "$curdir/$entry" : $entry;
20 if ( -d "$rRoot/$fentry" ) {
21 if ( -d "$oRoot/$fentry" ) {
22 push @children,$fentry;
23 } else {
24 print "[d] $fentry\n";
25 }
26 } else {
27 $fentry =~ s/$rPat/$oPat/;
28 ( -f "$oRoot/$fentry") or
29 print "[f] $fentry\n";
30 }
31 }
32
33 # recurse
34 foreach my $child(@children) {
35 &scandir($rRoot,$oRoot,$rPat,$oPat,$child);
36 }
37 }
38
39
40 # display usage
41 sub syntax {
42 $revision =~ s/(\$)Revision: (.*) \$$/v\2/;
43
44 print "[ This is checkspool.pl ($revision), a checker for Diogenes's spool ]\n\n",
45 "Syntax:\n",
46 " checkspool.pl <rcs> <spool>\n\n",
47 " Arguments:\n",
48 " rcs - the RCS root\n",
49 " spool - the spool directory\n",
50 "\n";
51 }
52
53
54 # the main routine
55 sub main {
56
57 if (@ARGV < 2) {
58 &syntax;
59 exit(1);
60 }
61
62 my $rcs = $ARGV[0];
63 my $spool = $ARGV[1];
64
65 # forward scan
66 print "\nNot in RCS (ignore templates_c) :\n";
67 &scandir($spool,$rcs,'$',',v');
68
69 # reverse scan
70 print "\nNot in spool :\n";
71 &scandir($rcs,$spool,',v$','');
72 }
73
74 &main