[ovs-dev] [RFC rhel-dkms] rhel: Add dkms support for ovs datapath build.

Alex Wang alexw at nicira.com
Tue Jun 30 22:56:44 UTC 2015


Hey Flavio,

Thx a lot for the suggestions,

Please see my reply inline,

On Tue, Jun 30, 2015 at 10:41 AM, Flavio Leitner <fbl at sysclose.org> wrote:

> >
> > diff --git a/rhel/dkms.conf.in b/rhel/dkms.conf.in
> > new file mode 100644
> > index 0000000..2c90b4d
> > --- /dev/null
> > +++ b/rhel/dkms.conf.in
> > @@ -0,0 +1,11 @@
>
> This file could be generated by the %install section so that
> you don't have an extra file in OVS tree, macros are expanded
> as usual and if we decide to have dkms support to specific
> distros, then the config remains inside each spec.
> It's just a suggestion to reduce the noise.
>
>

Sure, for all examples I saw, they define the dkms.conf file inside the spec
file.  I'll do that~




>
> > +MODULES=( __MODULES__ )
> > +
> > +PACKAGE_NAME="openvswitch"
> > +PACKAGE_VERSION="__VERSION__"
> > +MAKE="./configure --with-linux='${kernel_source_dir}' && make -C
> datapath/linux"
>
> That's the instruction to build the module, see below.
>
>
> > +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
> > diff --git a/rhel/openvswitch-dkms.spec.in b/rhel/
> openvswitch-dkms.spec.in
> > new file mode 100644
> > index 0000000..591418b
> > --- /dev/null
> > +++ b/rhel/openvswitch-dkms.spec.in
> > @@ -0,0 +1,99 @@
> > +# 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 from the dkms.conf.in template
> > +%{__sed} "s/__VERSION__/%{version}-%{release}/g;
> s/__MODULES__/`%{__make} -C datapath print-build-modules | grep -v make`/"
> rhel/dkms.conf.in > %{buildroot}%{_usrsrc}/%{oname}-%{version}/dkms.conf
>
> Yeap, we could generate the entire file here.
>
> > +
> > +# We don't need the debian folder in there, just upstream sources.
> > +%{__rm} -rf %{buildroot}%{_usrsrc}/%{oname}-%{version}/debian
> > +# We don't need the rhel stuff in there either.
> > +%{__rm} -rf %{buildroot}%{_usrsrc}/%{oname}-%{version}/rhel
> > +# We don't need the xenserver stuff in there either.
> > +%{__rm} -rf %{buildroot}%{_usrsrc}/%{oname}-%{version}/xenserver
> > +# And we should also clean useless license files, which are already
> > +# descriped in our debian/copyright anyway.
> > +%{__rm} -f %{buildroot}%{_usrsrc}/%{oname}-%{version}/COPYING \
> > +     %{buildroot}%{_usrsrc}/%{oname}-%{version}/LICENSE
>
> I am not really sure if the above is possible.
>
>

You mean the above will still be packaged?  or you mean it is not needed?



> > +
> > +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}" || :
>
> Here it actually builds the module, see below.
>
>
> > +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(644,root,root,755)
> > +%{_usrsrc}/%{oname}-%{version}/
>
> But the sources have perm forced to 0644, which means
> ``./configure创 shouldn't work.
>
>

Yeah, somehow I left this out while preparing the patch...  did that in my
experiment...



> fbl
>
> > +/etc/depmod.d/openvswitch.conf
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
>
>



More information about the dev mailing list