3 # Copyright (c) 2018 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:
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 function download_artifacts () {
19 # Get and/or install VPP artifacts from packagecloud.io.
22 # - CSIT_DIR - Path to existing root of local CSIT git repository.
24 # - REPO_URL - FD.io Packagecloud repository.
28 os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || {
29 die "Get OS release failed."
32 repo_url_path="${CSIT_DIR}/VPP_REPO_URL"
33 if [ -e "${repo_url_path}" ]; then
34 REPO_URL="$(<${repo_url_path})" || {
35 die "Read repo URL from ${repo_url_path} failed."
38 REPO_URL="https://packagecloud.io/install/repositories/fdio/master"
41 if [ "${os_id}" == "ubuntu" ]; then
42 download_ubuntu_artifacts || die
43 elif [ "${os_id}" == "centos" ]; then
44 download_centos_artifacts || die
45 elif [ "${os_id}" == "opensuse" ]; then
46 download_opensuse_artifacts || die
48 die "${os_id} is not yet supported."
52 function download_ubuntu_artifacts () {
53 # Get and/or install Ubuntu VPP artifacts from packagecloud.io.
56 # - REPO_URL - FD.io Packagecloud repository.
57 # - VPP_VERSION - VPP version.
58 # - INSTALL - If install packages or download only. Default: download
62 curl -s "${REPO_URL}"/script.deb.sh | sudo bash || {
63 die "Packagecloud FD.io repo fetch failed."
65 # If version is set we will add suffix.
67 vpp=(vpp vpp-dbg vpp-dev vpp-api-python libvppinfra libvppinfra-dev
68 vpp-plugin-core vpp-plugin-dpdk)
69 if [ -z "${VPP_VERSION-}" ]; then
70 artifacts+=(${vpp[@]})
72 artifacts+=(${vpp[@]/%/=${VPP_VERSION-}})
75 if [ "${INSTALL:-false}" = true ]; then
76 sudo apt-get -y install "${artifacts[@]}" || {
77 die "Install VPP artifacts failed."
80 apt-get -y download "${artifacts[@]}" || {
81 die "Download VPP artifacts failed."
86 function download_centos_artifacts () {
87 # Get and/or install CentOS VPP artifacts from packagecloud.io.
90 # - REPO_URL - FD.io Packagecloud repository.
91 # - VPP_VERSION - VPP version.
92 # - INSTALL - If install packages or download only. Default: download
96 curl -s "${REPO_URL}"/script.rpm.sh | sudo bash || {
97 die "Packagecloud FD.io repo fetch failed."
99 # If version is set we will add suffix.
101 vpp=(vpp vpp-selinux-policy vpp-devel vpp-lib vpp-plugins vpp-api-python)
102 if [ -z "${VPP_VERSION-}" ]; then
103 artifacts+=(${vpp[@]})
105 artifacts+=(${vpp[@]/%/-${VPP_VERSION-}})
108 if [ "${INSTALL:-false}" = true ]; then
109 sudo yum -y install "${artifacts[@]}" || {
110 die "Install VPP artifact failed."
113 sudo yum -y install --downloadonly --downloaddir=. "${artifacts[@]}" || {
114 die "Download VPP artifacts failed."
119 function download_opensuse_artifacts () {
120 # Get and/or install OpenSuSE VPP artifacts from packagecloud.io.
123 # - REPO_URL - FD.io Packagecloud repository.
124 # - VPP_VERSION - VPP version.
125 # - INSTALL - If install packages or download only. Default: download
129 curl -s "${REPO_URL}"/script.rpm.sh | sudo bash || {
130 die "Packagecloud FD.io repo fetch failed."
132 # If version is set we will add suffix.
134 vpp=(vpp vpp-devel vpp-lib vpp-plugins libvpp0)
135 if [ -z "${VPP_VERSION-}" ]; then
136 artifacts+=(${vpp[@]})
138 artifacts+=(${vpp[@]/%/-${VPP_VERSION-}})
141 if [ "${INSTALL:-false}" = true ]; then
142 sudo yum -y install "${artifacts[@]}" || {
143 die "Install VPP artifact failed."
146 sudo yum -y install --downloadonly --downloaddir=. "${artifacts[@]}" || {
147 die "Download VPP artifacts failed."