target_config_check.sh 1.7 KB

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