target_config.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$LEDE_TARGET" ] || exit 1
  4. output=
  5. profile=
  6. default_packages=
  7. profile_packages=
  8. LEDE_CONFIG_TARGET="${LEDE_TARGET//-/_}"
  9. emit() {
  10. [ "${output}" ] || return 0
  11. want_device "${output}" || return 0
  12. profile_packages="${profile_packages} $(site_packages "$output")"
  13. for package in $profile_packages; do
  14. [ "${package:0:1}" = '-' ] || echo "CONFIG_PACKAGE_${package}=m"
  15. done
  16. echo "CONFIG_TARGET_DEVICE_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=y"
  17. echo "CONFIG_TARGET_DEVICE_PACKAGES_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=\"${profile_packages}\""
  18. }
  19. . scripts/target_config.inc.sh
  20. config() {
  21. echo "$1"
  22. }
  23. device() {
  24. emit
  25. output="$1"
  26. profile="$3"
  27. if [ -z "$profile" ]; then
  28. profile="$2"
  29. fi
  30. profile_packages="${default_packages}"
  31. }
  32. packages() {
  33. if [ "${output}" ]; then
  34. profile_packages="${profile_packages} $@"
  35. else
  36. default_packages="${default_packages} $@"
  37. for package in "$@"; do
  38. if [ "${package:0:1}" = '-' ]; then
  39. echo "CONFIG_PACKAGE_${package:1}=m"
  40. else
  41. echo "CONFIG_PACKAGE_${package}=y"
  42. fi
  43. done
  44. fi
  45. }
  46. # The sort will not only remove duplicate entries,
  47. # but also magically make =y entries override =m ones
  48. (. targets/"$1"; emit) | sort -u