2017-01-18 16:21:43 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[ "$LEDE_TARGET" ] || exit 1
|
|
|
|
|
|
|
|
target="$1"
|
|
|
|
packages=$2
|
|
|
|
|
|
|
|
output=
|
|
|
|
|
2017-05-02 15:05:55 +00:00
|
|
|
ret=0
|
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
LEDE_CONFIG_TARGET="${LEDE_TARGET//-/_}"
|
|
|
|
|
|
|
|
|
2017-05-02 15:05:55 +00:00
|
|
|
fail() {
|
|
|
|
local message="$1"
|
|
|
|
|
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
ret=1
|
|
|
|
echo "Configuration failed:" >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " * $message" >&2
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
check_config() {
|
|
|
|
grep -q "$1" lede/.config
|
|
|
|
}
|
|
|
|
|
|
|
|
check_package() {
|
|
|
|
local package="$1"
|
|
|
|
local value="$2"
|
|
|
|
|
|
|
|
if ! check_config "^CONFIG_PACKAGE_${package}=${value}"; then
|
2017-05-02 15:05:55 +00:00
|
|
|
fail "unable to enable package '${package}'"
|
2017-01-18 16:21:43 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-15 21:23:02 +00:00
|
|
|
. scripts/target_config.inc.sh
|
2017-01-18 16:21:43 +00:00
|
|
|
|
|
|
|
config() {
|
|
|
|
local config="$1"
|
|
|
|
|
|
|
|
if ! check_config "^${config}\$"; then
|
2017-05-02 15:05:55 +00:00
|
|
|
fail "unable to set '${config}'"
|
2017-01-18 16:21:43 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
device() {
|
|
|
|
output="$1"
|
|
|
|
want_device "${output}" || return 0
|
|
|
|
|
|
|
|
local profile="$3"
|
|
|
|
if [ -z "$profile" ]; then
|
|
|
|
profile="$2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! check_config "CONFIG_TARGET_DEVICE_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=y"; then
|
2017-05-02 15:05:55 +00:00
|
|
|
fail "unable to enable device '${profile}'"
|
2017-01-18 16:21:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
for package in $(site_packages "$output"); do
|
|
|
|
[ "${package:0:1}" = '-' ] || check_package "$package"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-01-27 00:30:47 +00:00
|
|
|
factory_image() {
|
|
|
|
output="$1"
|
|
|
|
want_device "${output}" || return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
sysupgrade_image() {
|
|
|
|
output="$1"
|
|
|
|
want_device "${output}" || return 0
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
packages() {
|
|
|
|
if [ "${output}" ]; then
|
|
|
|
want_device "${output}" || return 0
|
|
|
|
|
|
|
|
for package in "$@"; do
|
|
|
|
[ "${package:0:1}" = '-' ] || check_package "$package"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
for package in "$@"; do
|
|
|
|
[ "${package:0:1}" = '-' ] || check_package "$package" 'y'
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-06 22:17:57 +00:00
|
|
|
. targets/generic
|
2017-01-18 16:21:43 +00:00
|
|
|
. targets/"$target"
|
|
|
|
check_devices
|
|
|
|
|
|
|
|
|
|
|
|
for package in $packages; do
|
|
|
|
check_package "$package" 'y'
|
|
|
|
done
|
2017-05-02 15:05:55 +00:00
|
|
|
|
|
|
|
exit $ret
|