Do not have good experience writing spec file...~ Would like to post this and look for hearing any obvious fault~
Tested it, on my own rhel7 vm, seems working~ Thanks, Alex Wang, On Sun, Jun 28, 2015 at 9:38 PM, Alex Wang <al...@nicira.com> 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> > --- > rhel/.gitignore | 1 + > rhel/automake.mk | 6 +++ > rhel/dkms.conf.in | 11 +++++ > rhel/openvswitch-dkms.spec.in | 99 > +++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 117 insertions(+) > create mode 100644 rhel/dkms.conf.in > 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..e24c1a0 100644 > --- a/rhel/automake.mk > +++ b/rhel/automake.mk > @@ -8,10 +8,13 @@ > EXTRA_DIST += \ > rhel/README.RHEL \ > rhel/automake.mk \ > + rhel/dkms.conf.in \ > rhel/etc_init.d_openvswitch \ > 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 +36,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/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 @@ > +MODULES=( __MODULES__ ) > + > +PACKAGE_NAME="openvswitch" > +PACKAGE_VERSION="__VERSION__" > +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 > 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 > + > +# 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 > + > +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(644,root,root,755) > +%{_usrsrc}/%{oname}-%{version}/ > +/etc/depmod.d/openvswitch.conf > -- > 1.7.9.5 > > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev