/[CCFs]/bin/checkupdates
ViewVC logotype

Annotation of /bin/checkupdates

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations)
Fri Dec 19 14:39:16 2014 UTC (9 years, 11 months ago) by ccflib
Branch: MAIN
Changes since 1.5: +30 -5 lines
removed Ccflib after considering it is not used at all

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

  ViewVC Help
Powered by ViewVC 1.1.27