# Generated by rust2rpm 27
%bcond check 1

Name:           yazi
Version:        25.3.2
Release:        %autorelease -b 2
Summary:        Yazi file manager

License:        MIT

URL:            https://yazi-rs.github.io 
Source:         https://github.com/sxyazi/yazi/archive/refs/tags/v%{version}.tar.gz

Requires: file
Recommends: ffmpeg
Recommends: p7zip
Recommends: p7zip-plugins
Recommends: jq
Recommends: poppler-utils
Recommends: fd-find
Recommends: ripgrep
Recommends: fzf
Recommends: zoxide
Recommends: ImageMagick
Recommends: git

BuildRequires: cargo-rpm-macros >= 24
BuildRequires: make
BuildRequires: gcc
BuildRequires: git

%global _description %{expand:
Blazing fast terminal file manager written in Rust, based on async I/O.}

%description %{_description}

%prep
%autosetup -n yazi-%{version} -p1

%build
%if 0%{?fedora} >= 42
CFLAGS="$CFLAGS -std=gnu17"
%endif
export YAZI_GEN_COMPLETIONS=1 
RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes' cargo build -j${RPM_BUILD_NCPUS} --locked --release
cargo tree --workspace --edges no-build,no-dev,no-proc-macro --no-dedupe --target all --prefix none --format "{l}: {p}" | sed -e "s: ($(pwd)[^)]*)::g" -e "s: / :/:g" -e "s:/: OR :g" | sort -u > LICENSE.dependencies

%install
install -Dpm 0755 -t %{buildroot}%{_bindir} target/release/yazi target/release/ya 
install -Dpm 0644 yazi-boot/completions/%{name}.bash yazi-cli/completions/ya.bash -t %{buildroot}%{bash_completions_dir}
install -Dpm 0644 yazi-boot/completions/%{name}.fish yazi-cli/completions/ya.fish -t %{buildroot}%{fish_completions_dir}
install -Dpm 0644 yazi-boot/completions/_%{name} yazi-cli/completions/_ya -t %{buildroot}%{zsh_completions_dir}

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

%files
%license LICENSE
%license LICENSE-ICONS
%license LICENSE.dependencies
%doc README.md
%{_bindir}/ya
%{_bindir}/yazi
%{bash_completions_dir}/%{name}.bash
%{bash_completions_dir}/ya.bash
%{zsh_completions_dir}/_%{name}
%{zsh_completions_dir}/_ya
%{fish_completions_dir}/%{name}.fish
%{fish_completions_dir}/ya.fish

%changelog
%autochangelog