Skip to content

Commit

Permalink
Use macro value for conditional build instead of bcond
Browse files Browse the repository at this point in the history
Use `%{with_python}` macro to enable/disable building python bluechi
module. By default building of the bluechi python module is enabled,
to disable it pass `--define "with_python 0"` to rpmbuild.

Fixes: #396
Signed-off-by: Martin Perina <[email protected]>
  • Loading branch information
mwperina authored and dougsland committed Aug 19, 2023
1 parent 0af9896 commit 86462a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 2 additions & 4 deletions README.developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,10 @@ The package build process can be adjusted using following environment variables:

- `ARTIFACTS_DIR`
- A full path to a directory where the RPMs will be saved. The script will create the directory if it does not exist.
- `BUILD_RPM_OPTS`
- Additional options passed to RPM creation, following options are available:
- `--without python`
- Disable building of python bluechi module RPM package
- `SKIP_BUILDDEP`
- To skip installation of build dependencies this option should contain `yes` value.
- `WITH_PYTHON`
- To skip building python bluechi modules this option should contain `0`.

So for example following command will skip build dependencies installation and store create RPM packages into `output`
subdirectory:
Expand Down
20 changes: 11 additions & 9 deletions bluechi.spec.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# python bluechi module is enabled by default, it can be disabled passing `--without python` option to rpmbuild
%bcond_without python
# python bluechi module is enabled by default, it can be disabled passing `--define "with_python 0"` option to rpmbuild
%if 0%{!?with_python:1}
%global with_python 1
%endif


Name: bluechi
Expand Down Expand Up @@ -175,7 +177,7 @@ This package contains the service controller command line tool.
%{_bindir}/bluechictl
%{_mandir}/man1/bluechictl.*

%if %{with python}
%if %{with_python}
%package -n python3-bluechi
Summary: Python bindings for BlueChi
BuildRequires: python3-devel
Expand All @@ -200,23 +202,23 @@ API description and manually written code to simplify recurring tasks.
%prep
%autosetup

%if %{with python}
cp -r src/bindings/python/* ./
%endif

%build
%meson -Dapi_bus=system
%meson_build

%if %{with python}
%if %{with_python}
pushd src/bindings/python
%py3_build
popd
%endif

%install
%meson_install

%if %{with python}
%if %{with_python}
pushd src/bindings/python
%py3_install
popd
%endif

%check
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi
rpmbuild \
--define "_topmdir rpmbuild" \
--define "_rpmdir rpmbuild" \
${BUILD_RPM_OPTS} \
--define "with_python ${WITH_PYTHON:=1}" \
--rebuild rpmbuild/SRPMS/*src.rpm

# Move RPMs to exported artifacts
Expand Down

0 comments on commit 86462a0

Please sign in to comment.