blob: 6d6d23ba8a5cc88b73a813abd0d20f1e85ad8827 [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/**' \
Brad Bishopbec4ebc2022-08-03 09:55:16 -040021 ':!:meta-arm/**' \
Ed Tanous7f8954e2021-09-09 11:46:43 -070022 ':!:meta-security/**' \
Ed Tanous7f8954e2021-09-09 11:46:43 -070023 ':!:meta-raspberrypi/**' \
24 ':!:meta-openembedded/**' \
25 ':!:meta-phosphor/**' \
Patrick Williams693d3db2021-10-26 16:10:20 -050026 | sort > "$patch_files_tmp"
Ed Tanous7f8954e2021-09-09 11:46:43 -070027
28
29# The following patches were present on master at the time this test was
30# written. Their presence in this list should not be acknowlegement that they
31# are now allowed, but ignoring them is required in the intermediate time
32# between when this test was created, and when the maintainers of these repos
33# clean them up.
34#
35# https://github.com/openbmc/docs/blob/master/meta-layer-guidelines.md
36echo "\
Ed Tanous7f8954e2021-09-09 11:46:43 -070037meta-aspeed/recipes-bsp/u-boot/files/default-gcc.patch
Ed Tanous7f8954e2021-09-09 11:46:43 -070038meta-bytedance/meta-g220a/recipes-kernel/linux/linux-aspeed/0005-ARM-dts-aspeed-Enable-g220a-uart-route.patch
Logananth Sundararaj971257a2022-03-23 17:34:12 +053039meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed-sdk/0001-board-aspeed-Add-Mux-for-yosemitev2.patch
40meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed-sdk/0002-spl-host-console-handle.patch
Ed Tanous7f8954e2021-09-09 11:46:43 -070041meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps/0001-Set-FIU0_DRD_CFG-and-FIU_Clk_divider-for-gbmc-hoth.patch
42meta-google/recipes-extended/libconfig/files/0001-conf2struct-Use-the-right-perl.patch
43meta-google/recipes-extended/libconfig/files/0001-makefile-Add-missing-LDFLAGS.patch
44meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/rwfs-clean-dev.patch
45meta-ingrasys/meta-zaius/recipes-bsp/u-boot/u-boot-aspeed/0001-board-aspeed-Add-reset_phy-for-Zaius.patch
46meta-nuvoton/recipes-bsp/images/npcm7xx-igps/0001-Adjust-paths-for-use-with-Bitbake.patch
47meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0001-Add-system-reset-status-support.patch
48meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0002-config-ast-common-set-fieldmode-to-true.patch
49meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0003-aspeed-add-gpio-support.patch
50meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0004-aspeed-add-bmc-position-support.patch
51meta-yadro/meta-nicole/recipes-kernel/linux/linux-aspeed/0001-Add-NCSI-channel-selector.patch
52meta-yadro/meta-nicole/recipes-phosphor/host/op-proc-control/0001-Stop-and-send-SRESET-for-one-thread-only.patch
53meta-yadro/recipes-phosphor/dbus/phosphor-dbus-interfaces/0001-Add-boot-initiator-mailbox-interface.patch
54meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-support-for-persistent-only-settings.patch
55meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Add-support-for-boot-initiator-mailbox.patch
56meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0003-Fix-version-parsing-update-AUX-revision-info.patch
Patrick Williams693d3db2021-10-26 16:10:20 -050057" | sort > "$allowed_patches_tmp"
Ed Tanous7f8954e2021-09-09 11:46:43 -070058
Patrick Williams693d3db2021-10-26 16:10:20 -050059files_diff=$(comm -23 "$patch_files_tmp" "$allowed_patches_tmp")
Ed Tanous7f8954e2021-09-09 11:46:43 -070060
Ed Tanous4734c222021-09-20 11:11:34 -070061files_count=$(echo -n "$files_diff" | grep -c '^' || true)
Ed Tanous7f8954e2021-09-09 11:46:43 -070062if [[ $files_count -ne 0 ]]; then
63 echo "Patch files found not in allow list"
64 echo "$files_diff"
65 echo "Patches are not allowed on OpenBMC in these layers. Please upstream your changes and see \
66 https://github.com/openbmc/docs/blob/master/meta-layer-guidelines.md"
67 exit 1
68fi
69
Andrew Geisslerfc328172022-01-21 09:37:06 -060070# Now verify there are no kernel dts files being added in a patch
71# All dts files should be sent upstream and can be carried in the openbmc/linux
72# tree until they are accepted upstream
73dts_files_tmp=$(mktemp)
74allowed_dts_tmp=$(mktemp)
75trap 'rm $dts_files_tmp $allowed_dts_tmp' exit
76
77git ls-files -- \
78 '*.dts' \
79 ':!:poky/**' \
Brad Bishopbec4ebc2022-08-03 09:55:16 -040080 ':!:meta-arm/**' \
Andrew Geisslerfc328172022-01-21 09:37:06 -060081 ':!:meta-security/**' \
82 ':!:meta-raspberrypi/**' \
83 ':!:meta-openembedded/**' \
84 | sort > "$dts_files_tmp"
85
86# There is a single dts currently in the tree that we will exempt for now
87echo "\
88meta-hpe/meta-dl360poc/recipes-kernel/linux/linux-obmc/gxp.dts
89" | sort > "$allowed_dts_tmp"
90
91files_diff=$(comm -23 "$dts_files_tmp" "$allowed_dts_tmp")
92
93files_count=$(echo -n "$files_diff" | grep -c '^' || true)
94if [[ $files_count -ne 0 ]]; then
95echo "Dts files found not in allow list"
96echo "$files_diff"
97echo "Dts files are not allowed on OpenBMC in these layers. Please upstream your changes and see \
98 https://github.com/openbmc/docs/blob/master/kernel-development.md"
99exit 1
100fi
101
Patrick Williams12a27b22021-10-26 16:07:31 -0500102lint_exempt="\
Patrick Williams12a27b22021-10-26 16:07:31 -0500103meta-google/recipes-google/gpio/gpio-ctrl/lib.sh
104meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh
105meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh
106meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh
107meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh
108meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh
109meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh
110meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
111meta-google/recipes-google/ncsi/files/gbmc-ncsi-ip-from-ra.sh.in
112meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
113meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
114meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
Patrick Williams521d8f62021-10-27 09:30:41 -0500115meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-from-ra.sh
116meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
117meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-nft.sh
118meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-ula.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500119meta-google/recipes-google/networking/google-usb-network/usb_network.sh
120meta-google/recipes-google/networking/google-usb-network/usb_network_test.sh
121meta-google/recipes-google/networking/network-sh/lib.sh
122meta-google/recipes-google/networking/network-sh/test.sh
123meta-google/recipes-google/nftables/files/nft-configure.sh
124meta-google/recipes-google/ssh/authorized-keys-comp/authorized-keys-comp.sh
125meta-google/recipes-google/test/test-sh/test.sh
126meta-google/recipes-phosphor/flash/google-key/verify-bmc-image.sh
127meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500128meta-ibm/meta-romulus/recipes-phosphor/chassis/vrm-control/vrm-control.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500129meta-ibm/recipes-phosphor/chassis/vrm-control/vrm-control.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500130meta-inventec/meta-transformers/recipes-phosphor/init/transformers-init/transformers-init.sh
Patrick Williams12a27b22021-10-26 16:07:31 -0500131meta-phosphor/recipes-support/nss-pam-ldapd/files/nslcd.init
Patrick Williams12a27b22021-10-26 16:07:31 -0500132"
133
Patrick Williams2ed00d82021-10-27 09:33:53 -0500134types=(json shell)
135# shellcheck disable=SC2034
136check_json="eslint --resolve-plugins-relative-to /usr/local/lib/node_modules"
Patrick Williams521d8f62021-10-27 09:30:41 -0500137# shellcheck disable=SC2034
138check_shell="shellcheck -x"
139
140for t in "${types[@]}"; do
141 check_cmd="check_${t}"
142 if ! which "${!check_cmd%% *}" > /dev/null 2>&1; then
143 eval "${check_cmd}=\"echo WARNING: Skipping $t due to missing command:\""
144 echo "${!check_cmd}"
145 fi
146done
147
Patrick Williams12a27b22021-10-26 16:07:31 -0500148non_bbfiles=$(git ls-files -- \
149 ':!:poky/**' \
Brad Bishopbec4ebc2022-08-03 09:55:16 -0400150 ':!:meta-arm/**' \
Patrick Williams12a27b22021-10-26 16:07:31 -0500151 ':!:meta-security/**' \
152 ':!:meta-raspberrypi/**' \
153 ':!:meta-openembedded/**' \
154 | grep -v -e "\.patch$" -e "\.bb$" -e "\.bbappend$")
155
156for f in $non_bbfiles; do
Patrick Williams521d8f62021-10-27 09:30:41 -0500157 unset file_type
158 file_info=$(file "$f")
159 case $file_info in
Patrick Williams12a27b22021-10-26 16:07:31 -0500160 *shell\ script*)
Patrick Williams521d8f62021-10-27 09:30:41 -0500161 file_type="shell"
Patrick Williams12a27b22021-10-26 16:07:31 -0500162 ;;
163
Patrick Williams2ed00d82021-10-27 09:33:53 -0500164 *JSON\ data*)
165 file_type="json"
166 ;;
167
Patrick Williams12a27b22021-10-26 16:07:31 -0500168 *)
Patrick Williams521d8f62021-10-27 09:30:41 -0500169 case $f in
170 *.sh)
171 file_type="shell"
172 ;;
173
Patrick Williams2ed00d82021-10-27 09:33:53 -0500174 *.json)
175 file_type="json"
176 ;;
Patrick Williams521d8f62021-10-27 09:30:41 -0500177 esac
Patrick Williams12a27b22021-10-26 16:07:31 -0500178 esac
Patrick Williams521d8f62021-10-27 09:30:41 -0500179
180 if [ -n "$file_type" ]; then
181 check_cmd="check_${file_type}"
182 if ! eval "${!check_cmd} $f"; then
183 if [[ $lint_exempt == *$f* ]]; then
184 echo "EXEMPT: $f"
185 else
186 echo "FAILED: $f"
187 false
188 fi
189 fi
190 fi
191
Patrick Williams12a27b22021-10-26 16:07:31 -0500192done
193
Ed Tanousd5cea142021-09-09 11:42:05 -0700194echo "Repo test passed"