2015-10-13 21:40:59 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
#
|
util/: Replace GPLv2 boiler plate with SPDX header
Used commands:
perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist)
perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist)
perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
Change-Id: I1008a63b804f355a916221ac994701d7584f60ff
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2015-10-13 21:40:59 +02:00
|
|
|
#set -x # uncomment for debug
|
|
|
|
|
|
|
|
usage () {
|
2016-08-30 17:39:48 +02:00
|
|
|
printf "Usage: %s <lint|lint-stable|lint-extended> [--junit]\n" "$0"
|
2015-10-13 23:04:17 +02:00
|
|
|
}
|
|
|
|
|
2015-10-16 18:23:57 +02:00
|
|
|
#write to the junit xml file if --junit was specified
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write () {
|
|
|
|
if [ "$JUNIT" -eq 1 ]; then
|
|
|
|
echo "$1" >> "$XMLFILE"
|
|
|
|
fi
|
2015-10-13 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
2015-10-16 18:23:57 +02:00
|
|
|
#verify the first command line parameter
|
2016-08-30 17:39:48 +02:00
|
|
|
if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ] && \
|
|
|
|
[ "$1" != "lint-extended" ]; then
|
2015-10-13 21:40:59 +02:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-05-17 21:57:57 +02:00
|
|
|
LINTLOG=$(mktemp .tmpconfig.lintXXXXXX);
|
2015-10-16 18:23:57 +02:00
|
|
|
XMLFILE="$(dirname "$0")/junit.xml"
|
2016-08-30 17:39:48 +02:00
|
|
|
if [ "$1" = "lint-extended" ]; then
|
|
|
|
XMLFILE="$(dirname "$0")/extended-junit.xml"
|
|
|
|
fi
|
2015-10-13 21:40:59 +02:00
|
|
|
FAILED=0;
|
|
|
|
|
2015-10-16 18:23:57 +02:00
|
|
|
#check optional second command line parameter.
|
2015-10-13 23:04:17 +02:00
|
|
|
if [ "$2" = "--junit" ]; then
|
|
|
|
JUNIT=1
|
|
|
|
echo '<?xml version="1.0" encoding="utf-8"?>' > "$XMLFILE"
|
|
|
|
junit_write '<testsuite>'
|
|
|
|
else
|
|
|
|
JUNIT=0
|
|
|
|
fi
|
2015-10-16 18:23:57 +02:00
|
|
|
|
|
|
|
#run all scripts of the requested type
|
|
|
|
for script in "$(dirname "$0")/${1}-"*; do
|
2018-05-30 18:43:32 +02:00
|
|
|
printf "%s " "$(grep '^# DESCR:' "$script" | sed 's,.*DESCR: *,,')"
|
|
|
|
printf "(%s): " "$(basename "$script")"
|
2015-10-16 18:23:57 +02:00
|
|
|
junit_write " <testcase classname='lint' name='$(basename "$script")'>"
|
2016-10-24 22:36:32 +02:00
|
|
|
$script | tee "$LINTLOG"
|
2015-10-16 18:23:57 +02:00
|
|
|
|
|
|
|
#if the lint script gives any output, that's a failure
|
|
|
|
if [ "$(wc -l < "$LINTLOG")" -eq 0 ]; then
|
2015-10-13 21:40:59 +02:00
|
|
|
echo "success"
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write " <system-out><![CDATA[success]]></system-out>"
|
2015-10-13 21:40:59 +02:00
|
|
|
else
|
2016-10-24 22:36:32 +02:00
|
|
|
echo "test failed"
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write " <failure type='testFailed'><![CDATA["
|
2015-10-16 18:23:57 +02:00
|
|
|
junit_write "$(cat "$LINTLOG")"
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write "]]></failure>"
|
2015-10-16 18:23:57 +02:00
|
|
|
rm -f "$LINTLOG"
|
|
|
|
FAILED=$(( FAILED + 1 ))
|
2015-10-13 21:40:59 +02:00
|
|
|
fi
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write ' </testcase>'
|
2015-10-13 21:40:59 +02:00
|
|
|
done
|
|
|
|
|
2015-10-16 18:23:57 +02:00
|
|
|
rm -f "$LINTLOG"
|
2015-10-13 23:04:17 +02:00
|
|
|
junit_write '</testsuite>'
|
2015-11-19 15:46:37 +01:00
|
|
|
test $FAILED -eq 0 || { echo "ERROR: $FAILED test(s) failed."; exit 1; };
|