# Template file for 'rclone'
pkgname=rclone
version=1.74.4
revision=1
build_style=go
build_helper="qemu"
go_import_path=github.com/rclone/rclone
go_build_tags="noselfupdate"
go_ldflags="-extldflags=-fuse-ld=bfd -X github.com/rclone/rclone/fs.Version=v${version}"
depends="mime-types"
checkdepends="${depends} rsync unzip"
short_desc="Rsync for cloud storage"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://rclone.org/"
changelog="https://raw.githubusercontent.com/rclone/rclone/master/docs/content/changelog.md"
distfiles="https://downloads.rclone.org/v${version}/rclone-v${version}.tar.gz"
checksum=23fb09cd209ac6f4540f75cbcfc913fb1e2a35b90cf1a9d67292e2239b4f3a24
make_check_pre="env RCLONE_CONFIG=/notfound CI=1"

pre_build() {
	if [ "$CROSS_BUILD" ] && [ "$XBPS_TARGET_LIBC" = musl ]; then
		# XXX: when cross building, the binary has a textrel, which segfaults when
		# launched on musl
		# FIXME: linkers for the musl toolchains should reject textrels entirely
		export CGO_ENABLED=0
	fi
}

pre_check() {
	rm -f cmd/mount/mount_test.go
	rm -f cmd/mount2/mount_test.go
	rm -f cmd/gitannex/e2e_test.go
}

post_install() {
	ln -sf rclone ${DESTDIR}/usr/bin/mount.rclone
	vlicense COPYING
	vman rclone.1

	for shell in bash zsh fish; do
		vtargetrun ${DESTDIR}/usr/bin/rclone genautocomplete $shell completion.$shell
		vcompletion completion.$shell $shell
	done
}
