diff mbox

[ovs-dev,1/1] rpm: Update rhel/automake.mk to build via mock

Message ID 1465330994-21340-1-git-send-email-lmadsen@redhat.com
State Changes Requested
Headers show

Commit Message

Leif Madsen June 7, 2016, 8:23 p.m. UTC
Provides changes to the automake.mk file in the rhel/ directory to utilize mock
instead of rpmbuild for the rpm-fedora build target. The usage of mock provides
an isolated environment for building packages, and makes things reproducible in
various environment by relying on the spec file for a list of dependencies to
install.

Documentation has been updated to reflect this change by noting that mock is a
package dependency.

It has also been noted that the existing package list for buil dependencies
remains unchanged for now, as the kmod packages are still utilizing rpmbuild. A
submission in the future will update the rpm-fedora-kmod build target to work
in a similar manner to what is being provided here.

Signed-off-by: Leif Madsen <lmadsen@redhat.com>
---
 AUTHORS           |  1 +
 INSTALL.Fedora.md | 19 ++++++++++++++++---
 rhel/automake.mk  | 15 ++++++++++++---
 3 files changed, 29 insertions(+), 6 deletions(-)

Comments

Ben Pfaff June 23, 2016, 9:48 p.m. UTC | #1
Russell or Flavio, would you mind reviewing this?  It seems like a
plausible patch to me but I am no judge of RPMs.

