fuel-plugin-opendaylight/pre_build_hook

114 lines
3.7 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/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.3.2-Lithium-SR2/distribution-karaf-0.3.2-Lithium-SR2.tar.gz}
#Verion number used in deb/rpm package
ODL_VERSION_NUMBER=${ODL_VERSION_NUMBER:-0.3.2}
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/kilo}
# 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 java and it dependencies will be part of the plugin.
# Useful for offline deployments.
INCLUDE_DEPENDENCIES=${INCLUDE_DEPENDENCIES:-false}
# Patch ODL to use br-floating as external bridge
USE_FUEL_PATCH=${USE_FUEL_PATCH:-true}
function cleanup {
rm -rf "${TMP_DIR}"
}
function download {
wget "$1" -qO $2
}
function unpack {
mkdir "${TMP_DIR}/${2}"
tar xzf $1 --strip-components=1 -C "${TMP_DIR}/${2}"
}
function patch_odl {
cp "${DIR}/odl_package/odl_lithium_patch/openstack.net-virt-1.1.2-Lithium-SR2.jar" "${TMP_DIR}/opendaylight_src/system/org/opendaylight/ovsdb/openstack.net-virt/1.1.2-Lithium-SR2/openstack.net-virt-1.1.2-Lithium-SR2.jar"
}
# Download packages required by ODL.
# List generated with commands:
# yumdownloader --urls --resolve java-1.7.0-openjdk
# apt-get --print-uris --yes install openjdk-7-jre-headless | grep ^\' | cut -d\' -f2 >downloads.list
function download_dependencies {
if [ "$INCLUDE_DEPENDENCIES" = true ]
then
wget -N -i "${DIR}/odl_package/${1}/dependencies.txt"
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 "openjdk-7-jre-headless" -C "${TMP_DIR}/opendaylight_src"
fpm --force -s python -t deb -m 'mskalski@mirantis.com' --no-python-dependencies -d python-pbr -d python-babel -d python-neutron ${TMP_DIR}/networking_odl/setup.py
download_dependencies ${1}
popd
;;
*) 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
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
if [ "$USE_FUEL_PATCH" = true ]
then
patch_odl
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