repotest: enable shellcheck-based linting

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I48ff0b633697ddd16a7119519399c6579688436d
diff --git a/meta-phosphor/scripts/run-repotest b/meta-phosphor/scripts/run-repotest
index 5f83383..7328bae 100755
--- a/meta-phosphor/scripts/run-repotest
+++ b/meta-phosphor/scripts/run-repotest
@@ -4,6 +4,8 @@
 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
 obmc_dir=${script_dir}/../../
 
+cd "$obmc_dir"
+
 # openbmc doesn't control what upstream poky, or any of the other layers do,
 # which do use patches as part of their upstreaming process.
 # meta-phosphor is also included such that patches that the community agrees to
@@ -13,7 +15,7 @@
 allowed_patches_tmp=$(mktemp)
 trap "rm $patch_files_tmp $allowed_patches_tmp" exit
 
-git -C "$obmc_dir" ls-files -- \
+git ls-files -- \
   '*.patch' \
   ':!:poky/**' \
   ':!:meta-security/**' \
@@ -75,5 +77,136 @@
   exit 1
 fi
 
+lint_exempt="\
+meta-amd/recipes-amd/amd-fpga/files/ethanolx/fpgardu.sh
+meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh
+meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
+meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
+meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh
+meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
+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-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
+meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh
+meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
+meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh
+meta-bytedance/meta-g220a/recipes-network/network/static-mac-addr/mac-check
+meta-bytedance/meta-g220a/recipes-phosphor/datetime/me-time-sync/me-time-sync.sh
+meta-facebook/recipes-fb/fb-powerctrl/files/power-util
+meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh
+meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh
+meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
+meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
+meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh
+meta-fii/meta-kudo/recipes-phosphor/console/obmc-console/kudo_uart_mux_ctrl.sh
+meta-google/recipes-google/gpio/gpio-ctrl/lib.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh
+meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh
+meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
+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/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
+meta-google/recipes-google/networking/network-sh/test.sh
+meta-google/recipes-google/nftables/files/nft-configure.sh
+meta-google/recipes-google/ssh/authorized-keys-comp/authorized-keys-comp.sh
+meta-google/recipes-google/test/test-sh/test.sh
+meta-google/recipes-phosphor/flash/google-key/verify-bmc-image.sh
+meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh
+meta-hpe/meta-common/recipes-hpe/host/host-boot-enable/host-boot-enable.sh
+meta-hpe/meta-common/recipes-phosphor/initrdscripts/files/gxp-obmc-init.sh
+meta-hpe/meta-dl360poc/recipes-hpe/host/host-boot-enable/host-boot-enable.sh
+meta-ibm/meta-romulus/recipes-phosphor/chassis/vrm-control/vrm-control.sh
+meta-ibm/meta-romulus/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
+meta-ibm/recipes-phosphor/chassis/power-workarounds/witherspoon/power-workarounds.sh
+meta-ibm/recipes-phosphor/chassis/vrm-control/ibm-ac-server/ir35221-unbind-bind.sh
+meta-ibm/recipes-phosphor/chassis/vrm-control/mihawk/ir35221-unbind-bind.sh
+meta-ibm/recipes-phosphor/chassis/vrm-control/vrm-control.sh
+meta-ibm/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/ibm_elogall
+meta-ibm/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/pels
+meta-ibm/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
+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-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
+meta-openpower/recipes-phosphor/occ/openpower-occ-control/occ-active.sh
+meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
+meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-shutdown.sh
+meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-update.sh
+meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
+meta-phosphor/recipes-phosphor/interfaces/bmcweb/run-ptest
+meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init
+meta-phosphor/recipes-support/nss-pam-ldapd/files/nslcd.init
+meta-phosphor/scripts/run-repotest
+meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh
+meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh
+meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh
+meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh
+meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh
+meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh
+meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
+meta-quanta/meta-gbs/recipes-google/acpi-power-state/acpi-power-state-daemon/gbs-check-host-state.sh
+meta-quanta/meta-gbs/recipes-google/acpi-power-state/acpi-power-state-daemon/gbs-set-failsafe.sh
+meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh
+meta-quanta/meta-gbs/recipes-phosphor/sensors/phosphor-nvme/nvme_json_rewrite.sh
+meta-quanta/meta-gsj/recipes-gsj/detect-fan-fail/files/detect-fan-fail.sh
+meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh
+meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh
+meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh
+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-olympus-nuvoton/recipes-olympus-nuvoton/power/first-boot-set-psu/first-boot-set-psu.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
+setup
+"
+
+non_bbfiles=$(git ls-files -- \
+  ':!:poky/**' \
+  ':!:meta-security/**' \
+  ':!:meta-raspberrypi/**' \
+  ':!:meta-openembedded/**' \
+  | grep -v -e "\.patch$" -e "\.bb$" -e "\.bbappend$")
+
+for f in $non_bbfiles; do
+    file_type=$(file $f)
+    case $file_type in
+        *shell\ script*)
+            if ! shellcheck -x $f; then
+                if [[ $lint_exempt == *$f* ]]; then
+                    echo "EXEMPT: $f"
+                else
+                    echo "FAILED: $f"
+                    false
+                fi
+            fi
+            ;;
+
+        *)
+            ;;
+    esac
+done
+
 echo "Repo test passed"