On Tue, Jun 07, 2016 at 04:23:14PM -0400, Leif Madsen wrote:
> Provides changes to the automake.mk file in the rhel/ directory to utilize mock
> instead of rpmbuild for the rpm-fedora build target. The usage of mock provides
> an isolated environment for building packages, and makes things reproducible in
> various environment by relying on the spec file for a list of dependencies to
> install.
> 
> Documentation has been updated to reflect this change by noting that mock is a
> package dependency.
> 
> It has also been noted that the existing package list for buil dependencies
> remains unchanged for now, as the kmod packages are still utilizing rpmbuild. A
> submission in the future will update the rpm-fedora-kmod build target to work
> in a similar manner to what is being provided here.
> 
> Signed-off-by: Leif Madsen <lmadsen@redhat.com>
> ---
>  AUTHORS           |  1 +
>  INSTALL.Fedora.md | 19 ++++++++++++++++---
>  rhel/automake.mk  | 15 ++++++++++++---
>  3 files changed, 29 insertions(+), 6 deletions(-)
> 
> diff --git a/AUTHORS b/AUTHORS
> index 9fda4c1..18c1d3a 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -133,6 +133,7 @@ Kyle Upton              kupton@baymicrosystems.com
>  Lance Richardson        lrichard@redhat.com
>  Lars Kellogg-Stedman    lars@redhat.com
>  Lei Huang               huang.f.lei@gmail.com
> +Leif Madsen             lmadsen@redhat.com
>  Leo Alterman            lalterman@nicira.com
>  Lilijun                 jerry.lilijun@huawei.com
>  Linda Sun               lsun@vmware.com
> diff --git a/INSTALL.Fedora.md b/INSTALL.Fedora.md
> index 12d9a72..5fff636 100644
> --- a/INSTALL.Fedora.md
> +++ b/INSTALL.Fedora.md
> @@ -12,8 +12,13 @@ for RHEL 7.x and its derivatives, including CentOS 7.x and Scientific Linux
>  
>  Build Requirements
>  ------------------
> -The tools and packages that are required for building Open vSwitch are
> -documented in [INSTALL.md]. Specific packages (by package name) include:
> +The only package required for building Open vSwitch is `mock` as all
> +dependencies will be automatically installed from the package list within the
> +RPM spec files. The tools and packages that are required for building Open vSwitch are
> +documented in [INSTALL.md].
> +
> +However, to build the kmod packages require the following specific packages
> +(by package name):
>  
>    - rpm-build
>    - autoconf automake libtool
> @@ -57,7 +62,8 @@ cd openvswitch-x.y.z
>  ### Building the User-Space RPMs
>  To build Open vSwitch user-space RPMs, after having completed the appropriate
>  preparation steps described above, execute the following from the directory
> -in which `./configure` was executed:
> +in which `./configure` was executed. The build will be done within `mock`,
> +allowing for reproducible builds in an isolated environment.
>  
>  ```
>  make rpm-fedora
> @@ -68,6 +74,13 @@ This will create the RPMs `openvswitch`, `python-openvswitch`,
>  `openvswitch-ovn-central`, `openvswitch-ovn-host`, `openvswitch-ovn-vtep`,
>  `openvswitch-ovn-docker`, and `openvswitch-debuginfo`.
>  
> +The default build root is Fedora 23 x86_64 (/etc/mock/fedora-23-x86_64.cfg). To
> +change the default build root you can pass RPMBUILD_ROOT environment variable:
> +
> +```
> +make rpm-fedora RPMBUILD_ROOT="epel-7-x86_64"
> +```
> +
>  To enable DPDK support in the openvswitch package,
>  the `--with dpdk` option can be added:
>  
> diff --git a/rhel/automake.mk b/rhel/automake.mk
> index dc30715..97d2117 100644
> --- a/rhel/automake.mk
> +++ b/rhel/automake.mk
> @@ -52,14 +52,23 @@ $(srcdir)/rhel/openvswitch-fedora.spec: rhel/openvswitch-fedora.spec.in $(top_bu
>  	$(update_rhel_spec)
>  
>  RPMBUILD_TOP := $(abs_top_builddir)/rpm/rpmbuild
> +RPMBUILD_ROOT := fedora-23-x86_64
>  
>  # Build user-space RPMs
>  rpm-fedora: dist $(srcdir)/rhel/openvswitch-fedora.spec
>  	${MKDIR_P} ${RPMBUILD_TOP}/SOURCES
>  	cp ${DIST_ARCHIVES} ${RPMBUILD_TOP}/SOURCES
> -	rpmbuild ${RPMBUILD_OPT} \
> -                 -D "_topdir ${RPMBUILD_TOP}" \
> -                 -bb $(srcdir)/rhel/openvswitch-fedora.spec
> +	mock --root ${RPMBUILD_ROOT} \
> +                --dnf \
> +                --spec $(srcdir)/rhel/openvswitch-fedora.spec \
> +                --sources=${RPMBUILD_TOP}/SOURCES  \
> +                --resultdir=${RPMBUILD_TOP}/SRPMS \
> +                --buildsrpm
> +	mock --root ${RPMBUILD_ROOT} ${RPMBUILD_OPT} \
> +                --dnf --define "_topdir ${RPMBUILD_TOP}" \
> +                --rebuild \
> +                --resultdir=${RPMBUILD_TOP}/RPMS \
> +                ${RPMBUILD_TOP}/SRPMS/openvswitch-$(VERSION)*.src.rpm
>  
>  # Build kernel datapath RPM
>  rpm-fedora-kmod: dist $(srcdir)/rhel/openvswitch-kmod-fedora.spec
> -- 
> 2.5.5
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Flavio Leitner June 23, 2016, 11:23 p.m. UTC | #2
On Tue, Jun 07, 2016 at 04:23:14PM -0400, Leif Madsen wrote:
> Provides changes to the automake.mk file in the rhel/ directory to utilize mock
> instead of rpmbuild for the rpm-fedora build target. The usage of mock provides
> an isolated environment for building packages, and makes things reproducible in
> various environment by relying on the spec file for a list of dependencies to
> install.
> 
> Documentation has been updated to reflect this change by noting that mock is a
> package dependency.
> 
> It has also been noted that the existing package list for buil dependencies
> remains unchanged for now, as the kmod packages are still utilizing rpmbuild. A
> submission in the future will update the rpm-fedora-kmod build target to work
> in a similar manner to what is being provided here.

Although the idea is nice, it doesn't seem like a good idea to force
everyone to install mock and download all dependencies when we can go
ahead and just build.

Perhaps it is possible to have a variable to select mock, e.g.:
make rpm-fedora MOCK_ROOT="epel-7-x86_64"
and that would use mock to build.

Or even a new target:
make rpm-mock-fedora MOCK_ROOT="epel-7-x86_64"

What do you think?

Thanks,
Russell Bryant June 24, 2016, 12:41 p.m. UTC | #3
Thanks for the patch!

I appreciate the attention to detail in your first patch to OVS: including
Signed-off-by, updating AUTHORS, and updating documentation for your
changes.  Thanks!

I have one minor nit that could be addressed while you're updating this to
account for Flavio's feedback.

On Tue, Jun 7, 2016 at 4:23 PM, Leif Madsen <lmadsen@redhat.com> wrote:

> Provides changes to the automake.mk file in the rhel/ directory to
> utilize mock
> instead of rpmbuild for the rpm-fedora build target. The usage of mock
> provides
> an isolated environment for building packages, and makes things
> reproducible in
> various environment by relying on the spec file for a list of dependencies
> to
> install.
>
> Documentation has been updated to reflect this change by noting that mock
> is a
> package dependency.
>
> It has also been noted that the existing package list for buil dependencies
> remains unchanged for now, as the kmod packages are still utilizing
> rpmbuild. A
> submission in the future will update the rpm-fedora-kmod build target to
> work
> in a similar manner to what is being provided here.
>
> Signed-off-by: Leif Madsen <lmadsen@redhat.com>
> ---
>  AUTHORS           |  1 +
>  INSTALL.Fedora.md | 19 ++++++++++++++++---
>  rhel/automake.mk  | 15 ++++++++++++---
>  3 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/AUTHORS b/AUTHORS
> index 9fda4c1..18c1d3a 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -133,6 +133,7 @@ Kyle Upton              kupton@baymicrosystems.com
>  Lance Richardson        lrichard@redhat.com
>  Lars Kellogg-Stedman    lars@redhat.com
>  Lei Huang               huang.f.lei@gmail.com
> +Leif Madsen             lmadsen@redhat.com
>  Leo Alterman            lalterman@nicira.com
>  Lilijun                 jerry.lilijun@huawei.com
>  Linda Sun               lsun@vmware.com
> diff --git a/INSTALL.Fedora.md b/INSTALL.Fedora.md
> index 12d9a72..5fff636 100644
> --- a/INSTALL.Fedora.md
> +++ b/INSTALL.Fedora.md
> @@ -12,8 +12,13 @@ for RHEL 7.x and its derivatives, including CentOS 7.x
> and Scientific Linux
>
>  Build Requirements
>  ------------------
> -The tools and packages that are required for building Open vSwitch are
> -documented in [INSTALL.md]. Specific packages (by package name) include:
> +The only package required for building Open vSwitch is `mock` as all
> +dependencies will be automatically installed from the package list within
> the
> +RPM spec files. The tools and packages that are required for building
> Open vSwitch are
> +documented in [INSTALL.md].
> +
> +However, to build the kmod packages require the following specific
> packages
>

This sentence is a little awkward.  Changing "require" to "requires" may be
enough.  We could also make it "building the kmod packages requires ...".

Flavio's feedback to still retain the option to run rpmbuild directly via a
separate makefile target seems reasonable, as well.
diff mbox

Patch

diff --git a/AUTHORS b/AUTHORS
index 9fda4c1..18c1d3a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -133,6 +133,7 @@  Kyle Upton              kupton@baymicrosystems.com
 Lance Richardson        lrichard@redhat.com
 Lars Kellogg-Stedman    lars@redhat.com
 Lei Huang               huang.f.lei@gmail.com
+Leif Madsen             lmadsen@redhat.com
 Leo Alterman            lalterman@nicira.com
 Lilijun                 jerry.lilijun@huawei.com
 Linda Sun               lsun@vmware.com
diff --git a/INSTALL.Fedora.md b/INSTALL.Fedora.md
index 12d9a72..5fff636 100644
--- a/INSTALL.Fedora.md
+++ b/INSTALL.Fedora.md
@@ -12,8 +12,13 @@  for RHEL 7.x and its derivatives, including CentOS 7.x and Scientific Linux
 
 Build Requirements
 ------------------
-The tools and packages that are required for building Open vSwitch are
-documented in [INSTALL.md]. Specific packages (by package name) include:
+The only package required for building Open vSwitch is `mock` as all
+dependencies will be automatically installed from the package list within the
+RPM spec files. The tools and packages that are required for building Open vSwitch are
+documented in [INSTALL.md].
+
+However, to build the kmod packages require the following specific packages
+(by package name):
 
   - rpm-build
   - autoconf automake libtool
@@ -57,7 +62,8 @@  cd openvswitch-x.y.z
 ### Building the User-Space RPMs
 To build Open vSwitch user-space RPMs, after having completed the appropriate
 preparation steps described above, execute the following from the directory
-in which `./configure` was executed:
+in which `./configure` was executed. The build will be done within `mock`,
+allowing for reproducible builds in an isolated environment.
 
 ```
 make rpm-fedora
