|
7 | 7 | ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner |
8 | 8 | BRANCH_NAME=master |
9 | 9 | CLIENT_NAME=python-openstackclient |
10 | | -requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?) |
| 10 | +GIT_BASE=${GIT_BASE:-https://git.openstack.org/} |
| 11 | + |
| 12 | +install_project() { |
| 13 | + local project=$1 |
| 14 | + local module_name=$2 |
| 15 | + local branch=${3:-$BRANCH_NAME} |
| 16 | + |
| 17 | + set +e |
| 18 | + project_installed=$(echo "import $module_name" | python 2>/dev/null ; echo $?) |
| 19 | + set -e |
| 20 | + |
| 21 | + if [ $project_installed -eq 0 ]; then |
| 22 | + echo "ALREADY INSTALLED" |
| 23 | + echo "$project already installed; using existing package" |
| 24 | + elif [ -x "$ZUUL_CLONER" ]; then |
| 25 | + echo "ZUUL CLONER" |
| 26 | + # Make this relative to current working directory so that |
| 27 | + # git clean can remove it. We cannot remove the directory directly |
| 28 | + # since it is referenced after $install_cmd -e |
| 29 | + PROJECT_DIR=$VIRTUAL_ENV/src |
| 30 | + mkdir -p $PROJECT_DIR |
| 31 | + pushd $PROJECT_DIR |
| 32 | + $ZUUL_CLONER --cache-dir \ |
| 33 | + /opt/git \ |
| 34 | + --branch $branch \ |
| 35 | + http://git.openstack.org \ |
| 36 | + openstack/$project |
| 37 | + cd openstack/$project |
| 38 | + $install_cmd -e . |
| 39 | + popd |
| 40 | + else |
| 41 | + echo "PIP HARDCODE" |
| 42 | + local GIT_REPO="$GIT_BASE/openstack/$project" |
| 43 | + SRC_DIR="$VIRTUAL_ENV/src/openstack/$project" |
| 44 | + git clone --depth 1 --branch $branch $GIT_REPO $SRC_DIR |
| 45 | + $install_cmd -U -e $SRC_DIR |
| 46 | + fi |
| 47 | +} |
11 | 48 |
|
12 | 49 | set -e |
| 50 | +set -x |
13 | 51 |
|
14 | 52 | CONSTRAINTS_FILE=$1 |
15 | 53 | shift |
16 | 54 |
|
17 | 55 | install_cmd="pip install" |
18 | | -mydir=$(mktemp -dt "$CLIENT_NAME-tox_install-XXXXXXX") |
19 | | -trap "rm -rf $mydir" EXIT |
20 | | -localfile=$mydir/upper-constraints.txt |
| 56 | +# NOTE(amotoki): Place this in the tox enviroment's log dir so it will get |
| 57 | +# published to logs.openstack.org for easy debugging. |
| 58 | +localfile="$VIRTUAL_ENV/log/upper-constraints.txt" |
21 | 59 | if [[ $CONSTRAINTS_FILE != http* ]]; then |
22 | 60 | CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE |
23 | 61 | fi |
24 | 62 | curl $CONSTRAINTS_FILE -k -o $localfile |
25 | 63 | install_cmd="$install_cmd -c$localfile" |
26 | 64 |
|
27 | | -if [ $requirements_installed -eq 0 ]; then |
28 | | - echo "ALREADY INSTALLED" > /tmp/tox_install.txt |
29 | | - echo "Requirements already installed; using existing package" |
30 | | -elif [ -x "$ZUUL_CLONER" ]; then |
31 | | - echo "ZUUL CLONER" > /tmp/tox_install.txt |
32 | | - pushd $mydir |
33 | | - $ZUUL_CLONER --cache-dir \ |
34 | | - /opt/git \ |
35 | | - --branch $BRANCH_NAME \ |
36 | | - git://git.openstack.org \ |
37 | | - openstack/requirements |
38 | | - cd openstack/requirements |
39 | | - $install_cmd -e . |
40 | | - popd |
41 | | -else |
42 | | - echo "PIP HARDCODE" > /tmp/tox_install.txt |
43 | | - if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then |
44 | | - REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements" |
45 | | - fi |
46 | | - $install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION} |
47 | | -fi |
| 65 | +install_project requirements openstack_requirements |
48 | 66 |
|
49 | 67 | # This is the main purpose of the script: Allow local installation of |
50 | 68 | # the current repo. It is listed in constraints file and thus any |
51 | 69 | # install will be constrained and we need to unconstrain it. |
52 | 70 | edit-constraints $localfile -- $CLIENT_NAME "-e file://$PWD#egg=$CLIENT_NAME" |
53 | 71 |
|
| 72 | +# NOTE(amotoki): In feature/osc4 branch we install osc-lib feature/osc4 branch, |
| 73 | +# we install the git version of ocs-lib explicitly |
| 74 | +# and specify it in upper-constraints.txt |
| 75 | +edit-constraints $localfile -- osc-lib "-e file://$VIRTUAL_ENV/src/openstack/osc-lib#egg=osc-lib" |
| 76 | +install_project osc-lib osc_lib feature/osc4 |
| 77 | + |
54 | 78 | $install_cmd -U $* |
55 | 79 | exit $? |
0 commit comments