3 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
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
9 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 echo "==============================="
19 echo "executing $0 $@"
20 echo "executing on machine `uname -a`"
23 echo "run BuildAndTestOVS -h for help"
26 while getopts "cdg:hkp:u:v" opt; do
29 setnocheck="--without check"
48 OVS_REPO_URL=${OPTARG}
62 source $BUILDDIR/functions.sh
64 echo "---------------------------------------"
65 echo "Clean out old working dir."
72 function install_pre_reqs() {
73 echo "----------------------------------------"
74 echo "Install pre-reqs."
76 sudo yum -y install gcc make python-devel openssl-devel kernel-devel graphviz \
77 kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \
78 libtool python-twisted-core desktop-file-utils groff PyQt4
83 kernel_version=$(uname -a | awk '{print $3}')
87 echo "---------------------------------------"
88 echo "Clean out old reminents of old rpms and rpm _topdir."
91 rm openvswitch*.rpm || true
92 if [ -d $RPMDIR ]; then
96 echo "---------------------------------------"
97 echo "Create new rpm _topdir."
99 mkdir -p $HOME/rpmbuild/RPMS
100 mkdir -p $HOME/rpmbuild/SOURCES
101 mkdir -p $HOME/rpmbuild/SPECS
102 mkdir -p $HOME/rpmbuild/SRPMS
109 if [ ! -z $DPDK ]; then
110 echo "----------------------------------"
111 echo "Build OVS for dpdk. Use Fedora copr repo"
113 echo "----------------------------------"
114 echo "Clone Fedora copr repo and copy files."
116 git clone https://github.com/tfherbert/ovs-snap.git
118 git checkout $COPR_OVS_VERSION
119 echo "-----------------------------------"
120 cp $TMPDIR/ovs-snap/openvswitch.spec $RPMDIR/SPECS
121 cp $TMPDIR/ovs-snap/* $RPMDIR/SOURCES
122 snapgit=`grep "define snapver" $TMPDIR/ovs-snap/openvswitch.spec | cut -c26-33`
123 echo "-----------------------------------------------"
124 echo "Remove any old installed ovs and dpdk rpms."
128 if [ -z $DPDK_VERSION ]; then
131 echo "-------------------------------------------"
132 echo "Install dpdk and dpdk development rpms for version $DPDK_VERSION"
134 sudo rpm -ivh $HOME/dpdk-${DPDK_VERSION:0:1}*.rpm
135 sudo rpm -ivh $HOME/dpdk-devel*.rpm
136 echo "----------------------------------------"
137 echo "Copy DPDK RPM to SOURCES"
139 cp $HOME/*.rpm $RPMDIR/SOURCES
140 echo "--------------------------------------------"
141 echo "Get commit from $snapgit User Space OVS version $TAG"
144 git clone $OVS_REPO_URL
146 git checkout $snapgit
147 echo "--------------------------------------------"
148 echo "Creating snapshot, $archive with name same as in spec file."
150 snapser=`git log --pretty=oneline | wc -l`
151 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
152 prefix=openvswitch-${basever}
153 archive=${prefix}-${snapser}.git${snapgit}.tar.gz
154 git archive --prefix=${prefix}-${snapser}.git${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
156 echo "--------------------------------------------"
157 echo "Build openvswitch RPM"
159 rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec
161 echo "-------------------------------------------------"
162 echo "Build OVS without DPDK:"
163 echo "Use spec files for $os_type in OVS distribution."
165 if [[ "$TAG" =~ "master" ]]; then
166 git clone $OVS_REPO_URL
169 if [[ ! "$OVS_PATCH" =~ "no" ]]; then
170 echo "Apply patches from $OVS_PATCH"
172 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
173 export VERSION=$basever
175 echo "--------------------------------------------"
176 echo "Making distribution tarball for Open vswitch version $VERSION"
182 echo cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
183 cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
185 export VERSION=${TAG}
186 echo "---------------------------------------------"
187 echo "Get openvswith-${VERSION}.tar.gz"
189 curl --silent --output $HOME/rpmbuild/SOURCES/openvswitch-${VERSION}.tar.gz http://openvswitch.org/releases/openvswitch-${VERSION}.tar.gz
194 # This section is for building OVS kernel module.
196 if [ ! -z $kmod ]; then
198 echo "--------------------------------------------"
199 echo "Making distribution tarball for Open vswitch version $VERSION"
204 echo "--------------------------------------------"
205 echo "Copy distribution tarball to $HOME/rpmbuild/SOURCES"
207 cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
208 echo "--------------------------------------------"
209 echo "Building openvswitch kernel module RPM"
211 rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch-kmod-${os_type}.spec
214 cp $RPMDIR/RPMS/x86_64/*.rpm $HOME