a9e9d5ee60
Change-Id: Ib816520d63a51ae37a9be8f2036131bd58ecd054
72 lines
1.6 KiB
Bash
Executable File
72 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
source $(dirname "$0")/activate
|
|
source $(dirname "$0")/tox
|
|
|
|
set -eu
|
|
|
|
IR_VIRTUAL_ENV=$(realpath "${IR_VIRTUAL_ENV:-.tox/infrared}")
|
|
IR_REPO="https://github.com/redhat-openstack/infrared.git"
|
|
IR_BRANCH=${IR_BRANCH:-master}
|
|
IR_SOURCE_DIR=$(realpath "${IR_SOURCE_DIR:-${IR_VIRTUAL_ENV}/infrared}")
|
|
IR_EXECUTABLE=${IR_VIRTUAL_ENV}/bin/infrared
|
|
export IR_HOME=$(realpath ${IR_HOME:-../.infrared/})
|
|
IR_TOBIKO_PLUGIN=$(realpath ${IR_TOBIKO_PLUGIN:-$(pwd)})
|
|
|
|
|
|
function ir {
|
|
ir_setup
|
|
"${IR_EXECUTABLE}" "$@"
|
|
}
|
|
|
|
|
|
function ir_setup {
|
|
if ! ir_activate; then
|
|
tox -e infrared --notest
|
|
ir_activate
|
|
fi
|
|
|
|
if ! [ -x "${IR_EXECUTABLE}" ]; then
|
|
git clone "${IR_REPO}" -b "${IR_BRANCH}" "${IR_SOURCE_DIR}"
|
|
local package_name
|
|
for package_name in pip setuptools "${IR_SOURCE_DIR}"; do
|
|
pip install --upgrade "${package_name}"
|
|
done
|
|
|
|
(
|
|
cd "${IR_SOURCE_DIR}"
|
|
"${IR_EXECUTABLE}" plugin list --available --versions || true
|
|
"${IR_EXECUTABLE}" plugin remove tobiko || true
|
|
"${IR_EXECUTABLE}" plugin add "${IR_TOBIKO_PLUGIN}"
|
|
)
|
|
fi
|
|
|
|
mkdir -p "${IR_HOME}"
|
|
}
|
|
|
|
|
|
function ir_activate {
|
|
local venv_script=${IR_VIRTUAL_ENV}/bin/activate
|
|
if ! [ -r "${venv_script}" ]; then
|
|
return 1
|
|
fi
|
|
|
|
if ! ir_is_active; then
|
|
# Activate only once
|
|
set +eu
|
|
source "${venv_script}"
|
|
set -eu
|
|
ir_is_active
|
|
fi
|
|
}
|
|
|
|
|
|
function ir_is_active {
|
|
[ "$(python_prefix)" == "${IR_VIRTUAL_ENV}" ]
|
|
}
|
|
|
|
|
|
if [ $(basename "$0") == ir ]; then
|
|
ir "$@"
|
|
fi
|