Re: [ovs-dev] [PATCH v3] rhel: support kmod build against mulitple kernel versions, fedora

2018-08-21 Thread Ben Pfaff
On Tue, Aug 21, 2018 at 05:17:53PM -0300, Flavio Leitner wrote:
> On Mon, Aug 20, 2018 at 02:24:05PM -0700, Martin Xu wrote:
> > This patch ports changes from kmod rhel6 spec file to fedora spec file,
> > to support packaging kernel modules built against multiple versions of
> > kernel sources.
> > 
> > RHEL 7.4 introduced backward incompatible changes in the kernel. As
> > a result, prebuilt PRM packages against kernels newer than 693.17.1
> > will cannot be used on systems with older kernels, vice versa.
> > 
> > Intended to work only on RHEL 7.4 (kernel version 3.10.0-693.yy.zz).
> > This patch allows multiple kernel version numbers delimited by
> > whitespace to be passed as variable "kversion". The result RPM packages
> > the kernel module .ko files from all specified kernel versions. For
> > example,
> > 
> > make rpm-fedora-kmod \
> > RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 \
> > 3.10.0-693.17.1.el7.x86_64"'
> > 
> > By default, make tries to build against the current running kernel.
> > 
> > This patch also includes a script to update the weak-update symlinks
> > if the system kernel version is upgraded or downgraded after
> > openvswitch-kmod is installed.
> > 
> > Signed-off-by: Martin Xu 
> > CC: Greg Rose 
> > CC: Flavio Leitner 
> > ---
> 
> LGTM, though I have not tested.
> Acked-by: Flavio Leitner 

Thanks, applied to master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] rhel: support kmod build against mulitple kernel versions, fedora

2018-08-21 Thread Flavio Leitner
On Mon, Aug 20, 2018 at 02:24:05PM -0700, Martin Xu wrote:
> This patch ports changes from kmod rhel6 spec file to fedora spec file,
> to support packaging kernel modules built against multiple versions of
> kernel sources.
> 
> RHEL 7.4 introduced backward incompatible changes in the kernel. As
> a result, prebuilt PRM packages against kernels newer than 693.17.1
> will cannot be used on systems with older kernels, vice versa.
> 
> Intended to work only on RHEL 7.4 (kernel version 3.10.0-693.yy.zz).
> This patch allows multiple kernel version numbers delimited by
> whitespace to be passed as variable "kversion". The result RPM packages
> the kernel module .ko files from all specified kernel versions. For
> example,
> 
> make rpm-fedora-kmod \
> RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 \
> 3.10.0-693.17.1.el7.x86_64"'
> 
> By default, make tries to build against the current running kernel.
> 
> This patch also includes a script to update the weak-update symlinks
> if the system kernel version is upgraded or downgraded after
> openvswitch-kmod is installed.
> 
> Signed-off-by: Martin Xu 
> CC: Greg Rose 
> CC: Flavio Leitner 
> ---

LGTM, though I have not tested.
Acked-by: Flavio Leitner 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3] rhel: support kmod build against mulitple kernel versions, fedora

2018-08-20 Thread Martin Xu
This patch ports changes from kmod rhel6 spec file to fedora spec file,
to support packaging kernel modules built against multiple versions of
kernel sources.

RHEL 7.4 introduced backward incompatible changes in the kernel. As
a result, prebuilt PRM packages against kernels newer than 693.17.1
will cannot be used on systems with older kernels, vice versa.

Intended to work only on RHEL 7.4 (kernel version 3.10.0-693.yy.zz).
This patch allows multiple kernel version numbers delimited by
whitespace to be passed as variable "kversion". The result RPM packages
the kernel module .ko files from all specified kernel versions. For
example,

make rpm-fedora-kmod \
RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 \
3.10.0-693.17.1.el7.x86_64"'

By default, make tries to build against the current running kernel.

This patch also includes a script to update the weak-update symlinks
if the system kernel version is upgraded or downgraded after
openvswitch-kmod is installed.

