2 |
# |
# |
3 |
# Giuseppe Vacanti (cosine science & computing bv) |
# Giuseppe Vacanti (cosine science & computing bv) |
4 |
# |
# |
5 |
# $Id: checkupdates,v 1.2 2002/03/19 15:36:00 ccflib Exp $ |
# $Id: checkupdates,v 1.3 2002/03/19 16:09:59 ccflib Exp $ |
6 |
# |
# |
7 |
# Called in a directory containing CCF constituents (*.CCF). It cheks |
# Called in a directory containing CCF constituents (*.CCF). It cheks |
8 |
# via the DBM .ccf.db if any CCF constituent has appeared or |
# via the DBM .ccf.db if any CCF constituent has appeared or |
31 |
my @gone; |
my @gone; |
32 |
my @present = glob("*.CCF"); |
my @present = glob("*.CCF"); |
33 |
|
|
34 |
|
print "Checking for new CCF constituents in track: $opts{'t'}\n"; |
35 |
|
|
36 |
foreach(keys %ccf) { $ccf{$_} = ""; } |
foreach(keys %ccf) { $ccf{$_} = ""; } |
37 |
foreach(@present){ |
foreach(@present){ |
38 |
|
# CALINDEX consituents are not considered. |
39 |
|
next if /XMM_CALINDEX/; |
40 |
push @new, ($_) if not exists $ccf{$_}; |
push @new, ($_) if not exists $ccf{$_}; |
41 |
$ccf{$_} = '+'; |
$ccf{$_} = '+'; |
42 |
} |
} |
43 |
foreach(keys %ccf){ |
foreach(keys %ccf){ |
44 |
if($ccf{$_} ne '+'){ |
if($ccf{$_} ne '+'){ |
45 |
|
# CALINDEX consituents are not considered. |
46 |
|
next if /XMM_CALINDEX/; |
47 |
push @gone, ($_); |
push @gone, ($_); |
48 |
delete $ccf{$_}; |
delete $ccf{$_}; |
49 |
} |
} |
54 |
my $cmd2 = "ccfnotify -t $opts{'t'} "; |
my $cmd2 = "ccfnotify -t $opts{'t'} "; |
55 |
my $l; |
my $l; |
56 |
foreach(@new){ |
foreach(@new){ |
57 |
print "New: $_\n"; |
print "New constituent: $_\n"; |
58 |
$l .= "$_ "; |
$l .= "$_ "; |
59 |
} |
} |
60 |
$cmd1 .= "$l'"; |
$cmd1 .= "$l'"; |
61 |
$cmd2 .= $l; |
$cmd2 .= $l; |
62 |
|
|
63 |
|
print "Running ccfextseq to update the SUBMISSION date:\n"; |
64 |
execute($cmd1); |
execute($cmd1); |
65 |
|
print "Notification:\n"; |
66 |
execute($cmd2); |
execute($cmd2); |
67 |
|
|
68 |
# update the MIF if there are new files in the public area. |
# update the MIF if there are new files in the public area. |
69 |
my $cmd3 = "updatemif"; |
my $cmd3 = "updatemif"; |
70 |
execute($cmd3) if($opts{'t'} eq 'public'); |
if($opts{'t'} eq 'public'){ |
71 |
|
print "Creating a new MIF:\n"; |
72 |
|
execute($cmd3); |
73 |
|
} |
74 |
} |
} |
75 |
|
|
76 |
if(@gone){ |
if(@gone){ |
77 |
my $cmd = "ccfnotify -t $opts{'t'} -d "; |
my $cmd = "ccfnotify -t $opts{'t'} -d "; |
78 |
foreach(@gone){ |
foreach(@gone){ |
79 |
print "Gone: $_\n"; |
print "Gone constituent: $_\n"; |
80 |
$cmd .= "$_ "; |
$cmd .= "$_ "; |
81 |
} |
} |
82 |
execute($cmd); |
if($opts{'t'} ne 'public'){ |
83 |
|
print "Notification:\n"; |
84 |
|
execute($cmd); |
85 |
|
} |
86 |
} |
} |
87 |
|
|
88 |
sub execute { |
sub execute { |
89 |
my $cmd = shift or return; |
my $cmd = shift or return; |
90 |
print STDERR "$cmd\n"; |
print "Executing: $cmd\n"; |
91 |
qx/$cmd/; |
qx/$cmd/; |
92 |
my $status = $? >> 8; |
my $status = $? >> 8; |
93 |
die("$cmd failed\n") if $status; |
die("$cmd failed\n") if $status; |