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

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

# we don't use upstream cargo binaries for ppc32, as they are busted (probably
# a dependency is wrong, which results in failed signature verification when
# updating the crates.io index)
# ppc64 is excluded because of ABI incompatibility
case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686|ppc64le) ;;
	# 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 avaialble here without hacky workarounds
case "$XBPS_TARGET_MACHINE" in
	i686)
		distfiles="${_bootstrap_url}/cargo-${version}-i686-unknown-linux-gnu.tar.xz"
		checksum="e2e20a16f5db52cd6b773c94225b03880743544ff2f317dd857cf0dceac6ab57"
		;;
	x86_64)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-gnu.tar.xz"
		checksum="21434d83a30ad3fa4e4831487c5574a20b07dd57d213b26e1246290c57d4ec41"
		;;
	x86_64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-musl.tar.xz"
		checksum="01d06176fd894b9299ed4f5b78e87d78a9a25b9ba803d3f8c50b7a4ea21d8807"
		;;
	ppc64le)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64le-unknown-linux-gnu.tar.xz"
		checksum="ba7188b2c7890e61bf58d3aa9e94c323fec375f67cf03841bbcc0f6c800fe6ad"
		;;
	ppc64le-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64le-unknown-linux-musl.tar.xz"
		checksum="1b54ab4793ac6c9c43ee9ee45677f403a9bba9c6610e8838c96ec194bcb4f261"
		;;
	ppc64)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc64-unknown-linux-gnu.tar.xz"
		checksum="96ce39dac948333b8321d2bc3ac70982879b185d69267f3d580df3f9c662dd0d"
		;;
	ppc)
		distfiles="${_bootstrap_url}/cargo-${version}-powerpc-unknown-linux-gnu.tar.xz"
		checksum="c7aa415b64b046626003fcafc76da90373adc8fc748f065fa8385dc19d3b3a2a"
		;;
	*) 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
}
