summaryrefslogtreecommitdiffstats
path: root/build/BuildAndTestOVS.sh
blob: 0a5f3572243c4e92dd0ec30411d07359c081af90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash

# 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\
             -i <kernel minor> -p <patch url> -t -u <OVS URL> -v <verbose\
    -a <kernel major> -- Specify major release if special kernel is required\
    The default kernel is Centos 7.2 kernel after upgrade.\
    -d <dpdk>         -- Specify dpdk build.\
                    The default is to build ovs for linux kernel data path.\
    -g <OVS TAG>      -- OVS release tag or branch to build such as 2.4.\
                    The default is master.\
    -h print this message\
    -i <kernel minor> -- Specify minor release if special kernel is required.\
                    The default kernel is Centos 7.2 kernel after upgrade.\
    -p <patch url>    -- Specify url to patches if required for ovs rpm.\
    -t                -- Test rpm.\
    -u <OVS URL>      -- path to OVS repo if using fork for patch.\
                    The default is https://github.com/openvswitch/ovs.git\
    -v                -- Set verbose mode."
}

while getopts "a:dg:hi:p:tu:v" opt; do
    case "$opt" in
        a)
            kernel_major=${OPTARG}
            ;;
        d)
            DPDK="yes"
            ;;
        g)
            TAG=${OPTARG}
            ;;
        h)
            usage
            exit 1
            ;;
        i)
            kernel_minor=${OPTARG}
            ;;
        p)
            OVS_PATCH=${OPTARG}
            ;;
        t)
            TESTRPM="yes"
            ;;
        u)
            OVS_REPO_URL=${OPTARG}
            ;;
        v)
            verbose="yes"
            ;;
    esac
done

#
# 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
    OVS_REPO_URL=https://github.com/openvswitch/ovs.git
fi

if [ ! -z $kernel_major ] && [ ! -z $kernel_minor ]; then
    kernel_version=$kernel_major.$kernel_minor
    echo ===================
    echo Will install kernel version: major is $kernel_major and minor is $kernel_minor
    echo ===================
else
    echo Will use default kernel in ovs test vm
fi

if [ -z $TAG ]; then
    TAG=master
fi

if [ ! -z $DPDK ]; then
    setbuilddpdk="-d"
fi

if [ -z ${WORKSPACE+1} ]; then
    # We are not being run by Jenkins.
    export WORKSPACE=`pwd`
fi

if [ -z ${BUILD_BASE+1} ]; then
    export BUILD_BASE=$WORKSPACE
fi

export PATH=$PATH:$BUILD_BASE

cd $BUILD_BASE
export TOPDIR=$BUILD_BASE

# build variables

export TMP_RELEASE_DIR=$TOPDIR/release
export CACHE_DIR=$TOPDIR/cache
export TMPDIR=$TOPDIR/scratch
export RPMDIR=$TOPDIR/rpmbuild


mkdir -p $RPMDIR/RPMS
mkdir -p $RPMDIR/SOURCES
mkdir -p $RPMDIR/SPECS
mkdir -p $RPMDIR/SRPMS
#
# 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
#
# Test rpm
#
if [ ! -z $TESTRPM ]; then
    ./test_ovs_rpm.sh $setdpdk $setkmod
fi

#
# If tests pass, copy rpms to release dir
#
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
#
# Test rpm
#
if [ ! -z $TESTRPM ]; then
    ./test_ovs_rpm.sh $setdpdk $setkmod
fi

#
# If tests pass, copy rpms to release dir
#
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