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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Oct 26 23:50:29 2009 UTC (10 years, 1 month ago) by chainsaw
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
FILE REMOVED
Security version bump for AST-2009-007, ACLs were not respected on a SIP INVITE. Removed vulnerable versions from the tree (this concerns the 1.6.1 branch only).
(Portage version: 2.2_rc46/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/asterisk/asterisk-1.6.1.6-r2.ebuild,v 1.2 2009/10/26 20:02:51 mr_bones_ Exp $
4
5 EAPI=1
6 inherit eutils autotools
7
8 MY_P="${PN}-${PV/_/-}"
9
10 DESCRIPTION="Asterisk: A Modular Open Source PBX System"
11 HOMEPAGE="http://www.asterisk.org/"
12 SRC_URI="http://downloads.digium.com/pub/asterisk/releases/${MY_P}.tar.gz"
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16
17 IUSE="alsa +caps curl dahdi debug freetds iconv jabber ldap keepsrc misdn newt nosamples odbc oss postgres radius snmp span speex ssl sqlite static vorbis"
18
19 RDEPEND="sys-libs/ncurses
20 dev-libs/popt
21 sys-libs/zlib
22 alsa? ( media-libs/alsa-lib )
23 caps? ( sys-libs/libcap )
24 curl? ( net-misc/curl )
25 dahdi? ( >=net-libs/libpri-1.4.7
26 net-misc/dahdi-tools )
27 freetds? ( dev-db/freetds )
28 iconv? ( virtual/libiconv )
29 jabber? ( dev-libs/iksemel )
30 ldap? ( net-nds/openldap )
31 misdn? ( net-dialup/misdnuser )
32 newt? ( dev-libs/newt )
33 odbc? ( dev-db/unixODBC )
34 postgres? ( virtual/postgresql-base )
35 radius? ( net-dialup/radiusclient-ng )
36 snmp? ( net-analyzer/net-snmp )
37 span? ( media-libs/spandsp )
38 speex? ( media-libs/speex )
39 sqlite? ( dev-db/sqlite )
40 ssl? ( dev-libs/openssl )
41 vorbis? ( media-libs/libvorbis )"
42
43 DEPEND="${RDEPEND}
44 !<net-misc/asterisk-addons-1.6"
45
46 S="${WORKDIR}/${MY_P}"
47
48 #
49 # shortcuts
50 #
51
52 # update from asterisk-1.0.x
53 is_ast10update() {
54 return $(has_version "=net-misc/asterisk-1.0*")
55 }
56
57 # update from asterisk-1.2.x
58 is_ast12update() {
59 return $(has_version "=net-misc/asterisk-1.2*")
60 }
61
62 # update from asterisk 1.4.x
63 is_ast14update() {
64 return $(has_version "=net-misc/asterisk-1.4*")
65 }
66
67 # update in the asterisk-1.6.x line
68 is_astupdate() {
69 if ! is_ast10update && ! is_ast12update && !is_ast14update; then
70 return $(has_version "<net-misc/asterisk-${PV}")
71 fi
72 return 0
73 }
74
75 get_available_modules() {
76 local modules mod x
77
78 # build list of available modules...
79 for x in app cdr codec format func pbx res; do
80
81 for mod in $(find "${S}" -type f -name "${x}_*.c*" -print)
82 do
83 modules="${modules} $(basename ${mod/%.c*})"
84 done
85 done
86
87 echo "${modules}"
88 }
89
90 pkg_setup() {
91 local checkfailed=0 waitaftermsg=0
92
93 if is_ast10update || is_ast12update || is_ast14update ; then
94 ewarn " Asterisk UPGRADE Warning"
95 ewarn ""
96 ewarn "- Please read "${ROOT}"usr/share/doc/${PF}/UPGRADE.txt.bz2 after the installation!"
97 ewarn ""
98 ewarn " Asterisk UPGRADE Warning"
99 echo
100 waitaftermsg=1
101 fi
102
103 if [[ $waitaftermsg -eq 1 ]]; then
104 einfo "Press Ctrl+C to abort"
105 echo
106 ebeep 10
107 fi
108
109 #
110 # Regular checks
111 #
112 einfo "Running some pre-flight checks..."
113 echo
114
115 if [[ -n "${ASTERISK_MODULES}" ]] ; then
116 ewarn "You are overriding ASTERISK_MODULES. We will assume you know what you are doing. There is no support for this option, try without if you see breakage."
117 fi
118 }
119
120 src_unpack() {
121 unpack ${A}
122 cd "${S}"
123
124 #
125 # put pid file(s) into /var/run/asterisk
126 #
127 epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-var_rundir.patch || die "patch failed"
128
129 #
130 # fix gsm codec cflags (e.g. i586 core epias) and disable
131 # assembler optimizations
132 #
133 epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-gsm-pic.patch || die "patch failed"
134
135 #
136 # add missing LIBS for uclibc
137 #
138 epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-uclibc.patch || die "patch failed"
139
140 #
141 # compensate for non-standard LUA header paths in Gentoo
142 #
143 epatch "${FILESDIR}"/1.6.1/${P}-lua-includes.patch || die "patch failed"
144
145 #
146 # make sure FXO ports are usable immediately, without requiring an inbound call first
147 # https://issues.asterisk.org/view.php?id=14577
148 #
149 epatch "${FILESDIR}"/1.6.1/${P}-fxsks-hookstate.patch || die "patch failed"
150
151 #
152 # avoid segmentation fault when transferring a queue call
153 # https://issues.asterisk.org/view.php?id=15848
154 #
155 epatch "${FILESDIR}"/1.6.1/${P}-transfer-segfault.patch || die "patch failed"
156
157 #
158 # do not ignore alarm-cleared event while V23 caller ID detection is in progress
159 # otherwise automated British Telecom line test causes permanent red alarm
160 # https://issues.asterisk.org/view.php?id=14163
161 #
162 epatch "${FILESDIR}"/1.6.1/${P}-bt-line-test.patch || die "patch failed"
163
164 AT_M4DIR=autoconf eautoreconf
165
166 # parse modules list
167 if [[ -n "${ASTERISK_MODULES}" ]]; then
168 local x modules="$(get_available_modules)"
169
170 einfo "Custom list of modules specified, checking..."
171
172 use debug && {
173 einfo "Available modules: ${modules}"
174 einfo " Selected modules: ${ASTERISK_MODULES}"
175 }
176
177 for x in ${ASTERISK_MODULES}; do
178 if [[ "${x}" = "-*" ]]; then
179 MODULES_LIST=""
180 else
181 if has ${x} ${modules}
182 then
183 MODULES_LIST="${MODULES_LIST} ${x}"
184 else
185 eerror "Unknown module: ${x}"
186 fi
187 fi
188 done
189
190 export MODULES_LIST
191 fi
192 }
193
194 src_compile() {
195 #
196 # start with configure
197 #
198 econf \
199 --libdir="/usr/$(get_libdir)" \
200 --localstatedir="/var" \
201 --with-gsm=internal \
202 --with-popt \
203 --with-z \
204 $(use_with alsa asound) \
205 $(use_with caps cap) \
206 $(use_with curl) \
207 $(use_with dahdi pri) \
208 $(use_with dahdi tonezone) \
209 $(use_with dahdi) \
210 $(use_with freetds tds) \
211 $(use_with iconv) \
212 $(use_with jabber iksemel) \
213 $(use_with misdn isdnnet) \
214 $(use_with misdn suppserv) \
215 $(use_with misdn) \
216 $(use_with newt) \
217 $(use_with odbc) \
218 $(use_with oss) \
219 $(use_with postgres) \
220 $(use_with radius) \
221 $(use_with snmp netsnmp) \
222 $(use_with span spandsp) \
223 $(use_with speex) \
224 $(use_with speex speexdsp) \
225 $(use_with sqlite sqlite3) \
226 $(use_with ssl crypto) \
227 $(use_with ssl) \
228 $(use_with vorbis ogg) \
229 $(use_with vorbis) || die "econf failed"
230
231 #
232 # custom module filter
233 # run menuselect to evaluate the list of modules
234 # and rewrite the list afterwards
235 #
236 if [[ -n "${MODULES_LIST}" ]]
237 then
238 local mod category tmp_list failed_list
239
240 ###
241 # run menuselect
242
243 emake menuselect.makeopts || die "emake menuselect.makeopts failed"
244
245 ###
246 # get list of modules with failed dependencies
247
248 failed_list="$(awk -F= '/^MENUSELECT_DEPSFAILED=/{ print $3 }' menuselect.makeopts)"
249
250 ###
251 # traverse our list of modules
252
253 for category in app cdr codec format func pbx res; do
254 tmp_list=""
255
256 # search list of modules for matching ones first...
257 for mod in ${MODULES_LIST}; do
258 # module is from current category?
259 if [[ "${mod/%_*}" = "${category}" ]]
260 then
261 # check menuselect thinks the dependencies are met
262 if has ${mod} ${failed_list}
263 then
264 eerror "${mod}: dependencies required to build this module are not met, NOT BUILDING!"
265 else
266 tmp_list="${tmp_list} ${mod}"
267 fi
268 fi
269 done
270
271 use debug && echo "${category} tmp: ${tmp_list}"
272
273 # replace the module list for $category with our custom one
274 if [[ -n "${tmp_list}" ]]
275 then
276 category="$(echo ${category} | tr '[:lower:]' '[:upper:]')"
277 sed -i -e "s:^\(MENUSELECT_${category}S?\):\1=${tmp_list}:" \
278 menuselect.makeopts || die "failed to set list of ${category} applications"
279 fi
280 done
281 fi
282
283 emake || die "emake failed"
284 }
285
286 src_install() {
287 # setup directory structure
288 #
289 mkdir -p "${D}"usr/lib/pkgconfig
290
291 emake DESTDIR="${D}" install || die "emake install failed"
292 emake DESTDIR="${D}" samples || die "emake samples failed"
293
294 # remove installed sample files if nosamples flag is set
295 if use nosamples; then
296 einfo "Skipping installation of sample files..."
297 rm -f "${D}"var/lib/asterisk/mohmp3/*
298 rm -f "${D}"var/lib/asterisk/sounds/demo-*
299 rm -f "${D}"var/lib/asterisk/agi-bin/*
300 else
301 einfo "Sample files have been installed"
302 fi
303 rm -rf "${D}"var/spool/asterisk/voicemail/default
304
305 # move sample configuration files to doc directory
306 if is_ast10update || is_ast12update || is_ast14update; then
307 einfo "Updating from old (pre-1.6) asterisk version, new configuration files have been installed"
308 einfo "into "${ROOT}"etc/asterisk, use etc-update or dispatch-conf to update them"
309 fi
310
311 einfo "Configuration samples have been moved to: "${ROOT}"/usr/share/doc/${PF}/conf"
312 insinto /usr/share/doc/${PF}/conf
313 doins "${D}"etc/asterisk/*.conf*
314
315 # keep directories
316 diropts -m 0770 -o asterisk -g asterisk
317 keepdir /etc/asterisk
318 keepdir /var/lib/asterisk
319 keepdir /var/run/asterisk
320 keepdir /var/spool/asterisk
321 keepdir /var/spool/asterisk/{system,tmp,meetme,monitor,dictate,voicemail}
322 diropts -m 0750 -o asterisk -g asterisk
323 keepdir /var/log/asterisk/{cdr-csv,cdr-custom}
324
325 newinitd "${FILESDIR}"/1.6.1/asterisk.initd asterisk
326 newconfd "${FILESDIR}"/1.6.0/asterisk.confd asterisk
327
328 # some people like to keep the sources around for custom patching
329 # copy the whole source tree to /usr/src/asterisk-${PVF} and run make clean there
330 if use keepsrc
331 then
332 einfo "keepsrc useflag enabled, copying source..."
333 dodir /usr/src
334
335 cp -dPR "${S}" "${D}"/usr/src/${PF} || die "copying source tree failed"
336
337 ebegin "running make clean..."
338 emake -C "${D}"/usr/src/${PF} clean >/dev/null || die "make clean failed"
339 eend $?
340
341 einfo "Source files have been saved to "${ROOT}"usr/src/${PF}"
342 fi
343
344 # install the upgrade documentation
345 #
346 dodoc README UPGRADE* BUGS CREDITS
347
348 # install snmp mib files
349 #
350 if use snmp
351 then
352 insinto /usr/share/snmp/mibs/
353 doins doc/digium-mib.txt doc/asterisk-mib.txt
354 fi
355 }
356
357 pkg_preinst() {
358 enewgroup asterisk
359 enewuser asterisk -1 -1 /var/lib/asterisk "asterisk,dialout"
360 }
361
362 pkg_postinst() {
363 ebegin "Fixing up permissions"
364 chown -R asterisk:asterisk "${ROOT}"var/log/asterisk
365 chmod -R u=rwX,g=rX,o= "${ROOT}"var/log/asterisk
366
367 chown asterisk:asterisk "${ROOT}"etc/asterisk/
368 chown asterisk:asterisk "${ROOT}"etc/asterisk/*.adsi
369 chown asterisk:asterisk "${ROOT}"etc/asterisk/extensions.ael
370 chmod u=rwX,g=rwX,o= "${ROOT}"etc/asterisk/
371 chmod u=rwX,g=rwX,o= "${ROOT}"etc/asterisk/*.adsi
372 chmod u=rwX,g=rwX,o= "${ROOT}"etc/asterisk/extensions.ael
373 eend $?
374
375 #
376 # Announcements, warnings, reminders...
377 #
378 einfo "Asterisk has been installed"
379 echo
380 elog "If you want to know more about asterisk, visit these sites:"
381 elog "http://www.asteriskdocs.org/"
382 elog "http://www.voip-info.org/wiki-Asterisk"
383 echo
384 elog "http://www.automated.it/guidetoasterisk.htm"
385 echo
386 elog "Gentoo VoIP IRC Channel:"
387 elog "#gentoo-voip @ irc.freenode.net"
388 echo
389 echo
390
391 #
392 # Warning about 1.x -> 1.6 changes...
393 #
394 if is_ast10update || is_ast12update || is_ast14update; then
395 ewarn ""
396 ewarn "- Please read "${ROOT}"usr/share/doc/${PF}/UPGRADE.txt.bz2 before continuing"
397 ewarn ""
398 fi
399 }
400
401 pkg_config() {
402 einfo "Do you want to reset file permissions and ownerships (y/N)?"
403
404 read tmp
405 tmp="$(echo $tmp | tr '[:upper:]' '[:lower:]')"
406
407 if [[ "$tmp" = "y" ]] ||\
408 [[ "$tmp" = "yes" ]]
409 then
410 einfo "Resetting permissions to defaults..."
411
412 for x in spool run lib log; do
413 chown -R asterisk:asterisk "${ROOT}"var/${x}/asterisk
414 chmod -R u=rwX,g=rwX,o= "${ROOT}"var/${x}/asterisk
415 done
416
417 chown -R root:asterisk "${ROOT}"etc/asterisk
418 chmod -R u=rwX,g=rwX,o= "${ROOT}"etc/asterisk
419
420 einfo "done"
421 else
422 einfo "skipping"
423 fi
424 }

  ViewVC Help
Powered by ViewVC 1.1.20