/[gentoo-x86]/net-misc/asterisk/asterisk-1.0.7-r1.ebuild
Gentoo

Contents of /net-misc/asterisk/asterisk-1.0.7-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Tue Nov 8 15:35:21 2005 UTC (14 years, 1 month ago) by stkn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.20: +1 -1 lines
FILE REMOVED
Security revbump for #111836 (fixes security hole in vmail.cgi)
(Portage version: 2.0.51.22-r2)

1 # Copyright 1999-2005 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.7-r1.ebuild,v 1.20 2005/09/15 02:40:34 stkn Exp $
4
5 inherit eutils perl-module
6
7 ADDONS_VERSION="1.0.7"
8 BRI_VERSION="0.2.0-RC8g"
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="~amd64 ~hppa ~ppc ~sparc x86"
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.7-r1 )
30 bri? ( >=net-libs/libpri-1.0.7-r1
31 >=net-misc/zaptel-1.0.7-r1 )
32 alsa? ( media-libs/alsa-lib )
33 mysql? ( dev-db/mysql )
34 speex? ( media-libs/speex )
35 zaptel? ( >=net-misc/zaptel-1.0.7-r1 )
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.7-r1 )"
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 # gsm codec still uses -fomit-frame-pointer, and other codecs have their
123 # own flags. We only change the arch.
124 sed -i -e "s:^OPTIMIZE+=.*:OPTIMIZE=${CFLAGS}:" \
125 -e "s:^CFLAGS[\t ]\++=:CFLAGS =:" \
126 codecs/gsm/Makefile
127
128 # hppa patch for gsm codec
129 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-hppa.patch
130
131 if use mmx; then
132 if ! use hardened; then
133 einfo "Enabling mmx optimization"
134 sed -i -e "s:^#\(K6OPT[\t ]\+= -DK6OPT\):\1:" \
135 codecs/gsm/Makefile
136 else
137 ewarn "Hardened use-flag is set, not enabling mmx optimization for codec_gsm!"
138
139 fi
140 fi
141 if ! use mmx || use hardened; then
142 # don't build + link asm mmx object file
143 # without this codec_gsm.so will include text relocations
144 sed -i -e "/k6opt\.\(s\|o\)/ d" \
145 codecs/gsm/Makefile
146 fi
147
148 if ! use debug; then
149 einfo "Disabling debugging"
150 sed -i -e "s:^\(DEBUG=\):#\1:" Makefile
151 fi
152
153 # change image path in voicemail cgi
154 sed -i -e "s:^\(\$astpath = \).*:\1 \"/asterisk\";:" contrib/scripts/vmail.cgi
155
156 #
157 # embedded perl
158 #
159 if use resperl; then
160 einfo "Patching asterisk for embedded perl support..."
161 epatch ${S_ADDONS}/res_perl/astmake.diff
162
163 # create necessary .c file
164 /usr/bin/perl -MExtUtils::Embed -e xsinit || die "Could not create perlxsi.c"
165
166 cd ${S_ADDONS}
167
168 # fix perl path, source location and remove res_musiconhold
169 sed -i -e "s:/usr/local/bin/perl:/usr/bin/perl:" \
170 res_perl/Makefile \
171 ${S}/Makefile \
172 res_perl/INC/*.pm
173 sed -i -e "s:^ASTSRC.*:ASTSRC = ${S}:" \
174 -e "s:\$(ASTLIBDIR)/modules/res_musiconhold.so::" \
175 res_perl/Makefile
176
177 if use bri; then
178 epatch ${FILESDIR}/1.0.0/res_perl-1.0.7-bristuff-0.2.0.diff
179 fi
180
181 cd ${S}
182 fi
183
184 #
185 # uclibc patch
186 #
187 if use elibc_uclibc; then
188 einfo "Patching asterisk for uclibc..."
189 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-uclibc-dns.diff
190 fi
191
192 #
193 # other patches
194 #
195
196 # fix lpc10 Makefile, remove the
197 # CFLAGS+=-march=$(shell uname -m) part
198 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-lpc10flags.diff
199
200 # asterisk-config
201 epatch ${FILESDIR}/1.0.0/${PN}-1.0.5-astcfg-0.0.2.diff
202
203 #
204 # database voicemail support
205 #
206 if use postgres; then
207 sed -i -e "s:^#\(APPS+=app_sql_postgres.so\):\1:" \
208 -e "s:/usr/local/pgsql/include:/usr/include/postgresql/pgsql:" \
209 -e "s:/usr/local/pgsql/lib:/usr/lib/postgresql:" \
210 apps/Makefile
211 fi
212
213 if use vmdbpostgres; then
214 einfo "Enabling PostgreSQL voicemail support"
215 sed -i -e "s:^\(USE_POSTGRES_VM_INTERFACE\).*:\1=1:" \
216 -e "s:/usr/local/pgsql/include:/usr/include/postgresql/pgsql:" \
217 -e "s:/usr/local/pgsql/lib:/usr/lib/postgresql:" \
218 apps/Makefile
219
220 # patch app_voicemail.c
221 sed -i -e "s:^#include <postgresql/libpq-fe\.h>:#include \"libpq-fe\.h\":" \
222 apps/app_voicemail.c
223
224 elif use vmdbmysql; then
225 einfo "Enabling MySQL voicemail support"
226 sed -i -e "s:^\(USE_MYSQL_VM_INTERFACE\).*:\1=1:" \
227 -e "s:^\(CFLAGS+=-DUSEMYSQLVM\):\1 -I${S_ADDONS}:" \
228 apps/Makefile
229 fi
230
231 #
232 # asterisk add-ons
233 #
234 cd ${S_ADDONS}
235 sed -i -e "s:-I../asterisk:-I${S} -I${S}/include:" Makefile
236 sed -i -e "s:^OPTIMIZE+=.*:OPTIMIZE+=${CFLAGS}:" \
237 -e "s:^\(CFLAGS=\)\(.*\):\1-I${S}/include -fPIC \2:" \
238 format_mp3/Makefile
239
240
241 #
242 # BRI patches
243 #
244 if use bri; then
245 cd ${S}
246 einfo "Patching asterisk w/ BRI stuff"
247
248 epatch ${WORKDIR}/bristuff-${BRI_VERSION}/patches/asterisk.patch
249 fi
250
251 #
252 # Revived snmp plugin support
253 #
254 # if use snmp; then
255 # cd ${S}
256 # einfo "Patching snmp plugin helper functions"
257 # epatch ${FILESDIR}/1.0.0/ast-ax-snmp-1.0.6.diff
258 # fi
259
260 # fix path for non-root
261 cd ${S}
262 sed -i -e "s:^\(ASTVARRUNDIR=\).*:\1\$(INSTALL_PREFIX)/var/run/asterisk:" \
263 Makefile
264
265 # fix contrib scripts for non-root
266 epatch ${FILESDIR}/1.0.0/${P}-scripts.diff
267
268 # add initgroups support to asterisk, this is needed
269 # to support supplementary groups for the asterisk
270 # user (start-stop-daemons --chguid breaks realtime priority support)
271 epatch ${FILESDIR}/1.0.0/${P}-initgroups.diff
272
273 # security fix (www.portcullis-security.com/advisory/advisory-05-013.txt)
274 epatch ${FILESDIR}/1.0.0/${P}-manager-cli-segv.patch
275
276 # fix segfault on amd64 and possibly other 64bit systems (#105762)
277 epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-ptr64fix.diff
278 }
279
280 src_compile() {
281 # build asterisk first...
282 einfo "Building Asterisk..."
283 cd ${S}
284 emake -j1 || die "Make failed"
285
286 # create api docs
287 use doc && \
288 emake -j1 progdocs
289
290 #
291 # add-ons
292 #
293 einfo "Building additional stuff..."
294 cd ${S_ADDONS}
295 emake -j1 || die "Make failed"
296
297 if use resperl; then
298 cd ${S_ADDONS}/res_perl
299 emake -j1 || die "Building embedded perl failed"
300 fi
301 }
302
303 src_install() {
304 make DESTDIR=${D} install || die "Make install failed"
305 make DESTDIR=${D} samples || die "Make install samples failed"
306
307 # install astconf.h, a lot of external modules need this
308 insinto /usr/include/asterisk
309 doins astconf.h
310
311 # install addmailbox and astgenkey
312 dosbin contrib/scripts/addmailbox
313 dosbin contrib/scripts/astgenkey
314
315 newinitd ${FILESDIR}/1.0.0/asterisk.rc6.sec asterisk
316 newconfd ${FILESDIR}/1.0.0/asterisk.confd.sec asterisk
317
318 # don't delete these, even if they are empty
319 keepdir /var/spool/asterisk/voicemail/default/1234/INBOX
320 keepdir /var/spool/asterisk/tmp
321 keepdir /var/log/asterisk/cdr-csv
322 keepdir /var/run/asterisk
323
324 # install standard docs...
325 dodoc BUGS CREDITS LICENSE ChangeLog HARDWARE README README.fpm
326 dodoc SECURITY doc/CODING-GUIDELINES doc/linkedlists.README
327 dodoc doc/README.*
328 dodoc doc/*.txt
329
330 docinto scripts
331 dodoc contrib/scripts/*
332 docinto firmware/iax
333 dodoc contrib/firmware/iax/*
334
335 # install api docs
336 if use doc; then
337 insinto /usr/share/doc/${PF}/api/html
338 doins doc/api/html/*
339 fi
340
341 insinto /usr/share/doc/${PF}/cgi
342 doins contrib/scripts/vmail.cgi
343 doins images/*.gif
344
345 #
346 # add-ons
347 #
348
349 # install additional modules...
350 einfo "Installing additional modules..."
351 cd ${S_ADDONS}
352 make INSTALL_PREFIX=${D} install || die "Make install failed"
353
354 if use resperl; then
355 perlinfo
356
357 cd ${S_ADDONS}/res_perl
358 make INSTALL_PREFIX=${D} install || die "Installation of perl AST_API failed"
359
360 # move AstApiBase.so to a proper place
361 dodir ${VENDOR_LIB}/auto/AstAPIBase
362 mv ${D}/etc/asterisk/perl/AstAPIBase.so ${D}${VENDOR_LIB}/auto/AstAPIBase
363
364 # move *.pm files to other location
365 dodir ${VENDOR_LIB}/AstAPI
366 dodir ${VENDOR_LIB}/AstAPIBase
367 for x in AstAPI.pm AstConfig.pm LoadFile.pm PerlSwitch.pm WebServer.pm; do
368 mv ${D}/etc/asterisk/perl/${x} ${D}${VENDOR_LIB}/AstAPI
369 dosed "s/^use[\t ]\+${x/.pm/};/use AstAPI::${x/.pm/};/" /etc/asterisk/perl/asterisk_init.pm
370 done
371 mv ${D}/etc/asterisk/perl/AstAPIBase.pm ${D}${VENDOR_LIB}/AstAPIBase
372 dosed "s/^use[\t ]\+AstAPI;/use AstAPI::AstAPI;/" /etc/asterisk/perl/asterisk_init.pm
373 dosed "s/^use[\t ]\+AstAPIBase;/use AstAPIBase::AstAPIBase;/" ${VENDOR_LIB}/AstAPI/AstAPI.pm
374
375 # move apps + htdocs to a proper place
376 dodir /var/lib/asterisk/perl
377 mv ${D}/etc/asterisk/perl/{apps,htdocs} ${D}/var/lib/asterisk/perl
378
379 # fix locations
380 sed -i -e "s:/etc/asterisk/perl:/var/lib/asterisk/perl:" \
381 ${D}${VENDOR_LIB}/AstAPI/LoadFile.pm ${D}${VENDOR_LIB}/AstAPI/WebServer.pm
382 fi
383 }
384
385 pkg_preinst() {
386 einfo "Adding asterisk user and group"
387 enewgroup asterisk
388 enewuser asterisk -1 -1 /var/lib/asterisk asterisk
389 }
390
391 pkg_postinst() {
392 #
393 # Change permissions and ownerships of asterisk
394 # directories and files
395 #
396 einfo "Fixing permissions and ownerships"
397 # fix permissions in /var/...
398 for x in spool run lib log; do
399 chown -R asterisk:asterisk ${ROOT}var/${x}/asterisk
400 chmod -R u=rwX,g=rX,o= ${ROOT}var/${x}/asterisk
401 done
402
403 chown -R root:asterisk ${ROOT}etc/asterisk
404 chmod -R u=rwX,g=rX,o= ${ROOT}etc/asterisk
405
406 #
407 # Fix locations of old installations (pre-non-root versions)
408 #
409 if [[ -z "$(grep "/var/run/asterisk" ${ROOT}etc/asterisk/asterisk.conf)" ]]
410 then
411 einfo "Fixing astrundir in ${ROOT}etc/asterisk/asterisk.conf"
412 mv -f ${ROOT}etc/asterisk/asterisk.conf \
413 ${ROOT}etc/asterisk/asterisk.conf.bak
414 sed -e "s:^\(astrundir[\t ]=>\).*:\1 /var/run/asterisk:" \
415 ${ROOT}etc/asterisk/asterisk.conf.bak >\
416 ${ROOT}etc/asterisk/asterisk.conf
417 einfo "Backup has been saved as ${ROOT}etc/asterisk/asterisk.conf.bak"
418 fi
419
420 #
421 # Some messages
422 #
423 einfo "Asterisk has been installed"
424 einfo ""
425 einfo "to add new Mailboxes use: /usr/sbin/addmailbox"
426 einfo ""
427 einfo "If you want to know more about asterisk, visit these sites:"
428 einfo "http://www.asteriskdocs.org/"
429 einfo "http://www.voip-info.org/wiki-Asterisk"
430 echo
431 einfo "http://asterisk.xvoip.com/"
432 einfo "http://junghanns.net/asterisk/"
433 einfo "http://www.automated.it/guidetoasterisk.htm"
434 echo
435 einfo "Gentoo VoIP IRC Channel:"
436 einfo "#gentoo-voip @ irc.freenode.net"
437
438 #
439 # Warning about security changes...
440 #
441 ewarn "*********************** Important changes **************************"
442 ewarn
443 ewarn "- Asterisk runs as user asterisk, group asterisk by default"
444 ewarn
445 ewarn "- Make sure the asterisk user is a member of the proper groups if you want it"
446 ewarn " to have access to hardware devices, e.g. \"audio\" for Alsa and OSS sound or"
447 ewarn " \"dialout\" for zaptel!"
448 ewarn
449 ewarn "- Permissions of /etc/asterisk have been changed to root:asterisk"
450 ewarn " 750 (rwxr-x--- directories) / 640 (rw-r----- files)"
451 ewarn
452 ewarn "- Permissions of /var/{log,lib,run,spool}/asterisk have been changed"
453 ewarn " to asterisk:asterisk 750 / 640"
454 ewarn
455 ewarn "- Asterisk's unix socket and pidfile are now in /var/run/astrisk"
456 ewarn
457 ewarn "- Asterisk cannot set the IP ToS bits when run as user,"
458 ewarn " use something like this to make iptables set them for you:"
459 ewarn " \"iptables -A OUTPUT -t mangle -p udp -m udp --dport 5060 -j DSCP --set-dscp 0x28\""
460 ewarn " \"iptables -A OUTPUT -t mangle -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x28\""
461 ewarn " (taken from voip-info.org comments (see below), thanks andrewid)"
462 ewarn
463 ewarn "For more details:"
464 ewarn " http://bugs.gentoo.org/show_bug.cgi?id=88732"
465 ewarn " http://www.voip-info.org/wiki-Asterisk+non-root"
466 }

  ViewVC Help
Powered by ViewVC 1.1.20