target_config_check.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. fail() {
  10. local message="$1"
  11. if [ $ret -eq 0 ]; then
  12. ret=1
  13. echo "Configuration failed:" >&2
  14. fi
  15. echo " * $message" >&2
  16. }
  17. check_config() {
  18. grep -q "$1" lede/.config
  19. }
  20. check_package() {
  21. local package="$1"
  22. local value="$2"
  23. if ! check_config "^CONFIG_PACKAGE_${package}=${value}"; then
  24. fail "unable to enable package '${package}'"
  25. fi
  26. }
  27. . scripts/target_config.inc.sh
  28. config() {
  29. local config="$1"
  30. if ! check_config "^${config}\$"; then
  31. fail "unable to set '${config}'"
  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. fail "unable to enable device '${profile}'"
  43. fi
  44. for package in $(site_packages "$output"); do
  45. [ "${package:0:1}" = '-' ] || check_package "$package"
  46. done
  47. }
  48. factory_image() {
  49. output="$1"
  50. want_device "${output}" || return 0
  51. }
  52. sysupgrade_image() {
  53. output="$1"
  54. want_device "${output}" || return 0
  55. }
  56. packages() {
  57. if [ "${output}" ]; then
  58. want_device "${output}" || return 0
  59. for package in "$@"; do
  60. [ "${package:0:1}" = '-' ] || check_package "$package"
  61. done
  62. else
  63. for package in "$@"; do
  64. [ "${package:0:1}" = '-' ] || check_package "$package" 'y'
  65. done
  66. fi
  67. }
  68. . targets/generic
  69. packages $packages
  70. . targets/"$target"
  71. check_devices
  72. exit $ret