# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=desync
pkgver=0.9.6
pkgrel=5
pkgdesc="Alternative casync implementation"
url="https://github.com/folbricht/desync"
arch="all"
license="BSD-3-Clause"
makedepends="go"
depends="fuse"
source="$pkgname-$pkgver.tar.gz::https://github.com/folbricht/desync/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
	mkdir build
	go build -o build ./cmd/desync
}

check() {
	# this test requires the fuse module to be loaded
	if ! grep -Fxq "^fuse " /proc/modules; then
		rm -rf mount-index_linux_test.go
	fi
	go test ./...
}

package() {
	install -Dm755 ./build/desync -t "$pkgdir"/usr/bin
}

sha512sums="
b1f840fda8aba170c93f4b17f53595290fed1eb0a3a408e47c60214e6aabe20583c8032aec838b883d1251b31f7a819c413dca0137ab8c7d83e8de04f466d4dd  desync-0.9.6.tar.gz
"
