summaryrefslogtreecommitdiff
path: root/rhel/openvswitch-kmod-fedora.spec.in
blob: 7b5c78606c4a821d3fe924d1269fa278c9df5ae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Spec file for Open vSwitch.

# Copyright (C) 2009, 2010, 2015, 2018 Nicira Networks, 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.

%global debug_package %{nil}

# Use the kversion macro such as
# RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 3.10.0-693.17.1.el7.x86_64"'
# to build package for mulitple kernel versions in the same package
# This only works for kernel 3.10.0 major revision 693 (RHEL 7.4)
# and major revision 327 (RHEL 7.2)
# By default, build against the current running kernel version
#%define kernel 3.1.5-1.fc16.x86_64
#define kernel %{kernel_source}
%{?kversion:%define kernel %kversion}

Name: openvswitch-kmod
Summary: Open vSwitch Kernel Modules
Group: System Environment/Daemons
URL: http://www.openvswitch.org/
Vendor: OpenSource Security Ralf Spenneberg <ralf@os-s.net>
Version: @VERSION@

# The entire source code is ASL 2.0 except datapath/ which is GPLv2
License: GPLv2
Release: 1%{?dist}
Source: openvswitch-%{version}.tar.gz
#Source1: openvswitch-init
Buildroot: /tmp/openvswitch-xen-rpm
Provides: kmod-openvswitch
Conflicts: kmod-openvswitch

%description
Open vSwitch provides standard network bridging functions augmented with
support for the OpenFlow protocol for remote per-flow control of
traffic. This package contains the kernel modules.

%prep
%setup -q -n openvswitch-%{version}

%build
for kv in %{kversion}; do
    mkdir -p _$kv
    (cd _$kv && /bin/cp -f ../configure . && %configure --srcdir=.. \
        --with-linux=/lib/modules/${kv}/build --enable-ssl)
    make %{_smp_mflags} -C _$kv/datapath/linux
done

%install
export INSTALL_MOD_DIR=extra/openvswitch
rm -rf $RPM_BUILD_ROOT
for kv in %{kversion}; do
    make INSTALL_MOD_PATH=$RPM_BUILD_ROOT -C _$kv/datapath/linux modules_install
done
mkdir -p $RPM_BUILD_ROOT/etc/depmod.d
for kv in %{kversion}; do
    for module in $RPM_BUILD_ROOT/lib/modules/${kv}/extra/openvswitch/*.ko
    do
        modname="$(basename ${module})"
        grep -qsPo "^\s*override ${modname%.ko} \* extra\/openvwitch" \
            $RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf || \
            echo "override ${modname%.ko} * extra/openvswitch" >> \
            $RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
        grep -qsPo "^\s*override ${modname%.ko} \* weak-updates\/openvwitch" \
            $RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf || \
            echo "override ${modname%.ko} * weak-updates/openvswitch" >> \
            $RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
    done
done
install -d -m 0755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
install -p -m 0755 rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh \
    $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-kmod-manage.sh

%clean
rm -rf $RPM_BUILD_ROOT

%post
current_kernel=$(uname -r)
IFS=. read installed_major installed_minor installed_micro installed_arch \
    installed_build <<<"${current_kernel##*-}"
if [ "$installed_major" = "327" ] || [ "$installed_major" = "693" ]; then
    # Workaround for RHEL 7.2 and 7.4
    if [ -x "/usr/share/openvswitch/scripts/ovs-kmod-manage.sh" ]; then
        /usr/share/openvswitch/scripts/ovs-kmod-manage.sh
    fi
else
    # Ensure that modprobe will find our modules.
    for k in $(cd /lib/modules && /bin/ls); do
        [ -d "/lib/modules/$k/kernel/" ] && /sbin/depmod -a "$k"
    done
    if [ -x "/sbin/weak-modules" ]; then
        for m in openvswitch vport-gre vport-stt vport-geneve \
                 vport-lisp vport-vxlan; do
            echo "/lib/modules/%{kernel}/extra/openvswitch/$m.ko"
        done | /sbin/weak-modules --add-modules
    fi
fi

%postun
if [ "$1" = 0 ]; then  # Erase, not upgrade
    for kname in `ls -d /lib/modules/*`
do
    rm -rf $kname/weak-updates/openvswitch
done
fi
/sbin/depmod -a

%files
%defattr(0644,root,root)
/lib/modules/*/extra/openvswitch/*.ko
/etc/depmod.d/kmod-openvswitch.conf
%exclude /lib/modules/*/modules.*
%attr(755,root,root) /usr/share/openvswitch/scripts/ovs-kmod-manage.sh

%changelog
* Wed Sep 21 2011 Kyle Mestery <kmestery@cisco.com>
- Updated for F15
* Wed Jan 12 2011 Ralf Spenneberg <ralf@os-s.net>
- First build on F14