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 "==============================="
20 echo executing on machine `uname -a`
23 echo run BuildAndTestOVS -h for help
30 sudo rpm -e --allmatches $1
34 function cleanrpms() {
42 while getopts "cdg:hkp:u:v" opt; do
45 setnocheck="--without check"
64 OVS_REPO_URL=${OPTARG}
76 echo "---------------------------------------"
77 echo Clean out old working dir
84 echo "----------------------------------------"
85 echo Install pre-reqs.
87 sudo yum -y install gcc make python-devel openssl-devel kernel-devel graphviz \
88 kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \
89 libtool python-twisted-core desktop-file-utils groff PyQt4
93 kernel_version=$(uname -a | awk '{print $3}')
97 echo "---------------------------------------"
98 echo Clean out old reminents of old rpms and rpm _topdir.
101 rm openvswitch*.rpm || true
102 if [ -d $RPMDIR ]; then
106 echo "---------------------------------------"
107 echo Create new rpm _topdir.
109 mkdir -p $HOME/rpmbuild/RPMS
110 mkdir -p $HOME/rpmbuild/SOURCES
111 mkdir -p $HOME/rpmbuild/SPECS
112 mkdir -p $HOME/rpmbuild/SRPMS
119 if [ ! -z $DPDK ]; then
120 echo "----------------------------------"
121 echo "Build OVS for dpdk. Use Fedora copr repo"
123 echo "----------------------------------"
124 echo "Clone Fedora copr repo and copy files."
126 git clone http://copr-dist-git.fedorainfracloud.org/cgit/pmatilai/dpdk-snapshot/openvswitch.git
128 git checkout $COPR_OVS_VERSION
129 cp $TMPDIR/openvswitch/openvswitch.spec $RPMDIR/SPECS
130 cp $TMPDIR/openvswitch/* $RPMDIR/SOURCES
131 snapgit=`grep "define snapver" $TMPDIR/openvswitch/openvswitch.spec | cut -c26-33`
132 echo "-------------------------------------------"
133 echo "Remove old dpdk, ovs and dpdk development rpms"
137 if [ -z $DPDK_VERSION ]; then
140 echo "-------------------------------------------"
141 echo "Install dpdk and dpdk development rpms for version $DPDK_VERSION"
143 sudo rpm -ivh $HOME/dpdk-${DPDK_VERSION:0:1}*.rpm
144 sudo rpm -ivh $HOME/dpdk-devel*.rpm
145 echo "----------------------------------------"
146 echo "Copy DPDK RPM to SOURCES"
148 cp $HOME/*.rpm $RPMDIR/SOURCES
149 echo "--------------------------------------------"
150 echo "Get commit from $snapgit User Space OVS version $TAG"
153 git clone $OVS_REPO_URL
155 git checkout $snapgit
156 echo "--------------------------------------------"
157 echo "Creating snapshot, $archive with name same as in spec file."
159 snapser=`git log --pretty=oneline | wc -l`
160 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
161 prefix=openvswitch-${basever}
162 archive=${prefix}-${snapser}.git${snapgit}.tar.gz
163 git archive --prefix=${prefix}-${snapser}.git${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
164 cd $TMPDIR/openvswitch
165 echo "--------------------------------------------"
166 echo "Build openvswitch RPM"
169 echo "-------------------------------------------------"
170 echo "Build OVS without DPDK:"
171 echo "Use spec files for $os_type in OVS distribution."
173 if [[ "$TAG" =~ "master" ]]; then
174 git clone $OVS_REPO_URL
177 if [[ ! "$OVS_PATCH" =~ "no" ]]; then
178 echo "Apply patches from $OVS_PATCH"
180 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
181 export VERSION=$basever
183 echo "--------------------------------------------"
184 echo making distribution tarball for Open vswitch version $VERSION
190 echo cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
191 cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
193 export VERSION=${TAG}
194 echo "---------------------------------------------"
195 echo "Get openvswith-${VERSION}.tar.gz"
197 curl --silent --output $HOME/rpmbuild/SOURCES/openvswitch-${VERSION}.tar.gz http://openvswitch.org/releases/openvswitch-${VERSION}.tar.gz
200 if [ ! -z $kmod ]; then
201 echo "--------------------------------------------"
202 echo "Building openvswitch kernel module RPM"
204 rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch-kmod-${os_type}.spec
206 echo "--------------------------------------------"
207 echo "Build openvswitch RPM"
210 rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec
212 cp $RPMDIR/RPMS/x86_64/*.rpm $HOME