3 # Copyright (c) 2019 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_hc () {
20 # Download or install HC artifacts from packagecloud.io.
23 # - CSIT_DIR - Path to existing root of local CSIT git repository.
25 # - REPO_URL - FD.io Packagecloud repository.
26 # Functions conditionally called (see their documentation for side effects):
27 # - download_ubuntu_artifacts_hc
28 # - download_centos_artifacts_hc
32 os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || {
33 die "Get OS release failed."
36 repo_url_path="${CSIT_DIR}/VPP_REPO_URL"
37 if [ -e "${repo_url_path}" ]; then
38 REPO_URL="$(<${repo_url_path})" || {
39 die "Read repo URL from ${repo_url_path} failed."
42 REPO_URL="https://packagecloud.io/install/repositories/fdio/master"
45 if [ "${os_id}" == "ubuntu" ]; then
46 download_ubuntu_artifacts_hc || die
47 elif [ "${os_id}" == "centos" ]; then
48 download_centos_artifacts_hc || die
50 die "${os_id} is not yet supported."
54 function download_ubuntu_artifacts_hc () {
56 # Download or install Ubuntu HC artifacts from packagecloud.io.
59 # - REPO_URL - FD.io Packagecloud repository.
60 # - HC_VERSION - HC version.
61 # - INSTALL - Whether install packages (if set to "true") or download only.
66 curl -s "${REPO_URL}"/script.deb.sh | sudo bash || {
67 die "Packagecloud FD.io repo fetch failed."
69 # If version is set we will add suffix.
72 if [ -z "${HC_VERSION-}" ]; then
75 artifacts+=(${hc[@]/%/=${HC_VERSION-}})
78 if [[ "${INSTALL:-false}" == "true" ]]; then
79 sudo apt-get -y install "${artifacts[@]}" || {
80 die "Install HC artifacts failed."
83 apt-get -y download "${artifacts[@]}" || {
84 die "Download HC artifacts failed."
89 function download_centos_artifacts_hc () {
91 # Download or install CentOS HC artifacts from packagecloud.io.
94 # - REPO_URL - FD.io Packagecloud repository.
95 # - HC_VERSION - HC version.
96 # - INSTALL - Whether install packages (if set to "true") or download only.
101 curl -s "${REPO_URL}"/script.rpm.sh | sudo bash || {
102 die "Packagecloud FD.io repo fetch failed."
104 # If version is set we will add suffix.
107 if [ -z "${HC_VERSION-}" ]; then
108 artifacts+=(${hc[@]})
110 artifacts+=(${hc[@]/%/-${HC_VERSION-}})
113 if [[ "${INSTALL:-false}" == "true" ]]; then
114 sudo yum -y install "${artifacts[@]}" || {
115 die "Install HC artifact failed."
118 sudo yum -y install --downloadonly --downloaddir=. "${artifacts[@]}" || {
119 die "Download HC artifacts failed."