From 31dc912057bb24e2077e62d8d0d72f9a35ba1daf Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 10 Sep 2013 13:50:53 +0200 Subject: [setup_target] Check config files for invalid variable names --- remote/setup_target | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'remote/setup_target') diff --git a/remote/setup_target b/remote/setup_target index b783729f..04af2158 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -74,6 +74,7 @@ read_config () { # sanity checks [ ! -e "${MODULE_CONFIG}" ] && perror "Config for '$MODULE' not found." + validate_config "$MODULE_CONFIG" # source the config file . "${MODULE_CONFIG}" || perror "Sourcing '${MODULE_CONFIG}' failed." # sanity checks - no distribution specific things in the global config @@ -85,13 +86,24 @@ read_config () { for FILE in $SYS_VERSIONS; do if [ -e "${MODULE_CONFIG}.${FILE}" ]; then # a specific tool.conf seems to exist, use it to override/extend certain vars - . "${MODULE_CONFIG}.${FILE}" || perror "Sourcing '${MODULE_CONFIG}.${PACKET_MANAGER}' failed." + validate_config "${MODULE_CONFIG}.${FILE}" + . "${MODULE_CONFIG}.${FILE}" || perror "Sourcing '${MODULE_CONFIG}.${FILE}' failed." pinfo "Sourced distribution specific ${MODULE_CONFIG}.${FILE}" break fi done } +validate_config () { + local INVALID=$(grep -h -E -o '^\s*\w+=' "$1" | grep -v -E '^\s*REQUIRED_') + [ -z "$INVALID" ] && return 0 + local i + for i in $INVALID; do + pwarning "Invalid variable $i" + done + perror "$1 contains invalid variables. All variables must start with REQUIRED_" +} + # # generic function to read the build script of the current $MODULE # -- cgit v1.2.3-55-g7522