From patchwork Fri Jul 20 22:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Xu X-Patchwork-Id: 947245 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X3eRgQBw"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41XQWW6mbLz9s55 for ; Sat, 21 Jul 2018 08:28:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7010BF32; Fri, 20 Jul 2018 22:25:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9C721F2B for ; Fri, 20 Jul 2018 22:25:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C0248E5 for ; Fri, 20 Jul 2018 22:25:28 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id b15-v6so12531269wrv.10 for ; Fri, 20 Jul 2018 15:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=qtTNgK0EvaThTykfvGKtdLbE6QGrchcH9mZpgDyJfdg=; b=X3eRgQBwvIX3tEVvHuIC1E40kPHkD59838XGoXviDEyyNu22JRd8H9b+oCjHTCfqdI 1Wh37+yrvvcQR4Ala1F/wgmlBOmV/FeGw3uQMoxz1mG4WNUprn3mTx873crcjV1/ie79 GUSl+qkq/c/XahB3SwfOzqo5Ibb5ASXgCx1eWAjXgGxphcmivk1q/ysnj2lGXsKbZdw4 9gcpk/g7tdvVj9kyvywJw06tQDoXESs4cZZ4zFLqACck2yleSDHEgAKL/dP8rAYsm8AF 6M24f7vN+MluFRTQCl1fYNizye+3gX16v/wZyJyfuJMMJRu1W8hJosk7Gi2kld8p64Pj 24aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qtTNgK0EvaThTykfvGKtdLbE6QGrchcH9mZpgDyJfdg=; b=F5XWICV1BJAI6F4CWYd73xB3ZsGOeqkB9TOQkk5nGNuW5x+EKVh1U9633DorVzKaXP 9MJSr2AkwKCBBwdsSHoylb+yJPLgIgx1W6b6OKi81Pxf1k3nwVvGfvWvMst1LrtcDFHM qymh15qxkDgy/CnDjmy9sxt9gpRMlryg2UCHBXnYkG9vJ7CH0jQwmmmWuJudLl5xl7/K cyp7iE/HGwbjuD7brPBwIDjXRg6R/EFSHTEVCRBK2P2Jdx2UBhm+QyUH/PBCINaeWx/H FLcbJk+27+VzfkFvnreWrWONpkgrwXrRao18Sj4BZvahmdehEJlxZ17io3O7jmHDptA7 j1EQ== X-Gm-Message-State: AOUpUlGliluGV0YHXrQEDG9H2jgxzuuE9FNruksuW/svZpikPzWF+vLm 5OUZNZqMamTu5QjK0OwborXvxn++ X-Google-Smtp-Source: AAOMgpcnNz5MW/q7gLYCJP11+d5724yR7YbH/P5GI7IcqM1pBpE+PjOAObucRigCssWtzSmF25752g== X-Received: by 2002:adf:aa0b:: with SMTP id p11-v6mr2483176wrd.220.1532125527084; Fri, 20 Jul 2018 15:25:27 -0700 (PDT) Received: from vm1-rhel74-local.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id v15-v6sm1889134wmc.16.2018.07.20.15.25.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 15:25:26 -0700 (PDT) From: Martin Xu To: dev@openvswitch.org Date: Fri, 20 Jul 2018 15:24:53 -0700 Message-Id: <1532125493-118514-1-git-send-email-martinxu9.ovs@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Flavio Leitner Subject: [ovs-dev] [PATCH v1] rhel: support kmod build against mulitple kernel versions, fedora X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- rhel/openvswitch-kmod-fedora.spec.in | 86 +++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/rhel/openvswitch-kmod-fedora.spec.in b/rhel/openvswitch-kmod-fedora.spec.in index c0cd298..24f8290 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 @@ -26,6 +26,9 @@ Release: 1%{?dist} Source: openvswitch-%{version}.tar.gz #Source1: openvswitch-init Buildroot: /tmp/openvswitch-xen-rpm +Provides: kmod-openvswitch +Conflicts: kmod-openvswitch +Obsoletes: kmod-openvswitch %description Open vSwitch provides standard network bridging functions augmented with @@ -36,55 +39,76 @@ 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 %clean rm -rf $RPM_BUILD_ROOT %post -# Ensure that modprobe will find our modules. -for k in $(cd /lib/modules && /bin/ls); do - [ -d "/lib/modules/$k/kernel/" ] && depmod -a "$k" -done -if [ -x "/sbin/weak-modules" ]; then - for m in openvswitch vport-gre vport-stt vport-geneve \ - vport-lisp vport-vxlan; do - echo "/lib/modules/%{kernel}/extra/$m.ko" - done | /sbin/weak-modules --add-modules -fi - -%postun -for k in $(cd /lib/modules && /bin/ls); do - [ -d "/lib/modules/$k/kernel/" ] && depmod -a "$k" -done -if [ "$1" = 0 ]; then # Erase, not upgrade +current_kernel=$(uname -r) +IFS=. read installed_major installed_minor installed_micro installed_arch \ + installed_build <<<"${current_kernel##*-}" +if [ "$installed_major" = "693" ]; then + # Workaround for RHEL 7.4 + if [ -x "/usr/share/openvswitch/scripts/ovs-kmod-manage.sh" ]; then + /usr/share/openvswitch/scripts/ovs-kmod-manage.sh + fi +else + # Ensure that modprobe will find our modules. + for k in $(cd /lib/modules && /bin/ls); do + [ -d "/lib/modules/$k/kernel/" ] && depmod -a "$k" + done if [ -x "/sbin/weak-modules" ]; then for m in openvswitch vport-gre vport-stt vport-geneve \ vport-lisp vport-vxlan; do - echo "/lib/modules/%{kernel}/extra/$m.ko" - done | /sbin/weak-modules --remove-modules + echo "/lib/modules/%{kernel}/extra/openvswitch/$m.ko" + done | /sbin/weak-modules --add-modules fi fi +%postun +for kname in `ls -d /lib/modules/*` +do + rm -rf $kname/weak-updates/openvswitch +done +/sbin/depmod -a + %files %defattr(0644,root,root) -/lib/modules/%{kernel}/extra/*.ko +/lib/modules/*/extra/openvswitch/*.ko /etc/depmod.d/kmod-openvswitch.conf -%exclude /lib/modules/%{kernel}/modules.* +%exclude /lib/modules/*/modules.* +%attr(755,root,root) /usr/share/openvswitch/scripts/ovs-kmod-manage.sh %changelog * Wed Sep 21 2011 Kyle Mestery