From 79dfeb69cda04a9e4455b57b64901e0662271ec0 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Sun, 28 Jun 2015 16:31:16 -0700 Subject: [PATCH] rhel: Add dkms support for ovs datapath build. This commit adds a rpmbuild spec file for building ovs datapath in dkms similar to the one for debian. Signed-off-by: Alex Wang Acked-by: Flavio Leitner --- rhel/.gitignore | 1 + rhel/automake.mk | 5 ++ rhel/openvswitch-dkms.spec.in | 100 ++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 rhel/openvswitch-dkms.spec.in diff --git a/rhel/.gitignore b/rhel/.gitignore index fa2554fa5..164bb6671 100644 --- a/rhel/.gitignore +++ b/rhel/.gitignore @@ -1,3 +1,4 @@ +openvswitch-dkms.spec openvswitch-kmod-rhel5.spec openvswitch-kmod-rhel6.spec openvswitch-kmod-fedora.spec diff --git a/rhel/automake.mk b/rhel/automake.mk index 9c3433bac..b1b67ec34 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -12,6 +12,8 @@ EXTRA_DIST += \ rhel/etc_logrotate.d_openvswitch \ rhel/etc_sysconfig_network-scripts_ifdown-ovs \ rhel/etc_sysconfig_network-scripts_ifup-ovs \ + rhel/openvswitch-dkms.spec \ + rhel/openvswitch-dkms.spec.in \ rhel/openvswitch-kmod-rhel6.spec \ rhel/openvswitch-kmod-rhel6.spec.in \ rhel/openvswitch-kmod.files \ @@ -31,6 +33,9 @@ update_rhel_spec = \ < $(srcdir)/rhel/$(@F).in > $(@F).tmp || exit 1; \ if cmp -s $(@F).tmp $@; then touch $@; rm $(@F).tmp; else mv $(@F).tmp $@; fi +$(srcdir)/rhel/openvswitch-dkms.spec: rhel/openvswitch-dkms.spec.in $(top_builddir)/config.status + $(update_rhel_spec) + $(srcdir)/rhel/openvswitch-kmod-rhel6.spec: rhel/openvswitch-kmod-rhel6.spec.in $(top_builddir)/config.status $(update_rhel_spec) diff --git a/rhel/openvswitch-dkms.spec.in b/rhel/openvswitch-dkms.spec.in new file mode 100644 index 000000000..a47c038fd --- /dev/null +++ b/rhel/openvswitch-dkms.spec.in @@ -0,0 +1,100 @@ +# 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 + +Name: %{oname}-dkms +Version: @VERSION@ +Release: 1%{?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 + + +%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 -- 2.20.1