# Generated by rust2rpm 27
%bcond check 0

%global crate typst

Name:           rust-typst
Version:        0.14.2
Release:        1%?dist
Summary:        New markup-based typesetting system that is powerful and easy to learn

License:        Apache-2.0
URL:            https://typst.app
Source:         https://github.com/typst/typst/archive/refs/tags/v%version.tar.gz
Packager:       madonuko <mado@fyralabs.com>

BuildRequires:  anda-srpm-macros cargo-rpm-macros >= 24
BuildRequires:  pkgconfig(openssl)

%global _description %{expand:
A new markup-based typesetting system that is powerful and easy to
learn.}

%description %{_description}

%package     -n %crate
Summary:        %{summary}
License:        ((MIT OR Apache-2.0) AND Unicode-3.0) AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT AND (MIT OR Apache-2.0)) AND (MIT OR Apache-2.0) AND (MIT OR Apache-2.0 OR CC0-1.0) AND (MIT OR Apache-2.0 OR Zlib) AND (MIT OR Zlib OR Apache-2.0) AND MPL-2.0 AND Unicode-3.0 AND (Unlicense OR MIT) AND Zlib AND (Zlib OR Apache-2.0 OR MIT)
Provides:       %crate-cli = %version-%release

%description -n %crate %{_description}

%files       -n %crate
%license LICENSE
%license LICENSE.dependencies
%doc README.md
%_bindir/typst
%_mandir/man1/typst-compile.1.gz
%_mandir/man1/typst-completions.1.gz
%_mandir/man1/typst-fonts.1.gz
%_mandir/man1/typst-init.1.gz
%_mandir/man1/typst-info.1.gz
%_mandir/man1/typst-query.1.gz
%_mandir/man1/typst-update.1.gz
%_mandir/man1/typst-watch.1.gz
%_mandir/man1/typst.1.gz


%pkg_completion -Bfzn %crate


%prep
%autosetup -n %{crate}-%{version} -p1
%cargo_prep_online
pushd crates/%{crate}-cli
%cargo_prep_online
popd

%build
pushd crates/%{crate}-cli
%{cargo_license_summary_online}
%{cargo_license_online} > ../../LICENSE.dependencies
popd
export TYPST_VERSION="%version"
export GEN_ARTIFACTS=artifacts/
export OPENSSL_NO_VENDOR=true
%{cargo_build} -p typst-cli

%install
#? https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=typst-git#n60
_artifacts='crates/typst-cli/artifacts'
install -Dm755 -t %buildroot%_bindir                target/rpm/%crate
install -Dm644 -t %buildroot%_mandir/man1           $_artifacts/%{crate}*.1
install -Dm644 -t %buildroot%zsh_completions_dir    $_artifacts/_%crate
install -Dm644 -t %buildroot%fish_completions_dir   $_artifacts/%crate.fish
# no .bash suffix
install -Dm644    $_artifacts/%crate.bash           %buildroot%bash_completions_dir/%crate

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