File obs-git-explorer.spec of Package obs-git-explorer

#
# spec file for package python-sybil
#
# Copyright (c) 2017 SUSE LINUX 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 pythons python313
%define user_name obsgitexplorer

Name:           obs-git-explorer
Version:        0.0
Release:        0
Summary:        Smart Home Management
License:        GPLv3
Group:          Development/Languages/Python
Url:            https://src.opensuse.org/adrianSuSE/obs-git-explorer
#!RemoteAsset: git+https://src.opensuse.org/adrianSuSE/obs-git-explorer
#!CreateArchive
Source:         %name-%{version}.tar.xz
BuildRequires:  %{python_module gunicorn}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module Flask}
BuildRequires:  %{python_module Markdown}
BuildRequires:  %{python_module requests}
BuildRequires:  %{python_module yaspin}

%if %{with test}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module requests_mock}
%endif

BuildRequires:  fdupes
BuildRequires:  python-rpm-macros

Recommends: %pythons-gunicorn
Requires:  %pythons-Flask
Requires:  %pythons-Markdown
Requires:  %pythons-requests
Requires:  %pythons-yaspin
Requires:  %pythons-PyYAML >= 6.0

# optional redis support, makes only sense when you have access to the backend
Suggests: %pythons-redis
Suggests: %pythons-flask-socketio
Suggests: %pythons-python-socketio
Suggests: %pythons-eventlet
Conflicts: %pythons-redis < 4.5.0
Conflicts: %pythons-flask-socketio < 5.3.0
Conflicts: %pythons-python-socketio < 5.9.0
Conflicts: %pythons-eventlet < 0.33.0


# for useradd call
Requires(pre): shadow
Provides: user(obsgitexplorer)

%systemd_requires

BuildArch:      noarch

%description

%prep
%setup -q -n %name-%{version}

%build
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

mkdir -p '%{buildroot}'%{_sbindir}
ln -sf service '%{buildroot}'%{_sbindir}/rc%name
install -D -m 644 dist/%name.service '%{buildroot}'%{_unitdir}/%name.service

ln -sf service '%{buildroot}'%{_sbindir}/rcobs-git-cache-daemon
install -D -m 644 dist/obs-git-cache-daemon.service '%{buildroot}'%{_unitdir}

mkdir -p %{buildroot}/%{_prefix}/lib/firewalld/services/
install -D -m 644 dist/%name.xml %{buildroot}/%{_prefix}/lib/firewalld/services/

mkdir -p %{buildroot}/usr/lib/%name
install -m 0644 example-gunicorn.conf.py %{buildroot}/usr/lib/%name/gunicorn.conf.py

# our work directory
mkdir -p %{buildroot}/srv/obs-git-explorer

%if %{with test}
%check
%python_exec -m pytest tests -k "not (TestTimeout and connect)"
%endif

%pre -n %name
getent passwd %user_name >/dev/null || \
    /usr/sbin/useradd -r -m -s %{_sbindir}/nologin \
    -d /srv/obs-git-explorer \
    -c "OBS Git Explorer User" \
    %user_name
%service_add_pre %name.service
%service_add_pre obs-git-cache-daemon.service
exit 0

%preun -n %name
%service_del_preun %name.service
%service_del_preun obs-git-cache-daemon.service

%post -n %name
%service_add_post %name.service
%service_add_post obs-git-cache-daemon.service

%postun -n %name
%service_del_postun %name.service
%service_del_postun obs-git-cache-daemon.service

%files
%doc README.md
%_unitdir/*.service
%_bindir/obs-git-*
%_sbindir/rc*
%{python_sitelib}/*
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/%name.xml
/usr/lib/%name
%attr(0755,obsgitexplorer,root) /srv/obs-git-explorer

%changelog
openSUSE Build Service is sponsored by