]> git.ipfire.org Git - thirdparty/u-boot.git/blob - scripts/check-of.sh
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-riscv into...
[thirdparty/u-boot.git] / scripts / check-of.sh
1 #!/bin/sh
2 # Copyright 2021 Google LLC
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Check that the .config file provided does not try to disable OF_BOARD for
6 # boards that use CONFIG_OF_HAS_PRIOR_STAGE
7 #
8 # Usage
9 # check-of.sh <path to .config> <path to allowlist file>
10 #
11 # For example:
12 # scripts/check-of.sh b/chromebook_link/u-boot.cfg kconfig_allowlist.txt
13 #
14 # Exit code is 0 if OK, 3 if the .config is wrong, as above
15
16 set -e
17 set -u
18
19 PROG_NAME="${0##*/}"
20
21 usage() {
22 echo "$PROG_NAME <path to .config> <path to allowlist file>"
23 exit 1
24 }
25
26 [ $# -ge 2 ] || usage
27
28 path="$1"
29 allowlist="$2"
30
31 sys_config="$(sed -n 's/CONFIG_SYS_CONFIG_NAME="\(.*\)"$/\1/p' "${path}")"
32
33 if grep -q OF_HAS_PRIOR_STAGE=y "${path}"; then
34 if ! grep -lq CONFIG_OF_BOARD=y "${path}"; then
35 echo >&2 "This board uses a prior stage to provide the device tree."
36 echo >&2 "Please enable CONFIG_OF_BOARD to ensure that it works correctly."
37 if grep -q "${sys_config}" "${allowlist}"; then
38 exit 0
39 fi
40 exit 3
41 fi
42 fi