# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=restic
pkgver=0.17.3
pkgrel=5
pkgdesc="Fast, secure, efficient backup program"
url="https://restic.net/"
arch="all"
license="BSD-2-Clause"
makedepends="go"
checkdepends="python3"
options="net chmod-clean"
subpackages="$pkgname-doc $pkgname-bash-completion $pkgname-zsh-completion $pkgname-fish-completion"
source="https://github.com/restic/restic/releases/download/v$pkgver/restic-$pkgver.tar.gz"

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

build() {
	go build -v ./cmd/...
}

check() {
	# may fail if /tmp is tmpfs
	rm internal/restic/node_xattr_all_test.go
	RESTIC_TEST_FUSE=0 make test
}

package() {
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname

	local man
	for man in doc/man/*.?; do
		install -Dm644 "$man" \
			"$pkgdir"/usr/share/man/man${man##*.}/${man##*/}
	done

	install -Dm644 doc/bash-completion.sh \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 doc/zsh-completion.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
	install -Dm644 doc/fish-completion.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
}

sha512sums="
d2efc27588f4b08120f68ba4e72d007c49b340c66928aaa261312a9caa32ec44c80d562c69ae25d2e7be1b5fa3600b3239fc49651a8c8be50581bfd73ae59036  restic-0.17.3.tar.gz
"
