# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

MY_PN="${PN/-bin/}"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="Open-source scientific and technical publishing system built on Pandoc"
HOMEPAGE="http://quarto.org https://github.com/quarto-dev/quarto-cli"

QUARTO_SRC_BASE_URI="https://github.com/quarto-dev/${MY_PN}-cli/releases/download/v${PV}/${MY_P}"
SRC_URI="amd64? ( ${QUARTO_SRC_BASE_URI}-linux-amd64.tar.gz )
         arm64? ( ${QUARTO_SRC_BASE_URI}-linux-arm64.tar.gz )"

inherit pax-utils

KEYWORDS="-* amd64 arm64"

LICENSE="MIT"
SLOT="0"

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND=""

S="${WORKDIR}/${MY_P}"

RESTRICT="strip"

src_compile() {
    :
}

src_install() {
    insinto /opt/${MY_PN}
    cp -pR --reflink=auto . "${D}/opt/${MY_PN}" || die "Failed to install the package into '/opt/${PN}'"
    dosym "/opt/${MY_PN}/bin/${MY_PN}" /usr/bin/"${MY_PN}"

    pax-mark m "${ED}/opt/${MY_PN}/bin/tools/*/deno"
}