blob: 0972dd90d6a94ebf91e5f825e1bb96f2c7abaec8 (
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
#!/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 "executing on machine `uname -a`"
usage() {
echo "run BuildAndTestOVS -h for help"
}
while getopts "cdg:hkp:u:v" opt; do
case "$opt" in
c)
setnocheck="--without check"
;;
d)
DPDK="yes"
;;
g)
TAG=${OPTARG}
;;
h|\?)
usage
exit 1
;;
k)
kmod="yes"
;;
p)
OVS_PATCH=${OPTARG}
;;
u)
OVS_REPO_URL=${OPTARG}
;;
v)
verbose="yes"
;;
esac
done
HOME=`pwd`
TOPDIR=$HOME
TMPDIR=$TOPDIR/ovsrpm
BUILDDIR=$HOME
BUILD_BASE=$BUILDDIR
source $BUILDDIR/functions.sh
echo "---------------------------------------"
echo "Clean out old working dir."
echo
if [ -d $TMPDIR ]
then
rm -rf $TMPDIR
fi
function install_pre_reqs() {
echo "----------------------------------------"
echo "Install pre-reqs."
echo
sudo yum -y install gcc make python-devel openssl-devel kernel-devel graphviz \
kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \
libtool python-twisted-core desktop-file-utils groff PyQt4
}
function apply_nsh_patches() {
echo "-------------------------------------------"
echo "Clone NSH patch and copy patch files."
echo
cd $TMPDIR
if [ -e ovs_nsh_patches ]; then
rm -rf ovs_nsh_patches
fi
git clone https://github.com/yyang13/ovs_nsh_patches.git
cp $TMPDIR/ovs_nsh_patches/*.patch $RPMDIR/SOURCES
cd $TMPDIR
if [ -e buildovsnsh ]; then
rm -rf buildovsnsh
fi
git clone https://github.com/tfherbert/buildovsnsh.git
cp buildovsnsh/*.spec $BUILDDIR
}
VERSION=2.3.90
os_type=fedora
kernel_version=$(uname -a | awk '{print $3}')
RPMDIR=$HOME/rpmbuild
echo "---------------------------------------"
echo "Clean out old reminents of old rpms and rpm _topdir."
echo
rm openvswitch*.rpm || true
if [ -d $RPMDIR ]; then
rm -rf $RPMDIR
fi
echo "---------------------------------------"
echo "Create new rpm _topdir."
echo
mkdir -p $HOME/rpmbuild/RPMS
mkdir -p $HOME/rpmbuild/SOURCES
mkdir -p $HOME/rpmbuild/SPECS
mkdir -p $HOME/rpmbuild/SRPMS
mkdir -p $TMPDIR
install_pre_reqs
cd $TMPDIR
if [ ! -z $DPDK ]; then
echo "----------------------------------"
echo "Build OVS for dpdk. Use Fedora copr repo"
echo
echo "----------------------------------"
echo "Clone Fedora copr repo and copy files."
echo
git clone https://github.com/tfherbert/ovs-snap.git
cd ovs-snap
git checkout $COPR_OVS_VERSION
echo "-----------------------------------"
cp $TMPDIR/ovs-snap/openvswitch.spec $RPMDIR/SPECS
cp $TMPDIR/ovs-snap/* $RPMDIR/SOURCES
snapgit=`grep "define snapver" $TMPDIR/ovs-snap/openvswitch.spec | cut -c26-33`
echo "-----------------------------------------------"
echo "Remove any old installed ovs and dpdk rpms."
echo
cleanrpms
if [ -z $DPDK_VERSION ]; then
DPDK_VERSION=16.04.0
fi
echo "-------------------------------------------"
echo "Install dpdk and dpdk development rpms for version $DPDK_VERSION"
echo
sudo rpm -ivh $HOME/dpdk-${DPDK_VERSION:0:1}*.rpm
sudo rpm -ivh $HOME/dpdk-devel*.rpm
echo "----------------------------------------"
echo "Copy DPDK RPM to SOURCES"
echo
cp $HOME/*.rpm $RPMDIR/SOURCES
echo "--------------------------------------------"
echo "Get commit from $snapgit User Space OVS version $TAG"
echo
cd $TMPDIR
git clone $OVS_REPO_URL
cd $TMPDIR/ovs
git checkout $snapgit
echo "--------------------------------------------"
echo "Creating snapshot, $archive with name same as in spec file."
echo
snapser=`git log --pretty=oneline | wc -l`
basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
prefix=openvswitch-${basever}
archive=${prefix}-${snapser}.git${snapgit}.tar.gz
git archive --prefix=${prefix}-${snapser}.git${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
cd $TMPDIR/ovs-snap
echo "--------------------------------------------"
echo "Build openvswitch RPM"
echo
rpmbuild -bb -vv --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec
else
echo "-------------------------------------------------"
echo "Build OVS without DPDK:"
echo "Use spec files for $os_type in OVS distribution."
echo
echo "-------------------------------------------"
echo "Remove old rpms."
echo
cleanrpms
cd $TMPDIR
git clone $OVS_REPO_URL
cd $TMPDIR/ovs
git checkout $OVS_VERSION
echo "--------------------------------------------"
echo "Get commit from $snapgit User Space OVS version $TAG"
echo
snapgit=`git log --pretty=oneline -n1|cut -c1-8`
snapser=`git log --pretty=oneline | wc -l`
basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
prefix=openvswitch-${basever}
snapver=${snapser}.NSH${snapgit}
archive=${prefix}-${snapser}.NSH${snapgit}.tar.gz
if [ ! -z $OVS_PATCH ]; then
echo "-------------------------------------------"
echo "Apply OVS patches."
echo
apply_nsh_patches
fi
echo "----------------------------------"
echo "Create dist name and rpm name. Put $snapver into spec file"
echo
cd $BUILD_BASE
sed -i "s/%define snapver.*/%define snapver ${snapver}/" openvswitch.spec
echo "----------------------------------"
echo "Copy spec file."
echo
cp $BUILD_BASE/openvswitch.spec $RPMDIR/SPECS
cp $BUILD_BASE/openvswitch.spec $RPMDIR/SOURCES
echo "--------------------------------------------"
echo "Creating snapshot, $archive with name same as in spec file."
echo
cd $TMPDIR/ovs
git archive --prefix=${prefix}-${snapser}.NSH${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
echo "--------------------------------------------"
echo "Build openvswitch RPM"
echo
cd $BUILD_BASE
rpmbuild -bb -vv --without dpdk --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec
fi
#
# This section is for building OVS kernel module.
#
if [ ! -z $kmod ]; then
echo "--------------------------------------------"
echo Build Open vswitch kernel module
echo
cd $TMPDIR
if [ -e ovs ]; then
rm -rf ovs
fi
git clone $OVS_REPO_URL
cd $TMPDIR/ovs
git checkout $OVS_VERSION
echo "--------------------------------------------"
echo "Get commit from $snapgit User Space OVS version $TAG"
echo
snapgit=`git log --pretty=oneline -n1|cut -c1-8`
snapser=`git log --pretty=oneline | wc -l`
basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
prefix=openvswitch-kmod-${basever}
snapver=${snapser}.NSH${snapgit}
archive=${prefix}-${snapser}.NSH${snapgit}.tar.gz
if [ ! -z $OVS_PATCH ]; then
echo "-------------------------------------------"
echo "Apply OVS patches."
echo
apply_nsh_patches
fi
echo "----------------------------------"
echo "Create dist name and rpm name. Put $snapver into spec file"
echo
cd $BUILD_BASE
sed -i "s/%define snapver.*/%define snapver ${snapver}/" openvswitch-kmod.spec
echo "----------------------------------"
echo "Copy spec file."
echo
cp $BUILD_BASE/openvswitch-kmod.spec $RPMDIR/SPECS
cp $BUILD_BASE/openvswitch-kmod.spec $RPMDIR/SOURCES
echo "-------------------------------------------"
echo "Apply nsh patches."
echo
apply_nsh_patches
echo "--------------------------------------------"
echo "Creating snapshot, $archive with name same as in spec file."
echo
cd $TMPDIR/ovs
git archive --prefix=${prefix}-${snapser}.NSH${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
echo "--------------------------------------------"
echo "Building openvswitch kernel module RPM"
echo
cd $BUILD_BASE
rpmbuild -bb -vv -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch-kmod.spec
fi
cp $RPMDIR/RPMS/x86_64/*.rpm $HOME
exit 0
|