target_config_check.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. packages() {
  50. if [ "${output}" ]; then
  51. want_device "${output}" || return 0
  52. for package in "$@"; do
  53. [ "${package:0:1}" = '-' ] || check_package "$package"
  54. done
  55. else
  56. for package in "$@"; do
  57. [ "${package:0:1}" = '-' ] || check_package "$package" 'y'
  58. done
  59. fi
  60. }
  61. . targets/"$target"
  62. check_devices
  63. for package in $packages; do
  64. check_package "$package" 'y'
  65. done