summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 44112e2083a394f3bab5f2da33c9961182c17563 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Maintainer: Daniel Peukert <daniel@peukert.cc>
_pkgname='bitw'
pkgname="$_pkgname-git"
pkgver='r91.gae87ee7'
pkgrel='1'
pkgdesc='Minimalist BitWarden client with Secret Service API implementation - git version'
arch=('x86_64' 'i686' 'pentium4' 'armv7h' 'aarch64')
url="https://github.com/mvdan/$_pkgname"
license=('BSD-3-Clause')
makedepends=('git' 'go>=1.19')
optdepends=(
	'wl-clipboard: clipboard utility for Wayland (one of the optdepends is required for the tests to pass - build time dep)'
	'xclip: clipboard utility for X11 (one of the optdepends is required for the tests to pass - build time dep)'
	'xsel: clipboard utility for X11 (one of the optdepends is required for the tests to pass - build time dep)'
)
provides=("$_pkgname" 'org.freedesktop.secrets')
conflicts=("$_pkgname")
source=("$pkgname::git+$url")
sha512sums=('SKIP')

_sourcedirectory="$pkgname"
_bindir="$pkgname-bin"
_gopath="$pkgname-gopath"

prepare() {
	mkdir -p "$srcdir/$_bindir/"
	mkdir -p "$srcdir/$_gopath/"
}

pkgver() {
	cd "$srcdir/$_sourcedirectory/"
	printf 'r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
	cd "$srcdir/$_sourcedirectory/"
	export GOPATH="$srcdir/$_gopath"
	export CGO_CPPFLAGS="${CPPFLAGS}"
	export CGO_CFLAGS="${CFLAGS}"
	export CGO_CXXFLAGS="${CXXFLAGS}"
	export CGO_LDFLAGS="${LDFLAGS}"
	export GOFLAGS='-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw'
	go build -v -o "$srcdir/$_bindir/" './...'
}

check() {
	cd "$srcdir/$_sourcedirectory/"

	# Run tests
	go test -v './...'

	# Verify that the basic functionality works
	"$srcdir/$_bindir/$_pkgname" help 2>&1 | tee '/dev/stderr' | grep -q 'fetch the latest data from the server$'
}

package() {
	cd "$srcdir/"
	install -Dm755 "$_bindir/$_pkgname" "$pkgdir/usr/bin/$_pkgname"
	install -Dm644 "$_sourcedirectory/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/BSD-3-Clause"
}