5270f03633671ecf9297f40bad40dd732de68a33
[ovsnfv.git] / ci / buildovs.sh
1 #!/bin/bash
2
3 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
4 #
5 #    Licensed under the Apache License, Version 2.0 (the "License");
6 #    you may not use this file except in compliance with the License.
7 #    You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #    Unless required by applicable law or agreed to in writing, software
12 #    distributed under the License is distributed on an "AS IS" BASIS,
13 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #    See the License for the specific language governing permissions and
15 #    limitations under the License.
16
17 set -e
18
19 echo "==================================="
20 echo executing $0 $@
21
22 # Check to verify that I am being run by Jenkins CI.
23
24 if [ -z ${WORKSPACE+1} ]; then
25     # We are not being run by Jenkins.
26     export WORKSPACE=$HOME/opnfv/ovsnfv
27 fi
28
29
30 if [ ${OVSTAG} ]; then
31     export TAG=$OVSTAG
32 fi
33
34 export DATE=`date +%Y-%m-%d`
35
36 export BUILD_BASE=$WORKSPACE/build
37
38
39
40 if [ ! -d $BUILD_BASE ]
41 then
42     mkdir -p $BUILD_BASE
43 fi
44
45 if [ ! -f $BUILD_BASE/config ]; then
46     touch $BUILD_BASE/config
47 fi
48
49 export PATH=$PATH:$WORKSPACE/ci:$BUILD_BASE
50 source $BUILD_BASE/config
51
52 cd $BUILD_BASE
53 export TOPDIR=$BUILD_BASE
54
55 # build variables
56
57 export TMP_RELEASE_DIR=$TOPDIR/release
58 export CACHE_DIR=$TOPDIR/cache
59 export TMPDIR=$TOPDIR/scratch
60 export RPMDIR=$TOPDIR/rpmbuild
61
62 mkdir -p $RPMDIR/RPMS
63 mkdir -p $RPMDIR/SOURCES
64 mkdir -p $RPMDIR/SPECS
65 mkdir -p $RPMDIR/SRPMS
66
67 if [ ! -d $TMP_RELEASE_DIR ]
68 then
69     mkdir -p $TMP_RELEASE_DIR
70 fi
71
72 #
73 # Build ovs rpm with DPDK
74 #
75 echo =============================================
76 echo =======Build ovs rpm with DPDK and test in VM.
77 echo
78 $BUILD_BASE/BuildAndTestOVS.sh -d -g master -p none -t
79 #
80 # Build special version of ovs with patches --TODO
81 #
82
83 # Once build is done copy product to artifactory.
84 # and cleanup
85
86
87 echo "---------------------------------------"
88 echo "Cleanup temporary dirs"
89 echo
90 cd $BUILD_BASE
91
92 if [ -d $TMPDIR ]
93 then
94     echo rm -rf $TMPDIR
95     rm -rf $TMPDIR
96 fi
97
98 # copy artifacts.
99
100 if [[ "$JOB_NAME" =~ "daily" ]]; then
101     $BUILD_BASE/../ci/upload_artifacts.sh
102 fi
103
104 if [ -d $TMP_RELEASE_DIR ]; then
105     rm -rf $CACHE_RELEASE_DIR
106 fi
107
108 if [ -d $RPMDIR ]; then
109     rm -rf $RPMDIR
110 fi
111
112 # Destroy VM if one has been deployed. Also remove any local installation of
113 # DPDK and OVS
114 #
115 sudo $BUILD_BASE/../ci/clean.sh
116
117 exit 0