]> git.ipfire.org Git - thirdparty/u-boot.git/blame - scripts/check-of.sh
Merge tag 'v2024.04-rc4' into next
[thirdparty/u-boot.git] / scripts / check-of.sh
CommitLineData
24f073d4
SG
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
16set -e
17set -u
18
19PROG_NAME="${0##*/}"
20
21usage() {
22 echo "$PROG_NAME <path to .config> <path to allowlist file>"
23 exit 1
24}
25
26[ $# -ge 2 ] || usage
27
28path="$1"
29allowlist="$2"
30
31sys_config="$(sed -n 's/CONFIG_SYS_CONFIG_NAME="\(.*\)"$/\1/p' "${path}")"
32
33if 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
42fi