]>
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}..."
37 for FILENAME
in `ls -1`; do
44 # Code Style formatting maintenance
46 if test "${ASVER}" = "1.23"; then
47 ${ROOT}/scripts
/formater.pl
${FILENAME}
48 if test -e $FILENAME -a -e "$FILENAME.astylebak"; then
49 md51
=`cat $FILENAME| tr -d "\n \t\r" | $MD5`;
50 md52
=`cat $FILENAME.astylebak| tr -d "\n \t\r" | $MD5`;
52 if test "$md51" != "$md52" ; then
53 echo "ERROR: File $PWD/$FILENAME not formating well";
54 mv $FILENAME $FILENAME.astylebad
55 mv $FILENAME.astylebak
$FILENAME
57 rm -f $FILENAME.astylebak
63 # REQUIRE config.h/squid.h as first #include
67 FI
=`grep "#include" ${FILENAME} | head -1`;
68 if test "${FI}" != "#include \"config.h\"" -a "${FI}" != "#include \"squid.h\"" ; then
69 echo "ERROR: ${PWD}/${FILENAME} does not include config.h or squid.h first!"
73 FI
=`grep "#include \"config.h\"" ${FILENAME}`;
74 if test "x${FI}" != "x" ; then
75 echo "ERROR: ${PWD}/${FILENAME} duplicate include of config.h"
81 # Scan for incorrect use of #ifdef/#ifndef
83 grep -R -E "ifn?def .*_SQUID_" .
/* |
grep -v -E "_H$" |
while read f
; do echo "PROBLEM?: ${f}"; done
86 # DEBUG Section list maintenance
88 grep " DEBUG: section" <${FILENAME} |
sed -e 's/ \* DEBUG: //' >>${ROOT}/doc
/debug-sections.tmp
91 # File permissions maintenance.
98 # File permissions maintenance.
100 chmod 755 ${FILENAME}
105 perl
-i -p -e 's/@([A-Z0-9_]+)@/\$($1)/g' <${FILENAME} >${FILENAME}.styled
106 mv ${FILENAME}.styled
${FILENAME}
111 if test "$FILENAME" = "libltdl" ; then
113 elif test -d $FILENAME ; then
115 srcformat
${ROOT} ||
exit 1
122 # Build XPROF types file from current sources
123 echo "#ifndef _PROFILER_XPROF_TYPE_H_" >${ROOT}/lib
/profiler
/list
124 echo "#define _PROFILER_XPROF_TYPE_H_" >>${ROOT}/lib
/profiler
/list
125 echo "/* AUTO-GENERATED FILE */" >>${ROOT}/lib
/profiler
/list
126 echo "#if USE_XPROF_STATS" >>${ROOT}/lib
/profiler
/list
127 echo "typedef enum {" >>${ROOT}/lib
/profiler
/list
128 echo "XPROF_PROF_UNACCOUNTED," >>${ROOT}/lib
/profiler
/list
129 grep -R -h "PROF_start.*" .
/* |
grep -v probename |
sed -e 's/ //g; s/PROF_start(/XPROF_/; s/);/,/' |
sort -u >>${ROOT}/lib
/profiler
/list
130 echo " XPROF_LAST } xprof_type;" >>${ROOT}/lib
/profiler
/list
131 echo "#endif" >>${ROOT}/lib
/profiler
/list
132 echo "#endif" >>${ROOT}/lib
/profiler
/list
133 mv ${ROOT}/lib
/profiler
/list
${ROOT}/lib
/profiler
/xprof_type.h
135 # Build icons install include from current icons available
138 for f
in `ls -1 ${ROOT}/icons/silk/*`
144 )|
sed s
%${ROOT}/icons
/%%g
>${ROOT}/icons
/list
146 # Build templates install include from current templates available
148 echo -n "ERROR_TEMPLATES="
149 for f
in `ls -1 ${ROOT}/errors/templates/ERR_*`
155 )|
sed s
%${ROOT}/errors
/%%g
>${ROOT}/errors
/template.list
157 # Build errors translation install include from current .PO available
159 echo -n "TRANSLATE_LANGUAGES="
160 for f
in `ls -1 ${ROOT}/errors/*.po`
166 )|
sed s
%${ROOT}/errors
/%%g |
sed s
%\.po
%\.lang
%g
>${ROOT}/errors
/language.list
168 # Build manuals translation install include from current .PO available
170 echo -n "TRANSLATE_LANGUAGES="
171 for f
in `ls -1 ${ROOT}/doc/manuals/*.po`
177 )|
sed s
%${ROOT}/doc
/manuals
/%%g |
sed s
%\.po
%\.lang
%g
>${ROOT}/doc
/manuals
/language.list
180 echo "" >${ROOT}/doc
/debug-sections.tmp
182 sort -u <${ROOT}/doc
/debug-sections.tmp |
sort -n >${ROOT}/doc
/debug-sections.txt
183 rm ${ROOT}/doc
/debug-sections.tmp