/[gentoo-x86]/net-misc/asterisk/asterisk-1.0.8-r2.ebuild
Gentoo

Contents of /net-misc/asterisk/asterisk-1.0.8-r2.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Thu Jun 8 03:57:49 2006 UTC (13 years, 6 months ago) by rajiv
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
FILE REMOVED
remove old ebuilds.
(Portage version: 2.1_rc4-r4)
 (Unsigned Manifest commit)

1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.0.8-r2.ebuild,v 1.3 2006/03/06 14:25:49 gustavoz Exp $
4
5 inherit eutils perl-app
6
7 ADDONS_VERSION="1.0.8"
8 BRI_VERSION="0.2.0-RC8h"
9
10 DESCRIPTION="Asterisk: A Modular Open Source PBX System"
11 HOMEPAGE="http://www.asterisk.org/"
12 SRC_URI="ftp://ftp.digium.com/pub/telephony/${PN}/old-releases/${P}.tar.gz
13 ftp://ftp.digium.com/pub/telephony/${PN}/old-releases/${PN}-addons-${ADDONS_VERSION}.tar.gz
14 bri? ( http://www.junghanns.net/downloads/bristuff-${BRI_VERSION}.tar.gz )"
15
16 S_ADDONS=${WORKDIR}/${PN}-addons-${ADDONS_VERSION}
17
18 IUSE="alsa doc gtk mmx mysql pri zaptel debug postgres vmdbmysql vmdbpostgres bri hardened speex resperl"
19 SLOT="0"
20 LICENSE="GPL-2"
21 KEYWORDS="~x86 sparc ~hppa ~amd64 ~ppc"
22
23 DEPEND="dev-libs/newt
24 dev-libs/openssl
25 media-sound/mpg123
26 media-sound/sox
27 doc? ( app-doc/doxygen )
28 gtk? ( =x11-libs/gtk+-1.2* )
29 pri? ( >=net-libs/libpri-1.0.8 )
30 bri? ( >=net-libs/libpri-1.0.8
31 >=net-misc/zaptel-1.0.8 )
32 alsa? ( media-libs/alsa-lib )
33 mysql? ( dev-db/mysql )
34 speex? ( media-libs/speex )
35 zaptel? ( >=net-misc/zaptel-1.0.8 )
36 postgres? ( dev-db/postgresql )
37 vmdbmysql? ( dev-db/mysql )
38 vmdbpostgres? ( dev-db/postgresql )
39 resperl? ( dev-lang/perl
40 >=net-misc/zaptel-1.0.8 )"
41
42 pkg_setup() {
43 local n
44
45 #
46 # Warning about security changes...
47 #
48 ewarn "****************** Important changes warning! *********************"
49 ewarn
50 ewarn "- Asterisk runs as user asterisk, group asterisk by default"
51 ewarn
52 ewarn "- Permissions of /etc/asterisk have been changed to root:asterisk"
53 ewarn " 750 (directories) / 640 (files)"
54 ewarn
55 ewarn "- Permissions of /var/{log,lib,run,spool}/asterisk have been changed"
56 ewarn " to asterisk:asterisk 750 (directories) / 640 (files)"
57 ewarn
58 ewarn "- Asterisk's unix socket and pidfile are now in /var/run/asterisk"
59 ewarn
60 ewarn "- More information at the end of this emerge"
61 ewarn
62 ewarn " http://bugs.gentoo.org/show_bug.cgi?id=88732"
63 ewarn " http://www.voip-info.org/wiki-Asterisk+non-root"
64 ewarn
65 einfo "Press Ctrl+C to abort"
66 echo
67 ebeep
68
69 n=15
70 while [[ $n -gt 0 ]]; do
71 echo -en " Waiting $n seconds...\r"
72 sleep 1
73 (( n-- ))
74 done
75
76 #
77 # Regular checks
78 #
79 einfo "Running some pre-flight checks..."
80 if use resperl; then
81 # res_perl pre-flight check...
82 if ! $(perl -V | grep -q "usemultiplicity=define") ||\
83 ! built_with_use dev-lang/perl ithreads || ! built_with_use sys-devel/libperl ithreads
84 then
85 eerror "Embedded perl add-on needs Perl and libperl with built-in threads support"
86 eerror "(rebuild perl and libperl with ithreads use-flag enabled)"
87 die "Perl w/o threads support..."
88 fi
89 einfo "Perl with ithreads support found"
90 fi
91
92
93 # mysql and postgres voicemail support are mutually exclusive..
94 if use vmdbmysql && use vmdbpostgres; then
95 eerror "MySQL and PostgreSQL Voicemail support are mutually exclusive... choose one!"
96 die "Conflicting use-flags"
97 fi
98
99 # check if zaptel and libpri have been built with bri enabled
100 if use bri; then
101 if ! built_with_use net-misc/zaptel bri; then
102 eerror "Re-emerge zaptel with bri use-flag enabled!"
103 die "Zaptel without bri support detected"
104 fi
105
106 if ! built_with_use net-libs/libpri bri; then
107 eerror "Re-emerge libpri with bri use-flag enabled!"
108 die "Libpri without bri support detected"
109 fi
110 fi
111 }
112
113 src_unpack() {
114 unpack ${A}
115 cd ${S}
116
117 # set cflags & mmx optimization
118 sed -i -e "s:^\(OPTIMIZE+=\).*:\1 ${CFLAGS}:" \
119 -e "s:^\(CFLAGS+=\$(shell if \$(CC)\):#\1:" \
120 Makefile
121
122 # hppa patch for gsm codec
123 epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-hppa.patch
124
125 # mark adsi functions as weak references, things will blow
126 # on hardened otherwise (bug #100697 and possibly #85655)
127 epatch ${FILESDIR}/1.0.0/${PN}-1.0.9-weak-references.diff
128
129 # gsm codec still uses -fomit-frame-pointer, and other codecs have their
130 # own flags. We only change the arch.
131 sed -i -e "s:^OPTIMIZE+=.*:OPTIMIZE=${CFLAGS}:" \
132 -e "s:^CFLAGS[\t ]\++=:CFLAGS =:" \
133 codecs/gsm/Makefile
134
135 if use mmx; then
136 if ! use hardened; then
137 einfo "Enabling mmx optimization"
138 sed -i -e "s:^#\(K6OPT[\t ]\+= -DK6OPT\):\1:" \
139 codecs/gsm/Makefile
140 else
141 ewarn "Hardened use-flag is set, not enabling mmx optimization for codec_gsm!"
142
143 fi
144 fi
145 if ! use mmx || use hardened; then
146 # don't build + link asm mmx object file
147 # without this codec_gsm.so will include text relocations
148 sed -i -e "/k6opt\.\(s\|o\)/ d" \
149 codecs/gsm/Makefile
150 fi
151
152 if ! use debug; then
153 einfo "Disabling debugging"
154 sed -i -e "s:^\(DEBUG=\):#\1:" Makefile
155 fi
156
157 # change image path in voicemail cgi
158 sed -i -e "s:^\(\$astpath = \).*:\1 \"/asterisk\";:" contrib/scripts/vmail.cgi
159
160 #
161 # embedded perl
162 #
163 if use resperl; then
164 einfo "Patching asterisk for embedded perl support..."
165 epatch ${S_ADDONS}/res_perl/astmake.diff
166
167 # create necessary .c file
168 /usr/bin/perl -MExtUtils::Embed -e xsinit || die "Could not create perlxsi.c"
169
170 cd ${S_ADDONS}
171
172 # fix perl path, source location and remove res_musiconhold
173 sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:" \
174 res_perl/Makefile \
175 ${S}/Makefile \
176 res_perl/INC/*.pm
177 sed -i -e "s:^ASTSRC.*:ASTSRC = ${S}:" \
178 -e "s:\$(ASTLIBDIR)/modules/res_musiconhold.so::" \
179 res_perl/Makefile
180
181 if use bri; then
182 epatch ${FILESDIR}/1.0.0/res_perl-1.0.7-bristuff-0.2.0.diff
183 fi
184
185 cd ${S}
186 fi
187
188 #
189 # uclibc patch
190 #
191 if use elibc_uclibc; then
192 einfo "Patching asterisk for uclibc..."
193 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-uclibc-dns.diff
194 fi
195
196 #
197 # other patches
198 #
199
200 # fix lpc10 Makefile, remove the
201 # CFLAGS+=-march=$(shell uname -m) part
202 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-lpc10flags.diff
203
204 # asterisk-config
205 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-astcfg-0.0.2.diff
206
207 #
208 # database voicemail support
209 #
210 if use postgres; then
211 sed -i -e "s:^#\(APPS+=app_sql_postgres.so\):\1:" \
212 -e "s:/usr/local/pgsql/include:/usr/include/postgresql/pgsql:" \
213 -e "s:/usr/local/pgsql/lib:/usr/lib/postgresql:" \
214 apps/Makefile
215 fi
216
217 if use vmdbpostgres; then
218 einfo "Enabling PostgreSQL voicemail support"
219 sed -i -e "s:^\(USE_POSTGRES_VM_INTERFACE\).*:\1=1:" \
220 -e "s:/usr/local/pgsql/include:/usr/include/postgresql/pgsql:" \
221 -e "s:/usr/local/pgsql/lib:/usr/lib/postgresql:" \
222 apps/Makefile
223
224 # patch app_voicemail.c
225 sed -i -e "s:^#include <postgresql/libpq-fe\.h>:#include \"libpq-fe\.h\":" \
226 apps/app_voicemail.c
227
228 elif use vmdbmysql; then
229 einfo "Enabling MySQL voicemail support"
230 sed -i -e "s:^\(USE_MYSQL_VM_INTERFACE\).*:\1=1:" \
231 -e "s:^\(CFLAGS+=-DUSEMYSQLVM\):\1 -I${S_ADDONS}:" \
232 apps/Makefile
233 fi
234
235 #
236 # asterisk add-ons
237 #
238 cd ${S_ADDONS}
239 sed -i -e "s:-I../asterisk:-I${S} -I${S}/include:" Makefile
240 sed -i -e "s:^OPTIMIZE+=.*:OPTIMIZE+=${CFLAGS}:" \
241 -e "s:^\(CFLAGS=\)\(.*\):\1-I${S}/include -fPIC \2:" \
242 format_mp3/Makefile
243
244
245 #
246 # BRI patches
247 #
248 if use bri; then
249 cd ${S}
250 einfo "Patching asterisk w/ BRI stuff"
251
252 epatch ${WORKDIR}/bristuff-${BRI_VERSION}/patches/asterisk.patch
253 fi
254
255 #
256 # Revived snmp plugin support
257 #
258 # if use snmp; then
259 # cd ${S}
260 # einfo "Patching snmp plugin helper functions"
261 # epatch ${FILESDIR}/1.0.0/ast-ax-snmp-1.0.6.diff
262 # fi
263
264 # fix path for non-root
265 cd ${S}
266 sed -i -e "s:^\(ASTVARRUNDIR=\).*:\1\$(INSTALL_PREFIX)/var/run/asterisk:" \
267 Makefile
268
269 # fix contrib scripts for non-root
270 epatch ${FILESDIR}/1.0.0/${PN}-1.0.7-scripts.diff
271
272 # add initgroups support to asterisk, this is needed
273 # to support supplementary groups for the asterisk
274 # user (start-stop-daemons --chguid breaks realtime priority support)
275 epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-initgroups.diff
276
277 # fix callerid matching bug in dialplan
278 epatch ${FILESDIR}/1.0.0/${P}-callerid.patch
279
280 # fix segfault on amd64 and possibly other 64bit systems (#105762)
281 epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-ptr64fix.diff
282
283 # security fix, bug #111836
284 epatch ${FILESDIR}/1.0.0/${PN}-1.0.10-vmail.cgi.patch
285 }
286
287 src_compile() {
288 # build asterisk first...
289 einfo "Building Asterisk..."
290 cd ${S}
291 emake -j1 || die "Make failed"
292
293 # create api docs
294 use doc && \
295 emake -j1 progdocs
296
297 #
298 # add-ons
299 #
300 einfo "Building additional stuff..."
301 cd ${S_ADDONS}
302 emake -j1 || die "Make failed"
303
304 if use resperl; then
305 cd ${S_ADDONS}/res_perl
306 emake -j1 || die "Building embedded perl failed"
307 fi
308 }
309
310 src_install() {
311 make DESTDIR=${D} install || die "Make install failed"
312 make DESTDIR=${D} samples || die "Make install samples failed"
313
314 # install astconf.h, a lot of external modules need this
315 insinto /usr/include/asterisk
316 doins astconf.h
317
318 # install addmailbox and astgenkey
319 dosbin contrib/scripts/addmailbox
320 dosbin contrib/scripts/astgenkey
321
322 newinitd ${FILESDIR}/1.0.0/asterisk.rc6.sec asterisk
323 newconfd ${FILESDIR}/1.0.0/asterisk.confd.sec asterisk
324
325 # don't delete these, even if they are empty
326 keepdir /var/spool/asterisk/voicemail/default/1234/INBOX
327 keepdir /var/spool/asterisk/tmp
328 keepdir /var/log/asterisk/cdr-csv
329 keepdir /var/run/asterisk
330
331 # install standard docs...
332 dodoc BUGS CREDITS LICENSE ChangeLog HARDWARE README README.fpm
333 dodoc SECURITY doc/CODING-GUIDELINES doc/linkedlists.README
334 dodoc doc/README.*
335 dodoc doc/*.txt
336
337 docinto scripts
338 dodoc contrib/scripts/*
339 docinto firmware/iax
340 dodoc contrib/firmware/iax/*
341
342 # install api docs
343 if use doc; then
344 insinto /usr/share/doc/${PF}/api/html
345 doins doc/api/html/*
346 fi
347
348 insinto /usr/share/doc/${PF}/cgi
349 doins contrib/scripts/vmail.cgi
350 doins images/*.gif
351
352 #
353 # add-ons
354 #
355
356 # install additional modules...
357 einfo "Installing additional modules..."
358 cd ${S_ADDONS}
359 make INSTALL_PREFIX=${D} install || die "Make install failed"
360
361 if use resperl; then
362 perlinfo
363
364 cd ${S_ADDONS}/res_perl
365 make INSTALL_PREFIX=${D} install || die "Installation of perl AST_API failed"
366
367 # move AstApiBase.so to a proper place
368 dodir ${VENDOR_LIB}/auto/AstAPIBase
369 mv ${D}/etc/asterisk/perl/AstAPIBase.so ${D}${VENDOR_LIB}/auto/AstAPIBase
370
371 # move *.pm files to other location
372 dodir ${VENDOR_LIB}/AstAPI
373 dodir ${VENDOR_LIB}/AstAPIBase
374 for x in AstAPI.pm AstConfig.pm LoadFile.pm PerlSwitch.pm WebServer.pm; do
375 mv ${D}/etc/asterisk/perl/${x} ${D}${VENDOR_LIB}/AstAPI
376 dosed "s/^use[\t ]\+${x/.pm/};/use AstAPI::${x/.pm/};/" /etc/asterisk/perl/asterisk_init.pm
377 done
378 mv ${D}/etc/asterisk/perl/AstAPIBase.pm ${D}${VENDOR_LIB}/AstAPIBase
379 dosed "s/^use[\t ]\+AstAPI;/use AstAPI::AstAPI;/" /etc/asterisk/perl/asterisk_init.pm
380 dosed "s/^use[\t ]\+AstAPIBase;/use AstAPIBase::AstAPIBase;/" ${VENDOR_LIB}/AstAPI/AstAPI.pm
381
382 # move apps + htdocs to a proper place
383 dodir /var/lib/asterisk/perl
384 mv ${D}/etc/asterisk/perl/{apps,htdocs} ${D}/var/lib/asterisk/perl
385
386 # fix locations
387 sed -i -e "s:/etc/asterisk/perl:/var/lib/asterisk/perl:" \
388 ${D}${VENDOR_LIB}/AstAPI/LoadFile.pm ${D}${VENDOR_LIB}/AstAPI/WebServer.pm
389 fi
390 }
391
392 pkg_preinst() {
393 einfo "Adding asterisk user and group"
394 enewgroup asterisk
395 enewuser asterisk -1 -1 /var/lib/asterisk asterisk
396 }
397
398 pkg_postinst() {
399 #
400 # Change permissions and ownerships of asterisk
401 # directories and files
402 #
403 einfo "Fixing permissions and ownerships"
404 # fix permissions in /var/...
405 for x in spool run lib log; do
406 chown -R asterisk:asterisk ${ROOT}var/${x}/asterisk
407 chmod -R u=rwX,g=rX,o= ${ROOT}var/${x}/asterisk
408 done
409
410 chown -R root:asterisk ${ROOT}etc/asterisk
411 chmod -R u=rwX,g=rX,o= ${ROOT}etc/asterisk
412
413 #
414 # Fix locations for old installations (pre-non-root versions)
415 #
416 if [[ -z "$(grep "/var/run/asterisk" ${ROOT}etc/asterisk/asterisk.conf)" ]]
417 then
418 einfo "Fixing astrundir in ${ROOT}etc/asterisk/asterisk.conf"
419 mv -f ${ROOT}etc/asterisk/asterisk.conf \
420 ${ROOT}etc/asterisk/asterisk.conf.bak
421 sed -e "s:^\(astrundir[\t ]=>\).*:\1 /var/run/asterisk:" \
422 ${ROOT}etc/asterisk/asterisk.conf.bak >\
423 ${ROOT}etc/asterisk/asterisk.conf
424 einfo "Backup has been saved as ${ROOT}etc/asterisk/asterisk.conf.bak"
425 fi
426
427 #
428 # Some messages
429 #
430 einfo "Asterisk has been installed"
431 einfo ""
432 einfo "to add new Mailboxes use: /usr/sbin/addmailbox"
433 einfo ""
434 einfo "If you want to know more about asterisk, visit these sites:"
435 einfo "http://www.asteriskdocs.org/"
436 einfo "http://www.voip-info.org/wiki-Asterisk"
437 echo
438 einfo "http://asterisk.xvoip.com/"
439 einfo "http://junghanns.net/asterisk/"
440 einfo "http://www.automated.it/guidetoasterisk.htm"
441 echo
442 einfo "Gentoo VoIP IRC Channel:"
443 einfo "#gentoo-voip @ irc.freenode.net"
444
445 #
446 # Warning about security changes...
447 #
448 ewarn "*********************** Important changes **************************"
449 ewarn
450 ewarn "- Asterisk runs as user asterisk, group asterisk by default"
451 ewarn
452 ewarn "- Make sure the asterisk user is a member of the proper groups if you want it"
453 ewarn " to have access to hardware devices, e.g. \"audio\" for Alsa and OSS sound or"
454 ewarn " \"dialout\" for zaptel!"
455 ewarn
456 ewarn "- Permissions of /etc/asterisk have been changed to root:asterisk"
457 ewarn " 750 (rwxr-x--- directories) / 640 (rw-r----- files)"
458 ewarn
459 ewarn "- Permissions of /var/{log,lib,run,spool}/asterisk have been changed"
460 ewarn " to asterisk:asterisk 750 / 640"
461 ewarn
462 ewarn "- Asterisk's unix socket and pidfile are now in /var/run/astrisk"
463 ewarn
464 ewarn "- Asterisk cannot set the IP ToS bits when run as user,"
465 ewarn " use something like this to make iptables set them for you:"
466 ewarn " \"iptables -A OUTPUT -t mangle -p udp -m udp --dport 5060 -j DSCP --set-dscp 0x28\""
467 ewarn " \"iptables -A OUTPUT -t mangle -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x28\""
468 ewarn " (taken from voip-info.org comments (see below), thanks andrewid)"
469 ewarn
470 ewarn "For more details:"
471 ewarn " http://bugs.gentoo.org/show_bug.cgi?id=88732"
472 ewarn " http://www.voip-info.org/wiki-Asterisk+non-root"
473 }

  ViewVC Help
Powered by ViewVC 1.1.20