/[CCFs]/bin/checkupdates
ViewVC logotype

Annotation of /bin/checkupdates

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations)
Mon Feb 2 14:39:04 2015 UTC (9 years, 9 months ago) by ccflib
Branch: MAIN
Changes since 1.7: +8 -4 lines
Added to the header comments explanantion on the creation of .ccf.db files in case they are wrong or not existing. First time before exists .ccf.db treats all CCF as new

1 ccflib 1.1 #! /usr/local/bin/perl -w
2     #
3 ccflib 1.8 # $Id: checkupdates,v 1.7 2014/12/22 15:38:42 ccflib Exp $
4 ccflib 1.1 #
5 ccflib 1.6 # Called in a directory containing CCF constituents (*.CCF). It checks
6 ccflib 1.1 # via the DBM .ccf.db if any CCF constituent has appeared or
7     # disappeared, and launches the notification script with the
8     # appropriate options.
9     #
10     # It needs to be told what type of CCF directory it is via the -t
11     # development|release|public flag.
12     #
13 ccflib 1.6 # Required Ccflib.pm which defines directories in xvsoc01
14     # but it looks like have never been used. Commented out.
15     #
16 ccflib 1.7 # 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 ccflib 1.8 # 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 ccflib 1.6
33 ccflib 1.1 require 5;
34     use strict;
35 ccflib 1.6 #use lib "$ENV{'HOME'}/bin";
36 ccflib 1.8 $ENV{'PATH'} .= ":$ENV{'HOME'}/bin";
37 ccflib 1.6 #use Ccflib;
38     #use Ccflib_int;
39 ccflib 1.1 use DB_File;
40     use Getopt::Std;
41    
42     my %opts;
43     getopts('t:', \%opts);
44     die("Usage: -t development|release|public\n") if(not exists $opts{'t'});
45    
46 ccflib 1.8 # 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 ccflib 1.1 my %ccf;
49     tie %ccf, "DB_File", ".ccf.db";
50    
51 ccflib 1.6 # @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 ccflib 1.1 my @new;
63     my @gone;
64     my @present = glob("*.CCF");
65    
66 ccflib 1.4 print "Checking for new CCF constituents in track: $opts{'t'}\n";
67    
68 ccflib 1.1 foreach(keys %ccf) { $ccf{$_} = ""; }
69     foreach(@present){
70 ccflib 1.5 # CALINDEX constituents are not considered.
71 ccflib 1.4 next if /XMM_CALINDEX/;
72 ccflib 1.1 push @new, ($_) if not exists $ccf{$_};
73     $ccf{$_} = '+';
74     }
75     foreach(keys %ccf){
76     if($ccf{$_} ne '+'){
77 ccflib 1.4 # CALINDEX consituents are not considered.
78     next if /XMM_CALINDEX/;
79 ccflib 1.1 push @gone, ($_);
80     delete $ccf{$_};
81     }
82     }
83    
84 ccflib 1.6 # 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 ccflib 1.1 if(@new){
88     my $cmd1 = "ccfextseq --sets='";
89     my $cmd2 = "ccfnotify -t $opts{'t'} ";
90     my $l;
91     foreach(@new){
92 ccflib 1.4 print "New constituent: $_\n";
93 ccflib 1.1 $l .= "$_ ";
94     }
95     $cmd1 .= "$l'";
96     $cmd2 .= $l;
97    
98 ccflib 1.4 print "Running ccfextseq to update the SUBMISSION date:\n";
99 ccflib 1.1 execute($cmd1);
100 ccflib 1.4 print "Notification:\n";
101 ccflib 1.1 execute($cmd2);
102 ccflib 1.2
103     # update the MIF if there are new files in the public area.
104 ccflib 1.6 # 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 ccflib 1.2 my $cmd3 = "updatemif";
108 ccflib 1.4 if($opts{'t'} eq 'public'){
109     print "Creating a new MIF:\n";
110     execute($cmd3);
111     }
112 ccflib 1.1 }
113    
114 ccflib 1.6 # Notify also on those CCF removed from any directory being tracked.
115    
116 ccflib 1.1 if(@gone){
117     my $cmd = "ccfnotify -t $opts{'t'} -d ";
118     foreach(@gone){
119 ccflib 1.4 print "Gone constituent: $_\n";
120 ccflib 1.1 $cmd .= "$_ ";
121     }
122 ccflib 1.4 if($opts{'t'} ne 'public'){
123     print "Notification:\n";
124     execute($cmd);
125     }
126 ccflib 1.1 }
127    
128     sub execute {
129     my $cmd = shift or return;
130 ccflib 1.4 print "Executing: $cmd\n";
131 ccflib 1.1 qx/$cmd/;
132     my $status = $? >> 8;
133     die("$cmd failed\n") if $status;
134     return;
135     }

  ViewVC Help
Powered by ViewVC 1.1.27