| Ed Tanous | d5cea14 | 2021-09-09 11:42:05 -0700 | [diff] [blame] | 1 | #!/bin/bash -e | 
|  | 2 | # | 
|  | 3 |  | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 4 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | 
|  | 5 | obmc_dir=${script_dir}/../../ | 
|  | 6 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 7 | cd "$obmc_dir" | 
|  | 8 |  | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 9 | # 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 |  | 
|  | 14 | patch_files_tmp=$(mktemp) | 
|  | 15 | allowed_patches_tmp=$(mktemp) | 
| Patrick Williams | 693d3db | 2021-10-26 16:10:20 -0500 | [diff] [blame] | 16 | trap 'rm $patch_files_tmp $allowed_patches_tmp' exit | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 17 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 18 | git ls-files -- \ | 
| Patrick Williams | 1eb2b74 | 2024-01-02 07:48:04 -0600 | [diff] [blame] | 19 | '*.patch' '*.dts' \ | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 20 | ':!:poky/**' \ | 
| Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 21 | ':!:meta-arm/**' \ | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 22 | ':!:meta-security/**' \ | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 23 | ':!:meta-raspberrypi/**' \ | 
|  | 24 | ':!:meta-openembedded/**' \ | 
|  | 25 | ':!:meta-phosphor/**' \ | 
| Patrick Williams | 693d3db | 2021-10-26 16:10:20 -0500 | [diff] [blame] | 26 | | sort > "$patch_files_tmp" | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 27 |  | 
|  | 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 | 
|  | 36 | echo "\ | 
| Andrew Jeffery | 7c92857 | 2023-08-14 13:00:06 +0930 | [diff] [blame] | 37 | meta-aspeed/recipes-aspeed/python/socsec/0001-otptool-Define-value_start-in-rev_id-path.patch | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 38 | meta-aspeed/recipes-bsp/u-boot/files/default-gcc.patch | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 39 | meta-bytedance/meta-g220a/recipes-kernel/linux/linux-aspeed/0005-ARM-dts-aspeed-Enable-g220a-uart-route.patch | 
| Logananth Sundararaj | 971257a | 2022-03-23 17:34:12 +0530 | [diff] [blame] | 40 | meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed-sdk/0001-board-aspeed-Add-Mux-for-yosemitev2.patch | 
|  | 41 | meta-facebook/meta-yosemitev2/recipes-bsp/u-boot/u-boot-aspeed-sdk/0002-spl-host-console-handle.patch | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 42 | meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps/0001-Set-FIU0_DRD_CFG-and-FIU_Clk_divider-for-gbmc-hoth.patch | 
|  | 43 | meta-google/recipes-extended/libconfig/files/0001-conf2struct-Use-the-right-perl.patch | 
|  | 44 | meta-google/recipes-extended/libconfig/files/0001-makefile-Add-missing-LDFLAGS.patch | 
|  | 45 | meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/rwfs-clean-dev.patch | 
| Patrick Williams | 1eb2b74 | 2024-01-02 07:48:04 -0600 | [diff] [blame] | 46 | meta-hpe/meta-dl360poc/recipes-kernel/linux/linux-obmc/gxp.dts | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 47 | meta-ingrasys/meta-zaius/recipes-bsp/u-boot/u-boot-aspeed/0001-board-aspeed-Add-reset_phy-for-Zaius.patch | 
|  | 48 | meta-nuvoton/recipes-bsp/images/npcm7xx-igps/0001-Adjust-paths-for-use-with-Bitbake.patch | 
|  | 49 | meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0001-Add-system-reset-status-support.patch | 
|  | 50 | meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0002-config-ast-common-set-fieldmode-to-true.patch | 
|  | 51 | meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0003-aspeed-add-gpio-support.patch | 
|  | 52 | meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0004-aspeed-add-bmc-position-support.patch | 
|  | 53 | meta-yadro/meta-nicole/recipes-kernel/linux/linux-aspeed/0001-Add-NCSI-channel-selector.patch | 
|  | 54 | meta-yadro/meta-nicole/recipes-phosphor/host/op-proc-control/0001-Stop-and-send-SRESET-for-one-thread-only.patch | 
|  | 55 | meta-yadro/recipes-phosphor/dbus/phosphor-dbus-interfaces/0001-Add-boot-initiator-mailbox-interface.patch | 
|  | 56 | meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-support-for-persistent-only-settings.patch | 
|  | 57 | meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Add-support-for-boot-initiator-mailbox.patch | 
|  | 58 | meta-yadro/recipes-phosphor/ipmi/phosphor-ipmi-host/0003-Fix-version-parsing-update-AUX-revision-info.patch | 
| Patrick Williams | 693d3db | 2021-10-26 16:10:20 -0500 | [diff] [blame] | 59 | " | sort > "$allowed_patches_tmp" | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 60 |  | 
| Patrick Williams | 693d3db | 2021-10-26 16:10:20 -0500 | [diff] [blame] | 61 | files_diff=$(comm -23 "$patch_files_tmp" "$allowed_patches_tmp") | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 62 |  | 
| Ed Tanous | 4734c22 | 2021-09-20 11:11:34 -0700 | [diff] [blame] | 63 | files_count=$(echo -n "$files_diff" | grep -c '^' || true) | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 64 | if [[ $files_count -ne 0 ]]; then | 
| Patrick Williams | 1eb2b74 | 2024-01-02 07:48:04 -0600 | [diff] [blame] | 65 | echo "Patch or DTS files found not in allow list" | 
| Ed Tanous | 7f8954e | 2021-09-09 11:46:43 -0700 | [diff] [blame] | 66 | echo "$files_diff" | 
|  | 67 | echo "Patches are not allowed on OpenBMC in these layers.  Please upstream your changes and see \ | 
|  | 68 | https://github.com/openbmc/docs/blob/master/meta-layer-guidelines.md" | 
|  | 69 | exit 1 | 
|  | 70 | fi | 
|  | 71 |  | 
| Andrew Geissler | fc32817 | 2022-01-21 09:37:06 -0600 | [diff] [blame] | 72 | # Now verify there are no kernel dts files being added in a patch | 
|  | 73 | # All dts files should be sent upstream and can be carried in the openbmc/linux | 
|  | 74 | # tree until they are accepted upstream | 
|  | 75 | dts_files_tmp=$(mktemp) | 
|  | 76 | allowed_dts_tmp=$(mktemp) | 
|  | 77 | trap 'rm $dts_files_tmp $allowed_dts_tmp' exit | 
|  | 78 |  | 
|  | 79 | git ls-files -- \ | 
|  | 80 | '*.dts' \ | 
|  | 81 | ':!:poky/**' \ | 
| Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 82 | ':!:meta-arm/**' \ | 
| Andrew Geissler | fc32817 | 2022-01-21 09:37:06 -0600 | [diff] [blame] | 83 | ':!:meta-security/**' \ | 
|  | 84 | ':!:meta-raspberrypi/**' \ | 
|  | 85 | ':!:meta-openembedded/**' \ | 
|  | 86 | | sort > "$dts_files_tmp" | 
|  | 87 |  | 
|  | 88 | # There is a single dts currently in the tree that we will exempt for now | 
|  | 89 | echo "\ | 
|  | 90 | meta-hpe/meta-dl360poc/recipes-kernel/linux/linux-obmc/gxp.dts | 
|  | 91 | " | sort > "$allowed_dts_tmp" | 
|  | 92 |  | 
|  | 93 | files_diff=$(comm -23 "$dts_files_tmp" "$allowed_dts_tmp") | 
|  | 94 |  | 
|  | 95 | files_count=$(echo -n "$files_diff" | grep -c '^' || true) | 
|  | 96 | if [[ $files_count -ne 0 ]]; then | 
|  | 97 | echo "Dts files found not in allow list" | 
|  | 98 | echo "$files_diff" | 
|  | 99 | echo "Dts files are not allowed on OpenBMC in these layers. Please upstream your changes and see \ | 
|  | 100 | https://github.com/openbmc/docs/blob/master/kernel-development.md" | 
|  | 101 | exit 1 | 
|  | 102 | fi | 
|  | 103 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 104 | lint_exempt="\ | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 105 | meta-phosphor/recipes-support/nss-pam-ldapd/files/nslcd.init | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 106 | " | 
|  | 107 |  | 
| Patrick Williams | 2ed00d8 | 2021-10-27 09:33:53 -0500 | [diff] [blame] | 108 | types=(json shell) | 
|  | 109 | # shellcheck disable=SC2034 | 
|  | 110 | check_json="eslint --resolve-plugins-relative-to /usr/local/lib/node_modules" | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 111 | # shellcheck disable=SC2034 | 
|  | 112 | check_shell="shellcheck -x" | 
|  | 113 |  | 
|  | 114 | for t in "${types[@]}"; do | 
|  | 115 | check_cmd="check_${t}" | 
|  | 116 | if ! which "${!check_cmd%% *}" > /dev/null 2>&1; then | 
|  | 117 | eval "${check_cmd}=\"echo WARNING: Skipping $t due to missing command:\"" | 
|  | 118 | echo "${!check_cmd}" | 
|  | 119 | fi | 
|  | 120 | done | 
|  | 121 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 122 | non_bbfiles=$(git ls-files -- \ | 
|  | 123 | ':!:poky/**' \ | 
| Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 124 | ':!:meta-arm/**' \ | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 125 | ':!:meta-security/**' \ | 
|  | 126 | ':!:meta-raspberrypi/**' \ | 
|  | 127 | ':!:meta-openembedded/**' \ | 
|  | 128 | | grep -v -e "\.patch$" -e "\.bb$" -e "\.bbappend$") | 
|  | 129 |  | 
|  | 130 | for f in $non_bbfiles; do | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 131 | unset file_type | 
|  | 132 | file_info=$(file "$f") | 
|  | 133 | case $file_info in | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 134 | *shell\ script*) | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 135 | file_type="shell" | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 136 | ;; | 
|  | 137 |  | 
| Patrick Williams | 2ed00d8 | 2021-10-27 09:33:53 -0500 | [diff] [blame] | 138 | *JSON\ data*) | 
|  | 139 | file_type="json" | 
|  | 140 | ;; | 
|  | 141 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 142 | *) | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 143 | case $f in | 
|  | 144 | *.sh) | 
|  | 145 | file_type="shell" | 
|  | 146 | ;; | 
|  | 147 |  | 
| Patrick Williams | 2ed00d8 | 2021-10-27 09:33:53 -0500 | [diff] [blame] | 148 | *.json) | 
|  | 149 | file_type="json" | 
|  | 150 | ;; | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 151 | esac | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 152 | esac | 
| Patrick Williams | 521d8f6 | 2021-10-27 09:30:41 -0500 | [diff] [blame] | 153 |  | 
|  | 154 | if [ -n "$file_type" ]; then | 
|  | 155 | check_cmd="check_${file_type}" | 
|  | 156 | if ! eval "${!check_cmd} $f"; then | 
|  | 157 | if [[ $lint_exempt == *$f* ]]; then | 
|  | 158 | echo "EXEMPT: $f" | 
|  | 159 | else | 
|  | 160 | echo "FAILED: $f" | 
|  | 161 | false | 
|  | 162 | fi | 
|  | 163 | fi | 
|  | 164 | fi | 
|  | 165 |  | 
| Patrick Williams | 12a27b2 | 2021-10-26 16:07:31 -0500 | [diff] [blame] | 166 | done | 
|  | 167 |  | 
| Ed Tanous | d5cea14 | 2021-09-09 11:42:05 -0700 | [diff] [blame] | 168 | echo "Repo test passed" |