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