Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 159013 | Differences between
and this patch

Collapse All | Expand All

(-)/in/zaptel-1.4.9.ebuild (-22 / +272 lines)
Lines 2-32 Link Here
2
# Distributed under the terms of the GNU General Public License v2
2
# Distributed under the terms of the GNU General Public License v2
3
# $Header: $
3
# $Header: $
4
4
5
# inherit subversion linux-mod toolchain-funcs eutils
5
inherit toolchain-funcs eutils linux-info linux-mod
6
inherit linux-mod toolchain-funcs eutils
6
7
## NOTE:
8
#
9
# florz disabled
10
#
11
12
BRI_VERSION="0.4.0-test6"
13
14
IUSE="bri ecmark ecmark2 ecmark3 ecaggressive eckb1 ecmg2 ecsteve ecsteve2 florz rtc usb watchdog zapras zapnet"
7
15
8
# ESVN_REPO_URI="http://svn.digium.com/svn/zaptel/branches/1.4"
9
MY_P="${P/_/-}"
16
MY_P="${P/_/-}"
10
17
11
DESCRIPTION="Drivers for Digium and ZapataTelephony cards"
18
DESCRIPTION="Drivers for Digium and ZapataTelephony cards"
12
HOMEPAGE="http://www.asterisk.org"
19
HOMEPAGE="http://www.asterisk.org"
13
# SRC_URI=""
20
SRC_URI="http://ftp.digium.com/pub/zaptel/releases/${MY_P}.tar.gz
14
SRC_URI="http://ftp.digium.com/pub/zaptel/releases/${MY_P}.tar.gz"
21
	 bri? ( http://www.junghanns.net/downloads/bristuff-${BRI_VERSION}.tar.gz )"
15
22
16
S="${WORKDIR}/${MY_P}"
23
S="${WORKDIR}/${MY_P}"
17
24
25
S_BRI="${WORKDIR}/bristuff-${BRI_VERSION}"
26
18
SLOT="0"
27
SLOT="0"
19
LICENSE="GPL-2"
28
LICENSE="GPL-2"
20
KEYWORDS="~amd64 ~x86"
29
KEYWORDS="~x86 ~amd64"
21
IUSE="ztdummy-only rtc"
22
30
23
31
24
RDEPEND="virtual/libc
32
RDEPEND="virtual/libc
33
	usb? ( dev-libs/libusb )
25
	>=dev-libs/newt-0.50.0"
34
	>=dev-libs/newt-0.50.0"
26
35
27
DEPEND="${RDEPEND}
36
DEPEND="${RDEPEND}
28
	virtual/linux-sources"
37
	virtual/linux-sources"
29
38
39
# list of echo canceller use flags,
40
# first active in this list is selected (=order does matter)
41
ZAP_EC_FLAGS="ecmark ecmark2 ecmark3 ecsteve ecsteve2 eckb1 ecmg2"
42
43
### Begin: Helper functions
44
45
select_echo_cancel() {
46
	local myEC=""
47
48
	for x in ${ZAP_EC_FLAGS}; do
49
		if use $x; then
50
			myEC=$(echo "$x" | sed -e "s:^ec::" | tr '[:lower:]' '[:upper:]')
51
			break;
52
		fi
53
	done
54
55
	echo ${myEC}
56
}
57
58
zconfig_disable() {
59
	if grep -q "${1}" "${S}"/zconfig.h; then
60
		# match a little more than ${1} so we can use zconfig_disable
61
		# to disable all echo cancellers in zconfig.h w/o calling it several times
62
		sed -i -e "s:^[ \t]*#define[ \t]\+\(${1}[a-zA-Z0-9_-]*\).*:#undef \1:" \
63
			"${S}"/zconfig.h
64
	fi
65
66
	return $?
67
}
68
69
zconfig_enable() {
70
	if grep -q "${1}" "${S}"/zconfig.h; then
71
		sed -i  -e "s:^/\*[ \t]*#define[ \t]\+\(${1}\).*:#define \1:" \
72
			-e "s:^[ \t]*#undef[ \t]\+\(${1}\).*:#define \1:" \
73
			"${S}"/zconfig.h
74
	fi
75
76
	return $?
77
}
78
79
### End: Helper functions
30
80
31
pkg_setup() {
81
pkg_setup() {
32
	local result=0 numec=0
82
	local result=0 numec=0
Lines 35-46 Link Here
35
85
36
	einfo "Running pre-flight checks..."
86
	einfo "Running pre-flight checks..."
37
87
88
	# basic zaptel checks
89
	if kernel_is 2 4 ; then
90
		if ! linux_chkconfig_present CRC32; then
91
			echo
92
			eerror "Your kernel lacks CRC32 support!"
93
			eerror "Enable CONFIG_CRC32!"
94
			result=$((result+1))
95
		fi
96
	else
38
		if ! linux_chkconfig_present CRC_CCITT; then
97
		if ! linux_chkconfig_present CRC_CCITT; then
39
			echo
98
			echo
40
			eerror "Your kernel lacks CRC_CCIT support!"
99
			eerror "Your kernel lacks CRC_CCIT support!"
41
			eerror "Enable CONFIG_CRC_CCIT!"
100
			eerror "Enable CONFIG_CRC_CCIT!"
42
			result=$((result+1))
101
			result=$((result+1))
43
		fi
102
		fi
103
	fi
104
105
	# check if multiple echo cancellers have been selected
106
	for x in ${ZAP_EC_FLAGS}; do
107
		use $x && numec=$((numec+1))
108
	done
109
	if [[ $numec -gt 1 ]]; then
110
		# multiple flags are active, only the first in the ZAP_EC_FLAGS list
111
		# will be used, make sure the user knows about this
112
		echo
113
		ewarn "Multiple echo canceller flags are active but only one will be used!"
114
		ewarn "Selected: $(select_echo_cancel)"
115
	fi
116
117
	# we need at least HDLC generic support
118
	if use zapnet && ! linux_chkconfig_present HDLC; then
119
		echo
120
		eerror "zapnet: Your kernel lacks HDLC support!"
121
		eerror "zapnet: Enable CONFIG_HDLC* to use zaptel network support!"
122
		result=$((result+1))
123
	fi
124
125
	# zapras needs PPP support
126
	if use zapras && ! linux_chkconfig_present PPP; then
127
		echo
128
		eerror "zapras: Your kernel lacks PPP support!"
129
		eerror "zapras: Enable CONFIG_PPP* to use zaptel ras support!"
130
		result=$((result+1))
131
	fi
44
132
45
	# rtc needs linux-2.6 and CONFIG_RTC
133
	# rtc needs linux-2.6 and CONFIG_RTC
46
	if use rtc; then
134
	if use rtc; then
Lines 74-111 Link Here
74
	einfo "Zaptel is happy and continues... :)"
162
	einfo "Zaptel is happy and continues... :)"
75
}
163
}
76
164
165
src_unpack() {
166
	unpack ${A}
77
167
78
src_compile() {
168
	cd "${S}"
169
	epatch "${FILESDIR}/${PN}-1.4.9.2-gentoo.diff"
79
170
80
	econf \
171
	# try to apply bristuff patch
81
		  --sysconfdir=/etc \
172
	if use bri; then
82
		  || die
173
		# fix for userpriv
174
		chmod -R a=rwX "${S_BRI}"
175
176
		cd "${S}/kernel"
177
		einfo "Patching zaptel with bristuff"
178
		epatch "${S_BRI}/patches/zaptel/100-bri_dchan.diff"
179
180
		einfo "Patching zaphfc"
181
		cd "${S_BRI}"
182
		for PATCH in `sed -e 's/#.*$//' ${S_BRI}/patches/zaphfc/series` ; do
183
			epatch "${S_BRI}/patches/zaphfc/$PATCH"
184
		done
185
186
		# patch includes
187
		sed -i  -e "s:^#include.*zaptel\.h.*:#include <zaptel.h>:" \
188
			qozap/qozap.c \
189
			zaphfc/zaphfc.c \
190
			cwain/cwain.c
191
192
		# patch makefiles
193
		sed -i  -e "s:^ZAP[\t ]*=.*:ZAP=-I${S}/kernel:" \
194
			-e "s:^MODCONF=.*:MODCONF=/etc/modules.d/zaptel:" \
195
			-e "s:linux-2.6:linux:g" \
196
			qozap/Makefile \
197
			zaphfc/Makefile \
198
			cwain/Makefile
199
200
		sed -i  -e "s:^\(CFLAGS+=-I. \).*:\1 \$(ZAP):" \
201
			zaphfc/Makefile
202
203
		epatch "${FILESDIR}"/${PN}-1.4.9.2-bristuff-KSRC.patch
204
		cd "${S}"
205
	fi
83
206
84
	# menuselect.makeopts for ztdummy only
207
### Configuration changes
208
	local myEC
209
210
	# prepare zconfig.h
211
	myEC=$(select_echo_cancel)
212
	if [[ -n "${myEC}" ]]; then
213
		einfo "Selected echo canceller: ${myEC}"
214
		# disable default first, set new selected ec afterwards
215
		zconfig_disable ECHO_CAN
216
		zconfig_enable ECHO_CAN_${myEC}
217
	fi
218
219
	# enable rtc support on 2.6
220
	if use rtc && linux_chkconfig_present RTC && kernel_is 2 6; then
221
		einfo "Enabling ztdummy RTC support"
222
		zconfig_enable USE_RTC
223
	fi
224
225
	# enable agressive echo surpression
226
	use ecaggressive && \
227
		zconfig_enable AGGRESSIVE_SUPPRESSOR
228
229
	# ppp ras support
230
	use zapras && \
231
		zconfig_enable CONFIG_ZAPATA_PPP
232
233
	# frame relay, syncppp...
234
	use zapnet && \
235
		zconfig_enable CONFIG_ZAPATA_NET
236
237
	# zaptel watchdog
238
	use watchdog && \
239
		zconfig_enable CONFIG_ZAPTEL_WATCHDOG
240
}
85
241
86
	use ztdummy-only && cp "${FILESDIR}"/menuselect.makeopts ${S}
242
src_compile() {
87
	
243
	# fun, zaptel uses autotools now
88
	epatch ${FILESDIR}/zaptel-1.4.9-gentoo.diff
244
	econf \
89
	
245
		--sysconfdir=/etc \
90
	# build
246
		$(use_with usb) || die
91
	make DESTDIR="${D}" KVERS=${KV_FULL} KSRC=${KV_DIR} || die
92
247
248
	# build. xpp stuff is included
249
	make KVERS=${KV_FULL} \
250
	     KSRC=${KV_DIR} ARCH=$(tc-arch-kernel) || \
251
		 	die "KVERS=${KV_FULL} KSRC=${KV_DIR} ARCH=$(tc-arch-kernel)"
252
253
	# zaphfc driver
254
	if use bri; then
255
		cd "${S_BRI}"
256
		for x in zaphfc; do
257
			einfo "Building ${x}..."
258
			make KVERS="${KV_FULL}" \
259
				KSRC="${KV_DIR}" \
260
				INSTALL_PREFIX="${D}" \
261
				ARCH=$(tc-arch-kernel) \
262
				-C ${x} || die "make ${x} failed"
263
		done
264
	fi
93
}
265
}
94
266
95
src_install() {
267
src_install() {
268
	kernel_is 2 4 && cp /etc/modules.conf "${D}"/etc
269
	make DESTDIR="${D}" ARCH=$(tc-arch-kernel) \
270
	     KVERS=${KV_FULL} KSRC=${KV_DIR} install || die
271
272
	dodoc ChangeLog README README.Linux26 README.fxsusb zaptel.init
273
	dodoc zaptel.conf.sample LICENSE zaptel.sysconfig README.fxotune
274
275
	# additional tools
276
	dobin ztmonitor ztspeed zttest fxotune
277
278
	# install all header files, several packages need the complete set
279
	# (e.g. sangoma wanpipe)
280
	insinto /usr/include/zaptel
281
	doins *.h
282
283
	if use bri; then
284
		einfo "Installing bri"
285
		cd "${S_BRI}"
286
287
		insinto /lib/modules/${KV_FULL}/misc
288
		doins qozap/qozap.${KV_OBJ}
289
		doins zaphfc/zaphfc.${KV_OBJ}
290
		doins cwain/cwain.${KV_OBJ}
291
292
		# install example configs for octoBRI and quadBRI
293
		insinto /etc
294
		doins qozap/zaptel.conf.octoBRI
295
		newins qozap/zaptel.conf zaptel.conf.quadBRI
296
		newins zaphfc/zaptel.conf zaptel.conf.zaphfc
297
298
		insinto /etc/asterisk
299
		doins qozap/zapata.conf.octoBRI
300
		newins qozap/zapata.conf zapata.conf.quadBRI
301
		newins zaphfc/zapata.conf zapata.conf.zaphfc
302
303
		docinto bristuff
304
		dodoc CHANGES INSTALL
305
306
		docinto bristuff/qozap
307
		dodoc qozap/LICENSE qozap/TODO qozap/*.conf*
308
309
		docinto bristuff/zaphfc
310
		dodoc zaphfc/LICENSE zaphfc/*.conf
311
312
		docinto bristuff/cwain
313
		dodoc cwain/TODO cwain/LICENSE
314
315
		cd "${S}"
316
	fi
96
317
97
	# install init script
318
	# install init script
98
	newinitd ${FILESDIR}/zaptel.rc6 zaptel
319
	newinitd "${FILESDIR}"/zaptel.rc6 zaptel
99
	newconfd ${FILESDIR}/zaptel.confd zaptel
320
	newconfd "${FILESDIR}"/zaptel.confd zaptel
100
				
321
322
	# install devfsd rule file
323
	insinto /etc/devfs.d
324
	newins "${FILESDIR}"/zaptel.devfsd zaptel
325
326
	# fix permissions if there's no udev / devfs around
327
	if [[ -d "${D}"/dev/zap ]]; then
328
		chown -R root:dialout	"${D}"/dev/zap
329
		chmod -R u=rwX,g=rwX,o= "${D}"/dev/zap
330
	fi
101
331
102
	make DESTDIR="${D}" KVERS=${KV_FULL} KSRC=${KV_DIR} install || die
103
}
332
}
104
333
105
pkg_postinst() {
334
pkg_postinst() {
335
	linux-mod_pkg_postinst
106
336
107
	echo
337
	echo
108
	einfo "Use the /etc/init.d/zaptel script to load zaptel.conf settings on startup!"
338
	einfo "Use the /etc/init.d/zaptel script to load zaptel.conf settings on startup!"
109
	echo
339
	echo
110
340
341
	if use bri; then
342
		einfo "Bristuff configs have been merged as:"
343
		einfo ""
344
		einfo "${ROOT}etc/"
345
		einfo "    zaptel.conf.zaphfc"
346
		einfo "    zaptel.conf.quadBRI"
347
		einfo "    zaptel.conf.octoBRI"
348
		einfo ""
349
		einfo "${ROOT}etc/asterisk/"
350
		einfo "    zapata.conf.zaphfc"
351
		einfo "    zapata.conf.quadBRI"
352
		einfo "    zapata.conf.octoBRI"
353
		echo
354
	fi
355
356
	# fix permissions if there's no udev / devfs around
357
	if [[ -d "${ROOT}"dev/zap ]]; then
358
		chown -R root:dialout	"${ROOT}"dev/zap
359
		chmod -R u=rwX,g=rwX,o= "${ROOT}"dev/zap
360
	fi
111
}
361
}

Return to bug 159013