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 # - REPO_URL - FD.io Packagecloud repository.
26 os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || {
27 die "Get OS release failed."
30 repo_url_path="./VPP_REPO_URL"
31 if [ -e "${repo_url_path}" ]; then
32 REPO_URL="$(<${repo_url_path})" || {
33 die "Read repo URL from ${repo_url_path} failed."
36 REPO_URL="https://packagecloud.io/install/repositories/fdio/master"
39 if [ "${os_id}" == "ubuntu" ]; then
40 download_ubuntu_artifacts || die
41 elif [ "${os_id}" == "centos" ]; then
42 download_centos_artifacts || die
43 elif [ "${os_id}" == "opensuse" ]; then
44 download_opensuse_artifacts || die
46 die "${os_id} is not yet supported."
50 function download_ubuntu_artifacts () {
51 # Get and/or install Ubuntu VPP artifacts from packagecloud.io.
54 # - REPO_URL - FD.io Packagecloud repository.
55 # - VPP_VERSION - VPP version.
56 # - DKMS_VERSION - DKMS version.
57 # - INSTALL - If install packages or download only. Default: download
61 curl -s "${REPO_URL}"/script.deb.sh | sudo bash || {
62 die "Packagecloud FD.io repo fetch failed."
64 # If version is set we will add suffix.
66 vpp=(vpp vpp-dbg vpp-dev vpp-lib vpp-plugins)
67 if [ -z "${VPP_VERSION-}" ]; then
68 artifacts+=(${vpp[@]})
70 artifacts+=(${vpp[@]/%/=${VPP_VERSION-}})
73 if [ -z "${DKMS_VERSION-}" ]; then
74 artifacts+=(${dkms[@]})
76 artifacts+=(${dkms[@]/%/=${DKMS_VERSION-}})
79 if [ "${INSTALL:-false}" = true ]; then
80 sudo apt-get -y install "${artifacts[@]}" || {
81 die "Install VPP artifacts failed."
84 apt-get -y download "${artifacts[@]}" || {
85 die "Download VPP artifacts failed."
90 function download_centos_artifacts () {
91 # Get and/or install CentOS VPP artifacts from packagecloud.io.
94 # - REPO_URL - FD.io Packagecloud repository.
95 # - VPP_VERSION - VPP version.
96 # - INSTALL - If install packages or download only. Default: download
100 curl -s "${REPO_URL}"/script.rpm.sh | sudo bash || {
101 die "Packagecloud FD.io repo fetch failed."
103 # If version is set we will add suffix.
105 vpp=(vpp vpp-selinux-policy vpp-devel vpp-lib vpp-plugins)
106 if [ -z "${VPP_VERSION-}" ]; then
107 artifacts+=(${vpp[@]})
109 artifacts+=(${vpp[@]/%/-${VPP_VERSION-}})
112 if [ "${INSTALL:-false}" = true ]; then
113 sudo yum -y install "${artifacts[@]}" || {
114 die "Install VPP artifact failed."
117 sudo yum -y install --downloadonly --downloaddir=. "${artifacts[@]}" || {
118 die "Download VPP artifacts failed."
123 function download_opensuse_artifacts () {
124 # Get and/or install OpenSuSE VPP artifacts from packagecloud.io.
127 # - REPO_URL - FD.io Packagecloud repository.
128 # - VPP_VERSION - VPP version.
129 # - INSTALL - If install packages or download only. Default: download
133 curl -s "${REPO_URL}"/script.rpm.sh | sudo bash || {
134 die "Packagecloud FD.io repo fetch failed."
136 # If version is set we will add suffix.
138 vpp=(vpp vpp-devel vpp-lib vpp-plugins libvpp0)
139 if [ -z "${VPP_VERSION-}" ]; then
140 artifacts+=(${vpp[@]})
142 artifacts+=(${vpp[@]/%/-${VPP_VERSION-}})
145 if [ "${INSTALL:-false}" = true ]; then
146 sudo yum -y install "${artifacts[@]}" || {
147 die "Install VPP artifact failed."
150 sudo yum -y install --downloadonly --downloaddir=. "${artifacts[@]}" || {
151 die "Download VPP artifacts failed."