check-of.sh 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. set -e
  16. set -u
  17. PROG_NAME="${0##*/}"
  18. usage() {
  19. echo "$PROG_NAME <path to .config> <path to allowlist file>"
  20. exit 1
  21. }
  22. [ $# -ge 2 ] || usage
  23. path="$1"
  24. allowlist="$2"
  25. sys_config="$(sed -n 's/CONFIG_SYS_CONFIG_NAME="\(.*\)"$/\1/p' "${path}")"
  26. if grep -q OF_HAS_PRIOR_STAGE=y "${path}"; then
  27. if ! grep -lq CONFIG_OF_BOARD=y "${path}"; then
  28. echo >&2 "This board uses a prior stage to provide the device tree."
  29. echo >&2 "Please enable CONFIG_OF_BOARD to ensure that it works correctly."
  30. if grep -q "${sys_config}" "${allowlist}"; then
  31. exit 0
  32. fi
  33. exit 3
  34. fi
  35. fi