File python-sushy-tools.spec of Package python-sushy-tools

#
# spec file for package python-sushy-tools
#
# Copyright (c) 2023 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


Name:           python-sushy-tools
Version:        0.21.1
Release:        0
Summary:        A set of tools to support the development and test of the Sushy library
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://opendev.org/openstack/sushy-tools
Source0:        https://files.pythonhosted.org/packages/source/s/sushy-tools/sushy-tools-0.21.1.tar.gz
Source1:        sushy-emulator.service
Source2:        sushy-emulator.conf
BuildRequires:  openstack-macros
BuildRequires:  python3-devel
BuildRequires:  python39-Flask
BuildRequires:  python39-pbr
BuildRequires:  python39-requests
BuildRequires:  python39-setuptools
BuildRequires:  python39-tenacity
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun):systemd
Requires(preun):systemd
%endif

%description
A set of tools to support the development and test of the Sushy library

%package -n python39-sushy-tools
Summary:        A set of tools to support the development and test of the Sushy library
Requires:       python39-Flask
Requires:       python39-pbr
Requires:       python39-requests
Requires:       python39-tenacity

%description -n python39-sushy-tools
A set of tools to support the development and test of the Sushy library

%if 0%{?with_doc}
%package -n python-sushy-tools-doc
Summary:        sushy-tools documentation
BuildRequires:  python39-Sphinx
BuildRequires:  python39-openstackdocstheme
BuildRequires:  python39-sphinxcontrib-apidoc

%description -n python-sushy-tools-doc
Summary:        sushy-tools documentation
%endif

%prep
%autosetup -p1 -n sushy-tools-0.21.1
%py_req_cleanup

%build
%{py3_build}

%if 0%{?with_doc}
# generate html docs
sphinx-build-3 -W -b html doc/source doc/build/html
# remove the sphinx-build-3 leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif

%install
%{py3_install}

# Install systemd script
mkdir -p %{buildroot}%{_unitdir}
install -p -D -m 644 %{SOURCE1} %{buildroot}/%{_unitdir}/sushy-emulator.service

# Install distribution config
mkdir -p %{buildroot}%{_sysconfdir}/sushy-emulator/
install -p -D -m 640 %{SOURCE2} %{buildroot}/%{_sysconfdir}/sushy-emulator/sushy-emulator.conf

### install symlinks on SUSE
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif

%files -n python39-sushy-tools
%license LICENSE
%{_bindir}/sushy-emulator
%{_bindir}/sushy-static
%{python3_sitelib}/sushy_tools
%{python3_sitelib}/sushy_tools-*.egg-info
%{_unitdir}/sushy-emulator.service
%config(noreplace) %attr(-, root, sushy-tools) %{_sysconfdir}/sushy-emulator
%attr(-, root, sushy-tools) %{_sysconfdir}/sushy-emulator/sushy-emulator.conf
%exclude %{python3_sitelib}/python-sushy-tools/tests
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif

%pre -n python39-sushy-tools
getent group sushy-tools >/dev/null || groupadd -r sushy-tools
getent passwd sushy-tools >/dev/null || useradd -r \
    -g sushy-tools -M -s /sbin/nologin -c "Redfish Emulator" sushy-tools

%if 0%{?with_doc}
%files -n python-sushy-tools-doc
%license LICENSE
%doc doc/build/html README.rst
%endif

%post -n python39-sushy-tools
%systemd_post sushy-emulator.service

%preun -n python39-sushy-tools
%systemd_preun sushy-emulator.service

%postun -n python39-sushy-tools
%systemd_postun_with_restart sushy-emulator.service

%changelog
openSUSE Build Service is sponsored by