-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_status.pl
executable file
·162 lines (130 loc) · 3.76 KB
/
check_status.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env perl -w
#
# Usage:
# check_status.pl --type=test|live|trial
# Default for type is test
#
# --config=config-file
# The name (including path) of the configuration file.
# Defaults to <path to this script>/config.dat
#
# --verbose
# Turn on screen output that's only useful for testing/debugging
#
# Aim:
# Report those files that need to be re-published because of
# changes in their dependencies.
#
# Looks for all files in the current site (does not restrict
# to the current directory, but may be changed to do so).
#
# Creates:
# A list of file names, to the screen.
#
# Requires:
#
# Author:
# Doug Burke ([email protected])
#
use strict;
$|++;
use Getopt::Long;
use FindBin;
use Cwd;
use File::Find;
use lib $FindBin::Bin;
use CIAODOC qw( :util :cfg :deps );
## Subroutines (see end of file)
#
## set up variables that are also used in CIAODOC
use vars qw( $configfile $verbose $group $site );
$configfile = "$FindBin::Bin/config.dat";
$verbose = 0;
$group = "";
$site = "";
## Variables
#
# We need a default prefix in order to find the default
# config file, even if we want to be able to over-ride
# everything from the command-line
#
my $prefix = "/data/da/Docs"; # should NOT end in a /
## Code
#
my $progname = (split( m{/}, $0 ))[-1];
my $usage = <<"EOD";
Usage:
$progname --config=name --type=test|live|trial
The default is --type=test.
The --config option gives the path to the configuration file; this
defaults to config.dat in the same directory as the script.
The --verbose option is useful for testing/debugging the code.
EOD
# this will be mangled later
my $dname = cwd();
# handle options
my $type = "test";
die $usage unless
GetOptions
'config=s' => \$configfile,
'type=s' => \$type,
'verbose!' => \$verbose;
# check the options
die "Error: the config option can not be blank\n"
if $configfile eq "";
my $config = parse_config( $configfile );
# most of the config stuff is parsed below, but we need these two here
my $site_config;
( $site, $site_config ) = find_site $config, $dname;
$config = undef; # DBG: just make sure no one is trying to access it
dbg "Site = $site";
check_type_known $site_config, $type;
dbg "Type = $type";
# check usage
#
die $usage unless $#ARGV == -1;
# Handle the remaining config values
#
# shouldn't have so many global variables...
#
$group = get_group $site_config;
my ( $version, $version_config, $dhead, $depth ) = check_location $site_config, $dname;
# get the site version
my $site_version = "";
if ( ! ($site =~ /caldb/)) {
if (check_config_exists( $version_config, "number" )){
$site_version = get_config_version( $version_config, "number" );
} else {
die "Error: version $version in the config file ($configfile) does not contain the number parameter\n";
}
}
my $storageloc = "";
$storageloc = get_config_type( $version_config, "storageloc", $type )
if check_config_exists( $version_config, "storageloc" );
die "Error: no dependency information possible for site=$site/type=$type as storageloc is empty!\n"
if $storageloc eq "";
dbg "Using storage area: $storageloc";
die "Error: unable to find storageloc=$storageloc\n"
unless -e $storageloc;
my $storagedir = get_storage_location $storageloc, $site;
# Get the list of revdep files to query
my @revdeps;
sub wanted {
push @revdeps, $File::Find::name
if /\.revdep$/ && -e $_;
}
File::Find::find(\&wanted, $storagedir);
dbg "Found " . (1 + $#revdeps) . " matching files";
my %seen = ();
foreach my $revdep (@revdeps) {
dbg "Processing: $revdep";
my $files = identify_files_to_republish $revdep;
dbg " -> " . (1 + $#$files) . " matches";
foreach my $file (@$files) {
# TODO: convert file into a relative path
print "$file\n"
unless exists $seen{$file};
$seen{$file} = 1;
}
}
# end