[ovs-dev] [PATCH] xenserver: Simplify RPM build instructions.

Ben Pfaff blp at nicira.com
Fri Feb 3 00:38:34 UTC 2012


I got tired of trying to follow them properly myself.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 INSTALL.XenServer                                  |   53 +++++++++++++-------
 rhel/automake.mk                                   |   10 ++--
 xenserver/automake.mk                              |    9 +++-
 xenserver/openvswitch-xen.spec                     |   11 ++++
 ...penvswitch-xen.spec => openvswitch-xen.spec.in} |   11 ++++
 5 files changed, 70 insertions(+), 24 deletions(-)
 copy xenserver/{openvswitch-xen.spec => openvswitch-xen.spec.in} (97%)

diff --git a/INSTALL.XenServer b/INSTALL.XenServer
index 827a840..02c9a66 100644
--- a/INSTALL.XenServer
+++ b/INSTALL.XenServer
@@ -10,30 +10,51 @@ These instructions have been tested with XenServer 5.6 FP1.
 Building Open vSwitch for XenServer
 -----------------------------------
 
-The recommended build environment to build RPMs for Citrix XenServer
-is the DDK VM available from Citrix.  If you are building from an Open
-vSwitch distribution tarball, this VM has all the tools that you will
-need.  If you are building from an Open vSwitch Git tree, then you
-will need to first create a distribution tarball elsewhere, by running
-"./boot.sh; ./configure; make dist" in the Git tree, because the DDK
-VM does not include Autoconf or Automake that are required to
-bootstrap the Open vSwitch distribution.
-
-Once you have a distribution tarball, copy it into
-/usr/src/redhat/SOURCES inside the VM.  Then execute the following:
+You may build from an Open vSwitch distribution tarball or from an
+Open vSwitch Git tree.  The recommended build environment to build
+RPMs for Citrix XenServer is the DDK VM available from Citrix.
+
+1. If you are building from an Open vSwitch Git tree, then you will
+   need to first create a distribution tarball by running "./boot.sh;
+   ./configure; make dist" in the Git tree.  You cannot run this in
+   the DDK VM, because it lacks tools that are necessary to bootstrap
+   the Open vSwitch distribution.  Instead, you must run this on a
+   machine that has the tools listed in INSTALL.Linux as prerequisites
+   for building from a Git tree.
+
+2. Copy the distribution tarball into /usr/src/redhat/SOURCES inside
+   the DDK VM.
+
+3. In the DDK VM, unpack the distribution tarball into a temporary
+   directory and "cd" into the root of the distribution tarball.
+
+4. To build Open vSwitch userspace, run:
+
+       rpmbuild -bb xenserver/openvswitch-xen.spec
+
+   This produces three RPMs in /usr/src/redhat/RPMS/i386:
+   "openvswitch", "openvswitch-modules-xen", and
+   "openvswitch-debuginfo".
+
+Build Parameters
+----------------
+
+openvswitch-xen.spec needs to know a number of pieces of information
+about the XenServer kernel.  Usually, it can figure these out for
+itself, but if it does not do it correctly then you can specify them
+yourself as parameters to the build.  Thus, the final "rpmbuild" step
+above can be elaborated as:
 
    VERSION=<Open vSwitch version>
    KERNEL_NAME=<Xen Kernel name>
    KERNEL_VERSION=<Xen Kernel version>
    KERNEL_FLAVOR=<Xen Kernel flavor(suffix) >
-   cd /tmp
-   tar xfz /usr/src/redhat/SOURCES/openvswitch-$VERSION.tar.gz
    rpmbuild \
         -D "openvswitch_version $VERSION" \
         -D "kernel_name $KERNEL_NAME" \
         -D "kernel_version $KERNEL_VERSION" \
         -D "kernel_flavor $KERNEL_FLAVOR" \
-        -bb openvswitch-$VERSION/xenserver/openvswitch-xen.spec
+        -bb xenserver/openvswitch-xen.spec
 
 where:
 
@@ -52,10 +73,6 @@ where:
     The "xen" flavor is the main running kernel flavor and the "kdump" flavor is
     the crashdump kernel flavor. Commonly, one would specify "xen" here.
 
-Three RPMs will be output into /usr/src/redhat/RPMS/i386, whose names begin
-with "openvswitch", "openvswitch-modules-xen" (if building for kernel_flavor=xen),
-and "openvswitch-debuginfo".
-
 Installing Open vSwitch for XenServer
 -------------------------------------
 
