CSIT-544 HC Test: adapt package download script to changes in hc2vpp
[csit.git] / resources / tools / download_hc_build_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 -ex
17
18 trap 'rm -f *.deb.md5; exit' EXIT
19 trap 'rm -f *.deb.md5;rm -f *.deb; exit' ERR
20 STREAM=$1
21 OS=$2
22
23 # Download the latest VPP and VPP plugin .deb packages
24 URL="https://nexus.fd.io/service/local/artifact/maven/content"
25 VER="RELEASE"
26 VPP_GROUP="io.fd.vpp"
27 NSH_GROUP="io.fd.nsh_sfc"
28 VPP_ARTIFACTS="vpp vpp-dbg vpp-dev vpp-dpdk-dev vpp-dpdk-dkms vpp-lib vpp-plugins vpp-api-java"
29 NSH_ARTIFACTS="vpp-nsh-plugin"
30
31 if [ "${OS}" == "ubuntu1404" ]; then
32     OS="ubuntu.trusty.main"
33     PACKAGE="deb deb.md5"
34     CLASS="deb"
35 elif [ "${OS}" == "ubuntu1604" ]; then
36     OS="ubuntu.xenial.main"
37     PACKAGE="deb deb.md5"
38     CLASS="deb"
39 elif [ "${OS}" == "centos7" ]; then
40     OS="centos7"
41     PACKAGE="rpm rpm.md5"
42     CLASS="rpm"
43 fi
44
45 REPO="fd.io.${STREAM}.${OS}"
46
47 for ART in ${VPP_ARTIFACTS}; do
48     for PAC in ${PACKAGE}; do
49         curl "${URL}?r=${REPO}&g=${VPP_GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
50     done
51 done
52
53 for ART in ${NSH_ARTIFACTS}; do
54     for PAC in ${PACKAGE}; do
55         curl "${URL}?r=${REPO}&g=${NSH_GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit
56     done
57 done
58
59 for FILE in *.deb; do
60     echo " "${FILE} >> ${FILE}.md5
61 done
62
63 for MD5FILE in *.md5; do
64     md5sum -c ${MD5FILE} || exit
65 done
66
67 # installing vpp-api-java places jvpp jars into /usr/share/java
68 sudo dpkg -i *.deb
69
70 # install jvpp jars into maven repo, so that maven picks them up when building hc2vpp
71 version=`./jvpp-version`
72
73 current_dir=`pwd`
74 cd /usr/share/java
75
76 for item in jvpp*.jar; do
77     # Example filename: jvpp-registry-17.01-20161206.125556-1.jar
78     # ArtifactId = jvpp-registry
79     # Version = 17.01
80     basefile=$(basename -s .jar "$item")
81     artifactId=$(echo "$basefile" | cut -d '-' -f 1-2)
82     mvn install:install-file -Dfile=${item} -DgroupId=io.fd.vpp -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
83 done
84
85 cd current_dir