summaryrefslogtreecommitdiff
blob: ddcae5e621f0e76fbf09e0e3418c5f9fcecf53e6 (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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

PYTHON_COMPAT=( python3_4 python3_5 python3_6 )

inherit python-single-r1

DESCRIPTION="Host app for the PassFF WebExtension"
HOMEPAGE="https://github.com/passff/passff-host"

# Using raw because of difference between git and release
# See https://github.com/passff/passff-host/issues/18
SRC_URI="
	https://github.com/passff/passff-host/raw/${PV}/src/passff.py -> ${P}.py
	https://github.com/passff/passff-host/raw/${PV}/src/passff.json -> ${P}.json
"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="chrome chromium firefox vivaldi"
REQUIRED_USE="|| ( chrome chromium firefox vivaldi )"

S="${WORKDIR}"

src_unpack() {
	cp "${DISTDIR}/${P}.json" . || die
	cp "${DISTDIR}/${P}.py" . || die
}

src_prepare() {
	default

	sed -i "s/_VERSIONHOLDER_/${PV}/" "${P}.py" || die
	python_fix_shebang "${P}.py"
}

src_install() {
	local target_dirs=()

	use chrome   && target_dirs+=( "/etc/opt/chrome/native-messaging-hosts" )
	use chromium && target_dirs+=( "/etc/chromium/native-messaging-hosts" )
	use firefox  && target_dirs+=( "/usr/lib/mozilla/native-messaging-hosts" )
	use vivaldi  && target_dirs+=( "/etc/vivaldi/native-messaging-hosts" )

	for target_dir in "${target_dirs[@]}"; do
		sed "s;PLACEHOLDER;${target_dir}/passff.py;g" "${P}.json" > "passff.json" || die

		insinto "${target_dir}"
		doins passff.json
		exeinto "${target_dir}"
		newexe "${P}.py" passff.py
	done
}