14
0
forked from pool/python-bandit

- Convert to libalternatives on SLE-16-based and newer systems only

- Fix tests with libalternatives

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bandit?expand=0&rev=42
This commit is contained in:
2025-09-01 14:56:04 +00:00
committed by Git OBS Bridge
parent 7d1674a247
commit f723b6e4b3
2 changed files with 30 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Sep 1 12:44:09 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Convert to libalternatives on SLE-16-based and newer systems only
- Fix tests with libalternatives
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jul 23 07:18:53 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com> Wed Jul 23 07:18:53 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>

View File

@@ -1,7 +1,7 @@
# #
# spec file for package python-bandit # spec file for package python-bandit
# #
# Copyright (c) 2025 SUSE LLC # Copyright (c) 2025 SUSE LLC and contributors
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@@ -26,8 +26,12 @@
%endif %endif
# CLI tool, no module # CLI tool, no module
%define pythons python3 %define pythons python3
%bcond_without builddocs %if 0%{?suse_version} > 1500
%bcond_without libalternatives %bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
%bcond_without builddocs
%{?sle15_python_module_pythons} %{?sle15_python_module_pythons}
Name: python-bandit Name: python-bandit
Version: 1.8.6 Version: 1.8.6
@@ -41,10 +45,8 @@ BuildRequires: %{python_module pbr >= 2.0}
BuildRequires: %{python_module pip} BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel} BuildRequires: %{python_module wheel}
BuildRequires: alts
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: alts
Requires: python-GitPython >= 1.0.1 Requires: python-GitPython >= 1.0.1
Requires: python-PyYAML >= 5.3.1 Requires: python-PyYAML >= 5.3.1
Requires: python-jschema-to-python >= 1.2.3 Requires: python-jschema-to-python >= 1.2.3
@@ -54,6 +56,13 @@ Requires: python-stestr >= 1.0.0
Requires: python-stevedore >= 1.20.0 Requires: python-stevedore >= 1.20.0
Requires: (python-tomli >= 1.2.3 if python-base < 3.11) Requires: (python-tomli >= 1.2.3 if python-base < 3.11)
BuildArch: noarch BuildArch: noarch
%if %{with libalternatives}
BuildRequires: alts
Requires: alts
%else
Requires(post): update-alternatives
Requires(postun): update-alternatives
%endif
%if %{python_version_nodots} < 311 %if %{python_version_nodots} < 311
Requires: python-tomli Requires: python-tomli
%endif %endif
@@ -101,6 +110,11 @@ sed -i '/^#!/d' bandit/__main__.py
%python_clone -a %{buildroot}%{_bindir}/bandit %python_clone -a %{buildroot}%{_bindir}/bandit
%python_clone -a %{buildroot}%{_bindir}/bandit-config-generator %python_clone -a %{buildroot}%{_bindir}/bandit-config-generator
%python_clone -a %{buildroot}%{_bindir}/bandit-baseline %python_clone -a %{buildroot}%{_bindir}/bandit-baseline
%python_group_libalternatives bandit bandit-config-generator bandit-baseline
# libalternatives binaries break the tests
%if %{with libalternatives}
sed -i 's/import sys/import sys; sys.argv[0] = "bandit"/' %{buildroot}%{_bindir}/bandit-3*
%endif
%endif %endif
%if %{with test} %if %{with test}
@@ -112,6 +126,12 @@ sed -i '/^#!/d' bandit/__main__.py
%endif %endif
%if !%{with test} %if !%{with test}
%post
%python_install_alternative bandit bandit.1 bandit-config-generator bandit-baseline
%postun
%python_uninstall_alternative bandit
%pre %pre
%python_libalternatives_reset_alternative bandit %python_libalternatives_reset_alternative bandit
%endif %endif