target_config.sh 1.3 KB

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