dev-qt/qtx11extras: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / app-misc / g15daemon / g15daemon-1.9.5.3-r21.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 PYTHON_COMPAT=( python2_7 )
7 GENTOO_DEPEND_ON_PERL="no"
8
9 inherit eutils linux-info perl-module python-r1 base
10
11 DESCRIPTION="Takes control of the G15 keyboard, through the linux kernel uinput device driver"
12 HOMEPAGE="https://sourceforge.net/projects/g15daemon/"
13 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS=""
18 IUSE="perl python static-libs"
19
20 DEPEND="virtual/libusb:0
21         >=dev-libs/libg15-9999
22         >=dev-libs/libg15render-1.2
23         perl? (
24                 dev-lang/perl
25                 dev-perl/GDGraph
26                 >=dev-perl/Inline-0.4
27         )
28         python? ( ${PYTHON_DEPS} )"
29 RDEPEND="${DEPEND}"
30 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
31
32 PATCHES=(
33         "${FILESDIR}/${P}-forgotten-open-mode.patch"
34         "${FILESDIR}/${P}-overflow-fix.patch"
35         "${FILESDIR}/${P}-g510-keys.patch"
36 )
37
38 uinput_check() {
39         ebegin "Checking for uinput support"
40         local rc=1
41         linux_config_exists && linux_chkconfig_present INPUT_UINPUT
42         rc=$?
43
44         if [[ $rc -ne 0 ]] ; then
45                 eerror "To use g15daemon, you need to compile your kernel with uinput support."
46                 eerror "Please enable uinput support in your kernel config, found at:"
47                 eerror
48                 eerror "Device Drivers -> Input Device ... -> Miscellaneous devices -> User level driver support."
49                 eerror
50                 eerror "Once enabled, you should have the /dev/input/uinput device."
51                 eerror "g15daemon will not work without the uinput device."
52         fi
53 }
54
55 pkg_setup() {
56         linux-info_pkg_setup
57         uinput_check
58 }
59
60 src_unpack() {
61         unpack ${A}
62         if use perl; then
63                 unpack "./${P}/lang-bindings/perl-G15Daemon-0.2.tar.gz"
64         fi
65         if use python; then
66                 unpack "./${P}/lang-bindings/pyg15daemon-0.0.tar.bz2"
67         fi
68 }
69
70 src_prepare() {
71         if use perl; then
72                 perl-module_src_prepare
73                 sed -i \
74                         -e '1i#!/usr/bin/perl' \
75                         "${S}"/contrib/testbindings.pl
76         else
77                 # perl-module_src_prepare always calls base_src_prepare
78                 base_src_prepare
79         fi
80 }
81
82 src_configure() {
83         econf \
84                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
85                 $(use_enable static-libs static)
86
87         if use perl; then
88                 cd "${WORKDIR}/G15Daemon-0.2"
89                 perl-module_src_configure
90         fi
91 }
92
93 src_compile() {
94         default
95
96         if use perl; then
97                 cd "${WORKDIR}/G15Daemon-0.2"
98                 perl-module_src_compile
99         fi
100 }
101
102 src_install() {
103         default
104
105         find "${ED}" -name '*.la' -exec rm -f {} +
106
107         # remove odd docs installed my make
108         rm "${ED}/usr/share/doc/${PF}/"{LICENSE,README.usage}
109
110         insinto /usr/share/${PN}/contrib
111         doins contrib/xmodmaprc
112         doins contrib/xmodmap.sh
113         if use perl; then
114                 doins contrib/testbindings.pl
115         fi
116
117         newconfd "${FILESDIR}/${PN}-1.2.7.confd" ${PN}
118         newinitd "${FILESDIR}/${PN}-1.9.5.3.initd" ${PN}
119         dobin "${FILESDIR}/g15daemon-hotplug"
120         insinto /lib/udev/rules.d
121         doins "${FILESDIR}/99-g15daemon.rules"
122
123         insinto /etc
124         doins "${FILESDIR}"/g15daemon.conf
125
126         # Gentoo bug #301340, debian bug #611649
127         exeinto /usr/lib/pm-utils/sleep.d
128         doexe "${FILESDIR}"/20g15daemon
129
130         if use perl; then
131                 ebegin "Installing Perl Bindings (G15Daemon.pm)"
132                 cd "${WORKDIR}/G15Daemon-0.2"
133                 docinto perl
134                 perl-module_src_install
135         fi
136
137         if use python; then
138                 ebegin "Installing Python Bindings (g15daemon.py)"
139                 cd "${WORKDIR}/pyg15daemon"
140
141                 python_foreach_impl python_domodule g15daemon.py
142
143                 docinto python
144                 dodoc AUTHORS
145         fi
146 }
147
148 pkg_postinst() {
149         elog "To use g15daemon, you need to add g15daemon to the default runlevel."
150         elog "This can be done with:"
151         elog "# /sbin/rc-update add g15daemon default"
152         elog "You can edit some g15daemon options at /etc/conf.d/g15daemon"
153         elog ""
154         elog "To have all new keys working in X11, you'll need create a "
155         elog "specific xmodmap in your home directory or edit the existent one."
156         elog ""
157         elog "Create the xmodmap:"
158         elog "cp /usr/share/g15daemon/contrib/xmodmaprc ~/.Xmodmap"
159         elog ""
160         elog "Adding keycodes to an existing xmodmap:"
161         elog "cat /usr/share/g15daemon/contrib/xmodmaprc >> ~/.Xmodmap"
162 }