summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bd0e2e4fa2d94a991679f3f72c0d9e069fbd855c (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Maintainer: TheJonsey <mail@thejonsey.com>
pkgname=streamdeckd
_pkgname=streamdeckd
pkgver=${PKGVER:-autogenerated}
pkgrel=${PKGREL:-1}
pkgdesc="A Linux Driver for the Elgato Streamdeck"
arch=('i686' 'x86_64')
url='https://github.com/unix-streamdeck/streamdeckd'
license=('BSD-3')
depends=(
	'libusb'
	'xdotool'
	'xdg-utils'
)
makedepends=(
	'go'
	'git'
)

source=(
	"$_pkgname::git+git://github.com/unix-streamdeck/streamdeckd#branch=${BRANCH:-master}"
	"50-elgato.rules"
	"streamdeckd.service"
)

md5sums=(
	'SKIP'
	'c181439b9cd1c7905c37dcaa8c53580f'
	'3f9c5710d25ed2e7b613c498ba7fa12a'
)

backup=(
	"etc/udev/rules.d/50-elgato.rules"
)

pkgver() {
	if [[ "$PKGVER" ]]; then
		echo "$PKGVER"
		return
	fi

	cd "$srcdir/$_pkgname"
	local date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
	local count=$(git rev-list --count HEAD)
	local commit=$(git rev-parse --short HEAD)
	echo "$date.${count}_$commit"
}

build() {
	cd "$srcdir/$_pkgname"

	if [ -L "$srcdir/$_pkgname" ]; then
		rm "$srcdir/$_pkgname" -rf
		mv "$srcdir/go/src/$_pkgname/" "$srcdir/$_pkgname"
	fi

	rm -rf "$srcdir/go/src"

	mkdir -p "$srcdir/go/src"

	export GOPATH="$srcdir/go"

	mv "$srcdir/$_pkgname" "$srcdir/go/src/"

	cd "$srcdir/go/src/$_pkgname/"
	ln -sf "$srcdir/go/src/$_pkgname/" "$srcdir/$_pkgname"

	echo ":: Updating git submodules"
	git submodule update --init

	echo ":: Building binary"
	go get -v \
		-gcflags "-trimpath $GOPATH/src"
}

package() {
	find "$srcdir/go/bin/" -type f -executable | while read filename; do
		install -DT "$filename" "$pkgdir/usr/bin/$(basename $filename)"
	done
	install -DT -m0755 "$srcdir/50-elgato.rules" "$pkgdir/etc/udev/rules.d/50-elgato.rules"
	install -DT -m0755 "$srcdir/streamdeckd.service" "$pkgdir/usr/lib/systemd/user/streamdeckd.service"
	echo "To enable and start the service:"
	echo -e "systemctl --user enable --now streamdeckd.service"
	echo -e "A reboot might be required for streamdeckd to work correctly."
}