diff --git a/rhel/automake.mk b/rhel/automake.mk
index 3682541..87c4552 100644
--- a/rhel/automake.mk
+++ b/rhel/automake.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
+# Copyright (C) 2009, 2010, 2011, 2012 Nicira Networks, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -21,16 +21,16 @@ EXTRA_DIST += \
 	rhel/openvswitch.spec.in \
 	rhel/usr_share_openvswitch_scripts_sysconfig.template
 
-update_spec = \
+update_rhel_spec = \
   ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
     < $(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-kmod-rhel5.spec: rhel/openvswitch-kmod-rhel5.spec.in $(top_builddir)/config.status
-	$(update_spec)
+	$(update_rhel_spec)
 
 $(srcdir)/rhel/openvswitch-kmod-rhel6.spec: rhel/openvswitch-kmod-rhel6.spec.in $(top_builddir)/config.status
-	$(update_spec)
+	$(update_rhel_spec)
 
 $(srcdir)/rhel/openvswitch.spec: rhel/openvswitch.spec.in $(top_builddir)/config.status
-	$(update_spec)
+	$(update_rhel_spec)
diff --git a/xenserver/automake.mk b/xenserver/automake.mk
index 02fc65f..133448d 100644
--- a/xenserver/automake.mk
+++ b/xenserver/automake.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
+# Copyright (C) 2009, 2010, 2011, 2012 Nicira Networks, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -17,6 +17,7 @@ EXTRA_DIST += \
 	xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \
 	xenserver/etc_xensource_scripts_vif \
 	xenserver/openvswitch-xen.spec \
+	xenserver/openvswitch-xen.spec.in \
 	xenserver/opt_xensource_libexec_InterfaceReconfigure.py \
 	xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \
 	xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
@@ -24,3 +25,9 @@ EXTRA_DIST += \
 	xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
 	xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
 	xenserver/usr_share_openvswitch_scripts_sysconfig.template
+
+$(srcdir)/xenserver/openvswitch-xen.spec: xenserver/openvswitch-xen.spec.in $(top_builddir)/config.status
+  ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
+    < $(srcdir)/xenserver/$(@F).in > $(@F).tmp || exit 1; \
+  if cmp -s $(@F).tmp $@; then touch $@; rm $(@F).tmp; else mv $(@F).tmp $@; fi
+
diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec
index 29c3c1f..4fbb425 100644
--- a/xenserver/openvswitch-xen.spec
+++ b/xenserver/openvswitch-xen.spec
@@ -19,6 +19,17 @@
 #      -D "build_number --with-build-number=123"
 #      -bb /usr/src/redhat/SPECS/openvswitch-xen.spec
 
+%if %{?openvswitch_version:0}%{!?openvswitch_version:1}
+%define openvswitch_version 1.5.90
+%endif
+
+%if %{?kernel_name:0}%{!?kernel_name:1}
+%define kernel %(rpm -qa 'kernel*xen-devel')
+%define kernel_name %(rpm -q --queryformat "%%{Name}" %{kernel} | sed 's/-devel//' | sed 's/kernel-//')
+%define kernel_version %(rpm -q --queryformat "%%{Version}-%%{Release}" %{kernel})
+%define kernel_flavor xen
+%endif
+
 %define xen_version %{kernel_version}%{kernel_flavor}
 
 # bump this when breaking compatibility with userspace
diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec.in
similarity index 97%
copy from xenserver/openvswitch-xen.spec
copy to xenserver/openvswitch-xen.spec.in
index 29c3c1f..7ab5af8 100644
--- a/xenserver/openvswitch-xen.spec
+++ b/xenserver/openvswitch-xen.spec.in
@@ -19,6 +19,17 @@
 #      -D "build_number --with-build-number=123"
 #      -bb /usr/src/redhat/SPECS/openvswitch-xen.spec
 
+%if %{?openvswitch_version:0}%{!?openvswitch_version:1}
+%define openvswitch_version @VERSION@
+%endif
+
+%if %{?kernel_name:0}%{!?kernel_name:1}
+%define kernel %(rpm -qa 'kernel*xen-devel' | head -1)
+%define kernel_name %(rpm -q --queryformat "%%{Name}" %{kernel} | sed 's/-devel//' | sed 's/kernel-//')
+%define kernel_version %(rpm -q --queryformat "%%{Version}-%%{Release}" %{kernel})
+%define kernel_flavor xen
+%endif
+
 %define xen_version %{kernel_version}%{kernel_flavor}
 
 # bump this when breaking compatibility with userspace
-- 
1.7.2.5




More information about the dev mailing list