File yawn.spec of Package yawn

#
# spec file for package yawn
#
# Copyright (c) 2013 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/
#


%{!?python2_sitelib: %global python2_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

Name:           yawn
Version:        1.0+git20211121.851b080
Release:        0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version}
%define htdocsdir /srv/www/htdocs
%define apacheconfdir /etc/apache2
%else
%define htdocsdir /var/www/htdocs
%define apacheconfdir /etc/http
%endif

%if 0%{?suse_version} < 1600
BuildRequires:  python-distribute
BuildRequires:  python-rpm-macros
BuildRequires:  python
Requires:       python-pywbem
%else
BuildRequires:  python3-setuptools
BuildRequires:  python3-rpm-macros
BuildRequires:  python3
Requires:       python3-pywbem
%endif
BuildRequires:  unzip
Summary:        Yet Another WBEM Navigator
Url:            https://github.com/pywbem/yawn
License:        GPL-2.0
Group:          System/Management
# anywhere except sle 10 and 11
#  both put Python files below /usr/lib64
%if 0%{?sles_version} != 10 && 0%{?sles_version} != 11
BuildArch:      noarch
%endif
Source0:        %{name}-%{version}.tar.gz
# helper function for rpm building
Source1:	download_latest_svn
Patch0:         yawn-1.0-missing_title.patch
# run server on (user) port 8080
Patch1:         default-port-8080.patch

# SVN_INFO_START
# Path: trunk
# URL: svn://svn.code.sf.net/p/pywbem/code/yawn/trunk
# Repository Root: svn://svn.code.sf.net/p/pywbem/code
# Repository UUID: 84f79d66-d411-0410-a85a-a3183736c6e8
# Revision: 625
# Node Kind: directory
# Last Changed Author: miminar
# Last Changed Rev: 620
# Last Changed Date: 2013-04-26 09:45:08 +0200 (Fri, 26 Apr 2013)
# 
# SVN_INFO_END

%description
Web-based CIM/WBEM browser
The fastest and easiest way to navigate CIM objects.
In a nutshell, if you are developing providers or
CIM/WBEM infrastructure, you need YAWN.

%package server
Summary:        Standalone web server for yawn
Group:          System/Management
Requires:       %{name} = %version

%description server
Script to run yawn without Apache web server.

%package mod_wsgi
Summary:        Mod_wsgi based yawn package
Group:          System/Management
Requires:       %{name} = %version
%if 0%{?suse_version} < 1600
Requires:       python2-Mako
Requires:       python2-Werkzeug
%else
Requires:       python3(Mako)
Requires:       python3(Werkzeug)
%endif

%description mod_wsgi
WSGI based yawn package for use with any
wsgi compliant server

%package mod_python
Summary:        Mod Python2 based yawn package
Group:          System/Management
Requires:       apache2-mod_python
Requires:       %{name} = %version

%description mod_python
Mod python based yawn package for apache2-mod_python


%prep
%autosetup -p1

%build
%if 0%{?suse_version} < 1600
echo "%{python2_sitelib}" %{python2_sitelib}
%else
echo "%{python3_sitelib}" %{python3_sitelib}
%endif

%install
install -dm0755 %buildroot%{htdocsdir}/yawn
install -m0755 mod_python/yawn.py %buildroot%{htdocsdir}/yawn/index.py

install -d %buildroot%{apacheconfdir}/conf.d/
cat > %buildroot%{apacheconfdir}/conf.d/yawn_python.conf << EOS
<Directory %{htdocsdir}/yawn>
        SetHandler mod_python
        PythonHandler mod_python.publisher
        PythonDebug On
</Directory>
EOS

cd mod_wsgi
%if 0%{?suse_version} < 1600
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%else
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
%endif
mv %{buildroot}%{_bindir}/yawn.py %{buildroot}%{_bindir}/yawn
install -Dm0755 scripts/yawn.wsgi %{buildroot}%{_datadir}/%{name}/yawn.wsgi
install -dm0755 %{buildroot}%{apacheconfdir}/conf.d/
cat > %{buildroot}%{apacheconfdir}/conf.d/yawn_wsgi.conf <<EOF
<IfModule mod_wsgi.c>
WSGIPassAuthorization On
WSGIScriptAlias /yawn %{_datadir}/%{name}/yawn.wsgi

<Directory %{_datadir}/%{name}>
Order allow,deny
Allow from all
</Directory>
</IfModule>
EOF

%files
%defattr(-,root,root,-)
%if 0%{?suse_version} < 1600
%{python2_sitelib}/*
%else
%{python3_sitelib}/*
%endif

%files mod_python
%defattr(-,root,root,-)
%dir /srv/www
%dir %{htdocsdir}
%dir %{htdocsdir}/yawn
%{htdocsdir}/yawn/index.py*
%dir %{apacheconfdir}
%dir %{apacheconfdir}/conf.d
%config(noreplace) %{apacheconfdir}/conf.d/yawn_python.conf

%files mod_wsgi
%defattr(-,root,root,-)
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/yawn.wsgi
%dir %{apacheconfdir}
%dir %{apacheconfdir}/conf.d
%config(noreplace) %{apacheconfdir}/conf.d/yawn_wsgi.conf


%files server
%defattr(-,root,root,-)
%{_bindir}/yawn

%changelog
openSUSE Build Service is sponsored by