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
127 cp $TMPDIR/openvswitch/openvswitch.spec $RPMDIR/SPECS
128 cp $TMPDIR/openvswitch/* $RPMDIR/SOURCES
129 snapgit=`grep "define snapver" $TMPDIR/openvswitch/openvswitch.spec | cut -c26-33`
130 echo "-------------------------------------------"
131 echo "Remove old dpdk, ovs and dpdk development rpms"
135 if [ -z $DPDK_VERSION ]; then
138 echo "-------------------------------------------"
139 echo "Install dpdk and dpdk development rpms for version $DPDK_VERSION"
141 sudo rpm -ivh $HOME/dpdk-${DPDK_VERSION:0:1}*.rpm
142 sudo rpm -ivh $HOME/dpdk-devel*.rpm
143 echo "----------------------------------------"
144 echo "Copy DPDK RPM to SOURCES"
146 cp $HOME/*.rpm $RPMDIR/SOURCES
147 echo "--------------------------------------------"
148 echo "Get commit from $snapgit User Space OVS version $TAG"
151 git clone $OVS_REPO_URL
153 git checkout $snapgit
154 echo "--------------------------------------------"
155 echo "Creating snapshot, $archive with name same as in spec file."
157 snapser=`git log --pretty=oneline | wc -l`
158 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
159 prefix=openvswitch-${basever}
160 archive=${prefix}-${snapser}.git${snapgit}.tar.gz
161 git archive --prefix=${prefix}-${snapser}.git${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
162 cd $TMPDIR/openvswitch
163 echo "--------------------------------------------"
164 echo "Build openvswitch RPM"
167 echo "-------------------------------------------------"
168 echo "Build OVS without DPDK:"
169 echo "Use spec files for $os_type in OVS distribution."
171 if [[ "$TAG" =~ "master" ]]; then
172 git clone $OVS_REPO_URL
175 if [[ ! "$OVS_PATCH" =~ "no" ]]; then
176 echo "Apply patches from $OVS_PATCH"
178 basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1`
179 export VERSION=$basever
181 echo "--------------------------------------------"
182 echo making distribution tarball for Open vswitch version $VERSION
188 echo cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
189 cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES
191 export VERSION=${TAG}
192 echo "---------------------------------------------"
193 echo "Get openvswith-${VERSION}.tar.gz"
195 curl --silent --output $HOME/rpmbuild/SOURCES/openvswitch-${VERSION}.tar.gz http://openvswitch.org/releases/openvswitch-${VERSION}.tar.gz
198 if [ ! -z $kmod ]; then
199 echo "--------------------------------------------"
200 echo "Building openvswitch kernel module RPM"
202 rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch-kmod-${os_type}.spec
204 echo "--------------------------------------------"
205 echo "Build openvswitch RPM"
208 rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec
210 cp $RPMDIR/RPMS/x86_64/*.rpm $HOME