250 lines
7.9 KiB
Bash
Executable File
250 lines
7.9 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
|
|
CACHE=${CACHE:-false}
|
|
RENEW=${RENEW:-false}
|
|
DIR="$(dirname `readlink -f $0`)"
|
|
|
|
if [ "$CACHE" == true ];then
|
|
export cache_dir=$DIR/.cache/;
|
|
if [ -e $cache_dir ] && [[ "$RENEW" == false ]];then
|
|
export OPNFV_QUAGGE_PACKAGING_REPO=$cache_dir/opnfv-quagga/;
|
|
export NETWORKING_ODL_REPO=$cache_dir/networking_odl/;
|
|
export ODL_TARBALL_LOCATION=$cache_dir/karaf-odl.tar.gz;
|
|
fi
|
|
fi
|
|
# 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/public/org/opendaylight/integration/distribution-karaf/0.4.3-Beryllium-SR3/distribution-karaf-0.4.3-Beryllium-SR3.tar.gz}
|
|
ODL_BORON_TARBALL_LOCATION=${ODL_BORON_TARBALL_LOCATION:-false}
|
|
|
|
#ODL openflowjava NSH subtype patch related
|
|
# The patch's TAG should mach with ODL release being patched
|
|
# Normally it is release/beryllium-sr1 for ditribution-karaf-0.4.1-Beryllium-SR1.tar.gz
|
|
# release/beryllium-sr2 for ditribution-karaf-0.4.2-Beryllium-SR2.tar.gz
|
|
# stable/beryllium for ditribution-karaf-0.4.x-SNAPSHOT.tar.gz
|
|
# The patch should be explicitly enabled, since its build time is 1 hour and only applies
|
|
# while the openvswitch in fuel-plugin-ovs is not compatible with the actual openflow
|
|
# implementation of OpenDayLight. There is a possibility to build the patch separately
|
|
# and put into folder odl_package/nsh-pritesh-patch. Remember checking the file's naming
|
|
# in this case. If the plugin encounters the supplied jarball it wont build itself but
|
|
# will try using the supplied one.
|
|
ENA_NSH_SUB_PATCH=${ENA_NSH_SUB_PATCH:-false}
|
|
REPO=${REPO:-'openflowplugin'}
|
|
ODLTAG=${ODLTAG:-'release/beryllium-sr2'}
|
|
JARBALL=${JARBALL:-'openflowjava-extension-nicira'}
|
|
bdart=''
|
|
|
|
#Verion number used in deb/rpm package
|
|
ODL_VERSION_NUMBER=${ODL_VERSION_NUMBER:-0.4.3}
|
|
ODL_BORON_VERSION_NUMBER=${ODL_BORON_VERSION_NUMBER:-0.5.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/mitaka}
|
|
|
|
#Opnfv-quagga-packaging
|
|
OPNFV_QUAGGE_PACKAGING_REPO=${OPNFV_QUAGGE_PACKAGING_REPO:-https://github.com/nikolas-hermanns/opnfv-quagga-packaging}
|
|
OPNFV_QUAGGE_PACKAGING_BRANCH=stable/colorado
|
|
|
|
# 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"
|
|
|
|
#Remove temporary files
|
|
CLEANUP=${CLEANUP:-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 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/ ];then
|
|
sudo apt-get -y install `cat requirements.txt`
|
|
make -j6
|
|
fi
|
|
cp debian_package/* $path
|
|
popd
|
|
popd
|
|
|
|
}
|
|
|
|
#
|
|
#ODL patch related
|
|
function putbldenv() {
|
|
cat >env.sh <<EOF
|
|
#!bin/bash
|
|
REPO=${REPO}
|
|
ODLTAG=${ODLTAG}
|
|
EOF
|
|
}
|
|
|
|
function compute_ver() {
|
|
local ret=''
|
|
local rel=''
|
|
local amm=''
|
|
|
|
local tag=$(echo $1 | cut -d '/' -f 2)
|
|
if [ "$tag" != "${tag/-/}" ]; then
|
|
rel=$(echo $tag | cut -d '-' -f 1 | sed 's/.*/\u&/')
|
|
amm=$(echo $tag | cut -d '-' -f 2 | tr '[:lower:]' '[:upper:]')
|
|
ret="${rel}-${amm}"
|
|
else
|
|
rel=$(echo $tag | sed 's/.*/\u&/')
|
|
ret="${rel}"
|
|
fi
|
|
echo $ret
|
|
}
|
|
|
|
function build_jarball() {
|
|
local reporoot="/root/${REPO}"
|
|
local niciart="extension/${JARBALL}/target"
|
|
local artexp="odl_package/nsh-pritesh-patch"
|
|
local bld=''
|
|
local ver=''
|
|
|
|
case $1 in
|
|
ubuntu)
|
|
pushd ${DIR}/ofjavansh
|
|
putbldenv
|
|
wget -N https://raw.githubusercontent.com/opendaylight/odlparent/stable/beryllium/settings.xml
|
|
sudo docker build -t ofjavansh .
|
|
container_id=$(sudo docker run -d ofjavansh)
|
|
bld=$(echo $ODLTAG | cut -d '/' -f 1)
|
|
if [ "$bld" == "release" ] ; then
|
|
ver=$(compute_ver $ODLTAG)
|
|
else
|
|
ver='SNAPSHOT'
|
|
fi
|
|
mkdir -p ${DIR}/d
|
|
sudo docker cp $container_id:${reporoot}/${niciart}/. ${DIR}/d
|
|
pushd ${DIR}/d
|
|
bdart=$(echo ${JARBALL}-[0-9].[0-9].[0-9]-${ver}.jar)
|
|
cp $bdart ${DIR}/${artexp}/
|
|
popd
|
|
sudo rm -rf ${DIR}/d
|
|
popd
|
|
;;
|
|
*)
|
|
echo "Not supported system"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function patch_odl {
|
|
local artexp="odl_package/nsh-pritesh-patch"
|
|
local TARBASE="opendaylight_src/system/org/opendaylight/openflowplugin/openflowjava-extension-nicira"
|
|
local SRC="${DIR}/${artexp}/${bdart}"
|
|
echo "patching..."
|
|
TARGET=$(echo ${TMP_DIR}/${TARBASE}/*/${bdart})
|
|
cp $SRC $TARGET
|
|
}
|
|
|
|
function patch_networking_odl_deb {
|
|
if grep -q "neutron-lib>=0.1.0" $1
|
|
then
|
|
sed -i -e "s/neutron-lib>=0.1.0/neutron-lib>=0.0.1/" $1
|
|
fi
|
|
}
|
|
|
|
function get_karaf {
|
|
if [[ "$1" =~ ^http.* ]]
|
|
then
|
|
download $1 $2
|
|
unpack $2 $3
|
|
else
|
|
unpack $1 $3
|
|
fi
|
|
}
|
|
|
|
function build_pkg {
|
|
# clean up
|
|
rm -rf ${DIR}/repositories/${1}/*
|
|
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"
|
|
popd
|
|
;;
|
|
ubuntu)
|
|
pushd "${DIR}/repositories/${1}/"
|
|
fpm --architecture all --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-8-jre-headless -C "${TMP_DIR}/opendaylight_src"
|
|
if [ "$ODL_BORON_TARBALL_LOCATION" != false ] ; then
|
|
fpm --architecture all --force -s dir -t deb -m 'mskalski@mirantis.com' --version "${ODL_BORON_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-boron -d openjdk-8-jre-headless -C "${TMP_DIR}/opendaylight_boron_src"
|
|
fi
|
|
patch_networking_odl_deb ${TMP_DIR}/networking_odl/requirements.txt
|
|
fpm --architecture all --force -s python -t deb -m 'mskalski@mirantis.com' --python-install-lib /usr/lib/python2.7/dist-packages ${TMP_DIR}/networking_odl/setup.py
|
|
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
|
|
|
|
mkdir -p "${TMP_DIR}"
|
|
|
|
pushd $TMP_DIR
|
|
|
|
get_karaf $ODL_TARBALL_LOCATION "karaf-odl.tar.gz" "opendaylight_src"
|
|
|
|
if [ "$ODL_BORON_TARBALL_LOCATION" != false ] ; then
|
|
get_karaf $ODL_BORON_TARBALL_LOCATION "karaf-boron-odl.tar.gz" "opendaylight_boron_src"
|
|
fi
|
|
|
|
if [ "$ENA_NSH_SUB_PATCH" = true ] ; then
|
|
jarpatch=$(echo ${DIR}/odl_package/nsh-pritesh-patch/${JARBALL}-*.jar)
|
|
if [ ! -f "$jarpatch" ] ; then
|
|
build_jarball $BUILD_FOR
|
|
fi
|
|
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
|
|
|
|
if [ "$CACHE" == true ];then
|
|
if [ ! -e $cache_dir ] || [[ "$RENEW" == true ]];then
|
|
rm -rf $cache_dir
|
|
mkdir -p $cache_dir
|
|
cp -r ${DIR}/tmp/* $cache_dir/
|
|
fi
|
|
fi
|
|
|
|
if [ "$CLEANUP" != false ];then
|
|
cleanup
|
|
fi
|