## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 12;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%if 0%{?rhel}
%if 0%{?el9}
# Skip tests on EL9 due to missing dependencies
%bcond_with check
%else
%bcond_without check
%endif
# pypandoc is an optional dependency and is not available in EPEL
%bcond_with doc
%else
%bcond_without check
%bcond_without doc
%endif

# Created by pyp2rpm-3.3.5
%global pypi_name dcrpm

Name:           python-%{pypi_name}
Version:        0.6.3
Release:        %autorelease
Summary:        A tool to detect and correct common issues around RPM database corruption

# Automatically converted from old format: GPLv2 - review is highly recommended.
License:        GPL-2.0-only
URL:            https://github.com/facebookincubator/dcrpm
Source:         %{pypi_source}
BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3dist(psutil)
BuildRequires:  python3dist(setuptools)
%if %{with check}
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(testslide)
BuildRequires:  dnf
BuildRequires:  libdb-utils
BuildRequires:  lsof
%endif
%if %{with doc}
BuildRequires:  python3dist(pypandoc)
%endif

%global _description %{expand:
dcrpm is a tool to detect and correct common issues around RPM database
corruption.}

%description %{_description}


%package -n     %{pypi_name}
Summary:        %{summary}
%if 0%{?el8}
%py_provides    python3-%{pypi_name}
%endif

Requires:       python3dist(psutil)
Requires:       python3dist(setuptools)
Requires:       lsof
Recommends:     libdb-utils

%description -n %{pypi_name} %{_description}


%prep
%autosetup -n %{pypi_name}-%{version} -p1
# Remove unnecessary shebang
sed -e '\|#!/usr/bin/env python|d' -i dcrpm/*.py
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%if 0%{?el8}
# needed with setuptools < 40.9.0
mv legacy_setup.py setup.py
%endif


%build
%py3_build


%install
%py3_install


%check
%py3_check_import %{pypi_name}
%if %{with check}
%if 0%{?fedora} >= 37
# https://github.com/facebookincubator/dcrpm/issues/54
%pytest -v --deselect=tests/test_end_to_end.py::DcrpmIntegrationTest::test_rpmdb_centos7_missing_index
%else
%pytest -v
%endif
%endif


%files -n %{pypi_name}
%license LICENSE
%doc README.md CONTRIBUTING.md CODE_OF_CONDUCT.md
%doc HISTORY.md MANUAL_RPM_CLEANUP.md
%{_bindir}/dcrpm
%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info


%changelog
## START: Generated by rpmautospec
* Mon Jul 29 2024 Miroslav Suchý <msuchy@redhat.com> - 0.6.3-12
- convert GPLv2 license to SPDX

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sun Jun 09 2024 Python Maint <python-maint@redhat.com> - 0.6.3-10
- Rebuilt for Python 3.13

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri Jul 14 2023 Python Maint <python-maint@redhat.com> - 0.6.3-6
- Rebuilt for Python 3.12

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Fri Jul 01 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 0.6.3-3
- Disable broken test on F37; Fixes: RHBZ#2098880

* Thu Jun 30 2022 Python Maint <python-maint@redhat.com> - 0.6.3-2
- Rebuilt for Python 3.11

* Fri Apr 08 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.6.3-1
- Update to 0.6.3

* Tue Apr 05 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.6.2-8
- Adjust spec to build on EPEL 9
- Drop unused deprecated python3-mock test dependency
- Switch test runner to pytest

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.6.2-5
- Rebuilt for Python 3.10

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Jan 23 2021 Davide Cavalca <dcavalca@fedoraproject.org> - 0.6.2-3
- Enable tests for EPEL builds

* Sun Jan  3 2021 Davide Cavalca <dcavalca@fedoraproject.org> - 0.6.2-2
- Update patches

* Wed Dec 30 2020 Davide Cavalca <dcavalca@fedoraproject.org> - 0.6.2-1
- Initial package.

## END: Generated by rpmautospec