132 lines
4.1 KiB
Bash
Executable File
132 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Add here any the actions which are required before plugin build
|
|
# like packages building, packages downloading from mirrors and so on.
|
|
# The script should return 0 if there were no errors.
|
|
set -eux
|
|
|
|
# Where we can find odl karaf distribution tarball
|
|
# can be http(s) url or absolute path
|
|
ODL_TARBALL_LOCATION=${ODL_TARBALL_LOCATION:-https://nexus.opendaylight.org/content/repositories/staging/org/opendaylight/integration/distribution-karaf/0.4.0-Beryllium-RC1/distribution-karaf-0.4.0-Beryllium-RC1.tar.gz}
|
|
JAVA8_URL=${JAVA8_URL:-https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa/+files/openjdk-8-jre-headless_8u72-b15-1~trusty1_amd64.deb}
|
|
|
|
#Verion number used in deb/rpm package
|
|
ODL_VERSION_NUMBER=${ODL_VERSION_NUMBER:-0.4.0}
|
|
ODL_DESCRIPTION="OpenDaylight SDN Controller"
|
|
TMP_NAME="karaf-odl.tar.gz"
|
|
|
|
#Networking odl
|
|
NETWORKING_ODL_REPO=${NETWORKING_ODL_REPO:-https://github.com/openstack/networking-odl.git}
|
|
NETWORKING_ODL_BRANCH=${NETWORKING_ODL_BRANCH:-stable/liberty}
|
|
|
|
#Opnfv-quagga-packaging
|
|
OPNFV_QUAGGE_PACKAGING_REPO=${OPNFV_QUAGGE_PACKAGING_REPO:-https://github.com/nikolas-hermanns/opnfv-quagga-packaging}
|
|
OPNFV_QUAGGE_PACKAGING_BRANCH=stable/brahmaputra
|
|
|
|
# For which systems odl package should be build
|
|
BUILD_FOR=${BUILD_FOR:-ubuntu}
|
|
|
|
DIR="$(dirname `readlink -f $0`)"
|
|
TMP_DIR="${DIR}/tmp"
|
|
MODULES="${DIR}/deployment_scripts/puppet/modules"
|
|
|
|
# If true openjdk-8 will be used
|
|
USE_JAVA8=${USE_JAVA8:-false}
|
|
if [ "$USE_JAVA8" = true ]
|
|
then
|
|
JAVA_VERSION="openjdk-8-jre-headless"
|
|
else
|
|
JAVA_VERSION="openjdk-7-jre-headless"
|
|
fi
|
|
|
|
function cleanup {
|
|
rm -rf "${TMP_DIR}"
|
|
sed -i -e "s/java-8-openjdk-amd64/java-7-openjdk-amd64/" "${DIR}/odl_package/ubuntu/opendaylight"
|
|
}
|
|
|
|
function download {
|
|
wget "$1" -qO $2
|
|
}
|
|
|
|
function unpack {
|
|
mkdir "${TMP_DIR}/${2}"
|
|
tar xzf $1 --strip-components=1 -C "${TMP_DIR}/${2}"
|
|
}
|
|
|
|
function add_opnfv_quagga {
|
|
path=$1
|
|
pushd ${TMP_DIR}
|
|
git clone $OPNFV_QUAGGE_PACKAGING_REPO opnfv-quagga
|
|
pushd opnfv-quagga
|
|
git checkout $OPNFV_QUAGGE_PACKAGING_BRANCH
|
|
if [ ! -e debian_package/*.deb ];then
|
|
sudo apt-get -y install `cat requirements.txt`
|
|
make
|
|
fi
|
|
cp debian_package/* $path
|
|
popd
|
|
popd
|
|
|
|
}
|
|
|
|
# Download packages required by ODL.
|
|
function download_dependencies {
|
|
if [ "$USE_JAVA8" = true ]
|
|
then
|
|
wget -N "$JAVA8_URL"
|
|
fi
|
|
}
|
|
|
|
function build_pkg {
|
|
case $1 in
|
|
centos)
|
|
pushd "${DIR}/repositories/${1}/"
|
|
fpm --force -s dir -t rpm --version "${ODL_VERSION_NUMBER}" --description "${ODL_DESCRIPTION}" --prefix /opt/opendaylight --rpm-init "${DIR}/odl_package/${1}/opendaylight" --after-install "${DIR}/odl_package/${1}/opendaylight-post" --name opendaylight -d "java-1.7.0-openjdk" -C "${TMP_DIR}/opendaylight_src"
|
|
download_dependencies ${1}
|
|
popd
|
|
;;
|
|
ubuntu)
|
|
pushd "${DIR}/repositories/${1}/"
|
|
fpm --force -s dir -t deb -m 'mskalski@mirantis.com' --version "${ODL_VERSION_NUMBER}" --description "${ODL_DESCRIPTION}" --prefix /opt/opendaylight --deb-upstart "${DIR}/odl_package/${1}/opendaylight" --after-install "${DIR}/odl_package/${1}/opendaylight-post" --name opendaylight -d "${JAVA_VERSION}" -C "${TMP_DIR}/opendaylight_src"
|
|
fpm --force -s python -t deb -m 'mskalski@mirantis.com' --python-install-lib /usr/lib/python2.7/dist-packages ${TMP_DIR}/networking_odl/setup.py
|
|
download_dependencies ${1}
|
|
popd
|
|
add_opnfv_quagga "${DIR}/repositories/${1}/"
|
|
;;
|
|
*) echo "Not supported system"; exit 1;;
|
|
esac
|
|
}
|
|
|
|
command -v fpm >/dev/null 2>&1 || { echo >&2 "fpm ruby gem required but it's not installed. Aborting."; exit 1; }
|
|
|
|
cleanup
|
|
|
|
if [ "$USE_JAVA8" = true ]
|
|
then
|
|
sed -i -e "s/java-7-openjdk-amd64/java-8-openjdk-amd64/" "${DIR}/odl_package/ubuntu/opendaylight"
|
|
fi
|
|
|
|
mkdir -p "${TMP_DIR}"
|
|
|
|
pushd $TMP_DIR
|
|
|
|
if [[ "$ODL_TARBALL_LOCATION" =~ ^http.* ]]
|
|
then
|
|
download $ODL_TARBALL_LOCATION $TMP_NAME
|
|
unpack $TMP_NAME 'opendaylight_src'
|
|
else
|
|
unpack $ODL_TARBALL_LOCATION 'opendaylight_src'
|
|
fi
|
|
|
|
git clone $NETWORKING_ODL_REPO networking_odl
|
|
pushd networking_odl
|
|
git checkout $NETWORKING_ODL_BRANCH
|
|
popd
|
|
|
|
for system in $BUILD_FOR
|
|
do
|
|
build_pkg $system
|
|
done
|
|
|
|
cleanup
|