summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0ffc41a9aa743c2e5b14d1a2b6b4ee440edbfd29 (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
# Maintainer: eNV25 <env252525@gmail.com>

pkgname=ff2mpv-go-git
pkgver=1.0.1.r1.639496c
pkgrel=4
pkgdesc="Native messaging host for ff2mpv written in Go. Includes manifest json for many browsers."
arch=(x86_64 i686 aarch64 arm armv6h armv7h)
url="https://git.clsr.net/util/ff2mpv-go"
license=('custom: public domain')
depends=(mpv)
makedepends=(git go jq)
optdepends=(
#	"ff2mpv: browser extension"
	"chromium: supported browser"
	"firefox: supported browser"
	"firefox-developer-edition: supported browser"
	"google-chrome: supported browser"
	"librewolf: supported browser"
	"microsoft-edge: supported browser"
	"vivaldi: supported browser"
)
conflicts=("${pkgname%-git}" "ff2mpv-native-messaging-host-git" "ff2mpv-native-messaging-host-librewolf-git")
provides=("${pkgname%-git}" "ff2mpv-native-messaging-host-git" "ff2mpv-native-messaging-host-librewolf-git")
source=("$pkgname::git+$url")
sha256sums=('SKIP')

export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"

pkgver() {
	cd "$pkgname"
	git describe --long --tags | sed -E '
		s/([^-]*-)g/r\1/
		s/-/./g
		s/^v//
	'
}

build() {
	cd "$pkgname"
	go build -o "${pkgname%-git}"
}

package() {
	cd "$pkgname"
	install -Dm755 "${pkgname%-git}" "$pkgdir/usr/lib/${pkgname%-git}/ff2mpv"
	# paths from `pacman -Fyx 'native-messaging-hosts/'` and ff2mpv-native-messaging-host-{,librewolf}-git
	for _path in \
		usr/lib/mozilla/native-messaging-hosts \
		usr/lib/librewolf/native-messaging-hosts \
	; do
		"$pkgdir/usr/lib/${pkgname%-git}/ff2mpv" --manifest |
			# fix path
			jq '.path |= $path' --arg path "/usr/lib/${pkgname%-git}/ff2mpv" |
			install -Dm644 /dev/stdin "$pkgdir/$_path/ff2mpv.json"
	done
	for _path in \
		etc/chromium/native-messaging-hosts \
		etc/vivaldi/native-messaging-hosts \
		etc/opt/chrome/native-messaging-hosts \
		etc/opt/edge/native-messaging-hosts \
	; do
		"$pkgdir/usr/lib/${pkgname%-git}/ff2mpv" --manifest |
			# fix path
			jq '.path |= $path' --arg path "/usr/lib/${pkgname%-git}/ff2mpv" |
			# remove firefox support
			jq 'del(.allowed_extensions)' |
			# add support for chrome extension https://chrome.google.com/webstore/detail/ff2mpv/ephjcajbkgplkjmelpglennepbpmdpjg
			# https://github.com/DanSM-5/ff2mpv/blob/master/ff2mpv.json
			jq '.allowed_origins |= . + ["chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg/"]' |
			install -Dm644 /dev/stdin "$pkgdir/$_path/ff2mpv.json"
	done
}