File testcloud.spec of Package testcloud

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

%{?sle15_python_module_pythons}%{!?sle15_python_module_pythons:%define pythons python3}
Name:           testcloud
Version:        0.11.7
Release:        0
Summary:        A small helper script to download and boot cloud images
License:        GPL-2.0-or-later
URL:            https://github.com/teemtee/testcloud
Source0:        %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}.sysusers
Patch0:         xorriso.patch
BuildRequires:  %{python_module libguestfs}
BuildRequires:  %{python_module libvirt-python}
BuildRequires:  %{python_module peewee}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module pytest-cov}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module requests}
BuildRequires:  %{python_module wheel}
BuildRequires:  pkgconfig(bash-completion)
BuildRequires:  fdupes
BuildRequires:  polkit
BuildRequires:  sysuser-tools
Requires:       %{pythons}-libvirt-python
Requires:       %{pythons}-packaging
Requires:       %{pythons}-peewee
Requires:       %{pythons}-requests
Requires:       xorriso
Recommends:     selinux-tools
BuildArch:      noarch
%{sysusers_requires}

%description
testcloud is a small helper script to download and boot cloud/coreos VM images
locally. Testcloud supports wide range of distributions, namely Fedora, Fedora
CoreOS, CentOS, CentOS Stream, Red Hat Enterprise Linux, Debian and Ubuntu.

testcloud can run either in system mode or in constrained user session mode,
which is useful for running testcloud and its VMs in unprivileged containers.

%package bash-completion
Summary:        Bash completions for %{name}

%description bash-completion
%{summary}.

%prep
%autosetup -p1

%build
%sysusers_generate_pre %{SOURCE1} %{name} %{name}.conf
%pyproject_wheel

%install
%pyproject_install
%fdupes %{buildroot}

install -Dm0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{name}.conf
install -Dm0644 conf/settings-example.py %{buildroot}%{_sysconfdir}/%{name}/settings.py
install -Dm0644 conf/99-testcloud-nonroot-libvirt-access.rules %{buildroot}%{_sysconfdir}/polkit-1/rules.d/99-testcloud-nonroot-libvirt-access.rules
install -d %{buildroot}%{_sharedstatedir}/%{name}
install -d %{buildroot}%{_sharedstatedir}/%{name}/{backingstores,instances}

%check
%pytest

%pre -f %{name}.pre

%files
%license LICENSE
%doc README.md
%attr(0775,qemu,testcloud) %{_sharedstatedir}/{%{name},%{name}/backingstore,%{name}/instances}
%config %{_sysconfdir}/polkit-1/rules.d/99-testcloud-nonroot-libvirt-access.rules
%config(noreplace) %{_sysconfdir}/%{name}/settings.py
%dir %{_sysconfdir}/%{name}
%{_bindir}/%{name}
%{_bindir}/t7d
%{_mandir}/man?/%{name}.?%{ext_man}
%{_sysusersdir}/%{name}.conf
%{python_sitelib}/%{name}
%{python_sitelib}/%{name}-%{version}.dist-info

%files bash-completion
%{_datadir}/bash-completion/completions/%{name}

%changelog
openSUSE Build Service is sponsored by