1 |
#! /usr/local/bin/perl -w |
#! /usr/local/bin/perl -w |
2 |
# |
# |
3 |
# Giuseppe Vacanti (cosine science & computing bv) |
# $Id: checkupdates,v 1.7 2014/12/22 15:38:42 ccflib Exp $ |
4 |
# |
# |
5 |
# $Id: checkupdates,v 1.3 2002/03/19 16:09:59 ccflib Exp $ |
# Called in a directory containing CCF constituents (*.CCF). It checks |
|
# |
|
|
# Called in a directory containing CCF constituents (*.CCF). It cheks |
|
6 |
# via the DBM .ccf.db if any CCF constituent has appeared or |
# via the DBM .ccf.db if any CCF constituent has appeared or |
7 |
# disappeared, and launches the notification script with the |
# disappeared, and launches the notification script with the |
8 |
# appropriate options. |
# appropriate options. |
10 |
# It needs to be told what type of CCF directory it is via the -t |
# It needs to be told what type of CCF directory it is via the -t |
11 |
# development|release|public flag. |
# development|release|public flag. |
12 |
# |
# |
13 |
|
# Required Ccflib.pm which defines directories in xvsoc01 |
14 |
|
# but it looks like have never been used. Commented out. |
15 |
|
# |
16 |
|
# A word of warning regarding the .ccf.db files included in the |
17 |
|
# different subdirectories public, release and development. |
18 |
|
# Given that these directories have been duplicated from xvsoc01 |
19 |
|
# that is a Solaris system, the .db files were Berkeley DB Version 1. |
20 |
|
# As such, the copy to here did not work producing as a consequence that |
21 |
|
# all CCFs in public were considered NEW CCFs. |
22 |
|
# After some investigation, we discovered in xvsoc01 the utility db_upgrade |
23 |
|
# which when applied to .ccf.db in constituents produced a perfectly valid .db |
24 |
|
# file on Linux. After applying db_upgrade to .ccf.db in xvsoc01, we have copied it |
25 |
|
# to sasbld01 and used for the public directory of CCFs producing no problem. |
26 |
|
# The same was done for release and development. However we found that the .ccf.db |
27 |
|
# file found in xvsoc01's development directory is of the wrong byte-order. |
28 |
|
# Later investigation has shown that the previous exercise was not necessary due to |
29 |
|
# .ccf.db is re-built if not present in the directory analyzed. Therefore despite |
30 |
|
# the first run considers all CCF as new, the next takes the .ccf.db created and |
31 |
|
# lists as new only those added. |
32 |
|
|
33 |
require 5; |
require 5; |
34 |
use strict; |
use strict; |
35 |
use lib "$ENV{'HOME'}/cgi"; |
#use lib "$ENV{'HOME'}/bin"; |
36 |
$ENV{'PATH'} .= "$ENV{'HOME'}/bin:"; |
$ENV{'PATH'} .= ":$ENV{'HOME'}/bin"; |
37 |
use Ccflib; |
#use Ccflib; |
38 |
|
#use Ccflib_int; |
39 |
use DB_File; |
use DB_File; |
40 |
use Getopt::Std; |
use Getopt::Std; |
41 |
|
|
43 |
getopts('t:', \%opts); |
getopts('t:', \%opts); |
44 |
die("Usage: -t development|release|public\n") if(not exists $opts{'t'}); |
die("Usage: -t development|release|public\n") if(not exists $opts{'t'}); |
45 |
|
|
46 |
|
# This constructs makes available in %ccf all the CCFs that have been stored |
47 |
|
# so far in .ccf.db as keys and '+'as values, e.g {XRT3_XPSF_0016.CCF, '+'}. |
48 |
my %ccf; |
my %ccf; |
49 |
tie %ccf, "DB_File", ".ccf.db"; |
tie %ccf, "DB_File", ".ccf.db"; |
50 |
|
|
51 |
|
# @present will list all the CCFs that are now present in the selected directory. |
52 |
|
# Among them there will be some that were already processed and have been recorded in |
53 |
|
# the .ccf.db file within that particular directory and perhaps some new. |
54 |
|
# Those that were processed already appear in keys of %ccf as CCF already known. |
55 |
|
# Therefore any CCF in the directory not listed in the keys of %ccf is new and should be |
56 |
|
# put in @new. |
57 |
|
# Let us remove all '+' in %ccf. Now we go through all in @present. For each CCF found there |
58 |
|
# if the CCF is not in keys of %, then it is a new CCF and we push it to @new. |
59 |
|
# Finally, for each CCF present, including new ones, we put a '+" in the values of %ccf |
60 |
|
# just to mark them as present, so all the rest are gone and should go to @gone. |
61 |
|
|
62 |
my @new; |
my @new; |
63 |
my @gone; |
my @gone; |
64 |
my @present = glob("*.CCF"); |
my @present = glob("*.CCF"); |
67 |
|
|
68 |
foreach(keys %ccf) { $ccf{$_} = ""; } |
foreach(keys %ccf) { $ccf{$_} = ""; } |
69 |
foreach(@present){ |
foreach(@present){ |
70 |
# CALINDEX consituents are not considered. |
# CALINDEX constituents are not considered. |
71 |
next if /XMM_CALINDEX/; |
next if /XMM_CALINDEX/; |
72 |
push @new, ($_) if not exists $ccf{$_}; |
push @new, ($_) if not exists $ccf{$_}; |
73 |
$ccf{$_} = '+'; |
$ccf{$_} = '+'; |
81 |
} |
} |
82 |
} |
} |
83 |
|
|
84 |
|
# Those CCF that are new, must be processed with ccfextseq to set the submission date |
85 |
|
# as of today. Then a notification is sent via the ccfnotify external perl script. |
86 |
|
|
87 |
if(@new){ |
if(@new){ |
88 |
my $cmd1 = "ccfextseq --sets='"; |
my $cmd1 = "ccfextseq --sets='"; |
89 |
my $cmd2 = "ccfnotify -t $opts{'t'} "; |
my $cmd2 = "ccfnotify -t $opts{'t'} "; |
101 |
execute($cmd2); |
execute($cmd2); |
102 |
|
|
103 |
# update the MIF if there are new files in the public area. |
# update the MIF if there are new files in the public area. |
104 |
|
# The MIF or Master Index File is a CALINDEX file created as new, |
105 |
|
# but only if the repository is the public one. |
106 |
|
|
107 |
my $cmd3 = "updatemif"; |
my $cmd3 = "updatemif"; |
108 |
if($opts{'t'} eq 'public'){ |
if($opts{'t'} eq 'public'){ |
109 |
print "Creating a new MIF:\n"; |
print "Creating a new MIF:\n"; |
111 |
} |
} |
112 |
} |
} |
113 |
|
|
114 |
|
# Notify also on those CCF removed from any directory being tracked. |
115 |
|
|
116 |
if(@gone){ |
if(@gone){ |
117 |
my $cmd = "ccfnotify -t $opts{'t'} -d "; |
my $cmd = "ccfnotify -t $opts{'t'} -d "; |
118 |
foreach(@gone){ |
foreach(@gone){ |