Docs deploy via Terraform
[ci-management.git] / jjb / scripts / setup_jvpp_dev_env.sh
1 #!/bin/bash
2
3 # Copyright (c) 2020 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "---> jjb/scripts/setup_jvpp_dev_env.sh"
17
18 set -e -o pipefail
19
20 # Figure out what system we are running on
21 if [[ -f /etc/lsb-release ]];then
22     . /etc/lsb-release
23 elif [[ -f /etc/redhat-release ]];then
24     sudo yum install -y redhat-lsb
25     DISTRIB_ID=`lsb_release -si`
26     DISTRIB_RELEASE=`lsb_release -sr`
27     DISTRIB_CODENAME=`lsb_release -sc`
28     DISTRIB_DESCRIPTION=`lsb_release -sd`
29 fi
30 echo DISTRIB_ID: $DISTRIB_ID
31 echo DISTRIB_RELEASE: $DISTRIB_RELEASE
32 echo DISTRIB_CODENAME: $DISTRIB_CODENAME
33 echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
34
35 JVPP_VERSION=`./version`
36 echo JVPP_VERSION: $JVPP_VERSION
37 # Check release version
38 if [[ "$JVPP_VERSION" == *"-release" ]]; then
39     # at the time when JVPP release packages are being build,
40     # vpp release packages are already promoted to release repository.
41     # Therefore we need to switch to release repository in order to download
42     # correct vpp package versions
43     STREAM="release"
44 fi
45
46 function setup {
47     if ! [[ -z ${REPO_NAME} ]]; then
48         echo "INSTALLING VPP-DPKG-DEV from apt/yum repo"
49         REPO_URL="https://packagecloud.io/fdio/${STREAM}"
50         echo "REPO_URL: ${REPO_URL}"
51         # Setup by installing vpp-dev and vpp-lib
52         if [[ "$DISTRIB_ID" == "Ubuntu" ]]; then
53             if ! [[ "${STREAM}" == "master" ]]; then
54                 echo "stable branch - clearing all fdio repos. new one will be installed."
55                 sudo rm  -f /etc/apt/sources.list.d/fdio_*.list
56             fi
57             if [[ -f /etc/apt/sources.list.d/99fd.io.list ]];then
58                 echo "Deleting: /etc/apt/sources.list.d/99fd.io.list"
59                 sudo rm /etc/apt/sources.list.d/99fd.io.list
60             fi
61             curl -s https://packagecloud.io/install/repositories/fdio/${STREAM}/script.deb.sh | sudo bash
62             sudo apt-get -y --force-yes install libvppinfra libvppinfra-dev vpp vpp-dev vpp-plugin-core || true
63         elif [[ "$DISTRIB_ID" == "CentOS" ]]; then
64             if [[ -f /etc/yum.repos.d/fdio-master.repo ]]; then
65                 echo "Deleting: /etc/yum.repos.d/fdio-master.repo"
66                 sudo rm /etc/yum.repos.d/fdio-master.repo
67             fi
68             curl -s https://packagecloud.io/install/repositories/fdio/${STREAM}/script.rpm.sh | sudo bash
69             sudo yum -y install vpp-devel vpp-lib vpp-plugins || true
70         fi
71     fi
72 }
73
74 setup