blob: b43f6fe3b6a551c75f90af407724cc191d22a35b [file] [log] [blame]
tiernoa7f744d2018-09-10 11:04:31 +02001#!/bin/bash
2
3##
4# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5# This file is part of openmano
6# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License. You may obtain
10# a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17# License for the specific language governing permissions and limitations
18# under the License.
19#
20##
21
22# author: Alfonso Tierno
23
24# It uses following env, if not provided filling by default
25[ -z "$GIT_OVIM_URL" ] && GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git
26[ -z "$DEVELOP" ] && DEVELOP=""
27# folder where RO is installed
28[ -z "$BASEFOLDER" ] && HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]})) && BASEFOLDER=$(dirname $HERE)
29[ -z "$SUDO_USER" ] && SUDO_USER="$USER"
30[ -z "$NO_PACKAGES" ] && NO_PACKAGES=""
31[ -z "$_DISTRO" ] && _DISTRO="Ubuntu"
32
33
34su $SUDO_USER -c "git -C '${BASEFOLDER}' clone ${GIT_OVIM_URL} lib-openvim" ||
35 ! echo "Error cannot clone from '${GIT_OVIM_URL}'" >&2 || exit 1
36if [[ -n $COMMIT_ID ]] ; then
37 echo -e "Installing lib-osm-openvim from refspec: $COMMIT_ID"
38 su $SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout $COMMIT_ID" ||
39 ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OVIM_URL}'" >&2 || exit 1
40elif [[ -z $DEVELOP ]]; then
41 LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/lib-openvim" tag -l "v[0-9]*" | sort -V | tail -n1`
42 echo -e "Installing lib-osm-openvim from refspec: tags/${LATEST_STABLE_TAG}"
43 su $SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout tags/${LATEST_STABLE_TAG}" ||
44 ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OVIM_URL}'" >&2 || exit 1
45else
46 echo -e "Installing lib-osm-openvim from refspec: master"
47fi
48
49make -C "${BASEFOLDER}/lib-openvim" prepare_lite
50export LANG="en_US.UTF-8"
51pip2 install -e "${BASEFOLDER}/lib-openvim/build"