build: add make targets lint, lint-sh, lint-lua

[Matthias Schiffer: minor script improvements]
This commit is contained in:
Jan-Tarek Butt 2019-12-14 22:18:58 +01:00 committed by Matthias Schiffer
parent 25a4f3b816
commit a2ced263ab
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
3 changed files with 40 additions and 0 deletions

View File

@ -103,6 +103,13 @@ endef
list-targets: FORCE
@$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
lint: lint-lua lint-sh
lint-lua: FORCE
@scripts/lint-lua.sh
lint-sh: FORCE
@scripts/lint-sh.sh
GLUON_DEFAULT_PACKAGES := hostapd-mini

5
scripts/lint-lua.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
luacheck package scripts targets

28
scripts/lint-sh.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
set -e
is_scriptfile() {
echo "$1" | grep -qE '.*\.sh$' || head -n1 "$1" | grep -qE '^#.*(sh|bash)$'
}
find contrib -type f | while read -r file; do
is_scriptfile "$file" || continue
echo "Checking $file"
shellcheck -f gcc "$file"
done
find package -type f | while read -r file; do
is_scriptfile "$file" || continue
echo "Checking $file"
shellcheck -f gcc -x -s sh -e SC2039,SC1091,SC2155,SC2034 "$file"
done
find scripts -type f | while read -r file; do
is_scriptfile "$file" || continue
echo "Checking $file"
shellcheck -f gcc -x -e SC2154,SC1090,SC2181,SC2155,SC2148,SC2034,SC2148 "$file"
done