/[CCFs]/bin/checkupdates
ViewVC logotype

Contents of /bin/checkupdates

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Mon Jan 15 10:02:11 2018 UTC (6 years, 10 months ago) by ccflib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +2 -2 lines
Newer versions of archive_valid_ccf_lists.sh, checkupdates, deleteccf, findlatest and last_version to have a locally installed version of perl

1 #! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl -w
2 #
3 # $Id: checkupdates,v 1.8 2015/02/02 14:39:04 ccflib Exp $
4 #
5 # Called in a directory containing CCF constituents (*.CCF). It checks
6 # 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 # 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;
34 use strict;
35 #use lib "$ENV{'HOME'}/bin";
36 $ENV{'PATH'} .= ":$ENV{'HOME'}/bin";
37 #use Ccflib;
38 #use Ccflib_int;
39 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 # 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;
49 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;
63 my @gone;
64 my @present = glob("*.CCF");
65
66 print "Checking for new CCF constituents in track: $opts{'t'}\n";
67
68 foreach(keys %ccf) { $ccf{$_} = ""; }
69 foreach(@present){
70 # CALINDEX constituents are not considered.
71 next if /XMM_CALINDEX/;
72 push @new, ($_) if not exists $ccf{$_};
73 $ccf{$_} = '+';
74 }
75 foreach(keys %ccf){
76 if($ccf{$_} ne '+'){
77 # CALINDEX consituents are not considered.
78 next if /XMM_CALINDEX/;
79 push @gone, ($_);
80 delete $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){
88 my $cmd1 = "ccfextseq --sets='";
89 my $cmd2 = "ccfnotify -t $opts{'t'} ";
90 my $l;
91 foreach(@new){
92 print "New constituent: $_\n";
93 $l .= "$_ ";
94 }
95 $cmd1 .= "$l'";
96 $cmd2 .= $l;
97
98 print "Running ccfextseq to update the SUBMISSION date:\n";
99 execute($cmd1);
100 print "Notification:\n";
101 execute($cmd2);
102
103 # 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";
108 if($opts{'t'} eq 'public'){
109 print "Creating a new MIF:\n";
110 execute($cmd3);
111 }
112 }
113
114 # Notify also on those CCF removed from any directory being tracked.
115
116 if(@gone){
117 my $cmd = "ccfnotify -t $opts{'t'} -d ";
118 foreach(@gone){
119 print "Gone constituent: $_\n";
120 $cmd .= "$_ ";
121 }
122 if($opts{'t'} ne 'public'){
123 print "Notification:\n";
124 execute($cmd);
125 }
126 }
127
128 sub execute {
129 my $cmd = shift or return;
130 print "Executing: $cmd\n";
131 qx/$cmd/;
132 my $status = $? >> 8;
133 die("$cmd failed\n") if $status;
134 return;
135 }

  ViewVC Help
Powered by ViewVC 1.1.27