Merge "read jvpp version from file in hc2vpp"
[ci-management.git] / jjb / hc2vpp / include-raw-hc2vpp-integration-prebuild.sh
1 #!/bin/bash
2
3 set -ex
4
5 # Download the latest VPP java API package
6 URL="https://nexus.fd.io/service/local/artifact/maven/content"
7 VERSION="RELEASE"
8 GROUP="io.fd.vpp"
9 ARTIFACTS="vpp-api-java"
10
11 if [ "${OS}" == "ubuntu1404" ]; then
12     OS_PART="ubuntu.trusty.main"
13     PACKAGE="deb deb.md5"
14     CLASS="deb"
15 elif [ "${OS}" == "ubuntu1604" ]; then
16     OS_PART="ubuntu.xenial.main"
17     PACKAGE="deb deb.md5"
18     CLASS="deb"
19 elif [ "${OS}" == "centos7" ]; then
20     OS_PART="centos7"
21     PACKAGE="rpm rpm.md5"
22     CLASS=""
23 fi
24
25 if [ "${STREAM}" == "master" ]; then
26     STREAM_PART="master"
27 else
28     STREAM_PART="stable.${STREAM}"
29 fi
30
31 REPO="fd.io.${STREAM_PART}.${OS_PART}"
32
33 for ART in ${ARTIFACTS}; do
34     for PAC in ${PACKAGE}; do
35         curl "${URL}?r=${REPO}&g=${GROUP}&a=${ART}&p=${PAC}&v=${VERSION}&c=${CLASS}" -O -J || exit
36     done
37 done
38
39 # verify downloaded package
40 if [ "${OS}" == "centos7" ]; then
41     FILES=*.rpm
42 else
43     FILES=*.deb
44 fi
45
46 for FILE in ${FILES}; do
47     echo " "${FILE} >> ${FILE}.md5
48 done
49 for MD5FILE in *.md5; do
50     md5sum -c ${MD5FILE} || exit
51     rm ${MD5FILE}
52 done
53
54 # install vpp-api-java, this extracts jvpp .jar files into usr/share/java
55 if [ "${OS}" == "centos7" ]; then
56     sudo rpm --nodeps --install vpp-api-java*
57 else
58     sudo dpkg --ignore-depends=vpp --install vpp-api-java*
59 fi
60 rm vpp-api-java*
61
62 # install jvpp jars into maven repo, so that maven picks them up when building hc2vpp
63 version=`./jvpp-version`
64
65 current_dir=`pwd`
66 cd /usr/share/java
67
68 for item in jvpp*.jar; do
69     # Example filename: jvpp-registry-17.01-20161206.125556-1.jar
70     # ArtifactId = jvpp-registry
71     # Version = 17.01
72     basefile=$(basename -s .jar "$item")
73     artifactId=$(echo "$basefile" | cut -d '-' -f 1-2)
74     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
75 done
76
77 cd ${current_dir}