1 |
ccflib |
1.1 |
#! /usr/local/bin/perl -w |
2 |
|
|
# |
3 |
|
|
# Giuseppe Vacanti (cosine science & computing bv) |
4 |
|
|
# |
5 |
|
|
# $Id: deleteccf,v 1.1 2002/03/18 18:28:57 ccflib Exp $ |
6 |
|
|
# |
7 |
|
|
# Called in a directory containing CCF constituents (*.CCF). It cheks |
8 |
|
|
# via the DBM .ccf.db if any CCF constituent has appeared or |
9 |
|
|
# disappeared, and launches the notification script with the |
10 |
|
|
# appropriate options. |
11 |
|
|
# |
12 |
|
|
# It needs to be told what type of CCF directory it is via the -t |
13 |
|
|
# development|release|public flag. |
14 |
|
|
# |
15 |
|
|
require 5; |
16 |
|
|
use strict; |
17 |
|
|
use lib "$ENV{'HOME'}/cgi"; |
18 |
|
|
$ENV{'PATH'} .= "$ENV{'HOME'}/bin:"; |
19 |
|
|
use Ccflib; |
20 |
|
|
use DB_File; |
21 |
|
|
use Getopt::Std; |
22 |
|
|
|
23 |
|
|
my %opts; |
24 |
|
|
getopts('t:', \%opts); |
25 |
|
|
die("Usage: -t development|release|public\n") if(not exists $opts{'t'}); |
26 |
|
|
|
27 |
|
|
my %ccf; |
28 |
|
|
tie %ccf, "DB_File", ".ccf.db"; |
29 |
|
|
|
30 |
|
|
my @new; |
31 |
|
|
my @gone; |
32 |
|
|
my @present = glob("*.CCF"); |
33 |
|
|
|
34 |
|
|
foreach(keys %ccf) { $ccf{$_} = ""; } |
35 |
|
|
foreach(@present){ |
36 |
|
|
push @new, ($_) if not exists $ccf{$_}; |
37 |
|
|
$ccf{$_} = '+'; |
38 |
|
|
} |
39 |
|
|
foreach(keys %ccf){ |
40 |
|
|
if($ccf{$_} ne '+'){ |
41 |
|
|
push @gone, ($_); |
42 |
|
|
delete $ccf{$_}; |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
if(@new){ |
47 |
|
|
my $cmd1 = "ccfextseq --sets='"; |
48 |
|
|
my $cmd2 = "ccfnotify -t $opts{'t'} "; |
49 |
|
|
my $l; |
50 |
|
|
foreach(@new){ |
51 |
|
|
print "New: $_\n"; |
52 |
|
|
$l .= "$_ "; |
53 |
|
|
} |
54 |
|
|
$cmd1 .= "$l'"; |
55 |
|
|
$cmd2 .= $l; |
56 |
|
|
|
57 |
|
|
execute($cmd1); |
58 |
|
|
execute($cmd2); |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
if(@gone){ |
62 |
|
|
my $cmd = "ccfnotify -t $opts{'t'} -d "; |
63 |
|
|
foreach(@gone){ |
64 |
|
|
print "Gone: $_\n"; |
65 |
|
|
$cmd .= "$_ "; |
66 |
|
|
} |
67 |
|
|
execute($cmd); |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
sub execute { |
71 |
|
|
my $cmd = shift or return; |
72 |
|
|
print STDERR "$cmd\n"; |
73 |
|
|
qx/$cmd/; |
74 |
|
|
my $status = $? >> 8; |
75 |
|
|
die("$cmd failed\n") if $status; |
76 |
|
|
return; |
77 |
|
|
} |