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