1 |
#! /bin/bash |
2 |
|
3 |
# mtovccf (make tableof valid ccfs) |
4 |
# |
5 |
# Make a table of classes and issues type "Pipeline Release Notes" |
6 |
# Requires that mlovccf has been run before to produce the all_ccfs.txt file |
7 |
# |
8 |
# $Id: mtovccf,v 1.1 2015/03/10 13:28:13 ccflib Exp $ |
9 |
|
10 |
VALID_CCF="/home/ccflib/valid_ccf" |
11 |
|
12 |
if [ ! -f "${VALID_CCF}/all_ccfs.txt" ] ; then |
13 |
echo "Error: Please run first mlovccf" |
14 |
exit |
15 |
fi |
16 |
|
17 |
# Lists all CCF classes |
18 |
|
19 |
ccf_classes="${VALID_CCF}/ccf_classes.txt" |
20 |
|
21 |
while read line |
22 |
do |
23 |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
24 |
echo $class >> ${ccf_classes} |
25 |
done < ${VALID_CCF}/all_ccfs.txt |
26 |
|
27 |
cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt |
28 |
mv ${VALID_CCF}/kk.txt ${ccf_classes} |
29 |
|
30 |
# Output final file is named all_ccfs_table.txt |
31 |
|
32 |
total_number_of_ccfs=0 |
33 |
|
34 |
all_ccfs_table="${VALID_CCF}/all_ccfs_table.txt" |
35 |
|
36 |
[ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table} |
37 |
|
38 |
now=`date +'%Y-%M-%dT%H:%M:%S'` |
39 |
|
40 |
echo "Table of valid CCFs at $now" >> ${all_ccfs_table} |
41 |
echo >> ${all_ccfs_table} |
42 |
echo "|================================|=============|" >> ${all_ccfs_table} |
43 |
echo "| Calibration File | Issue range |" >> ${all_ccfs_table} |
44 |
echo "|================================|=============|" >> ${all_ccfs_table} |
45 |
|
46 |
|
47 |
while read ccf_class |
48 |
do |
49 |
echo -n "Processing class $ccf_class ..." |
50 |
issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt" |
51 |
[ -f "${issues_file}" ] && rm ${issues_file} |
52 |
while read line |
53 |
do |
54 |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
55 |
[ "$class" != "$ccf_class" ] && continue |
56 |
issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1` |
57 |
echo $issue >> ${issues_file} |
58 |
done < ${VALID_CCF}/all_ccfs.txt |
59 |
|
60 |
|
61 |
cat ${issues_file} | sort -u > kk.txt |
62 |
mv kk.txt ${issues_file} |
63 |
real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'` |
64 |
|
65 |
first_issue=`head -1 ${issues_file}` |
66 |
last_issue=`tail -1 ${issues_file}` |
67 |
|
68 |
li=$((10#$last_issue)) |
69 |
fi=$((10#$first_issue)) |
70 |
|
71 |
sequential_number_of_issues_for_this_class=$(($li - $fi + 1)) |
72 |
if [ "${real_number_of_issues_for_this_class}" -lt "${sequential_number_of_issues_for_this_class}" ] ; then |
73 |
asterisk="(*)" |
74 |
else |
75 |
asterisk=" " |
76 |
fi |
77 |
total_number_of_ccfs=$(($real_number_of_issues_for_this_class + $total_number_of_ccfs)) |
78 |
|
79 |
if [ "${first_issue}" != "${last_issue}" ] ; then |
80 |
printf "| %-30s | %4s-%4s%3s|\n" ${ccf_class} ${first_issue} ${last_issue} ${asterisk} >> ${all_ccfs_table} |
81 |
else |
82 |
printf "| %-30s | %4s |\n" ${ccf_class} ${first_issue} >> ${all_ccfs_table} |
83 |
fi |
84 |
|
85 |
echo "done" |
86 |
done < ${ccf_classes} |
87 |
|
88 |
echo "|================================|=============|" >> ${all_ccfs_table} |
89 |
echo >> ${all_ccfs_table} |
90 |
echo "(*): Some issues in the range are not required." >> ${all_ccfs_table} |
91 |
rm ${VALID_CCF}/ccf_classes.txt |
92 |
rm ${VALID_CCF}/ccf_issues_for*.txt |
93 |
|
94 |
|
95 |
|
96 |
echo ; echo "Number of valid CCFs required at $now : ${total_number_of_ccfs}" |