util/lint: Update tools that use git to use a library
Each of the tools that used git had similar functionality. This combines all of that into a single script that gets sourced by each. This makes maintenance much easier. By doing this and updating each of the scripts to do the correct thing if the script isn't being run in a git repository, it makes them work much better for the releases, which are just released as a tarball, without any attached git repository. Change-Id: I61ba1cc4f7205e0d4baf993588bbc774120405cb Signed-off-by: Martin Roth <martin@coreboot.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/64973 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
committed by
Martin L Roth
parent
7726a7f272
commit
d81debd946
44
util/lint/helper_functions.sh
Normal file
44
util/lint/helper_functions.sh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
# This file is sourced by the linters so that each one doesn't have to
|
||||||
|
# specify these routines individually
|
||||||
|
|
||||||
|
LC_ALL=C export LC_ALL
|
||||||
|
|
||||||
|
if [ -z "$GIT" ]; then
|
||||||
|
GIT="$(command -v git)"
|
||||||
|
else
|
||||||
|
# If git is specified, Do a basic check that it runs and seems like
|
||||||
|
# it's actually git
|
||||||
|
if ! "${GIT}" --version | grep -q git; then
|
||||||
|
echo "Error: ${GIT} does not seem to be valid."
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(${GIT} rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
|
||||||
|
IN_GIT_TREE=1
|
||||||
|
else
|
||||||
|
IN_GIT_TREE=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${IN_GIT_TREE}" -eq 1 ] && [ -z "${GIT}" ]; then
|
||||||
|
echo "This test needs git to run. Please install it, then run this test again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use git ls-files if the code is in a git repo, otherwise use find.
|
||||||
|
if [ "${IN_GIT_TREE}" -eq 1 ]; then
|
||||||
|
FIND_FILES="${GIT} ls-files"
|
||||||
|
else
|
||||||
|
FIND_FILES="find src"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use git grep if the code is in a git repo, otherwise use grep.
|
||||||
|
if [ "${IN_GIT_TREE}" -eq 1 ]; then
|
||||||
|
GREP_FILES="${GIT} grep"
|
||||||
|
else
|
||||||
|
GREP_FILES="grep -r"
|
||||||
|
fi
|
@ -5,6 +5,15 @@
|
|||||||
# DESCR: Check that files in have valid license headers
|
# DESCR: Check that files in have valid license headers
|
||||||
# $1 is an optional command line parameter containing directories to check
|
# $1 is an optional command line parameter containing directories to check
|
||||||
|
|
||||||
|
|
||||||
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
# regex list of files and directories to exclude from the search
|
# regex list of files and directories to exclude from the search
|
||||||
HEADER_EXCLUDED="\
|
HEADER_EXCLUDED="\
|
||||||
^src/commonlib/bsd/lz4.c.inc\$|\
|
^src/commonlib/bsd/lz4.c.inc\$|\
|
||||||
@ -69,11 +78,10 @@ else
|
|||||||
HEADER_DIRS="$1"
|
HEADER_DIRS="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
|
||||||
|
|
||||||
#get initial list from git, removing HEADER_EXCLUDED files.
|
#get initial list from git, removing HEADER_EXCLUDED files.
|
||||||
#make a copy to check for the old style header later.
|
#make a copy to check for the old style header later.
|
||||||
headerlist=$(git ls-files $HEADER_DIRS | egrep -v "($HEADER_EXCLUDED)")
|
headerlist=$(${FIND_FILES} $HEADER_DIRS | egrep -v "($HEADER_EXCLUDED)")
|
||||||
|
|
||||||
#update headerlist by removing files that match the license string
|
#update headerlist by removing files that match the license string
|
||||||
check_for_license() {
|
check_for_license() {
|
||||||
|
@ -4,7 +4,13 @@
|
|||||||
|
|
||||||
# DESCR: Checkpatch on .c, .h, & Kconfig files in the tree
|
# DESCR: Checkpatch on .c, .h, & Kconfig files in the tree
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
# GNU BRE syntax list of files to examine
|
# GNU BRE syntax list of files to examine
|
||||||
INCLUDED_FILES='.*\.[ch]\|Kconfig.*$'
|
INCLUDED_FILES='.*\.[ch]\|Kconfig.*$'
|
||||||
@ -36,7 +42,7 @@ fi
|
|||||||
|
|
||||||
# We want word splitting here, so disable the shellcheck warnings
|
# We want word splitting here, so disable the shellcheck warnings
|
||||||
# shellcheck disable=SC2046,SC2086
|
# shellcheck disable=SC2046,SC2086
|
||||||
FILELIST=$( git ls-files $INCLUDED_DIRS | \
|
FILELIST=$( ${FIND_FILES} $INCLUDED_DIRS | \
|
||||||
grep $INCLUDED_FILES | \
|
grep $INCLUDED_FILES | \
|
||||||
grep -v $EXCLUDED_DIRS )
|
grep -v $EXCLUDED_DIRS )
|
||||||
|
|
||||||
|
@ -4,18 +4,21 @@
|
|||||||
|
|
||||||
# DESCR: Check Kconfig files for warnings and errors
|
# DESCR: Check Kconfig files for warnings and errors
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
# Verify that the test can run, tell users the issue
|
# Verify that the test can run, tell users the issue
|
||||||
if [ -z "$(command -v perl)" ]; then
|
if [ -z "$(command -v perl)" ]; then
|
||||||
echo "The kconfig lint tool uses perl. Please install it to run this test."
|
echo "The kconfig lint tool uses perl. Please install it to run this test."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If coreboot is in a git repo, use git grep to check as it will ignore any
|
# Don't use git if coreboot isn't in a repo
|
||||||
# files in the tree that aren't checked into git
|
if [ "${IN_GIT_TREE}" -eq 1 ]; then
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
env perl util/lint/kconfig_lint
|
env perl util/lint/kconfig_lint
|
||||||
else
|
else
|
||||||
env perl util/lint/kconfig_lint --no_git_grep
|
env perl util/lint/kconfig_lint --no_git_grep
|
||||||
|
@ -4,22 +4,19 @@
|
|||||||
|
|
||||||
# DESCR: Check that variables have fully qualified types
|
# DESCR: Check that variables have fully qualified types
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
INCLUDED_DIRS='^src/\|^util/\|payloads/libpayload\|payloads/coreinfo'
|
INCLUDED_DIRS='^src/\|^util/\|payloads/libpayload\|payloads/coreinfo'
|
||||||
EXCLUDED_DIRS='^src/vendorcode\|cbfstool/lzma\|cbfstool/lz4'
|
EXCLUDED_DIRS='^src/vendorcode\|cbfstool/lzma\|cbfstool/lz4'
|
||||||
INCLUDED_FILES='\.[ch]:'
|
INCLUDED_FILES='\.[ch]:'
|
||||||
|
|
||||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
${GREP_FILES} -n 'unsigned[[:space:]]' | \
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
GREP_FILES="git grep -n"
|
|
||||||
else
|
|
||||||
GREP_FILES="grep -rn"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${GREP_FILES} 'unsigned[[:space:]]' | \
|
|
||||||
grep "$INCLUDED_DIRS" | \
|
grep "$INCLUDED_DIRS" | \
|
||||||
grep -v "$EXCLUDED_DIRS" | \
|
grep -v "$EXCLUDED_DIRS" | \
|
||||||
grep "$INCLUDED_FILES" | \
|
grep "$INCLUDED_FILES" | \
|
||||||
|
@ -4,22 +4,19 @@
|
|||||||
|
|
||||||
# DESCR: Check that files end with a single newline
|
# DESCR: Check that files end with a single newline
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
PIDS=""
|
PIDS=""
|
||||||
INCLUDED_DIRS_AND_FILES='util/* src/* payloads/* configs/* Makefile *.inc'
|
INCLUDED_DIRS_AND_FILES='util/* src/* payloads/* configs/* Makefile *.inc'
|
||||||
EXCLUDED_DIRS='src/vendorcode/\|cbfstool/lzma/\|cbfstool/lz4/\|Documentation/\|build/\|3rdparty/\|\.git/\|coreboot-builds/\|util/nvidia/cbootimage/'
|
EXCLUDED_DIRS='src/vendorcode/\|cbfstool/lzma/\|cbfstool/lz4/\|Documentation/\|build/\|3rdparty/\|\.git/\|coreboot-builds/\|util/nvidia/cbootimage/'
|
||||||
EXCLUDED_FILES='\.gif$\|\.jpg$\|\.cksum$\|\.bin$\|\.vbt$\|\.hex$\|\.ico$\|\.o$\|\.bz2$\|\.xz$\|^.tmpconfig\|\.pyc$\|_shipped$\|sha256$\|\.png$\|\.patch$'
|
EXCLUDED_FILES='\.gif$\|\.jpg$\|\.cksum$\|\.bin$\|\.vbt$\|\.hex$\|\.ico$\|\.o$\|\.bz2$\|\.xz$\|^.tmpconfig\|\.pyc$\|_shipped$\|sha256$\|\.png$\|\.patch$'
|
||||||
|
|
||||||
# Use git ls-files if the code is in a git repo, otherwise use find.
|
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
FIND_FILES="git ls-files"
|
|
||||||
else
|
|
||||||
FIND_FILES="find"
|
|
||||||
fi
|
|
||||||
|
|
||||||
HAVE_FILE=$(command -v file 1>/dev/null 2>&1; echo $?)
|
HAVE_FILE=$(command -v file 1>/dev/null 2>&1; echo $?)
|
||||||
|
|
||||||
is_eligible_executable() {
|
is_eligible_executable() {
|
||||||
@ -57,7 +54,7 @@ test_for_final_newline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for directory in $INCLUDED_DIRS_AND_FILES ; do
|
for directory in $INCLUDED_DIRS_AND_FILES ; do
|
||||||
${FIND_FILES} ${directory} | sed 's|^\./||' | sort | \
|
${FIND_FILES} "${directory}" | sed 's|^\./||' | sort | \
|
||||||
grep -v "$EXCLUDED_DIRS" | \
|
grep -v "$EXCLUDED_DIRS" | \
|
||||||
grep -v "$EXCLUDED_FILES" | \
|
grep -v "$EXCLUDED_FILES" | \
|
||||||
test_for_final_newline &
|
test_for_final_newline &
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#
|
#
|
||||||
# DESCR: Check for a signed-off-by line on the latest git commit
|
# DESCR: Check for a signed-off-by line on the latest commit
|
||||||
|
|
||||||
|
|
||||||
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# This test is mainly for the jenkins server
|
# This test is mainly for the jenkins server
|
||||||
if [ -n "$(command -v git)" ] && \
|
if ! ${GIT} log -n 1 | grep -q '[[:space:]]\+Signed-off-by: '; then
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
echo "No Signed-off-by line in commit message"
|
||||||
then
|
|
||||||
if [ -z "$(git log -n 1 | grep '[[:space:]]\+Signed-off-by: ')" ]; then
|
|
||||||
echo "No Signed-off-by line in commit message"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
@ -4,20 +4,26 @@
|
|||||||
|
|
||||||
# DESCR: Check for superfluous whitespace in the tree
|
# DESCR: Check for superfluous whitespace in the tree
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
INTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
EXCLUDELIST='^src/vendorcode/|^util/kconfig/|^util/nvidia/cbootimage$|^util/goswid$|COPYING|LICENSE|README|_shipped$|\.patch$|\.bin$|\.hex$|\.jpg$|\.gif$|\.ttf$|\.woff$|\.png$|\.eot$|\.vbt$|\.ico$|\.md$'
|
EXCLUDELIST='^src/vendorcode/|^util/kconfig/|^util/nvidia/cbootimage$|^util/goswid$|COPYING|LICENSE|README|_shipped$|\.patch$|\.bin$|\.hex$|\.jpg$|\.gif$|\.ttf$|\.woff$|\.png$|\.eot$|\.vbt$|\.ico$|\.md$'
|
||||||
INCLUDELIST="src util payloads Makefile* toolchain.inc tests"
|
INCLUDELIST="src util payloads Makefile* toolchain.inc tests"
|
||||||
|
|
||||||
# shellcheck disable=SC2086,SC2046
|
# shellcheck disable=SC2086,SC2046
|
||||||
if uname | grep -qi "linux"; then
|
if uname | grep -qi "linux"; then
|
||||||
grep -n -H "[[:space:]][[:space:]]*$" \
|
grep -n -H "[[:space:]][[:space:]]*$" \
|
||||||
$(git ls-files $INCLUDELIST | \
|
$(${FIND_FILES} $INCLUDELIST | \
|
||||||
grep -Ev "($EXCLUDELIST)" ) | \
|
grep -Ev "($EXCLUDELIST)" ) | \
|
||||||
sed -e "s,^.*$,File & has lines ending with whitespace.,"
|
sed -e "s,^.*$,File & has lines ending with whitespace.,"
|
||||||
else
|
else
|
||||||
# The above form is much (100x) faster, but doesn't work
|
# The above form is much (100x) faster, but doesn't work
|
||||||
# on all systems. A for loop also works but takes 30% longer
|
# on all systems. A for loop also works but takes 30% longer
|
||||||
git ls-files $INCLUDELIST | \
|
${FIND_FILES} $INCLUDELIST | \
|
||||||
grep -Ev "($EXCLUDELIST)" | \
|
grep -Ev "($EXCLUDELIST)" | \
|
||||||
xargs -I % \
|
xargs -I % \
|
||||||
grep -l "[[:space:]][[:space:]]*$" % | \
|
grep -l "[[:space:]][[:space:]]*$" % | \
|
||||||
|
@ -4,16 +4,13 @@
|
|||||||
|
|
||||||
# DESCR: Check that C labels begin at start-of-line
|
# DESCR: Check that C labels begin at start-of-line
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
# Use git ls-files if the code is in a git repo, otherwise use find.
|
# shellcheck source=helper_functions.sh
|
||||||
if [ -n "$(command -v git)" ] && \
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
FIND_FILES="git ls-files"
|
|
||||||
else
|
|
||||||
FIND_FILES="find src"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${FIND_FILES} | \
|
${FIND_FILES} | \
|
||||||
grep "^src/.*\.[csS]$" | \
|
grep "^src/.*\.[csS]$" | \
|
||||||
|
@ -3,8 +3,16 @@
|
|||||||
#
|
#
|
||||||
# DESCR: Check that every board has a meaningful board_info.txt
|
# DESCR: Check that every board has a meaningful board_info.txt
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
|
||||||
for mobodir in $(git ls-files src/mainboard | sed -n 's,^\(src/mainboard/[^/]*/[^/]*\)/.*$,\1,p'|sort|uniq); do
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
|
for mobodir in $(${FIND_FILES} src/mainboard | sed -n 's,^\(src/mainboard/[^/]*/[^/]*\)/.*$,\1,p'|sort|uniq); do
|
||||||
board_info="$mobodir/board_info.txt"
|
board_info="$mobodir/board_info.txt"
|
||||||
if ! [ -f "$board_info" ]; then
|
if ! [ -f "$board_info" ]; then
|
||||||
echo "No $board_info found"
|
echo "No $board_info found"
|
||||||
|
@ -4,18 +4,21 @@
|
|||||||
|
|
||||||
# DESCR: Check Kconfig files for errors
|
# DESCR: Check Kconfig files for errors
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
# Verify that the test can run, tell users the issue
|
# Verify that the test can run, tell users the issue
|
||||||
if [ -z "$(command -v perl)" ]; then
|
if [ -z "$(command -v perl)" ]; then
|
||||||
echo "The kconfig lint tool uses perl. Please install it to run this test."
|
echo "The kconfig lint tool uses perl. Please install it to run this test."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If coreboot is in a git repo, use git grep to check as it will ignore any
|
# Check whether coreboot is in a repo
|
||||||
# files in the tree that aren't checked into git
|
if [ "${IN_GIT_TREE}" -eq 1 ]; then
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
env perl util/lint/kconfig_lint --warnings_off 2>&1
|
env perl util/lint/kconfig_lint --warnings_off 2>&1
|
||||||
else
|
else
|
||||||
env perl util/lint/kconfig_lint --no_git_grep --warnings_off 2>&1
|
env perl util/lint/kconfig_lint --no_git_grep --warnings_off 2>&1
|
||||||
|
@ -5,6 +5,15 @@
|
|||||||
# DESCR: Verify that files don't have the old style header
|
# DESCR: Verify that files don't have the old style header
|
||||||
|
|
||||||
# regex list of files and directories to exclude from the search
|
# regex list of files and directories to exclude from the search
|
||||||
|
|
||||||
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
HEADER_EXCLUDED="\
|
HEADER_EXCLUDED="\
|
||||||
^src/lib/gnat/|\
|
^src/lib/gnat/|\
|
||||||
^src/vendorcode/|\
|
^src/vendorcode/|\
|
||||||
@ -26,9 +35,7 @@ if [ -z "$HEADER_DIRS" ]; then
|
|||||||
HEADER_DIRS="src util tests"
|
HEADER_DIRS="src util tests"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
headerlist=$(${FIND_FILES} $HEADER_DIRS | egrep -v "($HEADER_EXCLUDED)")
|
||||||
|
|
||||||
headerlist=$(git ls-files $HEADER_DIRS | egrep -v "($HEADER_EXCLUDED)")
|
|
||||||
|
|
||||||
#check for the old style header
|
#check for the old style header
|
||||||
headerlist=$(grep -il "You should have received a copy of the GNU" \
|
headerlist=$(grep -il "You should have received a copy of the GNU" \
|
||||||
|
@ -4,5 +4,12 @@
|
|||||||
|
|
||||||
# DESCR: Check that we use a single assembler syntax
|
# DESCR: Check that we use a single assembler syntax
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
git grep -n "\.\(att\|intel\)_syntax\>" | grep -v '\.patch:'
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
|
${GREP_FILES} -n "\.\(att\|intel\)_syntax\>" | grep -v '\.patch:'
|
||||||
|
@ -3,6 +3,18 @@
|
|||||||
#
|
#
|
||||||
# DESCR: Check that source files are not executable
|
# DESCR: Check that source files are not executable
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
git ls-tree --full-tree -r HEAD src tests |grep "^100[7531][7531][7531] blob " |cut -f2- |grep -v "\.sh$" | \
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
|
# Exit if the code isn't in a git repo
|
||||||
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
${GIT} ls-tree --full-tree -r HEAD src tests |grep "^100[7531][7531][7531] blob " | cut -f2- | grep -v "\.sh$" | \
|
||||||
sed -e "s,^.*$,File & has one or more executable bits set in the file permissions.,"
|
sed -e "s,^.*$,File & has one or more executable bits set in the file permissions.,"
|
||||||
|
@ -6,14 +6,22 @@
|
|||||||
# Because site-local is intended for local use only, it should never be
|
# Because site-local is intended for local use only, it should never be
|
||||||
# pushed to coreboot.org. Even for committing it for local use, it's
|
# pushed to coreboot.org. Even for committing it for local use, it's
|
||||||
# recommended that it be kept in a separate repository, and pulled in
|
# recommended that it be kept in a separate repository, and pulled in
|
||||||
# as a git submodule.
|
# as a submodule.
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
if [ -n "$(command -v git)" ] && \
|
# shellcheck source=helper_functions.sh
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
then
|
|
||||||
if [ -n "$(git ls-files site-local/*)" ]; then
|
# Exit if the code isn't in a git repo
|
||||||
echo "Error: site-local must be kept separate from the coreboot repository."
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
fi
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$(${FIND_FILES} site-local/*)" ]; then
|
||||||
|
echo "Error: site-local must be kept separate from the coreboot repository."
|
||||||
fi
|
fi
|
||||||
|
@ -4,18 +4,22 @@
|
|||||||
|
|
||||||
# DESCR: Check for non-ASCII and unprintable characters
|
# DESCR: Check for non-ASCII and unprintable characters
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
INCLUDED_FILES='\.[chsS]$\|\.asl$\|\.cb$\|\.inc$\|Kconfig\|\.ld$|\.txt\|\.hex'
|
INCLUDED_FILES='\.[chsS]$\|\.asl$\|\.cb$\|\.inc$\|Kconfig\|\.ld$|\.txt\|\.hex'
|
||||||
EXCLUDED_DIRS='^payloads/external/\|^src/vendorcode/\|^Documentation/'
|
EXCLUDED_DIRS='^payloads/external/\|^src/vendorcode/\|^Documentation/'
|
||||||
EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11'
|
EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11'
|
||||||
EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©'
|
EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©'
|
||||||
|
|
||||||
# Exit if git isn't present or the code isn't in a git repo
|
# Exit if the code isn't in a git repo
|
||||||
if [ -z "$(command -v git)" ] || \
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true" ]
|
exit 0
|
||||||
then
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 1. Get the list of files to parse and send them through grep
|
# 1. Get the list of files to parse and send them through grep
|
||||||
@ -25,7 +29,7 @@ fi
|
|||||||
# 4. Run the result through grep again to highlight the issues that were
|
# 4. Run the result through grep again to highlight the issues that were
|
||||||
# found. Without this step, the characters can be difficult to see.
|
# found. Without this step, the characters can be difficult to see.
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
git grep -lP "[^\t-~]" | \
|
${GREP_FILES} -lP "[^\t-~]" | \
|
||||||
grep "$INCLUDED_FILES" | \
|
grep "$INCLUDED_FILES" | \
|
||||||
grep -v "$EXCLUDED_DIRS" | \
|
grep -v "$EXCLUDED_DIRS" | \
|
||||||
grep -v "$EXCLUDED_FILES" | \
|
grep -v "$EXCLUDED_FILES" | \
|
||||||
|
@ -4,21 +4,18 @@
|
|||||||
|
|
||||||
# DESCR: Check that saved config files are miniconfigs
|
# DESCR: Check that saved config files are miniconfigs
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
SYMBOLS='CONFIG_ARCH_\|CONFIG_MAINBOARD_HAS_'
|
SYMBOLS='CONFIG_ARCH_\|CONFIG_MAINBOARD_HAS_'
|
||||||
|
|
||||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
GREP="git grep -l"
|
|
||||||
else
|
|
||||||
GREP="grep -rl"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#look for a couple of things that should only be set by select keywords
|
#look for a couple of things that should only be set by select keywords
|
||||||
for file in \
|
for file in \
|
||||||
$($GREP "$SYMBOLS" configs) ; do \
|
$(${GREP_FILES} -l "$SYMBOLS" configs) ; do \
|
||||||
echo "Error: $file seems to be a full config"; \
|
echo "Error: $file seems to be a full config"; \
|
||||||
done
|
done
|
||||||
|
@ -4,21 +4,23 @@
|
|||||||
|
|
||||||
# DESCR: Report any symbolic links
|
# DESCR: Report any symbolic links
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
EXCLUDED_DIRS='^3rdparty\|^site-local'
|
EXCLUDED_DIRS='^3rdparty\|^site-local'
|
||||||
|
|
||||||
# If the code is in a git repo, only print files that are checked in
|
# Exit if the code isn't in a git repo
|
||||||
if [ -n "$(command -v git)" ] && \
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
exit 0
|
||||||
then
|
|
||||||
git ls-tree -r HEAD | \
|
|
||||||
grep ^120000 | \
|
|
||||||
cut -f2 | \
|
|
||||||
grep -v "$EXCLUDED_DIRS"
|
|
||||||
else
|
|
||||||
# If the code isn't in a git repo, print everything
|
|
||||||
find . -type l | \
|
|
||||||
sed 's|\.\/||' | \
|
|
||||||
grep -v "$EXCLUDED_DIRS"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
${GIT} ls-tree -r HEAD | \
|
||||||
|
grep ^120000 | \
|
||||||
|
cut -f2 | \
|
||||||
|
grep -v "$EXCLUDED_DIRS"
|
||||||
|
@ -4,7 +4,13 @@
|
|||||||
|
|
||||||
# DESCR: Check for auto-included headers
|
# DESCR: Check for auto-included headers
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
INCLUDED_DIRS='^src/'
|
INCLUDED_DIRS='^src/'
|
||||||
EXCLUDED_FILES='src/include/kconfig.h'
|
EXCLUDED_FILES='src/include/kconfig.h'
|
||||||
@ -33,17 +39,8 @@ elif [ "$1" = "--reset" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
GREP_FILES="git grep -n"
|
|
||||||
else
|
|
||||||
GREP_FILES="grep -rn"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for header in $HEADER_FILES; do
|
for header in $HEADER_FILES; do
|
||||||
${GREP_FILES} "#[[:blank:]]*include[[:blank:]]\+[\"<][[:blank:]]*${header}\.h[[:blank:]]*[\">]" | \
|
${GREP_FILES} -n "#[[:blank:]]*include[[:blank:]]\+[\"<][[:blank:]]*${header}\.h[[:blank:]]*[\">]" | \
|
||||||
grep "$INCLUDED_DIRS" | \
|
grep "$INCLUDED_DIRS" | \
|
||||||
grep -v "$EXCLUDED_FILES"; \
|
grep -v "$EXCLUDED_FILES"; \
|
||||||
done
|
done
|
||||||
|
@ -4,22 +4,21 @@
|
|||||||
|
|
||||||
# DESCR: Verify that the word 'coreboot' is lowercase
|
# DESCR: Verify that the word 'coreboot' is lowercase
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
EXCLUDE='^3rdparty/\|util/crossgcc/xgcc\|Binary file\|coreboot\|COREBOOT\|CorebootPayload\|CorebootModule\|minnowboard.org/Coreboot\|.*\.patch$\|CorebootBdsLib\|^payloads/external'
|
EXCLUDE='^3rdparty/\|util/crossgcc/xgcc\|Binary file\|coreboot\|COREBOOT\|CorebootPayload\|CorebootModule\|minnowboard.org/Coreboot\|.*\.patch$\|CorebootBdsLib\|^payloads/external'
|
||||||
|
|
||||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
# # Check last commit message if the code is in a git repo
|
||||||
if [ -n "$(command -v git)" ] && \
|
if [ "${IN_GIT_TREE}" -eq 1 ]; then
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
if [ -n "$(${GIT} log -n 1 | grep -i 'coreboot' | grep -v "$EXCLUDE" )" ]; then
|
||||||
then
|
|
||||||
GREP_FILES="git grep -in"
|
|
||||||
|
|
||||||
# Check last commit message
|
|
||||||
if [ -n "$(git log -n 1 | grep -i 'coreboot' | grep -v "$EXCLUDE" )" ]; then
|
|
||||||
echo "'coreboot' should be lowercase in commit message"
|
echo "'coreboot' should be lowercase in commit message"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
GREP_FILES="grep -rin"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${GREP_FILES} "coreboot" | grep -v "$EXCLUDE";
|
${GREP_FILES} -in "coreboot" | grep -v "$EXCLUDE";
|
||||||
|
@ -4,14 +4,21 @@
|
|||||||
|
|
||||||
# DESCR: Run clang-format on white-listed directories
|
# DESCR: Run clang-format on white-listed directories
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
# until we require this by default, we need a list of opted-in directories
|
# shellcheck source=helper_functions.sh
|
||||||
if [ ! -f .clang-format-scope ]; then
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
|
# Until we require this by default, we need a list of opted-in directories
|
||||||
|
# If the script isn't looking at a git repository, just exit
|
||||||
|
if [ ! -f .clang-format-scope ] || [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files_to_check=$(git log HEAD~..HEAD --format= --name-only $(cat .clang-format-scope) |grep "\.[ch]$")
|
files_to_check=$(${GIT} log HEAD~..HEAD --format= --name-only $(cat .clang-format-scope) | grep "\.[ch]$")
|
||||||
|
|
||||||
# nothing to do
|
# nothing to do
|
||||||
if [ -z "$files_to_check" ]; then
|
if [ -z "$files_to_check" ]; then
|
||||||
@ -19,9 +26,9 @@ if [ -z "$files_to_check" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(clang-format $files_to_check | wc -l) -gt 0 ]; then
|
if [ $(clang-format $files_to_check | wc -l) -gt 0 ]; then
|
||||||
if [ "$(git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff)" != "" ]; then
|
if [ "$(${GIT} diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff)" != "" ]; then
|
||||||
echo "Coding style mismatch. The following patch fixes it:"
|
echo "Coding style mismatch. The following patch fixes it:"
|
||||||
git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff
|
${GIT} diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
# DESCR: Check for illegal characters in filename
|
# DESCR: Check for illegal characters in filename
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
# Skip check if git isn't available
|
# shellcheck source=helper_functions.sh
|
||||||
if [ -n "$(command -v git)" ] && \
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
# Exit if the code isn't in a git repo
|
||||||
git ls-files | grep "[^A-Za-z0-9/_\.-]"
|
if [ "${IN_GIT_TREE}" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
${FIND_FILES} | grep "[^A-Za-z0-9/_\.-]"
|
||||||
|
@ -4,17 +4,14 @@
|
|||||||
|
|
||||||
# DESCR: Verify that files don't contain windows line endings
|
# DESCR: Verify that files don't contain windows line endings
|
||||||
|
|
||||||
LC_ALL=C export LC_ALL
|
LINTDIR="$(
|
||||||
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
||||||
|
pwd -P
|
||||||
|
)"
|
||||||
|
|
||||||
EXCLUDE='^3rdparty/\|^payloads/external\|^.git'
|
# shellcheck source=helper_functions.sh
|
||||||
|
. "${LINTDIR}/helper_functions.sh"
|
||||||
|
|
||||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
EXCLUDE='^3rdparty/\|^payloads/external\|^.git\|build\|util/crossgcc/xgcc'
|
||||||
if [ -n "$(command -v git)" ] && \
|
|
||||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
||||||
then
|
|
||||||
GREP_FILES="git grep -IlP"
|
|
||||||
else
|
|
||||||
GREP_FILES="grep -rIlP"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${GREP_FILES} "\r$" | grep -v "$EXCLUDE"
|
${GREP_FILES} -IlP "\r$" | grep -v "$EXCLUDE"
|
||||||
|
Reference in New Issue
Block a user