summaryrefslogtreecommitdiff
path: root/rhel/openvswitch-dkms.spec.in
blob: e3d77e3c7c4d70d1f7a3a955cd3f07f2278c5b0e (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
# Spec file for Open vSwitch kernel modules using DKMS.
#
# Copyright (C) 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.

%define oname openvswitch
%{!?release_number:%define release_number 1}

Name:             %{oname}-dkms
Version:          @VERSION@
Release:          %{release_number}%{?dist}
Summary:          Open vSwitch kernel module

Group:            System/Kernel
License:          GPLv2
URL:              http://openvswitch.org/
Source:           %{oname}-%{version}.tar.gz
Requires:         autoconf, gcc, make
Requires(post):   dkms
Requires(preun):  dkms
BuildRoot:        %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

# Without this we get an empty openvswitch-debuginfo package (whose name
# conflicts with the openvswitch-debuginfo package for OVS userspace).
%undefine _enable_debug_packages

# Disable shebangs mangling
%undefine __brp_mangle_shebangs

%description
Open vSwitch Linux kernel module.


%prep
%setup -n %{oname}-%{version}

cat > %{oname}.conf << EOF
override %{oname} * extra/%{oname}
override %{oname} * weak-updates/%{oname}
EOF


%build
# for running the '%{__make} -C datapath print-build-modules' below.
./configure


%install
%{__rm} -rf %{buildroot}

# Kernel module sources install for dkms
%{__mkdir_p} %{buildroot}%{_usrsrc}/%{oname}-%{version}/
%{__cp} -r * %{buildroot}%{_usrsrc}/%{oname}-%{version}/

# check we can get kernel module names
%{__make} -C datapath print-build-modules

# Prepare dkms.conf
cat > %{buildroot}%{_usrsrc}/%{oname}-%{version}/dkms.conf << EOF
MODULES=( `%{__make} -C datapath print-build-modules | grep -v make` )

PACKAGE_NAME="openvswitch"
PACKAGE_VERSION="%{version}-%{release}"
MAKE="./configure --with-linux='\${kernel_source_dir}' && make -C datapath/linux"
for __idx in \${!MODULES[@]}; do
    BUILT_MODULE_NAME[__idx]=\${MODULES[__idx]}
    BUILT_MODULE_LOCATION[__idx]=datapath/linux/
    DEST_MODULE_LOCATION[__idx]=/kernel/drivers/net/openvswitch/
done
AUTOINSTALL=yes
EOF

install -d %{buildroot}%{_sysconfdir}/depmod.d/
install -m 644 %{oname}.conf %{buildroot}%{_sysconfdir}/depmod.d/


%post
# Add to DKMS registry
isadded=`dkms status -m "%{oname}" -v "%{version}"`
if [ "x${isadded}" = "x" ] ; then
    dkms add -m "%{oname}" -v "%{version}" || :
fi
dkms build -m "%{oname}" -v "%{version}" || :
dkms install -m "%{oname}" -v "%{version}" --force || :


%preun
# Remove all versions from DKMS registry
dkms remove -m "%{oname}" -v "%{version}" --all || :


%clean
%{__rm} -rf %{buildroot}


%files
%defattr(-,root,root)
%{_usrsrc}/%{oname}-%{version}/
/etc/depmod.d/openvswitch.conf