On Tue, Jun 30, 2015 at 6:13 PM, Flavio Leitner <f...@sysclose.org> wrote:

> On Tue, Jun 30, 2015 at 05:26:00PM -0700, Alex Wang wrote:
> > This commit adds a rpmbuild spec file for building ovs datapath
> > in dkms similar to the one for debian.
> >
> > Signed-off-by: Alex Wang <al...@nicira.com>
> >
> > ---
> > RFC->PATCH:
> > - generate the dkms.conf inside %install.
> > - remove rhel/dkms.conf.in.
> > ---
> >  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 fa2554f..164bb66 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 f6272a3..d263325 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 \
> > @@ -33,6 +35,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 0000000..6b6c30b
> > --- /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(755,root,root,755)
> > +%{_usrsrc}/%{oname}-%{version}/
>
> Now you're forcing all files to have 0755.
> Better to leave with their defaults:
> %defattr(-,root,root)
>
>
Thx for pointing this out, just searched online to understand this, will
adopt
your suggestion~  and resend v2,




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

Reply via email to