Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 3 | # Copyright 2017-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 17 | BASEDIR=$(pwd) |
Matteo Scandolo | 0e852b9 | 2018-04-03 14:33:06 -0700 | [diff] [blame] | 18 | REQUIREMENTS=$BASEDIR/containers/xos/pip_requested.txt |
Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 19 | VENVDIR=venv-xos |
| 20 | |
| 21 | echo $BASEDIR |
| 22 | echo $REQUIREMENTS |
| 23 | echo $VENVDIR |
| 24 | |
| 25 | # create venv if it's not yet there |
| 26 | if [ ! -d "$BASEDIR/$VENVDIR" ]; then |
Matteo Scandolo | 9b849eb | 2017-09-14 13:44:33 -0700 | [diff] [blame] | 27 | echo "Setting up virtualenv for XOS" |
| 28 | virtualenv -q $BASEDIR/$VENVDIR --no-site-packages |
| 29 | pip install --upgrade pip |
| 30 | echo "Virtualenv created." |
Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 31 | fi |
| 32 | |
| 33 | # activate the virtual env |
| 34 | if [ ! $VIRTUAL_ENV ]; then |
Matteo Scandolo | 9b849eb | 2017-09-14 13:44:33 -0700 | [diff] [blame] | 35 | source $BASEDIR/$VENVDIR/bin/activate |
| 36 | echo "Virtualenv activated." |
Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 37 | fi |
| 38 | |
| 39 | # install pip requirements |
Matteo Scandolo | 5687972 | 2017-05-17 21:39:54 -0700 | [diff] [blame] | 40 | if \ |
| 41 | pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" && \ |
| 42 | pip install -r $REQUIREMENTS && \ |
Matteo Scandolo | 4a99b2c | 2017-06-22 10:31:44 -0700 | [diff] [blame] | 43 | cd $BASEDIR/lib/xos-config; python setup.py install && \ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 44 | |
Matteo Scandolo | 4a99b2c | 2017-06-22 10:31:44 -0700 | [diff] [blame] | 45 | #install xos-client |
| 46 | cp -R $BASEDIR/containers/xos/tmp.chameleon $BASEDIR/xos/xos_client/xosapi/chameleon && \ |
| 47 | cd $BASEDIR/xos/xos_client/xosapi/chameleon/protos; VOLTHA_BASE=anything make && \ |
| 48 | cd $BASEDIR/xos/xos_client; python setup.py install && \ |
| 49 | chmod 777 $BASEDIR/venv-xos/lib/python2.7/site-packages/xosapi/chameleon/protoc_plugins/gw_gen.py && \ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 50 | chmod 777 $BASEDIR/venv-xos/lib/python2.7/site-packages/xosapi/chameleon/protoc_plugins/swagger_gen.py && \ |
Matteo Scandolo | 0e852b9 | 2018-04-03 14:33:06 -0700 | [diff] [blame] | 51 | |
| 52 | #install xos-genx |
| 53 | cd $BASEDIR/lib/xos-genx; python setup.py install && \ |
| 54 | |
| 55 | #install xos-util |
| 56 | cd $BASEDIR/lib/xos-util; python setup.py install |
Matteo Scandolo | 9b849eb | 2017-09-14 13:44:33 -0700 | [diff] [blame] | 57 | then |
| 58 | echo "Requirements installed." |
| 59 | echo "Virtualenv ready" |
| 60 | else |
| 61 | echo "An error occurred" |
Matteo Scandolo | 297eb26 | 2017-05-15 17:00:53 -0700 | [diff] [blame] | 62 | fi |
Matteo Scandolo | 5687972 | 2017-05-17 21:39:54 -0700 | [diff] [blame] | 63 | cd $BASEDIR |