From eb10374b68ace1f82a21fc5183c6048d598bf83f Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Thu, 23 Jan 2020 12:16:06 +0100 Subject: [PATCH] Move realpath implementation tools/ci/activate Change-Id: Ie1523acbe5b30be90ec21bf825ac54ce809db454 --- tools/ci/activate | 31 ++++++++++++++++++++++++++---- tools/ci/{realpath => realpath.py} | 0 2 files changed, 27 insertions(+), 4 deletions(-) rename tools/ci/{realpath => realpath.py} (100%) diff --git a/tools/ci/activate b/tools/ci/activate index aa4c39152..8b35dde79 100644 --- a/tools/ci/activate +++ b/tools/ci/activate @@ -1,10 +1,33 @@ -function tools_dir { + +function get_ci_tools_dir { local tools_dir=$(dirname "${BASH_SOURCE[0]}") - PATH=${CI_TOOLS_ORIGINAL_PATH:-${PATH}} "${tools_dir}/realpath" "${tools_dir}" + realpath "${tools_dir}" } -export CI_TOOLS_DIR=${CI_TOOLS_DIR:-$(tools_dir)} + +function realpath { + ${REALPATH} "$@" +} + + +function get_realpath { + ( + export PATH=${CI_TOOLS_ORIGINAL_PATH:-${PATH}} + local tools_dir=$(dirname "${BASH_SOURCE[0]}") + local python=$(which python3 || which python2 || wich python) + if [ -x "${python}" ] && "${python}" --version > /dev/null; then + local script="${tools_dir}/realpath.py" + local script=$("${python}" "${script}" "${script}") + echo "${python}" "${script}" + else + which realpath + fi + ) +} + + +export REALPATH=${REALPATH:-$(get_realpath)} +export CI_TOOLS_DIR=${CI_TOOLS_DIR:-$(get_ci_tools_dir)} export CI_TOOLS_ORIGINAL_PATH=${CI_TOOLS_ORIGINAL_PATH:-${PATH}} export PATH=${CI_TOOLS_DIR}:${PATH} - export PYTHONWARNINGS=${PYTHONWARNINGS:-ignore} diff --git a/tools/ci/realpath b/tools/ci/realpath.py similarity index 100% rename from tools/ci/realpath rename to tools/ci/realpath.py