]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/source-maintenance.sh
3 # This script contains the code run to perform automatic source maintenance
6 ## Source Code Format Enforcement
8 # A checker to recursively reformat all source files: .h .c .cc .cci
9 # using a custom astyle formatter and to use MD5 to validate that
10 # the formatter has not altered the code syntax.
12 # If code alteration takes place the process is halted for manual intervention.
15 # On squid-cache.org we have to use the python scripted md5sum
17 if test "$HOST" = "squid-cache.org" ; then
25 ASVER
=`astyle --version 2>&1 | grep -o -E "[0-9.]+"`
26 if test "${ASVER}" != "1.23" ; then
27 echo "Astyle version problem. You have ${ASVER} instead of 1.23";
29 echo "Found astyle ${ASVER}. Formatting..."
35 #echo "FORMAT: ${PWD}..."
38 # Scan for incorrect use of #ifdef/#ifndef
40 grep -E "ifn?def .*_SQUID_" .
/* |
grep -v -E "_H$" |
while read f
; do echo "PROBLEM?: ${PWD} ${f}"; done
43 # Scan for file-specific actions
45 for FILENAME
in `ls -1`; do
52 # Code Style formatting maintenance
54 if test "${ASVER}" = "1.23"; then
55 ${ROOT}/scripts
/formater.pl
${FILENAME}
56 if test -e $FILENAME -a -e "$FILENAME.astylebak"; then
57 md51
=`cat $FILENAME| tr -d "\n \t\r" | $MD5`;
58 md52
=`cat $FILENAME.astylebak| tr -d "\n \t\r" | $MD5`;
60 if test "$md51" != "$md52" ; then
61 echo "ERROR: File $PWD/$FILENAME not formating well";
62 mv $FILENAME $FILENAME.astylebad
63 mv $FILENAME.astylebak
$FILENAME
65 rm -f $FILENAME.astylebak
71 # REQUIRE squid.h first #include
75 FI
=`grep "#include" ${FILENAME} | head -1`;
76 if test "${FI}" != "#include \"squid.h\"" -a "${FILENAME}" != "cf_gen.cc"; then
77 echo "ERROR: ${PWD}/${FILENAME} does not include squid.h first!"
81 FI
=`grep "#include \"squid.h\"" ${FILENAME}`;
82 if test "x${FI}" != "x" ; then
83 echo "ERROR: ${PWD}/${FILENAME} duplicate include of squid.h"
89 # forward.h means different things to Squid code depending on the path
90 # require the full path is explicit for every include
92 FI
=`grep "#include \"forward.h\"" ${FILENAME}`;
93 if test "x${FI}" != "x" ; then
94 echo "ERROR: ${PWD}/${FILENAME} contains reference to forward.h without path"
98 # DEBUG Section list maintenance
100 grep " DEBUG: section" <${FILENAME} |
sed -e 's/ \* DEBUG: //' >>${ROOT}/doc
/debug-sections.tmp
103 # File permissions maintenance.
105 chmod 644 ${FILENAME}
110 # File permissions maintenance.
112 chmod 755 ${FILENAME}
117 perl
-i -p -e 's/@([A-Z0-9_]+)@/\$($1)/g' <${FILENAME} >${FILENAME}.styled
118 mv ${FILENAME}.styled
${FILENAME}
123 if test "$FILENAME" = "libltdl" ; then
125 elif test -d $FILENAME ; then
127 srcformat
${ROOT} ||
exit 1
134 # Build XPROF types file from current sources
135 echo "#ifndef _PROFILER_XPROF_TYPE_H_" >${ROOT}/lib
/profiler
/list
136 echo "#define _PROFILER_XPROF_TYPE_H_" >>${ROOT}/lib
/profiler
/list
137 echo "/* AUTO-GENERATED FILE */" >>${ROOT}/lib
/profiler
/list
138 echo "#if USE_XPROF_STATS" >>${ROOT}/lib
/profiler
/list
139 echo "typedef enum {" >>${ROOT}/lib
/profiler
/list
140 echo "XPROF_PROF_UNACCOUNTED," >>${ROOT}/lib
/profiler
/list
141 grep -R -h "PROF_start.*" .
/* |
grep -v probename |
sed -e 's/ //g; s/PROF_start(/XPROF_/; s/);/,/' |
sort -u >>${ROOT}/lib
/profiler
/list
142 echo " XPROF_LAST } xprof_type;" >>${ROOT}/lib
/profiler
/list
143 echo "#endif" >>${ROOT}/lib
/profiler
/list
144 echo "#endif" >>${ROOT}/lib
/profiler
/list
145 mv ${ROOT}/lib
/profiler
/list
${ROOT}/lib
/profiler
/xprof_type.h
147 # Build icons install include from current icons available
150 for f
in `ls -1 ${ROOT}/icons/silk/*`
156 )|
sed s
%${ROOT}/icons
/%%g
>${ROOT}/icons
/list
158 # Build templates install include from current templates available
160 echo -n "ERROR_TEMPLATES="
161 for f
in `ls -1 ${ROOT}/errors/templates/ERR_*`
167 )|
sed s
%${ROOT}/errors
/%%g
>${ROOT}/errors
/template.list
169 # Build errors translation install include from current .PO available
171 echo -n "TRANSLATE_LANGUAGES="
172 for f
in `ls -1 ${ROOT}/errors/*.po`
178 )|
sed s
%${ROOT}/errors
/%%g |
sed s
%\.po
%\.lang
%g
>${ROOT}/errors
/language.list
180 # Build manuals translation install include from current .PO available
182 echo -n "TRANSLATE_LANGUAGES="
183 for f
in `ls -1 ${ROOT}/doc/manuals/*.po`
189 )|
sed s
%${ROOT}/doc
/manuals
/%%g |
sed s
%\.po
%\.lang
%g
>${ROOT}/doc
/manuals
/language.list
191 # Build STUB framework include from current stub_* available
193 echo -n "STUB_SOURCE= tests/STUB.h"
194 for f
in `ls -1 ${ROOT}/src/tests/stub_*.cc`
200 )|
sed s
%${ROOT}/src
/%%g
>${ROOT}/src
/tests
/Stub.list
203 echo "" >${ROOT}/doc
/debug-sections.tmp
205 sort -u <${ROOT}/doc
/debug-sections.tmp |
sort -n >${ROOT}/doc
/debug-sections.txt
206 rm ${ROOT}/doc
/debug-sections.tmp