From 4c54b37aca48867c694539692a3ada76be39f4d6 Mon Sep 17 00:00:00 2001 From: Thomas F Herbert Date: Sat, 23 Jan 2016 19:06:55 -0500 Subject: Introduce ability to accept command arguments to build with DPDK or Linux kernel. Specify patches to apply, build kernel module RPM and build with a special version of the kernel. Also instack_ovs.sh creates a VM for building and initial testing of RPMs and copies scripts to VMs build_ovs_rpm.sh builds the RPM according to command line options. test_ovs_rpm.sh tests the RPM by installing the RPM and running some ovs commands to create a bridge and dump flows. Also add two scripts generally to be executed in VM to do actual building and Testing. This 2nd series adds the following: Use fedora spec file for kmod builds. Added Explanations to configuration options. Fixes in response to review comments. Rename script for clarity and change references: buildtestovs.sh -> BuildTestOVS.sh Fix nocheck option, print default options, fix kmod option, fix test of kmod. For command line options execute build/buildtestovs.sh -h Change-Id: I415ca39afab27482b1cb473d392f48b36c8e0745 Signed-off-by: Thomas F Herbert --- build/build_ovs_rpm.sh | 130 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100755 build/build_ovs_rpm.sh (limited to 'build/build_ovs_rpm.sh') diff --git a/build/build_ovs_rpm.sh b/build/build_ovs_rpm.sh new file mode 100755 index 0000000..60b92e6 --- /dev/null +++ b/build/build_ovs_rpm.sh @@ -0,0 +1,130 @@ +#!/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 +############################################################################## +set -e +declare -i CNT + +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 + +if [ -d $TMPDIR ] +then + rm -rf $TMPDIR +fi + +sudo yum -y install gcc make python-devel openssl-devel kernel-devel graphviz \ + kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \ + libtool + +VERSION=2.3.90 +os_type=fedora +kernel_version=$(uname -a | awk '{print $3}') + +mkdir -p $TMPDIR + +cd $TMPDIR + +mkdir -p $HOME/rpmbuild/RPMS +mkdir -p $HOME/rpmbuild/SOURCES +mkdir -p $HOME/rpmbuild/SPECS +mkdir -p $HOME/rpmbuild/SRPMS + +RPMDIR=$HOME/rpmbuild + + +echo "---------------------" +echo "Clone git repo $OVS_REPO_URL and checkout branch or tag $TAG" +echo +git clone $OVS_REPO_URL + +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 +else + ./configure --with-linux=/lib/modules/`uname -r`/build +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 + +cp $RPMDIR/RPMS/x86_64/*.rpm $HOME + +exit 0 -- cgit 1.2.3-korg