# Template file for 'cargo-bootstrap'
pkgname=cargo-bootstrap
version=1.96.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="c478ba084e1f95d1dc0cc47d125ab415667277fbbed17d24b80c797cb3b71f42"
		;;
	x86_64)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-gnu.tar.xz"
		checksum="dee75c3c8f9f600ad75bc0c93249e767d3047845a4dd668327ce43ab039ba266"
		;;
	x86_64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-musl.tar.xz"
		checksum="8e2765c5815437c238b3bd37787398ada85f0cb41482a17f6f792036138387e5"
		;;
	aarch64)
		distfiles="${_bootstrap_url}/cargo-${version}-aarch64-unknown-linux-gnu.tar.xz"
		checksum="09ea03e74aa94e07db7bc00bd2ec1ad86d90a7348c89fde3909a8922543b949f"
		;;
	aarch64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-aarch64-unknown-linux-musl.tar.xz"
		checksum="0929d05e23137ff432e5a486c741421d69e30eb6d3f9e3c8606303574db2d662"
		;;
	# 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
}
