# Generated by rust2rpm 26
%bcond_without check

%global commit 19c6c409ec45a37996a82b38783b5b225b01b172
%global snapdate 20250311

%global crate hsize
%global cargo_install_lib 0

Name:           hsize
Version:        0^%{snapdate}g%(c=%{commit}; echo ${c:0:7})
Release:        %autorelease
Summary:        Convert file sizes to and from human-readable units

# (MIT OR Apache-2.0) AND Unicode-DFS-2016: regex-syntax v0.8.4
# Apache-2.0 OR MIT: utf8parse v0.2.2
# LGPL-3.0-or-later: hsize v0.1.0
# MIT OR Apache-2.0: anstream v0.6.15
# MIT OR Apache-2.0: anstyle v1.0.8
# MIT OR Apache-2.0: anstyle-parse v0.2.5
# MIT OR Apache-2.0: anstyle-query v1.1.1
# MIT OR Apache-2.0: clap v4.5.9
# MIT OR Apache-2.0: clap_builder v4.5.9
# MIT OR Apache-2.0: clap_lex v0.7.2
# MIT OR Apache-2.0: colorchoice v1.0.2
# MIT OR Apache-2.0: num-traits v0.2.19
# MIT OR Apache-2.0: regex v1.10.5
# MIT OR Apache-2.0: regex-automata v0.4.7
# MIT: oorandom v11.1.4
# MIT: strsim v0.11.1
# Unlicense OR MIT: aho-corasick v1.1.3
# Unlicense OR MIT: memchr v2.7.4
License:        (Apache-2.0 OR MIT) AND LGPL-3.0-or-later AND MIT AND (MIT OR Apache-2.0) AND ((MIT OR Apache-2.0) AND Unicode-DFS-2016) AND (Unlicense OR MIT)
SourceLicense:  LGPL-3.0-or-later

URL:            https://github.com/ErrorNoInternet/hsize
Source:         %{url}/archive/%{commit}/%{name}-%{commit}.tar.gz

BuildRequires:  cargo-rpm-macros >= 26

%global _description %{expand:
Convert file sizes to and from human-readable units.}

%description %{_description}

%package bash-completion
BuildArch:      noarch
Summary:        Bash completion files for %{name}
Provides:       %{name}-bash-completion = %{version}-%{release}

Requires:       bash-completion
Requires:       %{name} = %{version}-%{release}

%description bash-completion
This package installs Bash completion files for %{name}

%package fish-completion
BuildArch:      noarch
Summary:        Fish completion files for %{name}
Provides:       %{name}-fish-completion = %{version}-%{release}

Requires:       fish
Requires:       %{name} = %{version}-%{release}

%description fish-completion
This package installs Fish completion files for %{name}

%package zsh-completion
BuildArch:      noarch
Summary:        Zsh completion files for %{name}
Provides:       %{name}-zsh-completion = %{version}-%{release}

Requires:       zsh
Requires:       %{name} = %{version}-%{release}

%description zsh-completion
This package installs Zsh completion files for %{name}

%prep
%autosetup -n %{crate}-%{commit} -p1
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires

%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies

%install
%cargo_install

install -Dpm644 man/hsize-replace.1 %{buildroot}%{_mandir}/man1/hsize-replace.1
install -Dpm644 man/hsize.1 %{buildroot}%{_mandir}/man1/hsize.1

install -Dpm644 completions/hsize.bash %{buildroot}%{bash_completions_dir}/hsize
install -Dpm644 completions/hsize.fish %{buildroot}%{fish_completions_dir}/hsize.fish
install -Dpm644 completions/hsize.zsh %{buildroot}%{zsh_completions_dir}/_hsize

%if %{with check}
%check
%cargo_test
%endif

%files
%license LICENSE
%license LICENSE.dependencies
%doc README.md
%{_bindir}/hsize
%{_mandir}/man1/hsize-replace.1*
%{_mandir}/man1/hsize.1*

%files bash-completion
%{bash_completions_dir}/hsize

%files fish-completion
%{fish_completions_dir}/hsize.fish

%files zsh-completion
%{zsh_completions_dir}/_hsize

%changelog
%autochangelog