OVS Source Build Oracle Linux 6 UEK3 Kernel

The guide here at Foswiki is very accurate and applies for Oracle Linux 6 UEK kernel as well. I'm also including my steps below for reference as well.

Host OS Description

The system that OpenvSwitch will be built on is described and characterized below. Note that this is an Oracle Linux UEK kernel system.

[root@oracle67 SOURCES]# uname -a

Linux oracle67 3.8.13-68.3.4.el6uek.x86_64 #2 SMP Tue Jul 14 15:03:36 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux

[root@oracle67 SOURCES]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.8 (Santiago)

[root@oracle67 SOURCES]# cat /etc/oracle-release

Oracle Linux Server release 6.8

[root@oracle67 SOURCES]#

Preparing the RPM Build

Make sure the rpm-build package is installed.

[root@oracle67 ~]# yum -y install rpm-build

Loaded plugins: refresh-packagekit, security

Setting up Install Process

Package rpm-build-4.8.0-55.el6.x86_64 already installed and latest version

Nothing to do

[root@oracle67 ~]#

Get Python 2.7 Installed

Make sure python 2.7 is installed.

[root@localhost ~]# yum -y install python27

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.gigenet.com

* epel: lug.mtu.edu

* extras: mirrors.gigenet.com

* updates: mirrors.gigenet.com

No package python27 available.

Error: Nothing to do

[root@localhost ~]# python -V

Python 2.7.5

[root@localhost ~]#

This puts python2.7 in /opt/rh/python27. It won't be used unless you "source" the enable script.

[root@oracle67 ~]# python -V

Python 2.6.6

[root@oracle67 ~]# source /opt/rh/python27/enable

[root@oracle67 ~]# python -V

Python 2.7.8

[root@oracle67 ~]#

Building the RPMS

Next cd to the ~/rpmbuild/SOURCES directory and get the tarball as shown below.

[root@oracle67 SOURCES]# cd ~/rpmbuild/SOURCES

[root@oracle67 SOURCES]# wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz

--2016-08-03 19:45:25-- http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz

Resolving openvswitch.org... 69.56.251.103

Connecting to openvswitch.org|69.56.251.103|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 4603077 (4.4M) [application/x-gzip]

Saving to: “openvswitch-2.5.0.tar.gz.2”

100%[===========================================================================================================================================================>] 4,603,077 2.47M/s in 1.8s

2016-08-03 19:45:27 (2.47 MB/s) - “openvswitch-2.5.0.tar.gz.2” saved [4603077/4603077]

[root@oracle67 SOURCES]#

We can then unpack the tar-ball so we can get the needed .spec files for use with rpmbuild as shown below.

[root@oracle67 SOURCES]# tar -zxvf openvswitch-2.5.0.tar.gz

You have to edit the openvswitch.spec file as shown below to use "python27" where indicated. The bolded line shows how it should look after the edit with "python27" in the requires line.

[root@oracle67 rpmbuild]# cd SPECS/

[root@oracle67 SPECS]# ls -lrt

[root@oracle67 SPECS]# more openvswitch.spec

# Generated automatically -- do not modify! -*- buffer-read-only: t -*-

# Spec file for Open vSwitch on Red Hat Enterprise Linux.

# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.

#

# Copying and distribution of this file, with or without modification,

# are permitted in any medium without royalty provided the copyright

# notice and this notice are preserved. This file is offered as-is,

# without warranty of any kind.

#

# If tests have to be skipped while building, specify the '--without check'

# option. For example:

# rpmbuild -bb --without check rhel/openvswitch.spec

Name: openvswitch

Summary: Open vSwitch daemon/database/utilities

Group: System Environment/Daemons

URL: http://www.openvswitch.org/

Vendor: Nicira, Inc.

Version: 2.5.0

License: ASL 2.0

Release: 1

Source: openvswitch-%{version}.tar.gz

Buildroot: /tmp/openvswitch-rpm

Requires: logrotate, python27

