File bat.spec of Package bat
# SPDX-License-Identifier: MIT
# Packaging for bat 0.25.0
Name: bat
Version: 0.25.0
Release: 0
Summary: A cat(1) clone with syntax highlighting and Git integration
License: Apache-2.0 AND MIT
URL: https://github.com/sharkdp/bat
Source0: bat-%{version}.tar.xz
Source1: vendor.tar.xz
ExclusiveArch: %{rust_arches}
BuildRequires: cargo
BuildRequires: rust >= 1.72
BuildRequires: pkgconfig(oniguruma)
%description
bat is a cat(1) clone with wings. It provides syntax highlighting, Git
integration and more.
%prep
%setup -q -n bat-%{version}
# Unpack vendored dependencies
%setup -q -D -T -a 1
# Configure cargo to use vendored sources and build offline
mkdir -p .cargo
cat > .cargo/config << 'EOF'
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
%build
# Ensure onig_sys links against system liboniguruma instead of building bundled C sources
export ONIG_SYS_USE_PKG_CONFIG=1
# Build in release mode, offline using vendored dependencies
cargo build --release --offline
%install
install -Dm0755 target/release/bat %{buildroot}%{_bindir}/bat
# Install licenses if present
if [ -f LICENSE-MIT ]; then
install -Dm0644 LICENSE-MIT %{buildroot}%{_datadir}/licenses/%{name}/LICENSE-MIT
fi
if [ -f LICENSE-APACHE ]; then
install -Dm0644 LICENSE-APACHE %{buildroot}%{_datadir}/licenses/%{name}/LICENSE-APACHE
fi
%files
%{_bindir}/bat
%doc README.md
%license %{_datadir}/licenses/%{name}/LICENSE-MIT
%license %{_datadir}/licenses/%{name}/LICENSE-APACHE
%changelog
# changelog managed externally