Fix build errors.
[ovsnfv.git] / build / BuildAndTestOVS.sh
index ff2495c..57d2d2d 100755 (executable)
@@ -1,16 +1,24 @@
 #!/bin/bash
-##############################################################################
-# Copyright (c) 2016 Red Hat Inc. and others.
-# therbert@redhat.com
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
+
+# Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+
 set -e
 
 echo "==============================="
 echo executing $0 $@
+echo
 
 usage() {
     echo "$0 -a <kernel major> -d -g <OVS TAG> -h\
@@ -64,8 +72,26 @@ while getopts "a:dg:hi:p:tu:v" opt; do
     esac
 done
 
-if [ -z $TAG ]; then
-    TAG=master
+#
+# Default Config options
+#
+echo ===============================================
+echo Default Configuration Options.
+echo ===============================================
+echo option NOCHECK is set to $NOCHECK
+echo build DPDK option is set to $DPDK
+echo DPDK Patch URL is set to $DPDK_PATCH
+echo DPDK Version is set to $DPDK_VERSION
+echo Option for OVS Kernel Module is set to $KMOD
+echo ===============================================
+if [[ $NOCHECK =~ "yes" ]]; then
+    setnocheck="-c"
+fi
+if [[ $KMOD =~ "yes" ]]; then
+    setkmod="-k"
+fi
+if [[ $DPDK =~ "yes" ]]; then
+    setdpdk="-d"
 fi
 
 if [ -z $OVS_REPO_URL ]; then
@@ -81,29 +107,24 @@ else
     echo Will use default kernel in ovs test vm
 fi
 
-if [ -z ${WORKSPACE+1} ]; then
-    # We are not being run by Jenkins.
-    export WORKSPACE=$HOME/opnfv/ovsnfv
-    mkdir -p opnfv
-    cd opnfv
-    git clone https://git.opnfv.org/ovsnfv
+if [ -z $TAG ]; then
+    TAG=master
 fi
 
-export BUILD_BASE=$WORKSPACE/build
-
-
+if [ ! -z $DPDK ]; then
+    setbuilddpdk="-d"
+fi
 
-if [ ! -d $BUILD_BASE ]
-then
-    mkdir -p $BUILD_BASE
+if [ -z ${WORKSPACE+1} ]; then
+    # We are not being run by Jenkins.
+    export WORKSPACE=`pwd`
 fi
 
-if [ ! -f $BUILD_BASE/config ]; then
-    touch $BUILD_BASE/config
+if [ -z ${BUILD_BASE+1} ]; then
+    export BUILD_BASE=$WORKSPACE
 fi
 
-export PATH=$PATH:$WORKSPACE/ci:$BUILD_BASE
-source $BUILD_BASE/config
+export PATH=$PATH:$BUILD_BASE
 
 cd $BUILD_BASE
 export TOPDIR=$BUILD_BASE
@@ -120,26 +141,49 @@ mkdir -p $RPMDIR/RPMS
 mkdir -p $RPMDIR/SOURCES
 mkdir -p $RPMDIR/SPECS
 mkdir -p $RPMDIR/SRPMS
-
-
-if [ ! -z $TESTRPM ]; then
-    # Spawn VM to do the testing.
-    if [ ! -z $kernel_version ]; then
-        instack_ovs.sh -a $kernel_major -g $TAG -i $kernel_minor -p $OVS_PATCH -t -u $OVS_REPO_URL
-    else
-        instack_ovs.sh -g $TAG -p $OVS_PATCH -t -u $OVS_REPO_URL
-    fi
-else
-    # Run build locally.
-    build_ovs_rpm.sh -d -g -p $OVS_PATCH -u $OVS_REPO_URL
-    cp $HOME/rpmbuild/RPMS/* $TMP_RELEASE_DIR
+#
+# build dpdk rpm locally.
+#
+if [[ "$DPDK" =~ "yes" ]]; then
+    echo "==============================="
+    echo Build DPDK RPMs
+    echo
+    $BUILD_BASE/build_dpdk_rpm.sh -g $DPDK_VERSION
 fi
+#
+# Build locally and copy RPMS
+#
+echo "==============================="
+echo build OVS rpm locally
+echo
+    ./build_ovs_rpm.sh $setnocheck -g $TAG $setdpdk $setkmod -p $OVS_PATCH -u $OVS_REPO_URL
 
-echo "--------------------------------------------------"
-echo "Build OVS RPM from upstream git $OVS_REPO_URL version $TAG"
-if [ ! -z $OVS_PATCH ]; then
-    echo "Apply patches from: $OVS_PATCH"
-fi
+echo "==============================="
+echo copy rpms to release dir
+echo
+cp $RPMDIR/RPMS/x86_64/* $TMP_RELEASE_DIR
+rm $RPMDIR/RPMS/x86_64/*
+
+#
+# Build OVS without DPDK, apply patches and build kmod.
+#
+setkmod="-k"
+OVS_PATCH="yes"
+setdpdk=
+
+echo "==================================================="
+echo build OVS without DPDK, apply patches and build kmod.
 echo
+    ./build_ovs_rpm.sh $setnocheck -g $TAG $setdpdk $setkmod -p $OVS_PATCH -u $OVS_REPO_URL
 
+echo "==============================="
+echo copy rpms to release dir and add experimental tag
+echo
+cd $RPMDIR/RPMS/x86_64
+for i in `ls openvswitch*.rpm`
+do
+    echo copying $i to $TMP_RELEASE_DIR/EXPERIMENTAL-$i
+    cp $i $TMP_RELEASE_DIR/EXPERIMENTAL-$i
+    echo
+done
 exit 0