BuildRequires: openssl-devel

%bcond_without check

%description

Open vSwitch provides standard network bridging functions and

support for the OpenFlow protocol for remote per-flow control of

traffic.

%prep

%setup -q

%build

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --enable-ssl

make %{_smp_mflags}

%install

rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

rhel_cp() {

base=$1

mode=$2

dst=$RPM_BUILD_ROOT/$(echo $base | sed 's,_,/,g')

install -D -m $mode rhel/$base $dst

}

rhel_cp etc_init.d_openvswitch 0755

rhel_cp etc_logrotate.d_openvswitch 0644

rhel_cp etc_sysconfig_network-scripts_ifup-ovs 0755

rhel_cp etc_sysconfig_network-scripts_ifdown-ovs 0755

rhel_cp usr_share_openvswitch_scripts_sysconfig.template 0644

# Get rid of stuff we don't want to make RPM happy.

rm \

$RPM_BUILD_ROOT/usr/bin/ovs-testcontroller \

$RPM_BUILD_ROOT/usr/share/man/man8/ovs-testcontroller.8 \

$RPM_BUILD_ROOT/usr/bin/ovs-test \

$RPM_BUILD_ROOT/usr/bin/ovs-l3ping \

$RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8 \

$RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \

$RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \

$RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8 \

$RPM_BUILD_ROOT/usr/bin/ovn-* \

$RPM_BUILD_ROOT/usr/share/man/man?/ovn-* \

$RPM_BUILD_ROOT/usr/share/openvswitch/ovn-* \

$RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovn-*

(cd "$RPM_BUILD_ROOT" && rm -rf usr/lib)

(cd "$RPM_BUILD_ROOT" && rm -rf usr/include)

install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch

%check

%if %{with check}

if make check TESTSUITEFLAGS='%{_smp_mflags}' ||

make check TESTSUITEFLAGS='--recheck'; then :;

else

cat tests/testsuite.log

exit 1

fi

%endif

%clean

rm -rf $RPM_BUILD_ROOT

%post

# Create default or update existing /etc/sysconfig/openvswitch.

SYSCONFIG=/etc/sysconfig/openvswitch

TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template

if [ ! -e $SYSCONFIG ]; then

cp $TEMPLATE $SYSCONFIG

else

for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)

do

if ! grep $var $SYSCONFIG >/dev/null 2>&1; then

echo >> $SYSCONFIG

sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG

fi

done

fi

# Ensure all required services are set to run

/sbin/chkconfig --add openvswitch

/sbin/chkconfig openvswitch on

%preun

if [ "$1" = "0" ]; then # $1 = 0 for uninstall

/sbin/service openvswitch stop

/sbin/chkconfig --del openvswitch

fi

%postun

if [ "$1" = "0" ]; then # $1 = 0 for uninstall

rm -f /etc/openvswitch/conf.db

rm -f /etc/sysconfig/openvswitch

rm -f /etc/openvswitch/vswitchd.cacert

fi

exit 0

%files

%defattr(-,root,root)

%dir /etc/openvswitch

/etc/bash_completion.d/ovs-appctl-bashcomp.bash

/etc/bash_completion.d/ovs-vsctl-bashcomp.bash

/etc/init.d/openvswitch

%config(noreplace) /etc/logrotate.d/openvswitch

/etc/sysconfig/network-scripts/ifup-ovs

/etc/sysconfig/network-scripts/ifdown-ovs

/usr/bin/ovs-appctl

/usr/bin/ovs-benchmark

/usr/bin/ovs-dpctl

/usr/bin/ovs-dpctl-top

/usr/bin/ovs-docker

/usr/bin/ovs-ofctl

/usr/bin/ovs-parse-backtrace

/usr/bin/ovs-pcap

/usr/bin/ovs-pki

/usr/bin/ovs-tcpundump

/usr/bin/ovs-vlan-test

/usr/bin/ovs-vsctl

/usr/bin/ovsdb-client

