1 |
#! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl -w |
2 |
# |
3 |
# Giuseppe Vacanti (cosine science & computing) |
4 |
# $Date: 2011/01/10 13:50:13 $ |
5 |
# |
6 |
# It receives the mirror log for the current package on stdin. |
7 |
# |
8 |
require 5; |
9 |
use FileHandle; |
10 |
use strict; |
11 |
|
12 |
my @log = <STDIN>; |
13 |
# Catch ftp errors -> to sdterr |
14 |
foreach(@log){ |
15 |
if(/^Failed/){ |
16 |
my $name = (split)[3]; |
17 |
warn("$name: mirror failure\n"); |
18 |
} |
19 |
} |
20 |
|
21 |
my $update; |
22 |
my @to; |
23 |
my $subject; |
24 |
# Expect Mirrored when fed output directly from mirror |
25 |
# Expect mirroring when using the log file. |
26 |
if($log[0] =~ /^(Mirrored|mirroring) (.+) \(.+:(.+)\)/){ |
27 |
my $pkg = $2; my $dir = $3; |
28 |
foreach($pkg){ |
29 |
|
30 |
/^ccfdevel$/ && do { |
31 |
$update = "development"; |
32 |
@to = qw/xmm-it sas-devel/; |
33 |
$subject = "Update of the $update CCF area"; |
34 |
next; |
35 |
}; |
36 |
|
37 |
/^ccfreleasetrack$/ && do { |
38 |
$update = "release"; |
39 |
@to = qw/xmm-it sas-devel/; |
40 |
$subject = "Update of the $update CCF area"; |
41 |
next; |
42 |
}; |
43 |
|
44 |
/^ccf$/ && do { |
45 |
$update = "public"; |
46 |
@to = qw/ccf xmm-it sas-devel/; |
47 |
$subject = "XMM-Newton calibration update"; |
48 |
next; |
49 |
}; |
50 |
|
51 |
/^scisimccf$/ && do { |
52 |
$update = "scisim"; |
53 |
@to = qw/xmm-it sas-devel/; |
54 |
$subject = "Update of the $update CCF area"; |
55 |
next; |
56 |
}; |
57 |
|
58 |
/^extras$/ && do { |
59 |
$update = "public"; |
60 |
@to = qw/xmm-it sas-devel/; |
61 |
$subject = "Update of the $update CCF area"; |
62 |
next; |
63 |
}; |
64 |
|
65 |
die("Cannot match mirror package: $_"); |
66 |
} |
67 |
} else { |
68 |
die("Cannot find the word 'mirroring' in @log\n"); |
69 |
} |
70 |
|
71 |
my @names; |
72 |
foreach(@log){ |
73 |
next if /CALINDEX/; |
74 |
if(/^Put/){ |
75 |
push @names, (((split)[1])); |
76 |
} |
77 |
} |
78 |
exit(0) if(not @names); |
79 |
|
80 |
|
81 |
foreach(@to){ |
82 |
my $fh = new FileHandle "|/usr/lib/sendmail -t" or die ("$!\n"); |
83 |
|
84 |
$fh->print("From: ccflib\@xmm.esac.esa.int |
85 |
To: $_\@xmm.esac.esa.int |
86 |
Subject: $subject |
87 |
"); |
88 |
|
89 |
|
90 |
$fh->print("\nThe following new calibration constituents are available:\n\n"); |
91 |
|
92 |
foreach(@names){ |
93 |
$fh->print("$_\n"); |
94 |
} |
95 |
|
96 |
if($update eq "public"){ |
97 |
$fh->print(' |
98 |
For details and download instructions please refer to: |
99 |
|
100 |
https://www.cosmos.esa.int/web/xmm-newton/calibration |
101 |
https://www.cosmos.esa.int/web/xmm-newton/ccf-release-notes |
102 |
|
103 |
Best regards, |
104 |
|
105 |
The XMM-Newton Calibration Librarian |
106 |
xmmhelp@sciops.esa.int |
107 |
|
108 |
'); |
109 |
|
110 |
undef $fh; |
111 |
|
112 |
} |
113 |
|
114 |
} |
115 |
|
116 |
|
117 |
|
118 |
|