diff options
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/scripts/functions b/scripts/functions index 2261b8d0..f09df54b 100644 --- a/scripts/functions +++ b/scripts/functions @@ -842,7 +842,7 @@ CT_GetGit() { local url="${3}" local _out_cset="${4}" - local ref=$(echo "${cset_or_ref}" | sed -n 's/^ref=\(.*\)/\1/p') + local ref=$(echo "${cset_or_ref}" | ${sed} -n 's/^ref=\(.*\)/\1/p') if [ -n "$ref" ]; then local matches=$(git ls-remote --exit-code "$url" --refs "${ref}") local result=$? @@ -1428,3 +1428,51 @@ CT_DoLoadState(){ exec >>"${tmp_log_file}" rm -f "${state_dir}/tail.log" } + +# This function sets a kconfig option to a specific value in a .config file +# Usage: CT_KconfigSetOption <option> <value> <file> +CT_KconfigSetOption() { + option="$1" + value="$2" + file="$3" + + ${grep} -E -q "^${option}=.*" "${file}" && \ + ${sed} -i -r -e "s;^${option}=.*$;${option}=${value};" "${file}" || \ + ${grep} -E -q "^# ${option} is not set$" "${file}" && \ + ${sed} -i -r -e "s;^# ${option} is not set$;${option}=${value};" "${file}" || \ + echo "${option}=${value}" >> "${file}" +} + +# This function enables a kconfig option to '=y' in a .config file +# Usage: CT_KconfigEnableOption <option> <file> +CT_KconfigEnableOption() { + option="$1" + file="$2" + + CT_KconfigSetOption "${option}" "y" "${file}" +} + +# This function disables a kconfig option in a .config file +# Usage: CT_KconfigDisableOption <option> <file> +CT_KconfigDisableOption() { + option="${1}" + file="${2}" + + ${grep} -E -q "^# ${option} is not set$" "${file}" || \ + ${grep} -E -q "^${option}=.*$" "${file}" && \ + ${sed} -i -r -e "s;^${option}=.*$;# ${option} is not set;" "${file}" || \ + echo "# ${option} is not set" >> "${file}" +} + +# This function deletes a kconfig option in a .config file, no matter if it +# is set or commented out. +# Usage: CT_KconfigDeleteOption <option> <file> +CT_KconfigDeleteOption() { + option="${1}" + file="${2}" + + ${grep} -E -q "^# ${option} is not set$" "${file}" && \ + ${sed} -i -r -e "/^# ${option} is not set$/d" "${file}" || \ + ${grep} -E -q "^${option}=.*$" "${file}" && \ + ${sed} -i -r -e "/^${option}=.*$/d" "${file}" || true +} |