# Template file for 'cargo-bootstrap'
pkgname=cargo-bootstrap
version=1.98.0
revision=1
short_desc="Bootstrap binaries of Rust package manager"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0 OR MIT"
homepage="https://www.rust-lang.org/"
conflicts="cargo>=0"
lib32disabled=yes
nostrip=yes
repository=bootstrap

_bootstrap_url="https://static.rust-lang.org/dist"

case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686|aarch64*) ;;
	# See srcpkgs/rust-bootstrap/files/generating-distfiles.md for details
	*) _bootstrap_url="https://repo-default.voidlinux.org/distfiles" ;;
esac

# hardcode platform triplets
# because this info isn't available here without hacky workarounds
case "$XBPS_TARGET_MACHINE" in
	i686)
		distfiles="${_bootstrap_url}/cargo-${version}-i686-unknown-linux-gnu.tar.xz"
		checksum="b768fe07ae4bd233e5c3f864f935620abb8b72139f7369c869e964a0c30ae419"
		;;
	x86_64)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-gnu.tar.xz"
		checksum="2f512d170d3dd23e16ababcda32ee2e6d5172d861a7af1f504e0b1e270cafab9"
		;;
	x86_64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-musl.tar.xz"
		checksum="8a4da98a9a099e2bf8c210a236cd0cc8d6a259254f4b8fdf6997177ea9e1e4bf"
		;;
	aarch64)
		distfiles="${_bootstrap_url}/cargo-${version}-aarch64-unknown-linux-gnu.tar.xz"
		checksum="5784379d73ac881d15a9e67eed2882cd58c747c276221c23cdf9aff37e015ff6"
		;;
	aarch64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-aarch64-unknown-linux-musl.tar.xz"
		checksum="0d4ad14495f631df4d680b1ee970b69ec10f7249d939e85aadc313e04450219f"
		;;
	# placeholders for user-supplied distfiles
	ppc64le)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64le-unknown-linux-gnu.tar.xz"
		checksum="badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb"
		;;
	ppc64le-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64le-unknown-linux-musl.tar.xz"
		checksum="badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb"
		;;
	ppc64)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64-unknown-linux-gnu.tar.xz"
		checksum="badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb"
		;;
	ppc)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc-unknown-linux-gnu.tar.xz"
		checksum="badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb"
		;;
	*) broken="cargo bootstrap binaries unavailable for ${XBPS_TARGET_MACHINE}";;
esac

do_install() {
	vbin cargo/bin/cargo
	vlicense LICENSE-APACHE
	vlicense LICENSE-MIT
	vlicense LICENSE-THIRD-PARTY
}
