## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    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

# This specfile is licensed under:
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022 Maxwell G <gotmax@e.email>
Name:           fedrq
Version:        0.0.2^18.20221225.5ca6f9b
Release:        %autorelease
Summary:        A tool to query the Fedora and EPEL repositories

# - code is GPL-2.0-or-later
# - the data and config files in fedrq/config are UNLICENSEed
License:        GPL-2.0-or-later AND Unlicense
URL:            https://git.sr.ht/~gotmax23/fedrq
Source:         %{url}/archive/%{version}.tar.gz#/fedrq-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel
# Test deps
BuildRequires:  createrepo_c
BuildRequires:  fedora-repos-rawhide
BuildRequires:  python3-dnf
# Manpage
BuildRequires:  scdoc

Requires:       python3-dnf
Requires:       fedora-repos-rawhide

# fedrq config --dump
Recommends:     python3-tomli-w


%description
fedrq is a tool to query the Fedora and EPEL repositories.


%prep
%autosetup -p1

# Workaround F36's old flit-core
# https://bugzilla.redhat.com/show_bug.cgi?id=2155118
rm -r .data/*
sed -i \
    -e 's|^requires = \["flit_core >=3.7,<4"\]|requires = ["flit_core >=3.2,<4"]|' \
    -e '/\[tool.flit.external-data\]/d' \
    -e '/^directory = ".data"$/d' \
    pyproject.toml



%generate_buildrequires
%pyproject_buildrequires -x test


%build
%pyproject_wheel
scdoc < doc/fedrq.1.scd > fedrq.1


%install
%pyproject_install
%pyproject_save_files fedrq
install -Dpm 0644 fedrq.1 -t %{buildroot}%{_mandir}/man1/


%check
%pytest -v -m "not no_rpm_mock"


%files -f %{pyproject_files}
%license LICENSES/GPL-2.0-or-later.txt
%license LICENSES/Unlicense.txt
%doc README.md CONTRIBUTING.md
%{_bindir}/fedrq*
%{_mandir}/man1/fedrq.1*


%changelog
* Tue Dec 27 2022 Maxwell G <gotmax@e.email> 0.0.2^18.20221225.5ca6f9b-1
- Uncommitted changes

* Mon Dec 26 2022 Maxwell G <gotmax@e.email> 0.0.2-17
- formatters: Add missing attrs

* Mon Dec 26 2022 Maxwell G <gotmax@e.email> 0.0.2-16
- Reformat fedrq.1 yet again
- Properly signify optional options in SYNOPSIS
- Split up --formatter documentation

* Mon Dec 26 2022 Maxwell G <gotmax@e.email> 0.0.2-14
- Add initial --smartcache implementation
- Update v_default and improve handling of fatal errors

* Sun Dec 25 2022 Maxwell G <gotmax@e.email> 0.0.2-12
- Command: Fix configuration error handling

* Sun Dec 25 2022 Maxwell G <gotmax@e.email> 0.0.2-11
- Replace cli.base.get_packages with Repoquery method

* Sat Dec 24 2022 Maxwell G <gotmax@e.email> 0.0.2-10
- lint.sh: Change log formatting

* Wed Dec 21 2022 Maxwell G <gotmax@e.email> 0.0.2-9
- Rearchitect make_base()
- Make --cachedir actually work
- Properly handle failures when loading the repository
- Get rid of base_* functions in fedrq.repoquery in favor of a new
  BaseMaker class.

* Wed Dec 21 2022 Maxwell G <gotmax@e.email> 0.0.2-8
- Tweak README wording (2)

* Tue Dec 20 2022 Maxwell G <gotmax@e.email> 0.0.2-4
- Tweak README wording

* Tue Dec 20 2022 Maxwell G <gotmax@e.email> 0.0.2-3
- .copr/Makefile: Don't install weak deps

* Tue Dec 20 2022 Maxwell G <gotmax@e.email> 0.0.2-2
- srpm.sh: Sanity ${lastref}

* Tue Dec 20 2022 Maxwell G <gotmax@e.email> 0.0.2-1
- Release 0.0.2

* Tue Dec 20 2022 Maxwell G <gotmax@e.email> 0.0.1-1
- Release 0.0.1