File apache2-mod_wsgi.spec of Package apache2-mod_wsgi

#
# spec file for package apache2-mod_wsgi
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define modname        mod_wsgi
%define apache_branch  %(rpm -q --qf %%{version} apache2 | grep -E -o "2\\.[0-9]+")

%if "%{apache_branch}" == "2.4"
  %define bindir %{_bindir}
%else
  %define bindir %{_sbindir}
%endif

%if 0%{?suse_version}
%define apxs %{bindir}/apxs2
%else
%define apxs %{bindir}/apxs
%endif

%define apache apache2
%define apache_serverroot %(%{apxs} -q PREFIX)
%define apache_includedir %(%{apxs} -q INCLUDEDIR)
%define apache_libexecdir %(%{apxs} -q LIBEXECDIR)

%if 0%{?suse_version}
%define apache_sysconfdir %(%{apxs} -q SYSCONFDIR)
%else
%define apache_sysconfdir %(%{apxs} -q PREFIX)
%endif

%define apache_localstatedir %(%{apxs} -q LOCALSTATEDIR)
%define apache_mmn        %(MMN=$(%{apxs} -q LIBEXECDIR)_MMN; test -x $MMN && $MMN)

Name:           apache2-mod_wsgi
Summary:        Python WSGI adapter module for Apache
License:        Apache-2.0
Group:          Productivity/Networking/Web/Servers
Version:        4.2.5
Release:        0
Url:            https://github.com/GrahamDumpleton/mod_wsgi
#Source:        https://github.com/GrahamDumpleton/mod_wsgi/archive/%{version}.tar.gz
Source:         %{modname}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

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

%if 0%{?suse_version}
BuildRequires:  apache2-devel
%else
BuildRequires:  httpd
BuildRequires:  httpd-devel
%endif
BuildRequires:  python-devel

%if 0%{?suse_version}
Requires:       apache2
%else
Requires:       httpd
%endif

%description
The aim of mod_wsgi is to implement a simple to use Apache module which can
host any Python application which supports the Python WSGI interface.

%prep
%setup -n %{modname}-%{version}

%build
export CFLAGS="%{optflags} -fno-strict-aliasing"
%configure \
%if 0%{?suse_version}
    --with-apxs="%{apxs}-prefork" \
%else
    --with-apxs="%{apxs}" \
%endif
    --with-python="python"
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot} LIBEXECDIR=%{apache_libexecdir}

%post
%if 0%{?suse_version}
if ! %{_sbindir}/a2enmod -q wsgi; then
  %{_sbindir}/a2enmod wsgi
fi
%endif

%postun
%if 0%{?suse_version}
if [ "$1" = "0" ]; then
  if a2enmod -q wsgi; then
    %{_sbindir}/a2enmod -d wsgi
  fi
fi
%endif

%files
%defattr(-,root,root)
%doc LICENCE README.rst docs/release-notes
%dir %{apache_libexecdir}
%{apache_libexecdir}/%{modname}.so

%changelog
openSUSE Build Service is sponsored by