*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / app-misc / lirc / lirc-0.10.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python3_{6,7} )
7
8 inherit eutils flag-o-matic linux-info python-single-r1 systemd xdg-utils
9
10 DESCRIPTION="decode and send infra-red signals of many commonly used remote controls"
11 HOMEPAGE="http://www.lirc.org/"
12
13 LIRC_DRIVER_DEVICE="/dev/lirc0"
14
15 MY_P=${PN}-${PV/_/-}
16
17 if [[ "${PV/_pre/}" = "${PV}" ]]; then
18         SRC_URI="mirror://sourceforge/lirc/${MY_P}.tar.bz2"
19 else
20         SRC_URI="http://www.lirc.org/software/snapshots/${MY_P}.tar.bz2"
21 fi
22
23 LICENSE="GPL-2+"
24 SLOT="0"
25 KEYWORDS="amd64 ~arm64 ppc ppc64 x86"
26 IUSE="audio +devinput doc ftdi gtk inputlirc static-libs systemd +uinput usb X"
27
28 REQUIRED_USE="
29         ${PYTHON_REQUIRED_USE}
30         gtk? ( X )
31 "
32
33 S="${WORKDIR}/${MY_P}"
34
35 COMMON_DEPEND="
36         ${PYTHON_DEPS}
37         audio? (
38                 >media-libs/portaudio-18
39                 media-libs/alsa-lib
40         )
41         <dev-python/pyyaml-5[${PYTHON_USEDEP}]
42         ftdi? ( dev-embedded/libftdi:0 )
43         systemd? ( sys-apps/systemd )
44         usb? ( virtual/libusb:0 )
45         X? (
46                 x11-libs/libICE
47                 x11-libs/libSM
48                 x11-libs/libX11
49         )
50 "
51
52 DEPEND="
53         ${COMMON_DEPEND}
54         dev-libs/libxslt
55         dev-python/setuptools[${PYTHON_USEDEP}]
56         doc? ( app-doc/doxygen )
57         sys-apps/kmod
58         sys-kernel/linux-headers
59 "
60
61 RDEPEND="
62         ${COMMON_DEPEND}
63         gtk? (
64                 x11-libs/vte[introspection]
65                 dev-python/pygobject[${PYTHON_USEDEP}]
66         )
67         inputlirc? ( app-misc/inputlircd )
68 "
69
70 MAKEOPTS+=" -j1"
71
72 pkg_setup() {
73         use uinput && CONFIG_CHECK="~INPUT_UINPUT"
74         python-single-r1_pkg_setup
75         linux-info_pkg_setup
76 }
77
78 src_configure() {
79         xdg_environment_reset
80         econf \
81                 --localstatedir="${EPREFIX}/var" \
82                 $(use_enable static-libs static) \
83                 $(use_enable devinput) \
84                 $(use_enable uinput) \
85                 $(use_with X x)
86 }
87
88 src_install() {
89         default
90
91         if use !gtk ; then
92                 # lirc-setup requires gtk
93                 rm "${ED%/}"/usr/bin/lirc-setup || die
94         fi
95
96         newinitd "${FILESDIR}"/lircd-0.8.6-r2 lircd
97         newinitd "${FILESDIR}"/lircmd-0.9.4a-r2 lircmd
98         newconfd "${FILESDIR}"/lircd.conf.4 lircd
99         newconfd "${FILESDIR}"/lircmd-0.10.0.conf lircmd
100
101         insinto /etc/modprobe.d/
102         newins "${FILESDIR}"/modprobed.lirc lirc.conf
103
104         newinitd "${FILESDIR}"/irexec-initd-0.9.4a-r2 irexec
105         newconfd "${FILESDIR}"/irexec-confd irexec
106
107         keepdir /etc/lirc
108         if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
109                 newdoc "${ED%/}"/etc/lirc/lircd.conf lircd.conf.example
110         fi
111
112         find "${ED}" -name '*.la' -delete || die
113
114         # Avoid QA notice
115         rm -d "${ED%/}"/var/run/lirc || die
116         rm -d "${ED%/}"/var/run || die
117 }
118
119 pkg_preinst() {
120         local dir="${EROOT%/}/etc/modprobe.d"
121         if [[ -a "${dir}"/lirc && ! -a "${dir}"/lirc.conf ]]; then
122                 elog "Renaming ${dir}/lirc to lirc.conf"
123                 mv -f "${dir}/lirc" "${dir}/lirc.conf" || die
124         fi
125
126         # copy the first file that can be found
127         if [[ -f "${EROOT%/}"/etc/lirc/lircd.conf ]]; then
128                 cp "${EROOT%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
129         elif [[ -f "${EROOT%/}"/etc/lircd.conf ]]; then
130                 cp "${EROOT%/}"/etc/lircd.conf "${T}"/lircd.conf || die
131                 MOVE_OLD_LIRCD_CONF=1
132         elif [[ -f "${ED%/}"/etc/lirc/lircd.conf ]]; then
133                 cp "${ED%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
134         fi
135
136         # stop portage from touching the config file
137         if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
138                 rm -f "${ED%/}"/etc/lirc/lircd.conf || die
139         fi
140 }
141
142 pkg_postinst() {
143         # copy config file to new location
144         # without portage knowing about it
145         # so it will not delete it on unmerge or ever touch it again
146         if [[ -e "${T}"/lircd.conf ]]; then
147                 cp "${T}"/lircd.conf "${EROOT%/}"/etc/lirc/lircd.conf || die
148                 if [[ "$MOVE_OLD_LIRCD_CONF" = "1" ]]; then
149                         elog "Moved /etc/lircd.conf to /etc/lirc/lircd.conf"
150                         rm -f "${EROOT%/}"/etc/lircd.conf || die
151                 fi
152         fi
153
154         einfo "The new default location for lircd.conf is inside of"
155         einfo "${EROOT%/}/etc/lirc/ directory"
156 }