File risu.spec of Package risu

#
# spec file for package risu
#
# 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/
#


Name:           risu
Version:        1.14.4
Release:        0
Summary:        Automation troubleshooting framework for system configuration validation
License:        GPL-3.0-or-later
URL:            https://github.com/risuorg/risu
Source0:        https://github.com/risuorg/risu/archive/refs/tags/%{version}.tar.gz#/risu-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  python3-pbr >= 2.0.0
BuildRequires:  python3-pip
BuildRequires:  python3-requests
BuildRequires:  python3-setuptools
BuildRequires:  python3-urllib3 >= 2.2.2
BuildRequires:  python3-wheel
Requires:       python3-requests
Requires:       python3-urllib3 >= 2.2.2
BuildArch:      noarch

%description
Risu is a framework to help with system configuration validation on either
a live system or a sosreport snapshot of the filesystem. This empowers the
user to quickly troubleshoot known issues found in the system or issues
arising from different settings across a group of systems.

Via execution of 'plugins' it reports status on each one execution against
the system that gives you an idea on health status, actual problems or
problems that will reveal themselves if no preventive action is taken.

%prep
%autosetup -n risu-%{version}

# Remove shebang from Python libraries
find risuclient maguiclient -name "*.py" -exec sed -i '1{\@^#!/usr/bin/env python@d}' {} +

# Fix permissions
find . -name "*.sh" -exec chmod +x {} +
find . -name "*.py" -exec chmod +x {} +

# Patch setup.py to not require git
sed -i '/^command = "git tag/,/^version = out.strip/d' setup.py
sed -i 's/os.environ\["RELEASE_VERSION"\]/os.environ.get("RELEASE_VERSION", os.environ.get("PBR_VERSION", "%{version}"))/' setup.py

%build
export PBR_VERSION=%{version}
%python3_pyproject_wheel

%install
export PBR_VERSION=%{version}
%python3_pyproject_install

# Create wrapper scripts that include plugin paths
install -d %{buildroot}%{_bindir}

# RISU wrapper - automatically includes system plugin directory
printf '#!/bin/bash\nexec %%s --extraplugintree %%s "$@"\n' \
    '%{_bindir}/risu.py' '%{_datadir}/risu/plugins' > %{buildroot}%{_bindir}/risu
chmod 755 %{buildroot}%{_bindir}/risu

# Magui wrapper
printf '#!/bin/bash\nexec %%s "$@"\n' '%{_bindir}/magui.py' > %{buildroot}%{_bindir}/magui
chmod 755 %{buildroot}%{_bindir}/magui

# Remove deprecated citellus.py
rm -f %{buildroot}%{_bindir}/citellus.py

%fdupes %{buildroot}%{python3_sitelib}

# Install plugins directory
install -d %{buildroot}%{_datadir}/risu
cp -r risuclient/plugins %{buildroot}%{_datadir}/risu/
cp -r risuclient/hooks %{buildroot}%{_datadir}/risu/
cp -r risuclient/common.d %{buildroot}%{_datadir}/risu/
cp -r maguiclient/plugins %{buildroot}%{_datadir}/risu/magui-plugins

# Install common functions
install -d %{buildroot}%{_datadir}/risu/common
install -m 644 risuclient/common-functions.sh %{buildroot}%{_datadir}/risu/common/

# Install HTML templates
install -d %{buildroot}%{_datadir}/risu/templates
install -m 644 risuclient/risu.html %{buildroot}%{_datadir}/risu/templates/

%files
%license LICENSE
%doc README.md CHANGELOG.md
%{_bindir}/risu.py
%{_bindir}/risu
%{_bindir}/magui.py
%{_bindir}/magui
%{_bindir}/env-for-debug.sh
%{python3_sitelib}/risuclient
%{python3_sitelib}/maguiclient
%{python3_sitelib}/risu-*.dist-info
%{_datadir}/risu

%changelog

openSUSE Build Service is sponsored by