93df95e466417af8e90f267e05de991875f8ca32
4 # Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U.
5 # This file is part of openmano
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
12 # http://www.apache.org/licenses/LICENSE-2.0
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
22 # author: Alfonso Tierno
24 exit 0 # TODO py3 for the moment no openvim library is installed
26 # It uses following env, if not provided filling by default
27 [ -z "$GIT_OVIM_URL" ] && GIT_OVIM_URL
=https
://osm.etsi.org
/gerrit
/osm
/openvim.git
28 [ -z "$DEVELOP" ] && DEVELOP
=""
29 # folder where RO is installed
30 [ -z "$BASEFOLDER" ] && HERE
=$
(dirname $
(readlink
-f ${BASH_SOURCE[0]})) && BASEFOLDER
=$
(dirname $HERE)
31 [ -z "$SUDO_USER" ] && SUDO_USER
="$USER"
32 [ -z "$NO_PACKAGES" ] && NO_PACKAGES
=""
33 [ -z "$_DISTRO" ] && _DISTRO
="Ubuntu"
37 echo -e "usage: sudo -E $0 [OPTIONS]"
38 echo -e "Install last stable source code of lib-osm-openvim and the needed packages"
40 echo -e " -h --help: show this help"
41 echo -e " -b REFSPEC: install from source code using a specific branch (master, v2.0, ...) or tag"
42 echo -e " -b master (main branch)"
43 echo -e " -b v2.0 (v2.0 branch)"
44 echo -e " -b tags/v1.1.0 (a specific tag)"
46 echo -e " --develop: install last master version for developers"
47 echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This" \
48 "avoid wasting time if you are sure requires packages are present e.g. because of a previous installation"
50 while getopts ":b:h-:" o
; do
53 export COMMIT_ID
=${OPTARG}
59 [ "${OPTARG}" == "help" ] && usage
&& exit 0
60 [ "${OPTARG}" == "develop" ] && export DEVELOP
="y" && continue
61 [ "${OPTARG}" == "quiet" ] && export QUIET_MODE
=yes && export DEBIAN_FRONTEND
=noninteractive
&& continue
62 [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES
=yes && continue
63 echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
67 echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
71 echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
81 su
$SUDO_USER -c "git -C '${BASEFOLDER}' clone ${GIT_OVIM_URL} lib-openvim" ||
82 ! echo "Error cannot clone from '${GIT_OVIM_URL}'" >&2 ||
exit 1
83 if [[ -n $COMMIT_ID ]] ; then
84 echo -e "Installing lib-osm-openvim from refspec: $COMMIT_ID"
85 su
$SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout $COMMIT_ID" ||
86 ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OVIM_URL}'" >&2 ||
exit 1
87 elif [[ -z $DEVELOP ]]; then
88 LATEST_STABLE_TAG
=`git -C "${BASEFOLDER}/lib-openvim" tag -l "v[0-9]*" | sort -V | tail -n1`
89 echo -e "Installing lib-osm-openvim from refspec: tags/${LATEST_STABLE_TAG}"
90 su
$SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout tags/${LATEST_STABLE_TAG}" ||
91 ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OVIM_URL}'" >&2 ||
exit 1
93 echo -e "Installing lib-osm-openvim from refspec: master"
96 make -C "${BASEFOLDER}/lib-openvim" prepare_lite
97 export LANG
="en_US.UTF-8"
98 pip2
install -e "${BASEFOLDER}/lib-openvim/build" ||
! echo "ERROR installing lib-osm-openvim library!!!" >&2 ||