target_config.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. try_config() {
  24. echo "$1"
  25. }
  26. device() {
  27. emit
  28. output="$1"
  29. profile="$3"
  30. if [ -z "$profile" ]; then
  31. profile="$2"
  32. fi
  33. profile_packages="${default_packages}"
  34. }
  35. packages() {
  36. if [ "${output}" ]; then
  37. profile_packages="${profile_packages} $@"
  38. else
  39. default_packages="${default_packages} $@"
  40. for package in "$@"; do
  41. if [ "${package:0:1}" = '-' ]; then
  42. echo "CONFIG_PACKAGE_${package:1}=m"
  43. else
  44. echo "CONFIG_PACKAGE_${package}=y"
  45. fi
  46. done
  47. fi
  48. }
  49. . targets/generic
  50. # The sort will not only remove duplicate entries,
  51. # but also magically make =y entries override =m ones
  52. (. targets/"$1"; emit) | sort -u