summaryrefslogtreecommitdiff
path: root/sys-apps/openrazer/openrazer-3.4.0-r2.ebuild
blob: 1af09bba0ae35b921246a8ca317fe823fe301fdb (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{8..10} )

inherit readme.gentoo-r1 systemd udev xdg-utils distutils-r1 python-r1 linux-mod

DESCRIPTION="Drivers and user-space daemon to control Razer devices on GNU/Linux"
HOMEPAGE="https://openrazer.github.io/
	https://github.com/openrazer/openrazer/"
SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz
	-> ${P}.tar.gz"

LICENSE="GPL-2+"
SLOT="0"
KEYWORDS="~amd64 ~x86"

IUSE="+client +daemon"
REQUIRED_USE="
	client? ( daemon )
	daemon? ( ${PYTHON_REQUIRED_USE} )
	test? ( daemon )
"

RDEPEND="
	client? ( dev-python/numpy[${PYTHON_USEDEP}] )
	daemon? (
		acct-group/plugdev
		dev-python/daemonize[${PYTHON_USEDEP}]
		dev-python/dbus-python[${PYTHON_USEDEP}]
		dev-python/notify2[${PYTHON_USEDEP}]
		dev-python/pygobject:3[${PYTHON_USEDEP}]
		dev-python/pyudev[${PYTHON_USEDEP}]
		dev-python/setproctitle[${PYTHON_USEDEP}]
		x11-libs/gtk+:3[introspection]
		x11-misc/xautomation
		x11-misc/xdotool
	)
"
BDEPEND="
	${RDEPEND}
	virtual/linux-sources
"

DOCS=( README.md )

DOC_CONTENTS="To successfully use OpenRazer: load desired kernel module
(razeraccessory, razerkbd, razerkraken and/or razermouse),
add Your user to the \"plugdev\" group and start the \"openrazer-daemon\"."

BUILD_TARGETS="clean driver"
BUILD_PARAMS="-C ${S} SUBDIRS=${S}/driver KERNELDIR=${KERNEL_DIR}"
MODULE_NAMES="
	razeraccessory(hid:${S}/driver)
	razerkbd(hid:${S}/driver)
	razerkraken(hid:${S}/driver)
	razermouse(hid:${S}/driver)
"

distutils_enable_tests unittest

python_compile() {
	if use daemon ; then
		( cd "${S}"/daemon || die ; distutils-r1_python_compile )
	fi
	if use client ; then
		( cd "${S}"/pylib || die ; distutils-r1_python_compile )
	fi
}

python_install() {
	if use daemon ; then
		( cd "${S}"/daemon || die ; distutils-r1_python_install )
		python_scriptinto /usr/bin
		python_newscript "${S}"/daemon/run_openrazer_daemon.py ${PN}-daemon
	fi
	if use client ; then
		( cd "${S}"/pylib || die ; distutils-r1_python_install )
	fi
}

src_prepare() {
	xdg_environment_reset
	distutils-r1_src_prepare

	# Remove bad tests.
	rm "${S}"/daemon/tests/test_effect_sync.py || die
}

src_compile() {
	linux-mod_src_compile
	distutils-r1_src_compile

	if use daemon ; then
		emake -C "${S}"/daemon PREFIX=/usr service
	fi

	readme.gentoo_create_doc
}

src_test() {
	( cd "${S}"/daemon/tests || die ; distutils-r1_src_test )
}

src_install() {
	linux-mod_src_install
	distutils-r1_src_install

	udev_dorules "${S}"/install_files/udev/99-razer.rules
	exeinto "$(get_udevdir)"
	doexe "${S}"/install_files/udev/razer_mount

	# Install configuration example so that the daemon does not complain.
	insinto /usr/share/${PN}
	newins "${S}"/daemon/resources/razer.conf razer.conf.example

	if use daemon ; then
		# dbus service
		insinto /usr/share/dbus-1/services
		doins "${S}"/daemon/org.razer.service
		# systemd unit
		systemd_douserunit "${S}"/daemon/${PN}-daemon.service
		# Manpages
		doman "${S}"/daemon/resources/man/${PN}-daemon.8
		doman "${S}"/daemon/resources/man/razer.conf.5
	fi
}

pkg_postinst() {
	linux-mod_pkg_postinst
	udev_reload

	if use daemon ; then
		xdg_icon_cache_update
		xdg_desktop_database_update
	fi

	readme.gentoo_print_elog
}

pkg_postrm() {
	linux-mod_pkg_postrm
	udev_reload

	if use daemon ; then
		xdg_icon_cache_update
		xdg_desktop_database_update
	fi
}