summaryrefslogtreecommitdiff
path: root/meta-phosphor/scripts
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2021-10-27 17:30:41 +0300
committerPatrick Williams <patrick@stwcx.xyz>2021-11-04 02:09:42 +0300
commit521d8f69f9182a3d96e51b1df139c81302c026ef (patch)
treed5eb709cad70b697bae6aef948b80507758c2b6c /meta-phosphor/scripts
parent9958f3960418d4190e5a0e516cc25a63f398dce9 (diff)
downloadopenbmc-521d8f69f9182a3d96e51b1df139c81302c026ef.tar.xz
repotest: refactor shellcheck slightly
Refactor the shellcheck implementation so that: 1. Files are checked by extension if their `file` type doesn't match a known list. Some shell scripts do not use the proper shebang and end up not being detected by `file`; attempt to revert to extension in that case. 2. Facilitate easier addition of multiple linting tools for other file types. A follow up commit will add 'json' linting with only a few changes. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I5ce60432c4bd123d9d9c14466505c2d4b2477959
Diffstat (limited to 'meta-phosphor/scripts')
-rwxr-xr-xmeta-phosphor/scripts/run-repotest54
1 files changed, 43 insertions, 11 deletions
diff --git a/meta-phosphor/scripts/run-repotest b/meta-phosphor/scripts/run-repotest
index dc4e87ca1..8c47e536c 100755
--- a/meta-phosphor/scripts/run-repotest
+++ b/meta-phosphor/scripts/run-repotest
@@ -87,6 +87,7 @@ meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platfo
meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh
meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh
meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh
+meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh
meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
@@ -119,6 +120,10 @@ meta-google/recipes-google/ncsi/files/gbmc-ncsi-ip-from-ra.sh.in
meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
+meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-from-ra.sh
+meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
+meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-nft.sh
+meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-ula.sh
meta-google/recipes-google/networking/google-usb-network/usb_network.sh
meta-google/recipes-google/networking/google-usb-network/usb_network_test.sh
meta-google/recipes-google/networking/network-sh/lib.sh
@@ -144,6 +149,7 @@ meta-ibm/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh
meta-ingrasys/meta-zaius/recipes-phosphor/chassis/avsbus-control/zaius_avsbus.sh
meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh
meta-inventec/meta-transformers/recipes-phosphor/init/transformers-init/transformers-init.sh
+meta-openpower/recipes-bsp/pdata/files/power-target.sh
meta-openpower/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/guard
meta-openpower/recipes-phosphor/network/first-boot-set-hostname/first-boot-set-hostname.sh
meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac.sh
@@ -173,13 +179,27 @@ meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_libr
meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh
meta-quanta/meta-gsj/recipes-gsj/usb-network/files/usb_network.sh
meta-quanta/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-control.sh
+meta-quanta/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh
meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/power/first-boot-set-psu/first-boot-set-psu.sh
+meta-quanta/meta-olympus-nuvoton/recipes-phosphor/fans/phosphor-pid-control/fan-full-speed.sh
meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh
meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh
meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh
meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control.sh
"
+types=(shell)
+# shellcheck disable=SC2034
+check_shell="shellcheck -x"
+
+for t in "${types[@]}"; do
+ check_cmd="check_${t}"
+ if ! which "${!check_cmd%% *}" > /dev/null 2>&1; then
+ eval "${check_cmd}=\"echo WARNING: Skipping $t due to missing command:\""
+ echo "${!check_cmd}"
+ fi
+done
+
non_bbfiles=$(git ls-files -- \
':!:poky/**' \
':!:meta-security/**' \
@@ -188,22 +208,34 @@ non_bbfiles=$(git ls-files -- \
| grep -v -e "\.patch$" -e "\.bb$" -e "\.bbappend$")
for f in $non_bbfiles; do
- file_type=$(file "$f")
- case $file_type in
+ unset file_type
+ file_info=$(file "$f")
+ case $file_info in
*shell\ script*)
- if ! shellcheck -x "$f"; then
- if [[ $lint_exempt == *$f* ]]; then
- echo "EXEMPT: $f"
- else
- echo "FAILED: $f"
- false
- fi
- fi
+ file_type="shell"
;;
*)
- ;;
+ case $f in
+ *.sh)
+ file_type="shell"
+ ;;
+
+ esac
esac
+
+ if [ -n "$file_type" ]; then
+ check_cmd="check_${file_type}"
+ if ! eval "${!check_cmd} $f"; then
+ if [[ $lint_exempt == *$f* ]]; then
+ echo "EXEMPT: $f"
+ else
+ echo "FAILED: $f"
+ false
+ fi
+ fi
+ fi
+
done
echo "Repo test passed"