sys-block/btrace: Merge GitHub PR #1716
[gentoo.git] / app-misc / lirc / lirc-0.9.4a-r2.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6
7 inherit eutils flag-o-matic systemd
8
9 DESCRIPTION="decode and send infra-red signals of many commonly used remote controls"
10 HOMEPAGE="http://www.lirc.org/"
11
12 LIRC_DRIVER_DEVICE="/dev/lirc0"
13
14 MY_P=${PN}-${PV/_/}
15
16 if [[ "${PV/_pre/}" = "${PV}" ]]; then
17         SRC_URI="mirror://sourceforge/lirc/${MY_P}.tar.bz2"
18 else
19         SRC_URI="http://www.lirc.org/software/snapshots/${MY_P}.tar.bz2"
20 fi
21
22 LICENSE="GPL-2"
23 SLOT="0"
24 KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
25 IUSE="doc static-libs X audio irman ftdi inputlirc iguanair systemd usb"
26
27 S="${WORKDIR}/${MY_P}"
28
29 REQUIRED_USE="
30         iguanair? ( irman )
31 "
32 DEPEND="
33         doc? ( app-doc/doxygen )
34 "
35
36 RDEPEND="
37         X? (
38                 x11-libs/libX11
39                 x11-libs/libSM
40                 x11-libs/libICE
41         )
42         systemd? ( sys-apps/systemd )
43         audio? (
44                 >media-libs/portaudio-18
45                 media-libs/alsa-lib
46         )
47         irman? ( media-libs/libirman )
48         iguanair? ( app-misc/iguanaIR )
49         ftdi? ( dev-embedded/libftdi:0 )
50         inputlirc? ( app-misc/inputlircd )
51         usb? ( virtual/libusb:0 )
52 "
53
54 PATCHES=(
55         "${FILESDIR}"/lirc-0.9.4-doc-path-fix.patch # https://bugs.gentoo.org/show_bug.cgi?id=589246 https://sourceforge.net/p/lirc/tickets/214/
56 )
57
58 src_configure() {
59         filter-flags -Wl,-O1
60         econf \
61                 --localstatedir=/var \
62                 $(use_enable static-libs static) \
63                 $(use_with X x)
64 }
65
66 # Defined src_compile as a workaround for a parallel make issue
67 # See https://bugs.gentoo.org/show_bug.cgi?id=588864
68 # and https://sourceforge.net/p/lirc/tickets/210/
69 src_compile() {
70         emake lib
71         emake
72 }
73
74 src_install() {
75         default
76
77         newinitd "${FILESDIR}"/lircd-0.8.6-r2 lircd
78         newinitd "${FILESDIR}"/lircmd-0.9.4a-r2 lircmd
79         newconfd "${FILESDIR}"/lircd.conf.4 lircd
80         newconfd "${FILESDIR}"/lircmd.conf lircmd
81
82         insinto /etc/modprobe.d/
83         newins "${FILESDIR}"/modprobed.lirc lirc.conf
84
85         newinitd "${FILESDIR}"/irexec-initd-0.9.4a-r2 irexec
86         newconfd "${FILESDIR}"/irexec-confd irexec
87
88         keepdir /etc/lirc
89         if [[ -e "${D}"/etc/lirc/lircd.conf ]]; then
90                 newdoc "${D}"/etc/lirc/lircd.conf lircd.conf.example
91         fi
92
93         find "${D}" -name '*.la' -delete || die
94
95         # Avoid QA notice
96         rm -d "${D}"/var/run/lirc || die
97         rm -d "${D}"/var/run || die
98 }
99
100 pkg_preinst() {
101         local dir="${EROOT}/etc/modprobe.d"
102         if [[ -a "${dir}"/lirc && ! -a "${dir}"/lirc.conf ]]; then
103                 elog "Renaming ${dir}/lirc to lirc.conf"
104                 mv -f "${dir}/lirc" "${dir}/lirc.conf" || die
105         fi
106
107         # copy the first file that can be found
108         if [[ -f "${EROOT}"/etc/lirc/lircd.conf ]]; then
109                 cp "${EROOT}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
110         elif [[ -f "${EROOT}"/etc/lircd.conf ]]; then
111                 cp "${EROOT}"/etc/lircd.conf "${T}"/lircd.conf || die
112                 MOVE_OLD_LIRCD_CONF=1
113         elif [[ -f "${D}"/etc/lirc/lircd.conf ]]; then
114                 cp "${D}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
115         fi
116
117         # stop portage from touching the config file
118         if [[ -e "${D}"/etc/lirc/lircd.conf ]]; then
119                 rm -f "${D}"/etc/lirc/lircd.conf || die
120         fi
121 }
122
123 pkg_postinst() {
124         # copy config file to new location
125         # without portage knowing about it
126         # so it will not delete it on unmerge or ever touch it again
127         if [[ -e "${T}"/lircd.conf ]]; then
128                 cp "${T}"/lircd.conf "${EROOT}"/etc/lirc/lircd.conf || die
129                 if [[ "$MOVE_OLD_LIRCD_CONF" = "1" ]]; then
130                         elog "Moved /etc/lircd.conf to /etc/lirc/lircd.conf"
131                         rm -f "${EROOT}"/etc/lircd.conf || die
132                 fi
133         fi
134
135         einfo "The new default location for lircd.conf is inside of"
136         einfo "/etc/lirc/ directory"
137 }