]>
Commit | Line | Data |
---|---|---|
5cdc4335 AW |
1 | # Spec file for Open vSwitch kernel modules using DKMS. |
2 | # | |
3 | # Copyright (C) 2015 Nicira, Inc. | |
4 | # | |
5 | # Copying and distribution of this file, with or without modification, | |
6 | # are permitted in any medium without royalty provided the copyright | |
7 | # notice and this notice are preserved. This file is offered as-is, | |
8 | # without warranty of any kind. | |
9 | ||
10 | %define oname openvswitch | |
11 | ||
12 | Name: %{oname}-dkms | |
13 | Version: @VERSION@ | |
14 | Release: 1%{?dist} | |
15 | Summary: Open vSwitch kernel module | |
16 | ||
17 | Group: System/Kernel | |
18 | License: GPLv2 | |
19 | URL: http://openvswitch.org/ | |
20 | Source: %{oname}-%{version}.tar.gz | |
21 | Requires: autoconf, gcc, make | |
22 | Requires(post): dkms | |
23 | Requires(preun): dkms | |
24 | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | |
25 | ||
26 | # Without this we get an empty openvswitch-debuginfo package (whose name | |
27 | # conflicts with the openvswitch-debuginfo package for OVS userspace). | |
28 | %undefine _enable_debug_packages | |
29 | ||
30 | ||
31 | %description | |
32 | Open vSwitch Linux kernel module. | |
33 | ||
34 | ||
35 | %prep | |
36 | %setup -n %{oname}-%{version} | |
37 | ||
38 | cat > %{oname}.conf << EOF | |
39 | override %{oname} * extra/%{oname} | |
40 | override %{oname} * weak-updates/%{oname} | |
41 | EOF | |
42 | ||
43 | ||
44 | %build | |
45 | # for running the '%{__make} -C datapath print-build-modules' below. | |
46 | ./configure | |
47 | ||
48 | ||
49 | %install | |
50 | %{__rm} -rf %{buildroot} | |
51 | ||
52 | # Kernel module sources install for dkms | |
53 | %{__mkdir_p} %{buildroot}%{_usrsrc}/%{oname}-%{version}/ | |
54 | %{__cp} -r * %{buildroot}%{_usrsrc}/%{oname}-%{version}/ | |
55 | ||
56 | # check we can get kernel module names | |
57 | %{__make} -C datapath print-build-modules | |
58 | ||
59 | # Prepare dkms.conf | |
60 | cat > %{buildroot}%{_usrsrc}/%{oname}-%{version}/dkms.conf << EOF | |
61 | MODULES=( `%{__make} -C datapath print-build-modules | grep -v make` ) | |
62 | ||
63 | PACKAGE_NAME="openvswitch" | |
64 | PACKAGE_VERSION="%{version}-%{release}" | |
65 | MAKE="./configure --with-linux='\${kernel_source_dir}' && make -C datapath/linux" | |
66 | for __idx in \${!MODULES[@]}; do | |
67 | BUILT_MODULE_NAME[__idx]=\${MODULES[__idx]} | |
68 | BUILT_MODULE_LOCATION[__idx]=datapath/linux/ | |
69 | DEST_MODULE_LOCATION[__idx]=/kernel/drivers/net/openvswitch/ | |
70 | done | |
71 | AUTOINSTALL=yes | |
72 | EOF | |
73 | ||
74 | install -d %{buildroot}%{_sysconfdir}/depmod.d/ | |
75 | install -m 644 %{oname}.conf %{buildroot}%{_sysconfdir}/depmod.d/ | |
76 | ||
77 | ||
78 | %post | |
79 | # Add to DKMS registry | |
80 | isadded=`dkms status -m "%{oname}" -v "%{version}"` | |
81 | if [ "x${isadded}" = "x" ] ; then | |
82 | dkms add -m "%{oname}" -v "%{version}" || : | |
83 | fi | |
84 | dkms build -m "%{oname}" -v "%{version}" || : | |
85 | dkms install -m "%{oname}" -v "%{version}" --force || : | |
86 | ||
87 | ||
88 | %preun | |
89 | # Remove all versions from DKMS registry | |
90 | dkms remove -m "%{oname}" -v "%{version}" --all || : | |
91 | ||
92 | ||
93 | %clean | |
94 | %{__rm} -rf %{buildroot} | |
95 | ||
96 | ||
97 | %files | |
98 | %defattr(-,root,root) | |
99 | %{_usrsrc}/%{oname}-%{version}/ | |
100 | /etc/depmod.d/openvswitch.conf |