Signed-off-by: Martin Xu 
CC: Greg Rose 
CC: Flavio Leitner 
---
v1->v2: fix a bug in v1. v1 removed the if condition (erase but not upgrade)
in postun section by mistake. Without the if condition, the upgrade would also
remove the symlinks created in weak-updates created by the newer version.
v2->v3: added some comments for the use of kversion macro in fedora spec file;
removed "Obsoletes: kmod-openvswitch"; also incorporated change for
rhel7.2 change in rhel6 spec file in the %post section

 rhel/openvswitch-kmod-fedora.spec.in | 93 
 1 file changed, 62 insertions(+), 31 deletions(-)

diff --git a/rhel/openvswitch-kmod-fedora.spec.in 
b/rhel/openvswitch-kmod-fedora.spec.in
index c0cd298..dc5ea7a 100644
--- a/rhel/openvswitch-kmod-fedora.spec.in
+++ b/rhel/openvswitch-kmod-fedora.spec.in
@@ -1,6 +1,6 @@
 # Spec file for Open vSwitch.
 
-# Copyright (C) 2009, 2010, 2015 Nicira Networks, Inc.
+# Copyright (C) 2009, 2010, 2015, 2018 Nicira Networks, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -9,6 +9,12 @@
 
 %global debug_package %{nil}
 
+# Use the kversion macro such as
+# RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 
3.10.0-693.17.1.el7.x86_64"'
+# to build package for mulitple kernel versions in the same package
+# This only works for kernel 3.10.0 major revision 693 (RHEL 7.4)
+# and major revision 327 (RHEL 7.2)
+# By default, build against the current running kernel version
 #%define kernel 3.1.5-1.fc16.x86_64
 #define kernel %{kernel_source}
 %{?kversion:%define kernel %kversion}
@@ -26,6 +32,8 @@ Release: 1%{?dist}
 Source: openvswitch-%{version}.tar.gz
 #Source1: openvswitch-init
 Buildroot: /tmp/openvswitch-xen-rpm
+Provides: kmod-openvswitch
+Conflicts: kmod-openvswitch
 
 %description
 Open vSwitch provides standard network bridging functions augmented with
@@ -36,55 +44,78 @@ traffic. This package contains the kernel modules.
 %setup -q -n openvswitch-%{version}
 
 %build
-%configure --with-linux=/lib/modules/%{kernel}/build --enable-ssl
-make %{_smp_mflags} -C datapath/linux
+for kv in %{kversion}; do
+mkdir -p _$kv
+(cd _$kv && /bin/cp -f ../configure . && %configure --srcdir=.. \
+--with-linux=/usr/src/kernels/${kv}/ --enable-ssl)
+make %{_smp_mflags} -C _$kv/datapath/linux
+done
 
 %install
+export INSTALL_MOD_DIR=extra/openvswitch
 rm -rf $RPM_BUILD_ROOT
-make INSTALL_MOD_PATH=$RPM_BUILD_ROOT -C datapath/linux modules_install
+for kv in %{kversion}; do
+make INSTALL_MOD_PATH=$RPM_BUILD_ROOT -C _$kv/datapath/linux 
modules_install
+done
 mkdir -p $RPM_BUILD_ROOT/etc/depmod.d
-for module in $RPM_BUILD_ROOT/lib/modules/%{kernel}/extra/*.ko
-do
-modname="$(basename ${module})"
-echo "override ${modname%.ko} * extra" >> \
-$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
-echo "override ${modname%.ko} * weak-updates" >> \
-$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
+for kv in %{kversion}; do
+for module in $RPM_BUILD_ROOT/lib/modules/${kv}/extra/openvswitch/*.ko
+do
+modname="$(basename ${module})"
+grep -qsPo "^\s*override ${modname%.ko} \* extra\/openvwitch" \
+$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf || \
+echo "override ${modname%.ko} * extra/openvswitch" >> \
+$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
+grep -qsPo "^\s*override ${modname%.ko} \* weak-updates\/openvwitch" \
+$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf || \
+echo "override ${modname%.ko} * weak-updates/openvswitch" >> \
+$RPM_BUILD_ROOT/etc/depmod.d/kmod-openvswitch.conf
+done
 done
+install -d -m 0755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
+install -p -m 0755 rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh \
+$RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-kmod-manage.sh