@@ -68,6 +74,13 @@  This will create the RPMs `openvswitch`, `python-openvswitch`,
 `openvswitch-ovn-central`, `openvswitch-ovn-host`, `openvswitch-ovn-vtep`,
 `openvswitch-ovn-docker`, and `openvswitch-debuginfo`.
 
+The default build root is Fedora 23 x86_64 (/etc/mock/fedora-23-x86_64.cfg). To
+change the default build root you can pass RPMBUILD_ROOT environment variable:
+
+```
+make rpm-fedora RPMBUILD_ROOT="epel-7-x86_64"
+```
+
 To enable DPDK support in the openvswitch package,
 the `--with dpdk` option can be added:
 
diff --git a/rhel/automake.mk b/rhel/automake.mk
index dc30715..97d2117 100644
--- a/rhel/automake.mk
+++ b/rhel/automake.mk
@@ -52,14 +52,23 @@  $(srcdir)/rhel/openvswitch-fedora.spec: rhel/openvswitch-fedora.spec.in $(top_bu
 	$(update_rhel_spec)
 
 RPMBUILD_TOP := $(abs_top_builddir)/rpm/rpmbuild
+RPMBUILD_ROOT := fedora-23-x86_64
 
 # Build user-space RPMs
 rpm-fedora: dist $(srcdir)/rhel/openvswitch-fedora.spec
 	${MKDIR_P} ${RPMBUILD_TOP}/SOURCES
 	cp ${DIST_ARCHIVES} ${RPMBUILD_TOP}/SOURCES
-	rpmbuild ${RPMBUILD_OPT} \
-                 -D "_topdir ${RPMBUILD_TOP}" \
-                 -bb $(srcdir)/rhel/openvswitch-fedora.spec
+	mock --root ${RPMBUILD_ROOT} \
+                --dnf \
+                --spec $(srcdir)/rhel/openvswitch-fedora.spec \
+                --sources=${RPMBUILD_TOP}/SOURCES  \
+                --resultdir=${RPMBUILD_TOP}/SRPMS \
+                --buildsrpm
+	mock --root ${RPMBUILD_ROOT} ${RPMBUILD_OPT} \
+                --dnf --define "_topdir ${RPMBUILD_TOP}" \
+                --rebuild \
+                --resultdir=${RPMBUILD_TOP}/RPMS \
+                ${RPMBUILD_TOP}/SRPMS/openvswitch-$(VERSION)*.src.rpm
 
 # Build kernel datapath RPM
 rpm-fedora-kmod: dist $(srcdir)/rhel/openvswitch-kmod-fedora.spec