aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorzengchen228 <zengchen228@gmail.com>2020-11-12 01:11:39 +0800
committerRadosław Piliszek <radoslaw.piliszek@gmail.com>2020-11-18 20:41:01 +0000
commitaaab1d1b68db0c737b63ae6bce3179df0487f23f (patch)
treed77871567fdd8a3f29cda3282e2b82eaca9e2a70 /tools
parent6a3275b47dfcce11c21deb5d70773039ac1256b2 (diff)
downloadkolla-ansible-aaab1d1b68db0c737b63ae6bce3179df0487f23f.tar.gz
kolla-ansible-aaab1d1b68db0c737b63ae6bce3179df0487f23f.zip
Fix kolla-ansible to work with pyenv-virtualenv
One of the pyenv-virtualenv-set-up aliases depends on a symlink. It seems pyenv runs the bash script from such a path and it fails because of a failing comparison (VIRTUAL_ENV not detected). The VIRTUAL_ENV is ensured to be fully resolved as well for safety. This requires readlink from GNU coreutils but all supported platforms have it by default. Extra comments included, as well as simplification of directory detection - readlink handles this (not that `bin` itself was ever a symlink...). Closes-Bug: #1903887 Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com> Change-Id: I2fe6eb13ce7be68d346b1b3b7036859f34c896c4
Diffstat (limited to 'tools')
-rwxr-xr-xtools/kolla-ansible8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 87cc7a440..dc30fa7c7 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -66,13 +66,16 @@ function check_environment_coherence {
function find_base_dir {
local dir_name
- dir_name=$(cd "$(dirname "$0")" &>/dev/null && pwd)
+ dir_name=$(dirname "$0")
+ # NOTE(yoctozepto): Fix the case where dir_name is a symlink and VIRTUAL_ENV might not be. This
+ # happens with pyenv-virtualenv, see https://bugs.launchpad.net/kolla-ansible/+bug/1903887
+ dir_name=$(readlink -e "$dir_name")
if [ -z "$SNAP" ]; then
if [[ ${dir_name} == "/usr/bin" ]]; then
BASEDIR=/usr/share/kolla-ansible
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
BASEDIR=/usr/local/share/kolla-ansible
- elif [[ -n ${VIRTUAL_ENV} ]] && [[ ${dir_name} == "${VIRTUAL_ENV}/bin" ]]; then
+ elif [[ -n ${VIRTUAL_ENV} ]] && [[ ${dir_name} == "$(readlink -e "${VIRTUAL_ENV}/bin")" ]]; then
if test -f ${VIRTUAL_ENV}/lib/python*/site-packages/kolla-ansible.egg-link; then
# Editable install.
BASEDIR="$(head -n1 ${VIRTUAL_ENV}/lib/python*/site-packages/kolla-ansible.egg-link)"
@@ -80,6 +83,7 @@ function find_base_dir {
BASEDIR="${VIRTUAL_ENV}/share/kolla-ansible"
fi
else
+ # Running from sources (repo).
BASEDIR="$(dirname ${dir_name})"
fi
else