/[gentoo-x86]/net-misc/zaptel/zaptel-1.2.18-r1.ebuild
Gentoo

Contents of /net-misc/zaptel/zaptel-1.2.18-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Sat Nov 14 13:06:33 2009 UTC (10 years ago) by scarabeus
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +1 -1 lines
FILE REMOVED
Drop 2 years masked version. Since newer versions are around.
(Portage version: 2.2_rc49/cvs/Linux x86_64)

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-misc/zaptel/zaptel-1.2.18-r1.ebuild,v 1.5 2009/11/11 07:50:18 robbat2 Exp $
4
5 inherit toolchain-funcs eutils linux-mod
6
7 BRI_VERSION="0.3.0-PRE-1y-h"
8 FLORZ_VERSION="0.3.0-PRE-1y-h_florz-12"
9
10 OSLEC_VERSION="0.1"
11 OSLEC_PATCH="oslec-${OSLEC_VERSION}-${P}"
12
13 IUSE="astribank bri ecmark ecmark2 ecmark3 ecaggressive eckb1 ecmg2 ecsteve ecsteve2 ecoslec florz
14 mmx rtc watchdog zapras zapnet"
15
16 MY_P="${P/_/-}"
17
18 DESCRIPTION="Drivers for Digium and ZapataTelephony cards"
19 HOMEPAGE="http://www.asterisk.org"
20 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 )
22 florz? ( http://www.netdomination.org/pub/asterisk/zaphfc_${FLORZ_VERSION}.diff.gz )
23 ecoslec? ( http://www.rowetel.com/ucasterisk/downloads/oslec-${OSLEC_VERSION}.tar.gz
24 mirror://gentoo/${OSLEC_PATCH}.diff.gz )"
25
26 S="${WORKDIR}/${MY_P}"
27
28 S_BRI="${WORKDIR}/bristuff-${BRI_VERSION}"
29 S_OSLEC="${WORKDIR}/oslec-${OSLEC_VERSION}/kernel"
30
31 SLOT="0"
32 LICENSE="GPL-2"
33 KEYWORDS="~amd64 ~ppc ~x86"
34
35 RDEPEND="=virtual/libusb-0*
36 >=dev-libs/newt-0.50.0
37 astribank? ( dev-lang/perl )
38 ecoslec? ( dev-util/dialog )"
39
40 DEPEND="${RDEPEND} virtual/linux-sources"
41
42 # list of echo canceller use flags,
43 # first active in this list is selected (=order does matter)
44 ZAP_EC_FLAGS="ecmark ecmark2 ecmark3 ecsteve ecsteve2 eckb1 ecmg2 ecoslec"
45
46 ### Begin: Helper functions
47
48 select_echo_cancel() {
49 local myEC=""
50
51 for x in ${ZAP_EC_FLAGS}; do
52 if use $x; then
53 myEC=$(echo "$x" | sed -e "s:^ec::" | tr '[:lower:]' '[:upper:]')
54 break;
55 fi
56 done
57
58 echo ${myEC}
59 }
60
61 zconfig_disable() {
62 if grep -q "${1}" "${S}/zconfig.h"; then
63 # match a little more than ${1} so we can use zconfig_disable
64 # to disable all echo cancellers in zconfig.h w/o calling it several times
65 sed -i -e "s:^[ \t]*#define[ \t]\+\(${1}[a-zA-Z0-9_-]*\).*:#undef \1:" \
66 "${S}/zconfig.h"
67 fi
68
69 return $?
70 }
71
72 zconfig_enable() {
73 if grep -q "${1}" "${S}/zconfig.h"; then
74 sed -i -e "s:^/\*[ \t]*#define[ \t]\+\(${1}\).*:#define \1:" \
75 -e "s:^[ \t]*#undef[ \t]\+\(${1}\).*:#define \1:" \
76 "${S}/zconfig.h"
77 fi
78
79 return $?
80 }
81
82 ### End: Helper functions
83
84 pkg_setup() {
85 local result=0 numec=0
86
87 linux-mod_pkg_setup
88
89 einfo "Running pre-flight checks..."
90
91 # basic zaptel checks
92 if kernel_is 2 4 ; then
93 if ! linux_chkconfig_present CRC32; then
94 echo
95 eerror "Your kernel lacks CRC32 support!"
96 eerror "Enable CONFIG_CRC32!"
97 result=$((result+1))
98 fi
99 else
100 if ! linux_chkconfig_present CRC_CCITT; then
101 echo
102 eerror "Your kernel lacks CRC_CCIT support!"
103 eerror "Enable CONFIG_CRC_CCIT!"
104 result=$((result+1))
105 fi
106 if ! linux_chkconfig_present FW_LOADER; then
107 echo
108 eerror "Your kernel lacks FW_LOADER support!"
109 eerror "Enable CONFIG_FW_LOADER!"
110 result=$((result+1))
111 fi
112 fi
113
114 # check if multiple echo cancellers have been selected
115 for x in ${ZAP_EC_FLAGS}; do
116 use $x && numec=$((numec+1))
117 done
118 if [[ $numec -gt 1 ]]; then
119 # multiple flags are active, only the first in the ZAP_EC_FLAGS list
120 # will be used, make sure the user knows about this
121 echo
122 ewarn "Multiple echo canceller flags are active but only one will be used!"
123 ewarn "Selected: $(select_echo_cancel)"
124 fi
125
126 # we need at least HDLC generic support
127 if use zapnet && ! linux_chkconfig_present HDLC; then
128 echo
129 eerror "zapnet: Your kernel lacks HDLC support!"
130 eerror "zapnet: Enable CONFIG_HDLC* to use zaptel network support!"
131 result=$((result+1))
132 fi
133
134 # zapras needs PPP support
135 if use zapras && ! linux_chkconfig_present PPP; then
136 echo
137 eerror "zapras: Your kernel lacks PPP support!"
138 eerror "zapras: Enable CONFIG_PPP* to use zaptel ras support!"
139 result=$((result+1))
140 fi
141
142 # rtc needs linux-2.6 and CONFIG_RTC
143 if use rtc; then
144 if ! kernel_is 2 6; then
145 echo
146 eerror "rtc: >=Linux-2.6.0 is needed for rtc support!"
147 result=$((result+1))
148 fi
149
150 if ! linux_chkconfig_present RTC; then
151 eerror "rtc: Your kernel lacks RealTime-Clock support!"
152 result=$((result+1))
153 fi
154 fi
155
156 if [[ $result -gt 0 ]]; then
157 echo
158 ewarn "One or more of the neccessary precondition(s) is/are not met!"
159 ewarn "Look at the messages above, resolve the problem (or disable the use-flag) and try again"
160 echo
161
162 if [[ $result -lt 3 ]]; then
163 eerror "[$result Error(s)] Zaptel is not happy :("
164 else
165 eerror "[$result Error(s)] You're making zaptel cry :'("
166 fi
167 die "[$result] Precondition(s) not met"
168 fi
169
170 echo
171 einfo "Zaptel is happy and continues... :)"
172 }
173
174 src_unpack() {
175 unpack ${A}
176
177 cd "${S}"
178 epatch "${FILESDIR}/${P}-2.6.22.diff"
179 epatch "${FILESDIR}/${P}-gentoo.diff"
180 epatch "${FILESDIR}/zaptel-1.2.9.1-ar.patch"
181
182 # try to apply bristuff patch
183 if use bri; then
184 # fix for userpriv
185 chmod -R a=rwX "${S_BRI}"
186
187 einfo "Patching zaptel w/ BRI stuff (${BRI_VERSION})"
188 epatch "${S_BRI}"/patches/zaptel.patch
189
190 cd "${S_BRI}"
191
192 if use florz; then
193 einfo "Using florz patches (${FLORZ_VERSION}) for zaphfc"
194
195 # remove as soon as there's a new florz patch available
196 sed -i -e "s:zaptel-1\.2\.5:zaptel-1.2.6:g" \
197 "${WORKDIR}/zaphfc_${FLORZ_VERSION}.diff"
198
199 epatch "${WORKDIR}/zaphfc_${FLORZ_VERSION}.diff"
200 fi
201
202 # patch includes
203 sed -i -e "s:^#include.*zaptel\.h.*:#include <zaptel.h>:" \
204 qozap/qozap.c \
205 zaphfc/zaphfc.c \
206 cwain/cwain.c
207
208 # patch makefiles
209 sed -i -e "s:^ZAP[\t ]*=.*:ZAP=-I${S}:" \
210 -e "s:^MODCONF=.*:MODCONF=/etc/modules.d/zaptel:" \
211 -e "s:linux-2.6:linux:g" \
212 qozap/Makefile \
213 zaphfc/Makefile \
214 cwain/Makefile
215
216 sed -i -e "s:^\(CFLAGS+=-I. \).*:\1 \$(ZAP):" \
217 zaphfc/Makefile
218
219 cd "${S}"
220 fi
221
222 # oslec echo canceller
223 if use ecoslec; then
224 #
225 # meh... bristuff and oslec patch are touching the same place,
226 # apply bristuff first then fixup the oslec patch
227 # ugly, but saves us from creating yet another set of patches
228 #
229 if use bri; then
230 sed -i \
231 -e "s:^-\(#define ECHO_CAN_KB1\).*:-/* \1 */:" \
232 -e "s:^.*\(#define ECHO_CAN_MG2\).*: \1:" \
233 "${WORKDIR}/${OSLEC_PATCH}.diff" || die "Failed to fix oslec patch for bri"
234 fi
235
236 EPATCH_SINGLE_MSG="Applying ${OSLEC_PATCH} zaptel patch" \
237 epatch "${WORKDIR}/${OSLEC_PATCH}.diff"
238
239 if use mmx; then
240 einfo "Enabling oslec mmx support"
241
242 sed -i -e "/^CFLAGS/s/\(.*\)/\1 -DUSE_MMX/" \
243 -e "s/\(EXTRA_CFLAGS='\)/\1-DUSE_MMX /" \
244 "${S_OSLEC}/Makefile" || die "Failed to enable mmx for oslec"
245 fi
246 fi
247
248 ### Configuration changes
249 local myEC
250
251 # prepare zconfig.h
252 myEC=$(select_echo_cancel)
253 if [[ -n "${myEC}" ]]; then
254 einfo "Selected echo canceller: ${myEC}"
255 # disable default first, set new selected ec afterwards
256 zconfig_disable ECHO_CAN
257 zconfig_enable ECHO_CAN_${myEC}
258 fi
259
260 # enable rtc support on 2.6
261 if use rtc && linux_chkconfig_present RTC && kernel_is 2 6; then
262 einfo "Enabling ztdummy RTC support"
263 zconfig_enable USE_RTC
264 fi
265
266 # enable agressive echo surpression
267 use ecaggressive && \
268 zconfig_enable AGGRESSIVE_SUPPRESSOR
269
270 # ppp ras support
271 use zapras && \
272 zconfig_enable CONFIG_ZAPATA_PPP
273
274 # frame relay, syncppp...
275 use zapnet && \
276 zconfig_enable CONFIG_ZAPATA_NET
277
278 # zaptel watchdog
279 use watchdog && \
280 zconfig_enable CONFIG_ZAPTEL_WATCHDOG
281
282 # mmx support
283 use mmx && \
284 zconfig_enable CONFIG_ZAPTEL_MMX
285 }
286
287 src_compile() {
288 # build
289 make KVERS="${KV_FULL}" \
290 KSRC="${KV_DIR}" ARCH="$(tc-arch-kernel)" || die
291
292 if use astribank; then
293 cd "${S}"/xpp/utils
294 make || die "make xpp utils failed"
295 fi
296
297 if use bri; then
298 cd "${S_BRI}"
299 for x in cwain qozap zaphfc; do
300 einfo "Building ${x}..."
301 make KVERS="${KV_FULL}" \
302 KSRC=/usr/src/linux \
303 ARCH="$(tc-arch-kernel)" \
304 -C "${x}" || die "make ${x} failed"
305 done
306 fi
307
308 if use ecoslec; then
309 cd "${S_OSLEC}"
310 make KVERS="${KV_FULL}" \
311 KDIR=/usr/src/linux \
312 ARCH="$(tc-arch-kernel)" || die "emake oslec failed"
313 fi
314 }
315
316 src_install() {
317 # Create firmware directory
318 mkdir -p "${D}/lib/firmware/"
319
320 kernel_is 2 4 && cp /etc/modules.conf "${D}/etc"
321 make INSTALL_PREFIX="${D}" ARCH="$(tc-arch-kernel)" \
322 KVERS="${KV_FULL}" KSRC=/usr/src/linux install || die
323
324 dodoc ChangeLog README README.udev README.Linux26 README.fxsusb zaptel.init
325 dodoc zaptel.conf.sample zaptel.sysconfig README.fxotune
326
327 # additional tools
328 dobin ztmonitor ztspeed zttest fxotune
329
330 # install all header files, several packages need the complete set
331 # (e.g. sangoma wanpipe)
332 insinto /usr/include/zaptel
333 doins *.h
334
335 if use bri; then
336 einfo "Installing bri"
337 cd "${S_BRI}"
338
339 insinto "/lib/modules/${KV_FULL}/misc"
340 doins "qozap/qozap.${KV_OBJ}"
341 doins "zaphfc/zaphfc.${KV_OBJ}"
342 doins "cwain/cwain.${KV_OBJ}"
343
344 # install example configs for octoBRI and quadBRI
345 insinto /etc
346 doins qozap/zaptel.conf.octoBRI
347 newins qozap/zaptel.conf zaptel.conf.quadBRI
348 newins zaphfc/zaptel.conf zaptel.conf.zaphfc
349
350 insinto /etc/asterisk
351 doins qozap/zapata.conf.octoBRI
352 newins qozap/zapata.conf zapata.conf.quadBRI
353 newins zaphfc/zapata.conf zapata.conf.zaphfc
354
355 docinto bristuff
356 dodoc CHANGES INSTALL
357
358 docinto bristuff/qozap
359 dodoc qozap/LICENSE qozap/TODO qozap/*.conf*
360
361 docinto bristuff/zaphfc
362 dodoc zaphfc/LICENSE zaphfc/*.conf
363
364 docinto bristuff/cwain
365 dodoc cwain/TODO cwain/LICENSE
366
367 cd "${S}"
368 fi
369
370 if use ecoslec; then
371 cd "${S_OSLEC}"
372 insinto "/lib/modules/${KV_FULL}/misc"
373 doins "oslec.${KV_OBJ}"
374
375 newsbin oslec-ctrl-panel.sh oslec-ctrl-panel
376
377 docinto oslec
378 dodoc ../{README.txt,COPYING}
379
380 cd "${S}"
381 fi
382
383 # install init script
384 newinitd "${FILESDIR}/zaptel.rc6" zaptel
385 newconfd "${FILESDIR}/zaptel.confd" zaptel
386
387 # install devfsd rule file
388 insinto /etc/devfs.d
389 newins "${FILESDIR}/zaptel.devfsd" zaptel
390
391 # install udev rule file
392 insinto /etc/udev/rules.d
393 newins "${FILESDIR}/zaptel.udevd" 10-zaptel.rules
394
395 # fix permissions if there's no udev / devfs around
396 if [[ -d "${D}/dev/zap" ]]; then
397 chown -R root:dialout "${D}/dev/zap"
398 chmod -R u=rwX,g=rwX,o= "${D}/dev/zap"
399 fi
400
401 if use astribank; then
402 cd "${S}"/xpp/utils
403 eval `perl '-V:installarchlib'`
404 make DESTDIR="${D}" PERLLIBDIR="${installarchlib}" install \
405 || die "failed xpp utils install"
406 dosbin zt_registration xpp_sync lszaptel
407 fi
408 }
409
410 pkg_postinst() {
411 linux-mod_pkg_postinst
412
413 echo
414 einfo "Use the /etc/init.d/zaptel script to load zaptel.conf settings on startup!"
415 echo
416
417 if use bri; then
418 einfo "Bristuff configs have been merged as:"
419 einfo ""
420 einfo "${ROOT}etc/"
421 einfo " zaptel.conf.zaphfc"
422 einfo " zaptel.conf.quadBRI"
423 einfo " zaptel.conf.octoBRI"
424 einfo ""
425 einfo "${ROOT}etc/asterisk/"
426 einfo " zapata.conf.zaphfc"
427 einfo " zapata.conf.quadBRI"
428 einfo " zapata.conf.octoBRI"
429 echo
430 fi
431
432 if use ecoslec; then
433 einfo "The OSLEC control panel has been installed as:"
434 einfo " \"/usr/sbin/oslec-ctrl-panel\""
435 echo
436 einfo "More information about the OSLEC echo canceller:"
437 einfo " \"http://www.rowetel.com/ucasterisk/oslec.html\""
438 echo
439 fi
440
441 # fix permissions if there's no udev / devfs around
442 if [[ -d "${ROOT}dev/zap" ]]; then
443 chown -R root:dialout "${ROOT}dev/zap"
444 chmod -R u=rwX,g=rwX,o= "${ROOT}dev/zap"
445 fi
446 }

  ViewVC Help
Powered by ViewVC 1.1.20