Docs deploy via Terraform
[ci-management.git] / jjb / scripts / setup_vpp_dpdk_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_vpp_dpdk_dev_env.sh"
17
18 set -e -o pipefail
19
20 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
21 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
22
23 function setup {
24     if [ -n "$REPO_NAME" ] ; then
25         echo "Installing vpp-ext-deps..."
26         REPO_URL="https://packagecloud.io/fdio/${STREAM}"
27         echo "REPO_URL: $REPO_URL"
28         INSTALL_URL="https://packagecloud.io/install/repositories/fdio/${STREAM}"
29         echo "INSTALL_URL: $INSTALL_URL"
30         # Setup by installing vpp-dev and vpp-lib
31         if [ "${OS_ID,,}" == "ubuntu" ] || [ "${OS_ID,,}" == "debian" ] ; then
32             if [ "${STREAM}" != "master" ]; then
33                 echo "stream '${STREAM}' is not master: replacing packagecloud apt sources list with stream specific list"
34                 sudo apt-get -y remove vpp-ext-deps || true
35                 sudo rm -f /etc/apt/sources.list.d/fdio_master.list
36                 curl -s $INSTALL_URL/script.deb.sh | sudo bash
37             fi
38             sudo apt-get update -qq || true
39             local vpp_ext_deps_version="$(apt-cache show vpp-ext-deps | mawk '/Version/ {print $2}' | head -1)"
40             local vpp_ext_deps_arch="$(apt-cache show vpp-ext-deps | mawk '/Architecture/ {print $2}' | head -1)"
41             local vpp_ext_deps_pkg="/root/Downloads/vpp-ext-deps_${vpp_ext_deps_version}_${vpp_ext_deps_arch}.deb"
42             if [ -f "$vpp_ext_deps_pkg" ] ; then
43                 echo "Installing cached vpp-ext-deps pkg: $vpp_ext_deps_pkg"
44                 sudo dpkg -i $vpp_ext_deps_pkg
45             else
46                 echo "Installing vpp-ext-deps from packagecloud.io"
47                 local force_opts="--allow-downgrades --allow-remove-essential"
48                 force_opts="$force_opts --allow-change-held-packages"
49                 sudo apt-get -y $force_opts install vpp-ext-deps || true
50             fi
51             echo "Removing packagecloud.io repository references and running apt-get update"
52             sudo rm -f /etc/apt/sources.list.d/fdio_*.list
53             sudo apt-get update -qq || true
54         elif [ "${OS_ID,,}" == "centos" ] ; then
55             if [ "${STREAM}" != "master" ] ; then
56                 echo "stream '${STREAM}' is not master: replacing packagecloud repo list with stream specific list"
57                 sudo yum -y erase vpp-ext-deps || true
58                 sudo yum clean all || true
59                 sudo rm -f /etc/yum.repos.d/fdio_master.repo
60                 curl -s $INSTALL_URL/script.rpm.sh | sudo bash
61             fi
62             local vpp_ext_deps_version="$(yum -q list vpp-ext-deps 2> /dev/null | mawk '/vpp-ext-deps/{print $2}')"
63             local vpp_ext_deps_pkg="$(yum -q list vpp-ext-deps 2> /dev/null | mawk '/vpp-ext-deps/{print $1}')"
64             vpp_ext_deps_pkg="/root/Downloads/${vpp_ext_deps_pkg/./-${vpp_ext_deps_version}.}.rpm"
65             if [ -f "$vpp_ext_deps_pkg" ] ; then
66                 echo "Installing cached vpp-ext-deps pkg: $vpp_ext_deps_pkg"
67                 sudo yum -y localinstall $vpp_ext_deps_pkg || true
68             else
69                 echo "Installing vpp-ext-deps from packagecloud.io"
70                 sudo yum -y install vpp-ext-deps || true
71             fi
72         else
73             echo "ERROR: Unsupported OS '$OS_ID'!"
74         fi
75     else
76         echo "ERROR: REPO_NAME not found!"
77     fi
78 }
79
80 setup