116473336301eab445bdea4e0c50ff15fce69245
[ovsnfv.git] / ci / buildovs.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015,2016 Red Hat Inc. and others.
4 # therbert@redhat.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 set -e
11
12 echo "==================================="
13 echo executing $0 $@
14
15 # Check to verify that I am being run by Jenkins CI.
16
17 if [ -z ${WORKSPACE+1} ]; then
18     # We are not being run by Jenkins.
19     export WORKSPACE=$HOME/opnfv/ovsnfv
20 fi
21
22
23 if [ ${OVSTAG} ]; then
24     export TAG=$OVSTAG
25 fi
26
27 export DATE=`date +%Y-%m-%d`
28
29 export BUILD_BASE=$WORKSPACE/build
30
31
32
33 if [ ! -d $BUILD_BASE ]
34 then
35     mkdir -p $BUILD_BASE
36 fi
37
38 if [ ! -f $BUILD_BASE/config ]; then
39     touch $BUILD_BASE/config
40 fi
41
42 export PATH=$PATH:$WORKSPACE/ci:$BUILD_BASE
43 source $BUILD_BASE/config
44
45 cd $BUILD_BASE
46 export TOPDIR=$BUILD_BASE
47
48 # build variables
49
50 export TMP_RELEASE_DIR=$TOPDIR/release
51 export CACHE_DIR=$TOPDIR/cache
52 export TMPDIR=$TOPDIR/scratch
53 export RPMDIR=$TOPDIR/rpmbuild
54
55 echo "--------------------------------------------------"
56 echo "Build OVS RPM from upstream git $TAG"
57 echo
58
59 mkdir -p $RPMDIR/RPMS
60 mkdir -p $RPMDIR/SOURCES
61 mkdir -p $RPMDIR/SPECS
62 mkdir -p $RPMDIR/SRPMS
63
64 if [ ! -d $TMP_RELEASE_DIR ]
65 then
66     mkdir -p $TMP_RELEASE_DIR
67 fi
68
69 #
70 # Build ovs rpm without DPDK from ovs master
71 #
72 echo =======Build ovs rpm and ovs kmod rpm without DPDK Test in VM==========
73     BuildAndTestOVS.sh -p none -t
74 #
75 # Build ovs rpm with DPDK
76 #
77 echo =======Build ovs rpm with DPDK Test in VM==========
78 BuildAndTestOVS.sh -d -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     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 ../ci/clean.sh
116
117 exit 0