blob: 359262cf9df6b532e7b50a77fa0b6e69fa5deb13 [file] [log] [blame]
Ed Tanousd5cea142021-09-09 11:42:05 -07001#!/bin/bash -e
2#
3
Ed Tanous7f8954e2021-09-09 11:46:43 -07004script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5obmc_dir=${script_dir}/../../
6
Patrick Williams12a27b22021-10-26 16:07:31 -05007cd "$obmc_dir"
8
Ed Tanous7f8954e2021-09-09 11:46:43 -07009# openbmc doesn't control what upstream poky, or any of the other layers do,
10# which do use patches as part of their upstreaming process.
11# meta-phosphor is also included such that patches that the community agrees to
12# hold onto will be allowed in that layer.
13
14patch_files_tmp=$(mktemp)
15allowed_patches_tmp=$(mktemp)
Patrick Williams693d3db2021-10-26 16:10:20 -050016trap 'rm $patch_files_tmp $allowed_patches_tmp' exit
Ed Tanous7f8954e2021-09-09 11:46:43 -070017
Patrick Williams12a27b22021-10-26 16:07:31 -050018git ls-files -- \
Ed Tanous7f8954e2021-09-09 11:46:43 -070019 '*.patch' \
20 ':!:poky/**' \
21 ':!:meta-security/**' \
Ed Tanous7f8954e2021-09-09 11:46:43 -070022 ':!:meta-raspberrypi/**' \
23 ':!:meta-openembedded/**' \
24 ':!:meta-phosphor/**' \
Patrick Williams693d3db2021-10-26 16:10:20 -050025 | sort > "$patch_files_tmp"
Ed Tanous7f8954e2021-09-09 11:46:43 -070026
27
28# The following patches were present on master at the time this test was
29# written. Their presence in this list should not be acknowlegement that they
30# are now allowed, but ignoring them is required in the intermediate time
31# between when this test was created, and when the maintainers of these repos
32# clean them up.
33#
34# https://github.com/openbmc/docs/blob/master/meta-layer-guidelines.md
35echo "\
36meta-amd/meta-ethanolx/recipes-x86/chassis/x86-power-control/0001-Amd-power-control-modifications-for-EthanolX.patch
37meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch
Ed Tanous7f8954e2021-09-09 11:46:43 -070038meta-aspeed/recipes-bsp/u-boot/files/default-gcc.patch
Ed Tanous7f8954e2021-09-09 11:46:43 -070039meta-bytedance/meta-g220a/recipes-kernel/linux/linux-aspeed/0005-ARM-dts-aspeed-Enable-g220a-uart-route.patch
40meta-bytedance/meta-g220a/recipes-phosphor/ipmi/phosphor-node-manager-proxy/0001-Remove-Total_Power-sensor.patch
41meta-facebook/meta-bletchley/recipes-bsp/u-boot/u-boot-aspeed-sdk/0001-u-boot-ast2600-57600-baudrate-for-bletchley.patch
42meta-facebook/meta-tiogapass/recipes-bsp/u-boot/u-boot-aspeed/0001-configs-ast-common-use-57600-baud-rate-to-match-Tiog.patch
43meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed/0001-board-aspeed-Add-Mux-for-yosemitev2.patch
44meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed/0002-spl-host-console-handle.patch
45meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps/0001-Set-FIU0_DRD_CFG-and-FIU_Clk_divider-for-gbmc-hoth.patch
46meta-google/recipes-extended/libconfig/files/0001-conf2struct-Use-the-right-perl.patch
47meta-google/recipes-extended/libconfig/files/0001-makefile-Add-missing-LDFLAGS.patch
48meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/rwfs-clean-dev.patch
49meta-ingrasys/meta-zaius/recipes-bsp/u-boot/u-boot-aspeed/0001-board-aspeed-Add-reset_phy-for-Zaius.patch
50meta-nuvoton/recipes-bsp/images/npcm7xx-igps/0001-Adjust-paths-for-use-with-Bitbake.patch
51meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0001-Add-system-reset-status-support.patch
52meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0002-config-ast-common-set-fieldmode-to-true.patch
53meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0003-aspeed-add-gpio-support.patch
54meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0004-aspeed-add-bmc-position-support.patch
55meta-yadro/meta-nicole/recipes-kernel/linux/linux-aspeed/0001-Add-NCSI-channel-selector.patch
56meta-yadro/meta-nicole/recipes-phosphor/host/op-proc-control/0001-Stop-and-send-SRESET-for-one-thread-only.patch
57meta-yadro/recipes-phosphor/dbus/phosphor-dbus-interfaces/0001-Add-boot-initiator-mailbox-interface.patch
58meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-support-for-persistent-only-settings.patch
59meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Add-support-for-boot-initiator-mailbox.patch
60meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0003-Fix-version-parsing-update-AUX-revision-info.patch
Patrick Williams693d3db2021-10-26 16:10:20 -050061" | sort > "$allowed_patches_tmp"
Ed Tanous7f8954e2021-09-09 11:46:43 -070062
Patrick Williams693d3db2021-10-26 16:10:20 -050063files_diff=$(comm -23 "$patch_files_tmp" "$allowed_patches_tmp")
Ed Tanous7f8954e2021-09-09 11:46:43 -070064
Ed Tanous4734c222021-09-20 11:11:34 -070065files_count=$(echo -n "$files_diff" | grep -c '^' || true)
Ed Tanous7f8954e2021-09-09 11:46:43 -070066if [[ $files_count -ne 0 ]]; then
67 echo "Patch files found not in allow list"
68 echo "$files_diff"
69 echo "Patches are not allowed on OpenBMC in these layers. Please upstream your changes and see \
70 https://github.com/openbmc/docs/blob/master/meta-layer-guidelines.md"
71 exit 1
72fi
73
Andrew Geisslerfc328172022-01-21 09:37:06 -060074# Now verify there are no kernel dts files being added in a patch
75# All dts files should be sent upstream and can be carried in the openbmc/linux
76# tree until they are accepted upstream
77dts_files_tmp=$(mktemp)
78allowed_dts_tmp=$(mktemp)
79trap 'rm $dts_files_tmp $allowed_dts_tmp' exit
80
81git ls-files -- \
82 '*.dts' \
83 ':!:poky/**' \
84 ':!:meta-security/**' \
85 ':!:meta-raspberrypi/**' \
86 ':!:meta-openembedded/**' \
87 | sort > "$dts_files_tmp"
88
89# There is a single dts currently in the tree that we will exempt for now
90echo "\
91meta-hpe/meta-dl360poc/recipes-kernel/linux/linux-obmc/gxp.dts
92" | sort > "$allowed_dts_tmp"
93
94files_diff=$(comm -23 "$dts_files_tmp" "$allowed_dts_tmp")
95
96files_count=$(echo -n "$files_diff" | grep -c '^' || true)
97if [[ $files_count -ne 0 ]]; then
98echo "Dts files found not in allow list"
99echo "$files_diff"
100echo "Dts files are not allowed on OpenBMC in these layers. Please upstream your changes and see \
101 https://github.com/openbmc/docs/blob/master/kernel-development.md"
102exit 1
103fi
104
Patrick Williams12a27b22021-10-26 16:07:31 -0500105lint_exempt="\
106meta-amd/recipes-amd/amd-fpga/files/ethanolx/fpgardu.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500107meta-bytedance/meta-g220a/recipes-network/network/static-mac-addr/mac-check
108meta-bytedance/meta-g220a/recipes-phosphor/datetime/me-time-sync/me-time-sync.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500109meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
110meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
111meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
112meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
113meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
114meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
115meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
116meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh
117meta-fii/meta-kudo/recipes-phosphor/console/obmc-console/kudo_uart_mux_ctrl.sh
118meta-google/recipes-google/gpio/gpio-ctrl/lib.sh
119meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh
120meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh
121meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh
122meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh
123meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh
124meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh
125meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
126meta-google/recipes-google/ncsi/files/gbmc-ncsi-ip-from-ra.sh.in
127meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
128meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
129meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
Patrick Williams521d8f62021-10-27 09:30:41 -0500130meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-from-ra.sh
131meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
132meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-nft.sh
133meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-ula.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500134meta-google/recipes-google/networking/google-usb-network/usb_network.sh
135meta-google/recipes-google/networking/google-usb-network/usb_network_test.sh
136meta-google/recipes-google/networking/network-sh/lib.sh
137meta-google/recipes-google/networking/network-sh/test.sh
138meta-google/recipes-google/nftables/files/nft-configure.sh
139meta-google/recipes-google/ssh/authorized-keys-comp/authorized-keys-comp.sh
140meta-google/recipes-google/test/test-sh/test.sh
141meta-google/recipes-phosphor/flash/google-key/verify-bmc-image.sh
142meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh
143meta-hpe/meta-common/recipes-hpe/host/host-boot-enable/host-boot-enable.sh
144meta-hpe/meta-common/recipes-phosphor/initrdscripts/files/gxp-obmc-init.sh
145meta-hpe/meta-dl360poc/recipes-hpe/host/host-boot-enable/host-boot-enable.sh
146meta-ibm/meta-romulus/recipes-phosphor/chassis/vrm-control/vrm-control.sh
147meta-ibm/meta-romulus/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
148meta-ibm/recipes-phosphor/chassis/power-workarounds/witherspoon/power-workarounds.sh
149meta-ibm/recipes-phosphor/chassis/vrm-control/ibm-ac-server/ir35221-unbind-bind.sh
150meta-ibm/recipes-phosphor/chassis/vrm-control/mihawk/ir35221-unbind-bind.sh
151meta-ibm/recipes-phosphor/chassis/vrm-control/vrm-control.sh
152meta-ibm/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/ibm_elogall
153meta-ibm/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/pels
154meta-ibm/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
155meta-ibm/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh
156meta-ingrasys/meta-zaius/recipes-phosphor/chassis/avsbus-control/zaius_avsbus.sh
157meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh
158meta-inventec/meta-transformers/recipes-phosphor/init/transformers-init/transformers-init.sh
Patrick Williams521d8f62021-10-27 09:30:41 -0500159meta-openpower/recipes-bsp/pdata/files/power-target.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500160meta-openpower/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/guard
161meta-openpower/recipes-phosphor/network/first-boot-set-hostname/first-boot-set-hostname.sh
162meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac.sh
163meta-openpower/recipes-phosphor/occ/openpower-occ-control/occ-active.sh
164meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
165meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-shutdown.sh
166meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-update.sh
167meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
168meta-phosphor/recipes-phosphor/interfaces/bmcweb/run-ptest
169meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init
170meta-phosphor/recipes-support/nss-pam-ldapd/files/nslcd.init
Patrick Williams12a27b22021-10-26 16:07:31 -0500171meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh
172meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh
173meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh
174meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh
175meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh
176meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh
177meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
178meta-quanta/meta-gbs/recipes-google/acpi-power-state/acpi-power-state-daemon/gbs-check-host-state.sh
179meta-quanta/meta-gbs/recipes-google/acpi-power-state/acpi-power-state-daemon/gbs-set-failsafe.sh
180meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh
181meta-quanta/meta-gbs/recipes-phosphor/sensors/phosphor-nvme/nvme_json_rewrite.sh
182meta-quanta/meta-gsj/recipes-gsj/detect-fan-fail/files/detect-fan-fail.sh
183meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh
184meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh
185meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh
186meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh
187meta-quanta/meta-gsj/recipes-gsj/usb-network/files/usb_network.sh
188meta-quanta/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-control.sh
Patrick Williams521d8f62021-10-27 09:30:41 -0500189meta-quanta/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500190meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/power/first-boot-set-psu/first-boot-set-psu.sh
Patrick Williams521d8f62021-10-27 09:30:41 -0500191meta-quanta/meta-olympus-nuvoton/recipes-phosphor/fans/phosphor-pid-control/fan-full-speed.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500192meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh
193meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh
194meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh
195meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500196"
197
Patrick Williams2ed00d82021-10-27 09:33:53 -0500198types=(json shell)
199# shellcheck disable=SC2034
200check_json="eslint --resolve-plugins-relative-to /usr/local/lib/node_modules"
Patrick Williams521d8f62021-10-27 09:30:41 -0500201# shellcheck disable=SC2034
202check_shell="shellcheck -x"
203
204for t in "${types[@]}"; do
205 check_cmd="check_${t}"
206 if ! which "${!check_cmd%% *}" > /dev/null 2>&1; then
207 eval "${check_cmd}=\"echo WARNING: Skipping $t due to missing command:\""
208 echo "${!check_cmd}"
209 fi
210done
211
Patrick Williams12a27b22021-10-26 16:07:31 -0500212non_bbfiles=$(git ls-files -- \
213 ':!:poky/**' \
214 ':!:meta-security/**' \
215 ':!:meta-raspberrypi/**' \
216 ':!:meta-openembedded/**' \
217 | grep -v -e "\.patch$" -e "\.bb$" -e "\.bbappend$")
218
219for f in $non_bbfiles; do
Patrick Williams521d8f62021-10-27 09:30:41 -0500220 unset file_type
221 file_info=$(file "$f")
222 case $file_info in
Patrick Williams12a27b22021-10-26 16:07:31 -0500223 *shell\ script*)
Patrick Williams521d8f62021-10-27 09:30:41 -0500224 file_type="shell"
Patrick Williams12a27b22021-10-26 16:07:31 -0500225 ;;
226
Patrick Williams2ed00d82021-10-27 09:33:53 -0500227 *JSON\ data*)
228 file_type="json"
229 ;;
230
Patrick Williams12a27b22021-10-26 16:07:31 -0500231 *)
Patrick Williams521d8f62021-10-27 09:30:41 -0500232 case $f in
233 *.sh)
234 file_type="shell"
235 ;;
236
Patrick Williams2ed00d82021-10-27 09:33:53 -0500237 *.json)
238 file_type="json"
239 ;;
Patrick Williams521d8f62021-10-27 09:30:41 -0500240 esac
Patrick Williams12a27b22021-10-26 16:07:31 -0500241 esac
Patrick Williams521d8f62021-10-27 09:30:41 -0500242
243 if [ -n "$file_type" ]; then
244 check_cmd="check_${file_type}"
245 if ! eval "${!check_cmd} $f"; then
246 if [[ $lint_exempt == *$f* ]]; then
247 echo "EXEMPT: $f"
248 else
249 echo "FAILED: $f"
250 false
251 fi
252 fi
253 fi
254
Patrick Williams12a27b22021-10-26 16:07:31 -0500255done
256
Ed Tanousd5cea142021-09-09 11:42:05 -0700257echo "Repo test passed"