# Template file for 'cargo-bootstrap'
pkgname=cargo-bootstrap
reverts="1.83.0_1"
version=1.82.0
revision=2
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) ;;
	# 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="1cf5bae93e9724f50f1a20a752f05870565e0ce83baa157aad632aa162fd97d5"
		;;
	x86_64)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-gnu.tar.xz"
		checksum="97aeae783874a932c4500f4d36473297945edf6294d63871784217d608718e70"
		;;
	x86_64-musl)
		distfiles="${_bootstrap_url}/cargo-${version}-x86_64-unknown-linux-musl.tar.xz"
		checksum="a66b3129cb483d55188742769bf8282d9546630f2e25434ff233b22bbec5009e"
		;;
	# 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
}
