1 |
ccflib |
1.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 |
ccflib |
1.3 |
# $Id: mtovccf,v 1.2 2015/03/10 15:21:00 ccflib Exp $ |
9 |
ccflib |
1.1 |
|
10 |
|
|
VALID_CCF="/home/ccflib/valid_ccf" |
11 |
|
|
|
12 |
ccflib |
1.3 |
if [ -z "$1" ] ; then |
13 |
|
|
echo |
14 |
|
|
echo "Use: mtovccf all_ccfs" |
15 |
|
|
echo " File all_ccfs (without .txt ext) must be produced by mlovccf" |
16 |
|
|
echo |
17 |
ccflib |
1.1 |
exit |
18 |
|
|
fi |
19 |
|
|
|
20 |
ccflib |
1.3 |
all_ccfs=$1 |
21 |
|
|
|
22 |
|
|
if [ ! -f "${VALID_CCF}/${all_ccfs}.txt" ] ; then |
23 |
|
|
echo "Error: Cannot find ${all_ccfs}.txt in directory ${VALID_CCF}" |
24 |
|
|
exit |
25 |
|
|
fi |
26 |
|
|
|
27 |
|
|
now=`date +'%Y-%M-%dT%H:%M:%S'` |
28 |
|
|
|
29 |
ccflib |
1.1 |
# Lists all CCF classes |
30 |
|
|
|
31 |
|
|
ccf_classes="${VALID_CCF}/ccf_classes.txt" |
32 |
|
|
|
33 |
|
|
while read line |
34 |
|
|
do |
35 |
|
|
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
36 |
|
|
echo $class >> ${ccf_classes} |
37 |
ccflib |
1.3 |
done < ${VALID_CCF}/${all_ccfs}.txt |
38 |
ccflib |
1.1 |
|
39 |
|
|
cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt |
40 |
|
|
mv ${VALID_CCF}/kk.txt ${ccf_classes} |
41 |
|
|
|
42 |
|
|
# Output final file is named all_ccfs_table.txt |
43 |
|
|
|
44 |
ccflib |
1.2 |
total_number_of_ccfs=0 |
45 |
|
|
|
46 |
ccflib |
1.3 |
all_ccfs_table="${VALID_CCF}/${all_ccfs}_table.txt" |
47 |
ccflib |
1.1 |
|
48 |
|
|
[ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table} |
49 |
|
|
|
50 |
ccflib |
1.3 |
|
51 |
ccflib |
1.2 |
|
52 |
|
|
echo "Table of valid CCFs at $now" >> ${all_ccfs_table} |
53 |
|
|
echo >> ${all_ccfs_table} |
54 |
ccflib |
1.1 |
echo "|================================|=============|" >> ${all_ccfs_table} |
55 |
|
|
echo "| Calibration File | Issue range |" >> ${all_ccfs_table} |
56 |
|
|
echo "|================================|=============|" >> ${all_ccfs_table} |
57 |
|
|
|
58 |
ccflib |
1.2 |
|
59 |
ccflib |
1.1 |
while read ccf_class |
60 |
ccflib |
1.2 |
do |
61 |
|
|
echo -n "Processing class $ccf_class ..." |
62 |
ccflib |
1.1 |
issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt" |
63 |
|
|
[ -f "${issues_file}" ] && rm ${issues_file} |
64 |
|
|
while read line |
65 |
|
|
do |
66 |
|
|
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
67 |
|
|
[ "$class" != "$ccf_class" ] && continue |
68 |
|
|
issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1` |
69 |
|
|
echo $issue >> ${issues_file} |
70 |
ccflib |
1.3 |
done < ${VALID_CCF}/${all_ccfs}.txt |
71 |
ccflib |
1.1 |
|
72 |
ccflib |
1.2 |
|
73 |
ccflib |
1.1 |
cat ${issues_file} | sort -u > kk.txt |
74 |
|
|
mv kk.txt ${issues_file} |
75 |
ccflib |
1.2 |
real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'` |
76 |
ccflib |
1.1 |
|
77 |
|
|
first_issue=`head -1 ${issues_file}` |
78 |
|
|
last_issue=`tail -1 ${issues_file}` |
79 |
|
|
|
80 |
ccflib |
1.2 |
li=$((10#$last_issue)) |
81 |
|
|
fi=$((10#$first_issue)) |
82 |
|
|
|
83 |
|
|
sequential_number_of_issues_for_this_class=$(($li - $fi + 1)) |
84 |
|
|
if [ "${real_number_of_issues_for_this_class}" -lt "${sequential_number_of_issues_for_this_class}" ] ; then |
85 |
|
|
asterisk="(*)" |
86 |
|
|
else |
87 |
|
|
asterisk=" " |
88 |
|
|
fi |
89 |
|
|
total_number_of_ccfs=$(($real_number_of_issues_for_this_class + $total_number_of_ccfs)) |
90 |
|
|
|
91 |
ccflib |
1.1 |
if [ "${first_issue}" != "${last_issue}" ] ; then |
92 |
ccflib |
1.2 |
printf "| %-30s | %4s-%4s%3s|\n" ${ccf_class} ${first_issue} ${last_issue} ${asterisk} >> ${all_ccfs_table} |
93 |
ccflib |
1.1 |
else |
94 |
ccflib |
1.3 |
printf "| %-30s | %4s |\n" ${ccf_class} ${first_issue} >> ${all_ccfs_table} |
95 |
ccflib |
1.1 |
fi |
96 |
|
|
|
97 |
ccflib |
1.2 |
echo "done" |
98 |
ccflib |
1.1 |
done < ${ccf_classes} |
99 |
|
|
|
100 |
ccflib |
1.3 |
echo "|================================|=============|" >> ${all_ccfs_table} |
101 |
|
|
echo >> ${all_ccfs_table} |
102 |
|
|
echo "(*): Some issues in the range are not required." >> ${all_ccfs_table} |
103 |
ccflib |
1.2 |
rm ${VALID_CCF}/ccf_classes.txt |
104 |
|
|
rm ${VALID_CCF}/ccf_issues_for*.txt |
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
ccflib |
1.3 |
echo ; echo "Number of valid CCFs required as of $now : ${total_number_of_ccfs}" |