f1bc02efd700bbc5c813c9b07c0d76e58150afe1
[sliver-openvswitch.git] / rhel / openvswitch-kmod-rhel5.spec.in
1 # Spec file for Open vSwitch kernel modules on Red Hat Enterprise
2 # Linux 5.
3
4 # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
5 #
6 # Copying and distribution of this file, with or without modification,
7 # are permitted in any medium without royalty provided the copyright
8 # notice and this notice are preserved.  This file is offered as-is,
9 # without warranty of any kind.
10
11 %define kmod_name openvswitch
12 %{!?kversion: %define kversion 2.6.18-238.12.1.el5}
13
14 Name:    %{kmod_name}-kmod
15 Version: @VERSION@
16 Release: 1%{?dist}
17 Group:   System Environment/Kernel
18 License: GPLv2
19 Summary: Open vSwitch kernel modules
20 URL:     http://openvswitch.org/
21
22 BuildRequires: redhat-rpm-config
23 BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-build-%(%{__id_u} -n)
24 ExclusiveArch: i686 x86_64
25
26 # Sources.
27 Source0:  %{kmod_name}-%{version}.tar.gz
28 Source10: kmodtool-%{kmod_name}-el5.sh
29
30 # Define the variants for each architecture.
31 %define basevar ""
32 %ifarch i686
33 %define paevar PAE
34 %endif
35 %ifarch i686 x86_64
36 %define xenvar xen
37 %endif
38
39 # If kvariants isn't defined on the rpmbuild line, build all variants for this architecture.
40 %{!?kvariants: %define kvariants %{?basevar} %{?xenvar} %{?paevar}}
41
42 # Magic hidden here.
43 %{expand:%(sh %{SOURCE10} rpmtemplate_kmp %{kmod_name} %{kversion} %{kvariants})}
44
45 # Disable the building of the debug package(s).
46 %define debug_package %{nil}
47
48 # Define the filter.
49 %define __find_requires sh %{_builddir}/%{buildsubdir}/filter-requires.sh
50
51 %description
52 Open vSwitch Linux kernel module.
53
54 %prep
55 %setup -q -c -T -a 0
56 for kvariant in %{kvariants} ; do
57     %{__cp} -a %{kmod_name}-%{version} _kmod_build_$kvariant
58 done
59 echo "/usr/lib/rpm/redhat/find-requires | %{__sed} -e '/^ksym.*/d'" > filter-requires.sh
60 echo "override %{kmod_name} * weak-updates/%{kmod_name}" > kmod-%{kmod_name}.conf
61
62 %build
63 for kvariant in %{kvariants} ; do
64     KSRC=%{_usrsrc}/kernels/%{kversion}${kvariant:+-$kvariant}-%{_target_cpu}
65     cd _kmod_build_$kvariant
66     ../openvswitch-%{version}/configure --with-l26="$KSRC"
67     %{__make} -C datapath/linux-2.6 %{?_smp_mflags}
68     cd ..
69 done
70
71 %install
72 %{__rm} -rf %{buildroot}
73 export INSTALL_MOD_PATH=%{buildroot}
74 export INSTALL_MOD_DIR=extra/%{kmod_name}
75 for kvariant in %{kvariants} ; do
76     KSRC=%{_usrsrc}/kernels/%{kversion}${kvariant:+-$kvariant}-%{_target_cpu}
77     %{__make} -C "${KSRC}" modules_install M=$PWD/_kmod_build_$kvariant/datapath/linux-2.6
78 done
79 %{__install} -d %{buildroot}%{_sysconfdir}/depmod.d/
80 %{__install} kmod-%{kmod_name}.conf %{buildroot}%{_sysconfdir}/depmod.d/
81 # Set the module(s) to be executable, so that they will be stripped when packaged.
82 find %{buildroot} -type f -name \*.ko -exec %{__chmod} u+x \{\} \;
83
84 %clean
85 %{__rm} -rf %{buildroot}