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

Contents of /net-misc/zaptel/zaptel-1.2.24.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Sun Feb 27 19:24:34 2011 UTC (8 years, 9 months ago) by chainsaw
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
FILE REMOVED
net-misc/zaptel is wholly dependent upon Asterisk 1.2 which has been removed from Portage. It has been supersided by dahdi which is fully stable. Clean up accordingly.

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

  ViewVC Help
Powered by ViewVC 1.1.20