# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=thunar-vcs-plugin
pkgver=0.2.0
pkgrel=0
pkgdesc="Version Contol System plugin for the Thunar filemanager"
url="https://goodies.xfce.org/projects/thunar-plugins/thunar-vcs-plugin"
arch="all"
license="GPL-2.0-or-later"
options="!check" # no test suite
depends="thunar"
makedepends="thunar-dev subversion-dev apr-dev apr-util-dev util-linux-dev"
subpackages="$pkgname-git:_git $pkgname-svn:_svn $pkgname-lang"
source="https://archive.xfce.org/src/thunar-plugins/thunar-vcs-plugin/${pkgver%.*}/thunar-vcs-plugin-$pkgver.tar.bz2"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	cd "$builddir"
	default_prepare

	# quick and dirty fix for apr linking
	sed -i -e 's/APR_LDFLAGS/APR_LIBS/' thunar-vcs-plugin/Makefile.in
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libexecdir=/usr/lib/xfce4 \
		--disable-static \
		--enable-subversion \
		--enable-git
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

_mv_files() {
	local i
	for i in "$@"; do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i
	done
}

_git() {
	pkgdesc="Git support for thunar-vcs-plugin"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel git"
	cd "$pkgdir"
	_mv_files usr/lib/xfce4/tvp-git-helper \
		usr/share/icons/hicolor/*/apps/git.png
}

_svn() {
	pkgdesc="Subversion support for thunar-vcs-plugin"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel subversion"
	cd "$pkgdir"
	_mv_files usr/lib/xfce4/tvp-svn-helper \
		usr/share/icons/hicolor/*/apps/subversion.png
}

sha512sums="c33f54caa2f27de6c8f9e5cb8368f7538ea82730f1364ad974b19017a25bc6a398c19dfe861b0d0133db08ee36e4e209c8d824ce07de0c2ae6da830aca9e7e68  thunar-vcs-plugin-0.2.0.tar.bz2"
