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
This commit is contained in:
parent
6a3275b47d
commit
aaab1d1b68
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user