summaryrefslogtreecommitdiff
blob: 0d55080f738ef642e3c2b3628da68fc4c4e2ff5d (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
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

PYTHON_COMPAT=( python3_4 python3_5 )

inherit eutils flag-o-matic python-single-r1 systemd xdg-utils

DESCRIPTION="decode and send infra-red signals of many commonly used remote controls"
HOMEPAGE="http://www.lirc.org/"

LIRC_DRIVER_DEVICE="/dev/lirc0"

MY_P=${PN}-${PV/_/}

if [[ "${PV/_pre/}" = "${PV}" ]]; then
	SRC_URI="mirror://sourceforge/lirc/${MY_P}.tar.bz2"
else
	SRC_URI="http://www.lirc.org/software/snapshots/${MY_P}.tar.bz2"
fi

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
IUSE="audio doc ftdi gtk inputlirc static-libs systemd usb X"

REQUIRED_USE="
	${PYTHON_REQUIRED_USE}
	gtk? ( X )
"

S="${WORKDIR}/${MY_P}"

COMMON_DEPEND="
	${PYTHON_DEPS}
	audio? (
		>media-libs/portaudio-18
		media-libs/alsa-lib
	)
	dev-python/pyyaml[${PYTHON_USEDEP}]
	ftdi? ( dev-embedded/libftdi:0 )
	systemd? ( sys-apps/systemd )
	usb? ( virtual/libusb:0 )
	X? (
		x11-libs/libICE
		x11-libs/libSM
		x11-libs/libX11
	)
"

DEPEND="
	${COMMON_DEPEND}
	dev-libs/libxslt
	doc? ( app-doc/doxygen )
	sys-apps/kmod
	sys-kernel/linux-headers
"

RDEPEND="
	${COMMON_DEPEND}
	gtk? (
		x11-libs/vte[introspection]
		dev-python/pygobject[${PYTHON_USEDEP}]
	)
	inputlirc? ( app-misc/inputlircd )
"

PATCHES=(
	# https://bugs.gentoo.org/show_bug.cgi?id=589246 https://sourceforge.net/p/lirc/tickets/214/
	"${FILESDIR}"/lirc-0.9.4-doc-path-fix.patch
)

src_configure() {
	xdg_environment_reset
	econf \
		--localstatedir="${EPREFIX}/var" \
		$(use_enable static-libs static) \
		$(use_with X x)
}

src_install() {
	default

	if use !gtk ; then
		# lirc-setup requires gtk
		rm "${ED%/}"/usr/bin/lirc-setup || die
	fi

	newinitd "${FILESDIR}"/lircd-0.8.6-r2 lircd
	newinitd "${FILESDIR}"/lircmd-0.9.4a-r2 lircmd
	newconfd "${FILESDIR}"/lircd.conf.4 lircd
	newconfd "${FILESDIR}"/lircmd.conf lircmd

	insinto /etc/modprobe.d/
	newins "${FILESDIR}"/modprobed.lirc lirc.conf

	newinitd "${FILESDIR}"/irexec-initd-0.9.4a-r2 irexec
	newconfd "${FILESDIR}"/irexec-confd irexec

	keepdir /etc/lirc
	if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
		newdoc "${ED%/}"/etc/lirc/lircd.conf lircd.conf.example
	fi

	find "${ED}" -name '*.la' -delete || die

	# Avoid QA notice
	rm -d "${ED%/}"/var/run/lirc || die
	rm -d "${ED%/}"/var/run || die
}

pkg_preinst() {
	local dir="${EROOT%/}/etc/modprobe.d"
	if [[ -a "${dir}"/lirc && ! -a "${dir}"/lirc.conf ]]; then
		elog "Renaming ${dir}/lirc to lirc.conf"
		mv -f "${dir}/lirc" "${dir}/lirc.conf" || die
	fi

	# copy the first file that can be found
	if [[ -f "${EROOT%/}"/etc/lirc/lircd.conf ]]; then
		cp "${EROOT%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
	elif [[ -f "${EROOT%/}"/etc/lircd.conf ]]; then
		cp "${EROOT%/}"/etc/lircd.conf "${T}"/lircd.conf || die
		MOVE_OLD_LIRCD_CONF=1
	elif [[ -f "${ED%/}"/etc/lirc/lircd.conf ]]; then
		cp "${ED%/}"/etc/lirc/lircd.conf "${T}"/lircd.conf || die
	fi

	# stop portage from touching the config file
	if [[ -e "${ED%/}"/etc/lirc/lircd.conf ]]; then
		rm -f "${ED%/}"/etc/lirc/lircd.conf || die
	fi
}

pkg_postinst() {
	# copy config file to new location
	# without portage knowing about it
	# so it will not delete it on unmerge or ever touch it again
	if [[ -e "${T}"/lircd.conf ]]; then
		cp "${T}"/lircd.conf "${EROOT%/}"/etc/lirc/lircd.conf || die
		if [[ "$MOVE_OLD_LIRCD_CONF" = "1" ]]; then
			elog "Moved /etc/lircd.conf to /etc/lirc/lircd.conf"
			rm -f "${EROOT%/}"/etc/lircd.conf || die
		fi
	fi

	einfo "The new default location for lircd.conf is inside of"
	einfo "${EROOT%/}/etc/lirc/ directory"
}