#6 Switch conditions from %global to %bcond
Opened 3 months ago by lbalhar. Modified 3 months ago
rpms/ lbalhar/mod_wsgi master  into  master

file modified
+14 -14

@@ -7,15 +7,15 @@ 

  %{!?_httpd_moddir:    %{expand: %%global _httpd_moddir    %%{_libdir}/httpd/modules}}

  

  %if 0%{?fedora} || 0%{?rhel} > 7

- %global with_python3 1

+ %bcond_without python3

  %else

- %global with_python3 0

+ %bcond_with python3

  %endif

  

  %if (0%{?fedora} > 0 && 0%{?fedora} < 32) || (0%{?rhel} > 0 && 0%{?rhel} <= 7)

- %global with_python2 1

+ %bcond_without python2

  %else

- %global with_python2 0

+ %bcond_with python2

  %global debug_package %{nil}

  %endif

  

@@ -47,7 +47,7 @@ 

  

  %description %_description

  

- %if 0%{?with_python2} > 0

+ %if %{with python2}

  %package -n python2-%{name}

  Summary: %summary

  Requires:       httpd-mmn = %{_httpd_mmn}

@@ -62,12 +62,12 @@ 

  

  %endif

  

- %if 0%{?with_python3} > 0

+ %if %{with python3}

  %package -n python3-%{name}

  Summary:        %summary

  Requires:       httpd-mmn = %{_httpd_mmn}

  BuildRequires:  python3-devel, python3-sphinx, python3-sphinx_rtd_theme

- %if 0%{?with_python2} == 0

+ %if !%{with python2}

  Provides: mod_wsgi = %{version}-%{release}

  Provides: mod_wsgi%{?_isa} = %{version}-%{release}

  Obsoletes: mod_wsgi < %{version}-%{release}

@@ -83,14 +83,14 @@ 

  : Python2=%{with_python2} Python3=%{with_python3}

  

  %build

- %if %{with_python3}

+ %if %{with python3}

  make -C docs html SPHINXBUILD=%{_bindir}/sphinx-build-3

  %endif

  

  export LDFLAGS="$RPM_LD_FLAGS -L%{_libdir}"

  export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"

  

- %if 0%{?with_python3} > 0

+ %if %{with python3}

  mkdir py3build/

  # this always produces an error (because of trying to copy py3build

  # into itself) but we don't mind, so || :

@@ -102,7 +102,7 @@ 

  popd

  %endif

  

- %if 0%{?with_python2} > 0

+ %if %{with python2}

  %configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python2

  make %{?_smp_mflags}

  %py2_build

@@ -110,7 +110,7 @@ 

  

  %install

  # first install python3 variant and rename the so file

- %if 0%{?with_python3} > 0

+ %if %{with python3}

  pushd py3build

  make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir}

  mv  $RPM_BUILD_ROOT%{_httpd_moddir}/mod_wsgi{,_python3}.so

@@ -126,7 +126,7 @@ 

  %endif

  

  # second install python2 variant

- %if 0%{?with_python2} > 0

+ %if %{with python2}

  make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir}

  

  install -d -m 755 $RPM_BUILD_ROOT%{_httpd_modconfdir}

@@ -138,7 +138,7 @@ 

  ln -s %{_bindir}/mod_wsgi-express-2 $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express

  %endif

  

- %if 0%{?with_python2} > 0

+ %if %{with python2}

  %files -n python2-%{name}

  %license LICENSE

  %doc CREDITS.rst README.rst

@@ -150,7 +150,7 @@ 

  %{_bindir}/mod_wsgi-express

  %endif

  

- %if 0%{?with_python3} > 0

+ %if %{with python3}

  %files -n python3-%{name}

  %license LICENSE

  %doc CREDITS.rst README.rst

The big advantage of bconds is that they can be adjusted outside of the specfile for example when the package is a part of module.

Scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=39082578