Skip to content

Commit

Permalink
Add conditional build for offline/online builds (#1616)
Browse files Browse the repository at this point in the history
Instead of autoconf swapping in a 0 or 1 for a `%define` variable
in the `spec.in` file for `OFFLINE_BUILD`, add a conditional build.
See [1] for how they work.

With a conditional build, source rpms retain the ability to build with
different options depending on how `rpmbuild` is called.  This allows
an offline (using `ovirt-engine-nodejs-modules`) or online (using
`yarn install`) build from srpm to be selected at build time using
`--with` or `--without` build options.

Since at least copr builds chroots directly from a srpm, conditional
builds can be used to change build options.  With this change, an
"online build" can be enabled simply by configuring the target chroot
setting "without" to include "ovirt_use_nodejs_modules".

Notes:
  - An offline build with `ovirt-engine-nodejs-modules` is the default

  - An online build using standard `yarn install` can be achieved by
    using `--without ovirt_use_nodejs_modules` on the call to rpmbuild

  - Setting env var `OFFLINE_BUILD=0` when calling `make rpm` will
    add the `--without` option, and run an offline build.  This is
    the same behavior as previous.

[1] - https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
  • Loading branch information
sjd78 authored Jul 22, 2022
1 parent e297a79 commit b99a94d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ TMPREPOS = tmp.repos
RPMBUILD_ARGS :=
RPMBUILD_ARGS += --define="_topdir `pwd`/$(TMPREPOS)"
RPMBUILD_ARGS += $(if $(RELEASE_SUFFIX), --define="release_suffix $$RELEASE_SUFFIX")
RPMBUILD_ARGS += $(if $(filter 0,$(OFFLINE_BUILD)), --without ovirt_use_nodejs_modules)

srpm: dist-gzip
rm -fr "$(TMPREPOS)"
Expand Down
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ dnl TODO: Fail if rpmbuild is not present
PACKAGE_RPM_SUFFIX=${PACKAGE_RPM_SUFFIX:-"%{?release_suffix}"}
AC_ARG_VAR([PACKAGE_RPM_SUFFIX], [suffix to use on the rpm's release string])

OFFLINE_BUILD=${OFFLINE_BUILD:-1}
AC_ARG_VAR([OFFLINE_BUILD], [control if rpm builds will use an offline build via ovirt-engine-nodejs-modules (1) or should use an online build (0)])

AC_CONFIG_FILES([
Makefile
ovirt-web-ui.spec
Expand Down
11 changes: 8 additions & 3 deletions ovirt-web-ui.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
%global product oVirt
%global source_basename @PACKAGE_TARNAME@
%define debug_package %{nil}
%define offline_build @OFFLINE_BUILD@

# build condition `ovirt_use_nodejs_modules`
# - on by default, requires a build with `--without ovirt_use_nodejs_modules` to turn off
# - if on, the build uses `ovirt-engine-nodejs-modules`
# - if off, the build uses standard `yarn` accessing all node_modules packages directly
%bcond_without ovirt_use_nodejs_modules

Name: ovirt-web-ui
Version: @PACKAGE_RPM_VERSION@
Expand All @@ -23,7 +28,7 @@ BuildRequires: rpm-build
# requirements for building the rpm from src.rpm
BuildRequires: autoconf
BuildRequires: automake
%if %{offline_build}
%if %{with ovirt_use_nodejs_modules}
# nodejs-modules embeds yarn and requires nodejs
BuildRequires: ovirt-engine-nodejs-modules >= 2.3.2
%else
Expand All @@ -40,7 +45,7 @@ This package provides the VM Portal for %{product}.
%build
%configure
export SKIP_AUTOGEN=1
%if %{offline_build}
%if %{with ovirt_use_nodejs_modules}
rpm -qa | grep ovirt-engine-nodejs
source /usr/share/ovirt-engine-nodejs-modules/setup-env.sh
%else
Expand Down

0 comments on commit b99a94d

Please sign in to comment.