|
0 |
#!/usr/bin/env bash
|
|
1 |
|
|
2 |
# [liujiong] This file is refer to tox_install.sh in neutron-lib.
|
|
3 |
# Library constraint file contains this library version pin that is in conflict
|
|
4 |
# with installing the library from source. We should replace the version pin in
|
|
5 |
# the constraints file before applying it for from-source installation.
|
|
6 |
|
|
7 |
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
|
|
8 |
BRANCH_NAME=master
|
|
9 |
LIB_NAME=castellan
|
|
10 |
requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?)
|
|
11 |
|
|
12 |
set -e
|
|
13 |
|
|
14 |
CONSTRAINTS_FILE=$1
|
|
15 |
shift
|
|
16 |
|
|
17 |
install_cmd="pip install"
|
|
18 |
mydir=$(mktemp -dt "$LIB_NAME-tox_install-XXXXXXX")
|
|
19 |
trap "rm -rf $mydir" EXIT
|
|
20 |
localfile=$mydir/upper-constraints.txt
|
|
21 |
if [[ $CONSTRAINTS_FILE != http* ]]; then
|
|
22 |
CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE
|
|
23 |
fi
|
|
24 |
curl $CONSTRAINTS_FILE -k -o $localfile
|
|
25 |
install_cmd="$install_cmd -c$localfile"
|
|
26 |
|
|
27 |
if [ $requirements_installed -eq 0 ]; then
|
|
28 |
echo "Requirements already installed; using existing package"
|
|
29 |
elif [ -x "$ZUUL_CLONER" ]; then
|
|
30 |
pushd $mydir
|
|
31 |
$ZUUL_CLONER --cache-dir \
|
|
32 |
/opt/git \
|
|
33 |
--branch $BRANCH_NAME \
|
|
34 |
git://git.openstack.org \
|
|
35 |
openstack/requirements
|
|
36 |
cd openstack/requirements
|
|
37 |
$install_cmd -e .
|
|
38 |
popd
|
|
39 |
else
|
|
40 |
if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then
|
|
41 |
REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements"
|
|
42 |
fi
|
|
43 |
$install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION}
|
|
44 |
fi
|
|
45 |
|
|
46 |
# This is the main purpose of the script: Allow local installation of
|
|
47 |
# the current repo. It is listed in constraints file and thus any
|
|
48 |
# install will be constrained and we need to unconstrain it.
|
|
49 |
edit-constraints $localfile -- $LIB_NAME "-e file://$PWD#egg=$LIB_NAME"
|
|
50 |
|
|
51 |
$install_cmd -U $*
|
|
52 |
exit $?
|