9bcbfe77cafbc393201cd90f7e395bb84db7892a
[gentoo.git] / app-misc / lirc / lirc-0.10.1-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{5,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[${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 PATCHES=(
71         "${FILESDIR}/${P}-unsafe-load.patch"
72 )
73
74 MAKEOPTS+=" -j1"
75
76 pkg_setup() {
77         use uinput && CONFIG_CHECK="~INPUT_UINPUT"
78         python-single-r1_pkg_setup
79         linux-info_pkg_setup
80 }
81
82 src_configure() {
83         xdg_environment_reset
84         econf \
85                 --localstatedir="${EPREFIX}/var" \
86                 $(use_enable static-libs static) \
87                 $(use_enable devinput) \
88                 $(use_enable uinput) \
89                 $(use_with X x)
90 }
91
92 src_install() {
93         default
94
95         if use !gtk ; then
96                 # lirc-setup requires gtk
97                 rm "${ED%/}"/usr/bin/lirc-setup || die
98         fi
99
100         newinitd "${FILESDIR}"/lircd-0.8.6-r2 lircd
101         newinitd "${FILESDIR}"/lircmd-0.9.4a-r2 lircmd
102         newconfd "${FILESDIR}"/lircd.conf.4 lircd
103         newconfd "${FILESDIR}"/lircmd-0.10.0.conf lircmd
104
105         insinto /etc/modprobe.d/
106         newins "${FILESDIR}"/modprobed.lirc lirc.conf
107
108         newinitd "${FILESDIR}"/irexec-initd-0.9.4a-r2 irexec
109         newconfd "${FILESDIR}"/irexec-confd irexec
110
111         keepdir /etc/lirc
112         if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
113                 newdoc "${ED%/}"/etc/lirc/lircd.conf lircd.conf.example
114         fi
115
116         find "${ED}" -name '*.la' -delete || die
117
118         # Avoid QA notice
119         rm -d "${ED%/}"/var/run/lirc || die
120         rm -d "${ED%/}"/var/run || die
121 }
122
123 pkg_preinst() {
124         local dir="${EROOT%/}/etc/modprobe.d"
125         if [[ -a "${dir}"/lirc && ! -a "${dir}"/lirc.conf ]]; then
126                 elog "Renaming ${dir}/lirc to lirc.conf"
127                 mv -f "${dir}/lirc" "${dir}/lirc.conf" || die
128         fi
129
130         # copy the first file that can be found
131         if [[ -f "${EROOT%/}"/etc/lirc/lircd.conf ]]; then
132                 cp "${EROOT%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
133         elif [[ -f "${EROOT%/}"/etc/lircd.conf ]]; then
134                 cp "${EROOT%/}"/etc/lircd.conf "${T}"/lircd.conf || die
135                 MOVE_OLD_LIRCD_CONF=1
136         elif [[ -f "${ED%/}"/etc/lirc/lircd.conf ]]; then
137                 cp "${ED%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
138         fi
139
140         # stop portage from touching the config file
141         if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
142                 rm -f "${ED%/}"/etc/lirc/lircd.conf || die
143         fi
144 }
145
146 pkg_postinst() {
147         # copy config file to new location
148         # without portage knowing about it
149         # so it will not delete it on unmerge or ever touch it again
150         if [[ -e "${T}"/lircd.conf ]]; then
151                 cp "${T}"/lircd.conf "${EROOT%/}"/etc/lirc/lircd.conf || die
152                 if [[ "$MOVE_OLD_LIRCD_CONF" = "1" ]]; then
153                         elog "Moved /etc/lircd.conf to /etc/lirc/lircd.conf"
154                         rm -f "${EROOT%/}"/etc/lircd.conf || die
155                 fi
156         fi
157
158         einfo "The new default location for lircd.conf is inside of"
159         einfo "${EROOT%/}/etc/lirc/ directory"
160 }