target_config_check.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$LEDE_TARGET" ] || exit 1
  4. target="$1"
  5. packages=$2
  6. output=
  7. ret=0
  8. LEDE_CONFIG_TARGET="${LEDE_TARGET//-/_}"
  9. site_packages() {
  10. MAKEFLAGS= make PROFILE="$1" --no-print-directory -s -f - <<'END_MAKE'
  11. include $(GLUON_SITEDIR)/site.mk
  12. all:
  13. echo '$(GLUON_$(PROFILE)_SITE_PACKAGES)'
  14. END_MAKE
  15. }
  16. fail() {
  17. local message="$1"
  18. if [ $ret -eq 0 ]; then
  19. ret=1
  20. echo "Configuration failed:" >&2
  21. fi
  22. echo " * $message" >&2
  23. }
  24. check_config() {
  25. grep -q "$1" lede/.config
  26. }
  27. check_package() {
  28. local package="$1"
  29. local value="$2"
  30. if ! check_config "^CONFIG_PACKAGE_${package}=${value}"; then
  31. fail "unable to enable package '${package}'"
  32. fi
  33. }
  34. . scripts/common.inc.sh
  35. config() {
  36. local config="$1"
  37. if ! check_config "^${config}\$"; then
  38. fail "unable to set '${config}'"
  39. fi
  40. }
  41. device() {
  42. output="$1"
  43. want_device "${output}" || return 0
  44. local profile="$3"
  45. if [ -z "$profile" ]; then
  46. profile="$2"
  47. fi
  48. if ! check_config "CONFIG_TARGET_DEVICE_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=y"; then
  49. fail "unable to enable device '${profile}'"
  50. fi
  51. for package in $(site_packages "$output"); do
  52. [ "${package:0:1}" = '-' ] || check_package "$package"
  53. done
  54. }
  55. factory_image() {
  56. output="$1"
  57. want_device "${output}" || return 0
  58. }
  59. sysupgrade_image() {
  60. output="$1"
  61. want_device "${output}" || return 0
  62. }
  63. packages() {
  64. if [ "${output}" ]; then
  65. want_device "${output}" || return 0
  66. for package in "$@"; do
  67. [ "${package:0:1}" = '-' ] || check_package "$package"
  68. done
  69. else
  70. for package in "$@"; do
  71. [ "${package:0:1}" = '-' ] || check_package "$package" 'y'
  72. done
  73. fi
  74. }
  75. . targets/"$target"
  76. check_devices
  77. for package in $packages; do
  78. check_package "$package" 'y'
  79. done
  80. exit $ret