%undefine __brp_mangle_shebangs
# Generated by rust2rpm 27
%bcond check 0
%global appid land.deno.deno
%global appstream_component runtime
%global crate deno

Name:           rust-deno
Version:        2.8.0
Release:        1%{?dist}
Summary:        Deno executable

License:        MIT
URL:            https://crates.io/crates/deno
Source:         %{crates_source}
Source1:        https://raw.githubusercontent.com/denoland/deno/refs/tags/v%version/LICENSE.md
Source2:        gcc-wrapper.sh
Source3:        land.deno.deno.metainfo.xml
# Automatically generated patch to strip dependencies and normalize metadata
Patch:          deno-fix-metadata-auto.diff

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  anda-srpm-macros
BuildRequires:  protobuf-compiler
BuildRequires:  llvm17-devel
BuildRequires:  python3
BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  clang
BuildRequires:  clang-devel
# Why did Deno name their NPX equivalent this? At least OpenDX is pretty much dead.
Conflicts:      dx

%global _description %{expand:
Provides the deno executable.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
License:        ((Apache-2.0 OR MIT) AND BSD-3-Clause) AND ((MIT OR Apache-2.0) AND Unicode-DFS-2016) AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 AND ISC) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR BSL-1.0 OR MIT) AND (Apache-2.0 OR ISC OR MIT) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception) 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 (BSD-3-Clause OR MIT) AND BSL-1.0 AND CC0-1.0 AND ISC AND (ISC AND (Apache-2.0 OR ISC)) AND (ISC AND (Apache-2.0 OR ISC) AND OpenSSL) AND MIT AND (MIT AND BSD-3-Clause) AND (MIT OR Apache-2.0) AND (MIT OR Apache-2.0 OR BSD-1-Clause) AND (MIT OR Apache-2.0 OR LGPL-2.1-or-later) AND (MIT OR Apache-2.0 OR Zlib) AND (MIT OR Zlib OR Apache-2.0) AND MPL-2.0 AND MPL-2.0+ AND Unicode-3.0 AND (Unlicense OR MIT) AND Zlib AND (Zlib OR Apache-2.0 OR MIT)
# LICENSE.dependencies contains a full license breakdown

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE.md
%license LICENSE.dependencies
%doc README.md
%{_metainfodir}/%{appid}.metainfo.xml
%{_bindir}/deno
%{_bindir}/dx

%pkg_completion -Bfzn %crate

%prep
%autosetup -n %{crate}-%{version} -p1
%cargo_prep_online

cp %{S:1} .
cp %{S:2} gcc


%global __cc %_builddir/%buildsubdir/gcc
%dnl sed '/\[env\]/a CC="%__cc"' -i .cargo/config

%build
%{cargo_license_summary_online}
%{cargo_license_online} > LICENSE.dependencies
%{cargo_build} --locked

%install
%crate_install_bin
mkdir -p %buildroot{%bash_completions_dir,%elvish_completions_dir,%fish_completions_dir,%zsh_completions_dir}
target/rpm/deno completions bash > %buildroot%bash_completions_dir/deno
%dnl target/rpm/deno completions elvish > %buildroot%elvish_completions_dir/deno.elv
target/rpm/deno completions fish > %buildroot%fish_completions_dir/deno.fish
target/rpm/deno completions zsh > %buildroot%zsh_completions_dir/_deno
pushd %{buildroot}%{_bindir}
./deno x --install-alias
popd
%terra_appstream -o %{SOURCE3}
