Report: delete tmp dir
[csit.git] / resources / tools / scripts / download_hc_pkgs.sh
1 #!/bin/bash
2
3 # Copyright (c) 2017 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 set -x
17
18 STREAM=$1
19 OS=$2
20
21 URL="https://nexus.fd.io/service/local/artifact/maven/content"
22 VER="RELEASE"
23 GROUP="io.fd.vpp"
24 HC_GROUP="io.fd.hc2vpp"
25 HC_ARTIFACTS="honeycomb"
26 # TODO(CSIT-994): reenable NSH
27 # NSH_GROUP="io.fd.nsh_sfc"
28 # NSH_ARTIFACTS="vpp-nsh-plugin"
29
30 if [ "${OS}" == "ubuntu1404" ]; then
31     OS="ubuntu.trusty.main"
32     PACKAGE="deb deb.md5"
33     CLASS="deb"
34     VPP_ARTIFACTS="vpp vpp-dbg vpp-lib vpp-plugins"
35     DPDK_ARTIFACTS="vpp-dpdk-dkms"
36 elif [ "${OS}" == "ubuntu1604" ]; then
37     OS="ubuntu.xenial.main"
38     PACKAGE="deb deb.md5"
39     CLASS="deb"
40     VPP_ARTIFACTS="vpp vpp-dbg vpp-lib vpp-plugins"
41     DPDK_ARTIFACTS="vpp-dpdk-dkms"
42 elif [ "${OS}" == "centos7" ]; then
43     OS="centos7"
44     PACKAGE="rpm rpm.md5"
45     CLASS=""
46     VPP_ARTIFACTS="vpp vpp-debuginfo vpp-lib vpp-plugins"
47     DPDK_ARTIFACTS=""
48 fi
49
50 REPO="fd.io.${STREAM}.${OS}"
51
52 # download latest honeycomb, vpp-dpdk and nsh packages
53 for ART in ${HC_ARTIFACTS}; do
54     for PAC in ${PACKAGE}; do
55         curl "${URL}?r=${REPO}&g=${HC_GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
56     done
57 done
58
59 for ART in ${DPDK_ARTIFACTS}; do
60     for PAC in ${PACKAGE}; do
61         curl "${URL}?r=${REPO}&g=${GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
62     done
63 done
64
65 # TODO(CSIT-994): reenable NSH
66 # for ART in ${NSH_ARTIFACTS}; do
67 #     for PAC in ${PACKAGE}; do
68 #         curl "${URL}?r=${REPO}&g=${NSH_GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
69 #     done
70 # done
71
72 # determine VPP dependency
73 # use latest if honeycomb package does not depend on single VPP version, e.g. stable branches since HC2VPP-285
74 VER="RELEASE"
75 if [ "${OS}" == "centos7" ]; then
76     HC_VPP_VER=`rpm -qpR honeycomb*.rpm | grep -oP 'vpp = \K.+'`
77     if [ "${HC_VPP_VER}" != "" ]; then
78         VER=${HC_VPP_VER}.x86_64
79     fi
80 else
81     HC_VPP_VER=`dpkg -I honeycomb*.deb | grep -oP 'vpp \(= \K[^\)]+'`
82     if [ "${HC_VPP_VER}" != "" ]; then
83         VER=${HC_VPP_VER}_amd64
84     fi
85 fi
86
87 # download VPP packages
88 for ART in ${VPP_ARTIFACTS}; do
89     for PAC in ${PACKAGE}; do
90         curl "${URL}?r=${REPO}&g=${GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
91     done
92 done
93
94 # verify downloaded package
95 if [ "${OS}" == "centos7" ]; then
96     FILES=*.rpm
97 else
98     FILES=*.deb
99 fi
100
101 for FILE in ${FILES}; do
102     echo " "${FILE} >> ${FILE}.md5
103 done
104 for MD5FILE in *.md5; do
105     md5sum -c ${MD5FILE} || exit
106     rm ${MD5FILE}
107 done