X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=build%2Fbuild_ovs_rpm.sh;h=b03f4abaadcbf4e94f0e8c8582711f01be9eeb41;hb=4e07dd488cb78b8333763418c4ccc25e05766956;hp=60b92e6f4eb041fbec145c30cdd610a98df017ca;hpb=dc39acb395fb46ca255fed78ecbe2f1616db963d;p=ovsnfv.git diff --git a/build/build_ovs_rpm.sh b/build/build_ovs_rpm.sh index 60b92e6..b03f4ab 100755 --- a/build/build_ovs_rpm.sh +++ b/build/build_ovs_rpm.sh @@ -1,14 +1,19 @@ #!/bin/bash -############################################################################## -# Copyright (c) 2016 Red Hat Inc. and others. -# therbert@redhat.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## + +# 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 -declare -i CNT echo "===============================" echo executing $0 $@ @@ -18,6 +23,22 @@ usage() { echo run BuildAndTestOVS -h for help } +function delrpm() { + set +e + rpm -q $1 + if [ $? -eq 0 ]; then + sudo rpm -e --allmatches $1 + fi + set -e +} +function cleanrpms() { + delrpm openvswitch + delrpm dpdk-devel + delrpm dpdk-tools + delrpm dpdk-examples + delrpm dpdk +} + while getopts "cdg:hkp:u:v" opt; do case "$opt" in c) @@ -52,78 +73,141 @@ HOME=`pwd` TOPDIR=$HOME TMPDIR=$TOPDIR/ovsrpm +echo "---------------------------------------" +echo Clean out old working dir +echo if [ -d $TMPDIR ] then rm -rf $TMPDIR fi +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 + libtool python-twisted-core desktop-file-utils groff PyQt4 VERSION=2.3.90 os_type=fedora kernel_version=$(uname -a | awk '{print $3}') -mkdir -p $TMPDIR +RPMDIR=$HOME/rpmbuild -cd $TMPDIR +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 -RPMDIR=$HOME/rpmbuild +mkdir -p $TMPDIR -echo "---------------------" -echo "Clone git repo $OVS_REPO_URL and checkout branch or tag $TAG" -echo -git clone $OVS_REPO_URL +cd $TMPDIR -cd ovs -echo "--------------------" -echo "Checkout OVS $TAG" -echo -if [[ ! "$TAG" =~ "master" ]]; then - git checkout $TAG -fi -if [[ ! "$OVS_PATCH" =~ "no" ]]; then - echo "Apply patches from $OVS_PATCH" -fi -./boot.sh if [ ! -z $DPDK ]; then - ./configure --with-dpdk + 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 + 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 old dpdk, ovs and dpdk development 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 else - ./configure --with-linux=/lib/modules/`uname -r`/build + echo "-------------------------------------------------" + echo "Build OVS without DPDK:" + echo "Use spec files for $os_type in OVS distribution." + echo + if [[ "$TAG" =~ "master" ]]; then + git clone $OVS_REPO_URL + cd ovs + + if [[ ! "$OVS_PATCH" =~ "no" ]]; then + echo "Apply patches from $OVS_PATCH" + fi + basever=`grep AC_INIT configure.ac | cut -d' ' -f2 | cut -d, -f1` + export VERSION=$basever + + echo "--------------------------------------------" + echo making distribution tarball for Open vswitch version $VERSION + echo + ./boot.sh + ./configure + make dist + + echo cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES + cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES + else + export VERSION=${TAG} + echo "---------------------------------------------" + echo "Get openvswith-${VERSION}.tar.gz" + echo + curl --silent --output $HOME/rpmbuild/SOURCES/openvswitch-${VERSION}.tar.gz http://openvswitch.org/releases/openvswitch-${VERSION}.tar.gz + fi + + if [ ! -z $kmod ]; then + echo "--------------------------------------------" + echo "Building openvswitch kernel module RPM" + echo + rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch-kmod-${os_type}.spec + fi + echo "--------------------------------------------" + echo "Build openvswitch RPM" + echo fi -echo "--------------------" -echo "Make OVS $TAG" -echo -make - -if [[ "$TAG" =~ "master" ]]; then - v=$($TMPDIR/ovs/utilities/ovs-vsctl --version | head -1 | cut -d' ' -f4) - export VERSION=$v -else - export VERSION=${TAG:1} -fi - -echo making RPM for Open vswitch version $VERSION -make dist - -echo cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES -cp openvswitch-*.tar.gz $HOME/rpmbuild/SOURCES - -if [ ! -z $kmod ]; then - echo "Building kernel module..." - rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch-kmod-${os_type}.spec -echo " Kernel RPM built!" -fi - -echo "Building User Space..." -rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch.spec +rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch.spec cp $RPMDIR/RPMS/x86_64/*.rpm $HOME