include-raw-hc2vpp-integration-prebuild.sh revision e0033529
1#!/bin/bash
2
3set -ex
4# Download the latest VPP java API package
5VERSION="RELEASE"
6VERSION=`./jvpp-version`
7
8# Figure out what system we are running on
9if [[ -f /etc/lsb-release ]];then
10    . /etc/lsb-release
11elif [[ -f /etc/redhat-release ]];then
12    sudo yum install -y redhat-lsb
13    DISTRIB_ID=`lsb_release -si`
14    DISTRIB_RELEASE=`lsb_release -sr`
15    DISTRIB_CODENAME=`lsb_release -sc`
16    DISTRIB_DESCRIPTION=`lsb_release -sd`
17fi
18echo "----- OS INFO -----"
19echo DISTRIB_ID: ${DISTRIB_ID}
20echo DISTRIB_RELEASE: ${DISTRIB_RELEASE}
21echo DISTRIB_CODENAME: ${DISTRIB_CODENAME}
22echo DISTRIB_DESCRIPTION: ${DISTRIB_DESCRIPTION}
23
24echo "----- DOWNLOADING PACKAGES -----"
25if ! [[ -z ${REPO_NAME} ]]; then
26    REPO_URL="https://packagecloud.io/fdio/${STREAM}"
27    echo "REPO_URL: ${REPO_URL}"
28    if [[ "$DISTRIB_ID" == "Ubuntu" ]]; then
29        if [[ -f /etc/apt/sources.list.d/99fd.io.list ]];then
30            echo "Deleting: /etc/apt/sources.list.d/99fd.io.list"
31            sudo rm /etc/apt/sources.list.d/99fd.io.list
32        fi
33        curl -s https://packagecloud.io/install/repositories/fdio/${STREAM}/script.deb.sh | sudo bash
34        if [[ "${VERSION}" != 'RELEASE' ]]; then
35            # download specific version if set
36            echo VERSION: ${VERSION}
37            apt-get download vpp-api-java=${VERSION} || true
38        else
39            # download latest version for specified stream
40            apt-get download vpp-api-java || true
41        fi
42
43    elif [[ "$DISTRIB_ID" == "CentOS" ]]; then
44        if [[ -f /etc/yum.repos.d/fdio-master.repo ]]; then
45            echo "Deleting: /etc/yum.repos.d/fdio-master.repo"
46            sudo rm /etc/yum.repos.d/fdio-master.repo
47        fi
48        curl -s https://packagecloud.io/install/repositories/fdio/${STREAM}/script.rpm.sh | sudo bash
49        if [[ "${VERSION}" != 'RELEASE' ]]; then
50            # download specific version if set
51            echo VERSION: ${VERSION}
52            sudo yum -y install --downloadonly --downloaddir=./ vpp-api-java-${VERSION} || true
53        else
54            # download latest version for specified stream
55            sudo yum -y install --downloadonly --downloaddir=./ vpp-api-java || true
56        fi
57    fi
58fi
59
60# install vpp-api-java, this extracts jvpp .jar files into usr/share/java
61if [[ "${OS}" == "centos7" ]]; then
62    sudo rpm --nodeps --install vpp-api-java*
63else
64    sudo dpkg --ignore-depends=vpp,vpp-plugin-core --install vpp-api-java*
65fi
66sudo rm vpp-api-java*
67
68# install jvpp jars into maven repo, so that maven picks them up when building hc2vpp
69version=`./jvpp/version`
70
71current_dir=`pwd`
72cd /usr/share/java
73
74for item in jvpp*.jar; do
75    # Example filename: jvpp-registry-17.01-20161206.125556-1.jar
76    # ArtifactId = jvpp-registry
77    # Version = 17.01
78    basefile=$(basename -s .jar "$item")
79    artifactId=$(echo "$basefile" | cut -d '-' -f 1-2)
80    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
81done
82
83cd ${current_dir}
84