/[CCFs]/bin/checkupdates
ViewVC logotype

Annotation of /bin/checkupdates

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Mon Dec 22 15:38:42 2014 UTC (9 years, 11 months ago) by ccflib
Branch: MAIN
Changes since 1.6: +13 -1 lines
Added to heading some comments on .ccf.db files and db_upgrade

1 ccflib 1.1 #! /usr/local/bin/perl -w
2     #
3 ccflib 1.7 # $Id: checkupdates,v 1.6 2014/12/19 14:39:16 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.6
29 ccflib 1.1 require 5;
30     use strict;
31 ccflib 1.6 #use lib "$ENV{'HOME'}/bin";
32 ccflib 1.1 $ENV{'PATH'} .= "$ENV{'HOME'}/bin:";
33 ccflib 1.6 #use Ccflib;
34     #use Ccflib_int;
35 ccflib 1.1 use DB_File;
36     use Getopt::Std;
37    
38     my %opts;
39     getopts('t:', \%opts);
40     die("Usage: -t development|release|public\n") if(not exists $opts{'t'});
41    
42 ccflib 1.6 # This constructs makes available in %ccf all the CCFs that have been stored i
43     # so far in .ccf.db as keys and '+'as values, e.g {XRT3_XPSF_0016.CCF, '+"}.
44 ccflib 1.1 my %ccf;
45     tie %ccf, "DB_File", ".ccf.db";
46    
47 ccflib 1.6 # @present will list all the CCFs that are now present in the selected directory.
48     # Among them there will be some that were already processed and have been recorded in
49     # the .ccf.db file within that particular directory and perhaps some new.
50     # Those that were processed already appear in keys of %ccf as CCF already known.
51     # Therefore any CCF in the directory not listed in the keys of %ccf is new and should be
52     # put in @new.
53     # Let us remove all '+' in %ccf. Now we go through all in @present. For each CCF found there
54     # if the CCF is not in keys of %, then it is a new CCF and we push it to @new.
55     # Finally, for each CCF present, including new ones, we put a '+" in the values of %ccf
56     # just to mark them as present, so all the rest are gone and should go to @gone.
57    
58 ccflib 1.1 my @new;
59     my @gone;
60     my @present = glob("*.CCF");
61    
62 ccflib 1.4 print "Checking for new CCF constituents in track: $opts{'t'}\n";
63    
64 ccflib 1.1 foreach(keys %ccf) { $ccf{$_} = ""; }
65     foreach(@present){
66 ccflib 1.5 # CALINDEX constituents are not considered.
67 ccflib 1.4 next if /XMM_CALINDEX/;
68 ccflib 1.1 push @new, ($_) if not exists $ccf{$_};
69     $ccf{$_} = '+';
70     }
71     foreach(keys %ccf){
72     if($ccf{$_} ne '+'){
73 ccflib 1.4 # CALINDEX consituents are not considered.
74     next if /XMM_CALINDEX/;
75 ccflib 1.1 push @gone, ($_);
76     delete $ccf{$_};
77     }
78     }
79    
80 ccflib 1.6 # Those CCF that are new, must be processed with ccfextseq to set the submission date
81     # as of today. Then a notification is sent via the ccfnotify external perl script.
82    
83 ccflib 1.1 if(@new){
84     my $cmd1 = "ccfextseq --sets='";
85     my $cmd2 = "ccfnotify -t $opts{'t'} ";
86     my $l;
87     foreach(@new){
88 ccflib 1.4 print "New constituent: $_\n";
89 ccflib 1.1 $l .= "$_ ";
90     }
91     $cmd1 .= "$l'";
92     $cmd2 .= $l;
93    
94 ccflib 1.4 print "Running ccfextseq to update the SUBMISSION date:\n";
95 ccflib 1.1 execute($cmd1);
96 ccflib 1.4 print "Notification:\n";
97 ccflib 1.1 execute($cmd2);
98 ccflib 1.2
99     # update the MIF if there are new files in the public area.
100 ccflib 1.6 # The MIF or Master Index File is a CALINDEX file created as new,
101     # but only if the repository is the public one.
102    
103 ccflib 1.2 my $cmd3 = "updatemif";
104 ccflib 1.4 if($opts{'t'} eq 'public'){
105     print "Creating a new MIF:\n";
106     execute($cmd3);
107     }
108 ccflib 1.1 }
109    
110 ccflib 1.6 # Notify also on those CCF removed from any directory being tracked.
111    
112 ccflib 1.1 if(@gone){
113     my $cmd = "ccfnotify -t $opts{'t'} -d ";
114     foreach(@gone){
115 ccflib 1.4 print "Gone constituent: $_\n";
116 ccflib 1.1 $cmd .= "$_ ";
117     }
118 ccflib 1.4 if($opts{'t'} ne 'public'){
119     print "Notification:\n";
120     execute($cmd);
121     }
122 ccflib 1.1 }
123    
124     sub execute {
125     my $cmd = shift or return;
126 ccflib 1.4 print "Executing: $cmd\n";
127 ccflib 1.1 qx/$cmd/;
128     my $status = $? >> 8;
129     die("$cmd failed\n") if $status;
130     return;
131     }

  ViewVC Help
Powered by ViewVC 1.1.27