1 |
# Copyright 1999-2013 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-11.6.0.ebuild,v 1.1 2013/10/22 13:57:06 chainsaw Exp $ |
4 |
|
5 |
EAPI=5 |
6 |
inherit autotools base eutils linux-info multilib |
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.asterisk.org/pub/telephony/asterisk/releases/${MY_P}.tar.gz |
13 |
mirror://gentoo/gentoo-asterisk-patchset-3.7.tar.bz2" |
14 |
LICENSE="GPL-2" |
15 |
SLOT="0" |
16 |
KEYWORDS="~amd64 ~x86" |
17 |
|
18 |
IUSE_VOICEMAIL_STORAGE=" |
19 |
+voicemail_storage_file |
20 |
voicemail_storage_odbc |
21 |
voicemail_storage_imap |
22 |
" |
23 |
IUSE="${IUSE_VOICEMAIL_STORAGE} alsa bluetooth calendar +caps cluster curl dahdi debug doc freetds gtalk http iconv ilbc jabber ldap libedit lua mysql newt +samples odbc osplookup oss portaudio postgres radius selinux snmp span speex srtp static syslog vorbis" |
24 |
IUSE_EXPAND="VOICEMAIL_STORAGE" |
25 |
REQUIRED_USE="gtalk? ( jabber ) |
26 |
^^ ( ${IUSE_VOICEMAIL_STORAGE/+/} ) |
27 |
voicemail_storage_odbc? ( odbc ) |
28 |
" |
29 |
|
30 |
EPATCH_SUFFIX="patch" |
31 |
PATCHES=( "${WORKDIR}/asterisk-patchset" ) |
32 |
|
33 |
RDEPEND="dev-db/sqlite:3 |
34 |
dev-libs/popt |
35 |
dev-libs/libxml2 |
36 |
dev-libs/openssl |
37 |
sys-libs/ncurses |
38 |
sys-libs/zlib |
39 |
alsa? ( media-libs/alsa-lib ) |
40 |
bluetooth? ( net-wireless/bluez ) |
41 |
calendar? ( net-libs/neon |
42 |
dev-libs/libical |
43 |
dev-libs/iksemel ) |
44 |
caps? ( sys-libs/libcap ) |
45 |
cluster? ( sys-cluster/corosync ) |
46 |
curl? ( net-misc/curl ) |
47 |
dahdi? ( >=net-libs/libpri-1.4.12_beta2 |
48 |
net-misc/dahdi-tools ) |
49 |
freetds? ( dev-db/freetds ) |
50 |
gtalk? ( dev-libs/iksemel ) |
51 |
http? ( dev-libs/gmime:2.4 ) |
52 |
iconv? ( virtual/libiconv ) |
53 |
ilbc? ( dev-libs/ilbc-rfc3951 ) |
54 |
jabber? ( dev-libs/iksemel ) |
55 |
ldap? ( net-nds/openldap ) |
56 |
libedit? ( dev-libs/libedit ) |
57 |
lua? ( dev-lang/lua ) |
58 |
mysql? ( virtual/mysql ) |
59 |
newt? ( dev-libs/newt ) |
60 |
odbc? ( dev-db/unixODBC ) |
61 |
osplookup? ( net-libs/osptoolkit ) |
62 |
portaudio? ( media-libs/portaudio ) |
63 |
postgres? ( dev-db/postgresql-base ) |
64 |
radius? ( net-dialup/radiusclient-ng ) |
65 |
selinux? ( sec-policy/selinux-asterisk ) |
66 |
snmp? ( net-analyzer/net-snmp ) |
67 |
span? ( media-libs/spandsp ) |
68 |
speex? ( media-libs/speex ) |
69 |
srtp? ( net-libs/libsrtp ) |
70 |
vorbis? ( media-libs/libvorbis )" |
71 |
|
72 |
DEPEND="${RDEPEND} |
73 |
!net-libs/openh323 |
74 |
!net-libs/pjsip |
75 |
voicemail_storage_imap? ( virtual/imap-c-client ) |
76 |
" |
77 |
|
78 |
RDEPEND="${RDEPEND} |
79 |
syslog? ( virtual/logger )" |
80 |
|
81 |
PDEPEND="net-misc/asterisk-core-sounds |
82 |
net-misc/asterisk-extra-sounds |
83 |
net-misc/asterisk-moh-opsound" |
84 |
|
85 |
S="${WORKDIR}/${MY_P}" |
86 |
|
87 |
pkg_setup() { |
88 |
CONFIG_CHECK="~!NF_CONNTRACK_SIP" |
89 |
local WARNING_NF_CONNTRACK_SIP="SIP (NAT) connection tracking is enabled. Some users |
90 |
have reported that this module dropped critical SIP packets in their deployments. You |
91 |
may want to disable it if you see such problems." |
92 |
check_extra_config |
93 |
|
94 |
enewgroup asterisk |
95 |
enewgroup dialout 20 |
96 |
enewuser asterisk -1 -1 /var/lib/asterisk "asterisk,dialout" |
97 |
} |
98 |
|
99 |
src_prepare() { |
100 |
base_src_prepare |
101 |
AT_M4DIR=autoconf eautoreconf |
102 |
} |
103 |
|
104 |
src_configure() { |
105 |
local vmst |
106 |
|
107 |
econf \ |
108 |
--libdir="/usr/$(get_libdir)" \ |
109 |
--localstatedir="/var" \ |
110 |
--with-crypto \ |
111 |
--with-gsm=internal \ |
112 |
--with-popt \ |
113 |
--with-ssl \ |
114 |
--with-z \ |
115 |
--without-pwlib \ |
116 |
$(use_with caps cap) \ |
117 |
$(use_with http gmime) \ |
118 |
$(use_with newt) \ |
119 |
$(use_with portaudio) |
120 |
|
121 |
# Blank out sounds/sounds.xml file to prevent |
122 |
# asterisk from installing sounds files (we pull them in via |
123 |
# asterisk-{core,extra}-sounds and asterisk-moh-opsound. |
124 |
>"${S}"/sounds/sounds.xml |
125 |
|
126 |
# Compile menuselect binary for optional components |
127 |
emake menuselect.makeopts |
128 |
|
129 |
# Broken functionality is forcibly disabled (bug #360143) |
130 |
menuselect/menuselect --disable chan_misdn menuselect.makeopts |
131 |
menuselect/menuselect --disable chan_ooh323 menuselect.makeopts |
132 |
|
133 |
# Utility set is forcibly enabled (bug #358001) |
134 |
menuselect/menuselect --enable smsq menuselect.makeopts |
135 |
menuselect/menuselect --enable streamplayer menuselect.makeopts |
136 |
menuselect/menuselect --enable aelparse menuselect.makeopts |
137 |
menuselect/menuselect --enable astman menuselect.makeopts |
138 |
|
139 |
# this is connected, otherwise it would not find |
140 |
# ast_pktccops_gate_alloc symbol |
141 |
menuselect/menuselect --enable chan_mgcp menuselect.makeopts |
142 |
menuselect/menuselect --enable res_pktccops menuselect.makeopts |
143 |
|
144 |
# SSL is forcibly enabled, IAX2 & DUNDI are expected to be available |
145 |
menuselect/menuselect --enable pbx_dundi menuselect.makeopts |
146 |
menuselect/menuselect --enable func_aes menuselect.makeopts |
147 |
menuselect/menuselect --enable chan_iax2 menuselect.makeopts |
148 |
|
149 |
# SQlite3 is now the main database backend, enable related features |
150 |
menuselect/menuselect --enable cdr_sqlite3_custom menuselect.makeopts |
151 |
menuselect/menuselect --enable cel_sqlite3_custom menuselect.makeopts |
152 |
|
153 |
# The others are based on USE-flag settings |
154 |
use_select() { |
155 |
local state=$(use "$1" && echo enable || echo disable) |
156 |
shift # remove use from parameters |
157 |
|
158 |
while [[ -n $1 ]]; do |
159 |
menuselect/menuselect --${state} "$1" menuselect.makeopts |
160 |
shift |
161 |
done |
162 |
} |
163 |
|
164 |
use_select alsa chan_alsa |
165 |
use_select bluetooth chan_mobile |
166 |
use_select calendar res_calendar res_calendar_{caldav,ews,exchange,icalendar} |
167 |
use_select cluster res_corosync |
168 |
use_select curl func_curl res_config_curl res_curl |
169 |
use_select dahdi app_dahdibarge app_dahdiras chan_dahdi codec_dahdi res_timing_dahdi |
170 |
use_select freetds {cdr,cel}_tds |
171 |
use_select gtalk chan_motif |
172 |
use_select http res_http_post |
173 |
use_select iconv func_iconv |
174 |
use_select jabber res_xmpp |
175 |
use_select ilbc codec_ilbc format_ilbc |
176 |
use_select ldap res_config_ldap |
177 |
use_select lua pbx_lua |
178 |
use_select mysql app_mysql cdr_mysql res_config_mysql |
179 |
use_select odbc cdr_adaptive_odbc res_config_odbc {cdr,cel,res,func}_odbc |
180 |
use_select osplookup app_osplookup |
181 |
use_select oss chan_oss |
182 |
use_select postgres {cdr,cel}_pgsql res_config_pgsql |
183 |
use_select radius {cdr,cel}_radius |
184 |
use_select snmp res_snmp |
185 |
use_select span res_fax_spandsp |
186 |
use_select speex {codec,func}_speex |
187 |
use_select srtp res_srtp |
188 |
use_select syslog cdr_syslog |
189 |
use_select vorbis format_ogg_vorbis |
190 |
|
191 |
# Voicemail storage ... |
192 |
for vmst in ${IUSE_VOICEMAIL_STORAGE/+/}; do |
193 |
if use ${vmst}; then |
194 |
menuselect/menuselect --enable $(echo ${vmst##*_} | tr '[:lower:]' '[:upper:]')_STORAGE menuselect.makeopts |
195 |
fi |
196 |
done |
197 |
} |
198 |
|
199 |
src_compile() { |
200 |
ASTLDFLAGS="${LDFLAGS}" emake |
201 |
} |
202 |
|
203 |
src_install() { |
204 |
mkdir -p "${D}"usr/$(get_libdir)/pkgconfig || die |
205 |
emake DESTDIR="${D}" installdirs |
206 |
emake DESTDIR="${D}" install |
207 |
|
208 |
if use radius; then |
209 |
insinto /etc/radiusclient-ng/ |
210 |
doins contrib/dictionary.digium |
211 |
fi |
212 |
if use samples; then |
213 |
emake DESTDIR="${D}" samples |
214 |
for conffile in "${D}"etc/asterisk/*.* |
215 |
do |
216 |
chown asterisk:asterisk $conffile |
217 |
chmod 0660 $conffile |
218 |
done |
219 |
einfo "Sample files have been installed" |
220 |
else |
221 |
einfo "Skipping installation of sample files..." |
222 |
rm -f "${D}"var/lib/asterisk/mohmp3/* || die |
223 |
rm -f "${D}"var/lib/asterisk/sounds/demo-* || die |
224 |
rm -f "${D}"var/lib/asterisk/agi-bin/* || die |
225 |
rm -f "${D}"etc/asterisk/* || die |
226 |
fi |
227 |
rm -rf "${D}"var/spool/asterisk/voicemail/default || die |
228 |
|
229 |
# keep directories |
230 |
diropts -m 0770 -o asterisk -g asterisk |
231 |
keepdir /etc/asterisk |
232 |
keepdir /var/lib/asterisk |
233 |
keepdir /var/spool/asterisk |
234 |
keepdir /var/spool/asterisk/{system,tmp,meetme,monitor,dictate,voicemail} |
235 |
diropts -m 0750 -o asterisk -g asterisk |
236 |
keepdir /var/log/asterisk/{cdr-csv,cdr-custom} |
237 |
|
238 |
newinitd "${FILESDIR}"/1.8.0/asterisk.initd7 asterisk |
239 |
newconfd "${FILESDIR}"/1.8.0/asterisk.confd asterisk |
240 |
|
241 |
# install the upgrade documentation |
242 |
# |
243 |
dodoc README UPGRADE* BUGS CREDITS |
244 |
|
245 |
# install extra documentation |
246 |
# |
247 |
if use doc |
248 |
then |
249 |
dodoc doc/*.txt |
250 |
dodoc doc/*.pdf |
251 |
fi |
252 |
|
253 |
# install SIP scripts; bug #300832 |
254 |
# |
255 |
dodoc "${FILESDIR}/1.6.2/sip_calc_auth" |
256 |
dodoc "${FILESDIR}/1.8.0/find_call_sip_trace.sh" |
257 |
dodoc "${FILESDIR}/1.8.0/find_call_ids.sh" |
258 |
dodoc "${FILESDIR}/1.6.2/call_data.txt" |
259 |
|
260 |
# install logrotate snippet; bug #329281 |
261 |
# |
262 |
insinto /etc/logrotate.d |
263 |
newins "${FILESDIR}/1.6.2/asterisk.logrotate3" asterisk |
264 |
} |
265 |
|
266 |
pkg_postinst() { |
267 |
# |
268 |
# Announcements, warnings, reminders... |
269 |
# |
270 |
einfo "Asterisk has been installed" |
271 |
echo |
272 |
elog "If you want to know more about asterisk, visit these sites:" |
273 |
elog "http://www.asteriskdocs.org/" |
274 |
elog "http://www.voip-info.org/wiki-Asterisk" |
275 |
echo |
276 |
elog "http://www.automated.it/guidetoasterisk.htm" |
277 |
echo |
278 |
elog "Gentoo VoIP IRC Channel:" |
279 |
elog "#gentoo-voip @ irc.freenode.net" |
280 |
echo |
281 |
echo |
282 |
elog "Please read the Asterisk 11 upgrade document:" |
283 |
elog "https://wiki.asterisk.org/wiki/display/AST/Upgrading+to+Asterisk+11" |
284 |
} |
285 |
|
286 |
pkg_config() { |
287 |
einfo "Do you want to reset file permissions and ownerships (y/N)?" |
288 |
|
289 |
read tmp |
290 |
tmp="$(echo $tmp | tr '[:upper:]' '[:lower:]')" |
291 |
|
292 |
if [[ "$tmp" = "y" ]] ||\ |
293 |
[[ "$tmp" = "yes" ]] |
294 |
then |
295 |
einfo "Resetting permissions to defaults..." |
296 |
|
297 |
for x in spool run lib log; do |
298 |
chown -R asterisk:asterisk "${ROOT}"var/${x}/asterisk |
299 |
chmod -R u=rwX,g=rwX,o= "${ROOT}"var/${x}/asterisk |
300 |
done |
301 |
|
302 |
chown -R root:asterisk "${ROOT}"etc/asterisk |
303 |
chmod -R u=rwX,g=rwX,o= "${ROOT}"etc/asterisk |
304 |
|
305 |
einfo "done" |
306 |
else |
307 |
einfo "skipping" |
308 |
fi |
309 |
} |