summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions36
1 files changed, 16 insertions, 20 deletions
diff --git a/scripts/functions b/scripts/functions
index f075b62..eaa1a2b 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -4,10 +4,6 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-# NOTE: The functions in this file may be used before the tools override
-# directory is created (or in the scripts that don't create the tools override
-# directory at all). Therefore, use the variables exported by paths.sh.
-
CT_LoadConfig() {
local o
@@ -53,7 +49,7 @@ CT_LoadConfig() {
fi
# Double eval: first eval substitutes option name, second eval unescapes quotes
# and whitespace.
- for o in `set | ${sed_r} -n 's/^(CT_[A-Za-z0-9_]*_ARRAY)=.*/\1/p'`; do
+ for o in `set | ${sed} -rn 's/^(CT_[A-Za-z0-9_]*_ARRAY)=.*/\1/p'`; do
eval "eval $o=(\"\$$o\")"
done
}
@@ -495,7 +491,7 @@ CT_Which() {
# to the highest entire second
# Usage: CT_DoDate <fmt>
CT_DoDate() {
- date "$1" | ${sed_r} -e 's/%?N$/000000000/;'
+ date "$1" |${sed} -r -e 's/%?N$/000000000/;'
}
CT_STEP_COUNT=1
@@ -518,7 +514,7 @@ CT_DoStep() {
CT_EndStep() {
local stop=$(CT_DoDate +%s%N)
local duration=$(printf "%032d" $((stop-${CT_STEP_START[${CT_STEP_COUNT}]})) \
- | ${sed_r} -e 's/([[:digit:]]{2})[[:digit:]]{7}$/\.\1/; s/^0+//; s/^\./0\./;'
+ |${sed} -r -e 's/([[:digit:]]{2})[[:digit:]]{7}$/\.\1/; s/^0+//; s/^\./0\./;'
)
local elapsed=$(printf "%02d:%02d" $((SECONDS/60)) $((SECONDS%60)))
local level="${CT_STEP_LEVEL[${CT_STEP_COUNT}]}"
@@ -1006,7 +1002,7 @@ CT_GetGit() {
local url="${3}"
local _out_cset="${4}"
- local ref=$(echo "${cset_or_ref}" | ${sed_r} -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=$?
@@ -1186,7 +1182,7 @@ CT_ExtractGit() {
if [ -z "${ref}" ]; then
ref_type=head
ref=$(git rev-list -n1 HEAD)
- elif git tag |${grep} -E "^${ref}$" >/dev/null 2>&1; then
+ elif git tag |{grep} -E "^${ref}$" >/dev/null 2>&1; then
ref_type=tag
elif git branch -a --no-color |${grep} -E "^. ${ref}$" >/dev/null 2>&1; then
ref_type=branch
@@ -1429,7 +1425,7 @@ CT_DoBuildTargetTuple() {
# Sanity checks
__sed_alias=""
if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
- __sed_alias=$(echo "${CT_TARGET}" | ${sed_r} -e "${CT_TARGET_ALIAS_SED_EXPR}")
+ __sed_alias=$(echo "${CT_TARGET}" |${sed} -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
fi
case ":${CT_TARGET_VENDOR}:${CT_TARGET_ALIAS}:${__sed_alias}:" in
:*" "*:*:*:) CT_Abort "Don't use spaces in the vendor string, it breaks things.";;
@@ -1502,7 +1498,7 @@ CT_DoTarballIfExists() {
CT_DoLog DEBUG " Saving '${dir}'"
{ tar c -C "${dir}" -v -f - "${extra_tar_opts[@]}" . \
|"${compress[@]}" >"${tarball}.tar${tar_ext}" ;
- } 2>&1 | ${sed_r} -e 's/^/ /;' |CT_DoLog STATE
+ } 2>&1 |${sed} -r -e 's/^/ /;' |CT_DoLog STATE
else
CT_DoLog STATE " Not saving '${dir}': does not exist"
fi
@@ -1529,7 +1525,7 @@ CT_DoExtractTarballIfExists() {
CT_DoExecLog DEBUG mkdir -p "${dir}"
{ "${uncompress[@]}" "${tarball}.tar${tar_ext}" \
|tar x -C "${dir}" -v -f - "${extra_tar_opts[@]}" ;
- } 2>&1 | ${sed_r} -e 's/^/ /;' |CT_DoLog STATE
+ } 2>&1 |${sed} -r -e 's/^/ /;' |CT_DoLog STATE
else
CT_DoLog STATE " Not restoring '${dir}': does not exist"
fi
@@ -1557,7 +1553,7 @@ CT_DoSaveState() {
$0~/^[^ ]+ \(\)/ { _p = 0; }
_p == 1
$0 == "}" { _p = 1; }
- ' | ${sed_r} -e '/^BASH_(ARGC|ARGV|LINENO|SOURCE|VERSINFO)=/d;
+ ' |${sed} -r -e '/^BASH_(ARGC|ARGV|LINENO|SOURCE|VERSINFO)=/d;
/^(UID|EUID)=/d;
/^(FUNCNAME|GROUPS|PPID|SHELLOPTS)=/d;' >"${state_dir}/env.sh"
@@ -1618,9 +1614,9 @@ CT_KconfigSetOption() {
local file="$3"
${grep} -E -q "^${option}=.*" "${file}" && \
- ${sed_r} -i -e "s;^${option}=.*$;${option}=${value};" "${file}" || \
+ ${sed} -i -r -e "s;^${option}=.*$;${option}=${value};" "${file}" || \
${grep} -E -q "^# ${option} is not set$" "${file}" && \
- ${sed_r} -i -e "s;^# ${option} is not set$;${option}=${value};" "${file}" || \
+ ${sed} -i -r -e "s;^# ${option} is not set$;${option}=${value};" "${file}" || \
echo "${option}=${value}" >> "${file}"
}
@@ -1641,7 +1637,7 @@ CT_KconfigDisableOption() {
${grep} -E -q "^# ${option} is not set$" "${file}" || \
${grep} -E -q "^${option}=.*$" "${file}" && \
- ${sed_r} -i -e "s;^${option}=.*$;# ${option} is not set;" "${file}" || \
+ ${sed} -i -r -e "s;^${option}=.*$;# ${option} is not set;" "${file}" || \
echo "# ${option} is not set" >> "${file}"
}
@@ -1653,9 +1649,9 @@ CT_KconfigDeleteOption() {
local file="${2}"
${grep} -E -q "^# ${option} is not set$" "${file}" && \
- ${sed_r} -i -e "/^# ${option} is not set$/d" "${file}" || \
+ ${sed} -i -r -e "/^# ${option} is not set$/d" "${file}" || \
${grep} -E -q "^${option}=.*$" "${file}" && \
- ${sed_r} -i -e "/^${option}=.*$/d" "${file}" || true
+ ${sed} -i -r -e "/^${option}=.*$/d" "${file}" || true
}
# Multilib iterator. The caller should be in a directory where the directories
@@ -1724,7 +1720,7 @@ CT_IterateMultilibs() {
# We do supply original multi_os_dir for consumers that need to look inside
# GCC's directories (e.g. to locate the libraries), under the name of
# multi_os_dir_gcc.
- multi_flags=$( echo "${multilib#*;}" | ${sed_r} -e 's/@/ -/g;' )
+ multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' )
multi_dir="${multilib%%;*}"
multi_os_dir=$( "${CT_TARGET}-${CT_CC}" -print-multi-os-directory ${multi_flags} )
multi_root=$( "${CT_TARGET}-${CT_CC}" -print-sysroot ${multi_flags} )
@@ -1744,7 +1740,7 @@ CT_IterateMultilibs() {
# the architecture-specific functions.
multi_index=1
for multilib in "${multilibs[@]}"; do
- multi_flags=$( echo "${multilib#*;}" | ${sed_r} -e 's/@/ -/g;' )
+ multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' )
multi_dir="${multilib%%;*}"
multi_os_dir=$( "${CT_TARGET}-${CT_CC}" -print-multi-os-directory ${multi_flags} )
multi_os_dir_gcc="${multi_os_dir}"