configcheck.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Usage: configcheck.sh .config .config-template
  5. #
  6. # Non-empty output if errors detected.
  7. #
  8. # Copyright (C) IBM Corporation, 2011
  9. #
  10. # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
  11. T="`mktemp -d ${TMPDIR-/tmp}/configcheck.sh.XXXXXX`"
  12. trap 'rm -rf $T' 0
  13. # function test_kconfig_enabled ( Kconfig-var=val )
  14. function test_kconfig_enabled () {
  15. if ! grep -q "^$1$" $T/.config
  16. then
  17. echo :$1: improperly set
  18. return 1
  19. fi
  20. return 0
  21. }
  22. # function test_kconfig_disabled ( Kconfig-var )
  23. function test_kconfig_disabled () {
  24. if grep -q "^$1=n$" $T/.config
  25. then
  26. return 0
  27. fi
  28. if grep -q "^$1=" $T/.config
  29. then
  30. echo :$1=n: improperly set
  31. return 1
  32. fi
  33. return 0
  34. }
  35. sed -e 's/"//g' < $1 > $T/.config
  36. sed -e 's/^#CHECK#//' < $2 > $T/ConfigFragment
  37. grep '^CONFIG_.*=n$' $T/ConfigFragment |
  38. sed -e 's/^/test_kconfig_disabled /' -e 's/=n$//' > $T/kconfig-n.sh
  39. . $T/kconfig-n.sh
  40. grep -v '^CONFIG_.*=n$' $T/ConfigFragment | grep '^CONFIG_' |
  41. sed -e 's/^/test_kconfig_enabled /' > $T/kconfig-not-n.sh
  42. . $T/kconfig-not-n.sh