/usr/bin/ovsdb-tool

/usr/bin/vtep-ctl

/usr/sbin/ovs-bugtool

/usr/sbin/ovs-vswitchd

/usr/sbin/ovsdb-server

/usr/share/man/man1/ovs-benchmark.1.gz

/usr/share/man/man1/ovs-pcap.1.gz

/usr/share/man/man1/ovs-tcpundump.1.gz

/usr/share/man/man1/ovsdb-client.1.gz

/usr/share/man/man1/ovsdb-server.1.gz

/usr/share/man/man1/ovsdb-tool.1.gz

/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz

/usr/share/man/man5/vtep.5.gz

/usr/share/man/man8/ovs-appctl.8.gz

/usr/share/man/man8/ovs-bugtool.8.gz

/usr/share/man/man8/ovs-ctl.8.gz

/usr/share/man/man8/ovs-dpctl.8.gz

/usr/share/man/man8/ovs-dpctl-top.8.gz

/usr/share/man/man8/ovs-ofctl.8.gz

/usr/share/man/man8/ovs-parse-backtrace.8.gz

/usr/share/man/man8/ovs-pki.8.gz

/usr/share/man/man8/ovs-vlan-test.8.gz

/usr/share/man/man8/ovs-vsctl.8.gz

/usr/share/man/man8/ovs-vswitchd.8.gz

/usr/share/man/man8/vtep-ctl.8.gz

/usr/share/openvswitch/bugtool-plugins/

/usr/share/openvswitch/python/

/usr/share/openvswitch/scripts/ovs-bugtool-*

/usr/share/openvswitch/scripts/ovs-check-dead-ifs

/usr/share/openvswitch/scripts/ovs-ctl

/usr/share/openvswitch/scripts/ovs-lib

/usr/share/openvswitch/scripts/ovs-save

/usr/share/openvswitch/scripts/ovs-vtep

/usr/share/openvswitch/scripts/sysconfig.template

/usr/share/openvswitch/vswitch.ovsschema

/usr/share/openvswitch/vtep.ovsschema

%doc COPYING DESIGN.md INSTALL.SSL.md NOTICE README.md WHY-OVS.md FAQ.md NEWS

%doc INSTALL.DPDK.md rhel/README.RHEL README-native-tunneling.md

/var/lib/openvswitch

/var/log/openvswitch

[root@oracle67 SPECS]#

Now build the rpms as indicated below.

source /opt/rh/python27/enable

cd ~/rpmbuild/SPECS

rpmbuild -ba openvswitch.spec

Now the rpm is built if the above steps went well as shown below.

[root@oracle67 x86_64]# ls -lrt

total 12056

-rw-r--r--. 1 root root 3012436 Aug 3 19:16 openvswitch-2.5.0-1.x86_64.rpm

-rw-r--r--. 1 root root 9329736 Aug 3 19:16 openvswitch-debuginfo-2.5.0-1.x86_64.rpm

[root@oracle67 x86_64]#

Now install the rpm as shown below. If you get any messages about python version be sure you have sourced and verified that python 2.7 is in use.

[root@oracle67 x86_64]# yum localinstall openvswitch-2.5.0-1.x86_64.rpm

Now create the openvswitch db and reboot. It may be necessary to first create the

[root@localhost x86_64]# cd /usr/local/etc

[root@localhost etc]# which ovsdb-tool

/bin/ovsdb-tool

[root@localhost etc]# ls -lrt

total 0

[root@localhost etc]# pwd

/usr/local/etc

[root@localhost etc]# mkdir openvswitch

[root@localhost etc]# ovsdb-tool create /usr/local/etc/openvswitch/conf.db

[root@localhost etc]#

After reboot, check that ovs-vsctl shows good status as shown below.

[root@oracle67 x86_64]# sudo ovs-vsctl show

0b9b0d61-3f3a-40bc-a250-81d1b0502cf4

ovs_version: "2.5.0"

[root@oracle67 x86_64]#