-
Notifications
You must be signed in to change notification settings - Fork 17
/
yate-bts.spec
423 lines (352 loc) · 11.5 KB
/
yate-bts.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# to add a distro release tag run rpmbuild --define 'dist value'
# to add a revision tag run rpmbuild --define 'revision value'
# to create a debug info package run rpmbuild --define 'debuginfo 1'
# to suppress auto dependencies run rpmbuild --define 'nodeps 1'
# to disable RAD1 support run rpmbuild --define 'norad1 1'
# to disable bladeRF support run rpmbuild --define 'noblade 1'
# to disable USRP1 support run rpmbuild --define 'nousrp1 1'
# to disable UHD support run rpmbuild --define 'nouhd 1'
%{!?dist:%define dist %{nil}}
%{!?revision:%define revision %{nil}}
%{?nodeps:%define no_auto_deps 1}
%{?norad1:%define no_rad1 1}
%{?noblade:%define no_blade 1}
%{?nousrp1:%define no_usrp1 1}
%{?nouhd:%define no_uhd 1}
%{!?debuginfo:%define debuginfo %{nil}}
%if "%{debuginfo}"
%define stripped debug
%else
%define stripped strip
%define debug_package ${nil}
%endif
%if "%{revision}" == "svn"
%define revision 488svn
%endif
%if "%{dist}" == ""
%define dist %{?distsuffix:%distsuffix}%{?product_version:%product_version}
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/mandriva-release && echo mdv)
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/mandrake-release && echo mdk)
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/fedora-release && echo fc)
%endif
%if "%{dist}" == ""
%define dist %(grep -q ^CentOS /etc/issue && echo centos)
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/redhat-release && echo rh)
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/SuSE-release && echo suse)
%endif
%if "%{dist}" == "none"
%define dist %{nil}
%endif
Summary: GSM BTS based on Yet Another Telephony Engine
Name: yate-bts
Version: 5.0.0
Release: %{revision}1%{dist}
License: GPL
Packager: Paul Chitescu <[email protected]>
Source: http://yatebts.com/%{name}-%{version}-1.tar.gz
Group: Applications/Communications
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://yatebts.com/
BuildRequires: gcc-c++
BuildRequires: yate-devel >= 5.5.0
Requires: yate = 5.5.0
Requires: yate-gsm = 5.5.0
Requires: %{name}-transceiver = %{version}-%{release}
%define prefix /usr
%define moddir %{_libdir}/yate/server
%define btsdir %{moddir}/bts
%description
Yate is a telephony engine designed to implement PBX and IVR solutions
for small to large scale projects.
This module implements a 2G GSM BTS for Yate.
At least one transceiver package must also be installed for interfacing with the hardware.
%files
%defattr(-, root, root)
%docdir %{_defaultdocdir}/%{name}-%{version}
%doc %{_defaultdocdir}/%{name}-%{version}/*
%dir %{btsdir}
%{moddir}/*.yate
%{btsdir}/mbts
%config(noreplace) %{_sysconfdir}/yate/ybts.conf
%post
if grep -q '^ *Radio.C0 *= *[0-9]' %{_sysconfdir}/yate/ybts.conf 2>/dev/null; then
if [ -s /usr/lib/systemd/system/yate.service ]; then
systemctl condrestart yate.service
else
if [ -s /etc/init.d/yate ]; then
service yate condrestart
fi
fi
fi
%postun
test -f %{btsdir}/transceiver || rm -f %{btsdir}/transceiver
if [ -s /usr/lib/systemd/system/yate.service ]; then
systemctl condrestart yate.service
else
if [ -s /etc/init.d/yate ]; then
service yate condrestart
fi
fi
%package nib
Summary: GSM Network In a Box based on Yate-BTS
Group: Applications/Communications
Requires: %{name} = %{version}-%{release}
Requires: yate-scripts = 5.5.0
Requires: apache-mod_php
Requires(post): gawk
Suggests: pysim
%description nib
Scripts and support executables that implement a GSM Network In a Box.
%files nib
%defattr(-, root, root)
%dir %{_datadir}/yate/nib_web
%{_datadir}/yate/scripts/gsm_auth.sh
%{_datadir}/yate/scripts/do_*
%{_datadir}/yate/scripts/nib.js
%{_datadir}/yate/scripts/welcome.js
%{_datadir}/yate/scripts/custom_sms.js
%{_datadir}/yate/sounds/*
%{_datadir}/yate/nib_web/*
/var/www/html/nib
%config(noreplace) %{_datadir}/yate/nib_web/.htaccess
%config(noreplace) %{_datadir}/yate/nib_web/config.php
%config(noreplace) %{_sysconfdir}/yate/subscribers.conf
%post nib
sed -i 's/^ *\(roaming\|nib\) *=.*$/;; \0/' %{_sysconfdir}/yate/javascript.conf
if ! grep -q '; Installed by yate-bts-nib' %{_sysconfdir}/yate/javascript.conf 2>/dev/null; then
if grep -q '^ *\[general\]' %{_sysconfdir}/yate/javascript.conf 2>/dev/null; then
awk '/^ *\[/{sect=0}
/^ *\[general\]/{sect=1}
/^ *routing *=/{if(sect==2)sect=3}
{if(sect==3){print ";; " $0;sect=2} else print;
if(sect==1){print "; Installed by yate-bts-nib, do not remove this comment line\nrouting=welcome.js\n";sect=2}
}' <%{_sysconfdir}/yate/javascript.conf >%{_sysconfdir}/yate/javascript.conf.tmp
mv -f %{_sysconfdir}/yate/javascript.conf.tmp %{_sysconfdir}/yate/javascript.conf
else
cat <<-EOF >>%{_sysconfdir}/yate/javascript.conf
[general]
; Installed by yate-bts-nib, do not remove this comment line
routing=welcome.js
EOF
fi
fi
if ! grep -q '; Installed by yate-bts' %{_sysconfdir}/yate/ybts.conf 2>/dev/null; then
if grep -q '^ *\[ybts\]' %{_sysconfdir}/yate/ybts.conf 2>/dev/null; then
awk '/^ *\[/{sect=0}
/^ *\[ybts\]/{sect=1}
/^ *mode *=/{if(sect==2)sect=3}
{if(sect==3){print ";; " $0;sect=2} else print;
if(sect==1){print "; Installed by yate-bts-nib, do not remove this comment line\nmode=nib\n";sect=2}
}' <%{_sysconfdir}/yate/ybts.conf >%{_sysconfdir}/yate/ybts.conf.tmp
mv -f %{_sysconfdir}/yate/ybts.conf.tmp %{_sysconfdir}/yate/ybts.conf
fi
fi
if ! grep -q '; Installed by yate-bts-nib' %{_sysconfdir}/yate/extmodule.conf 2>/dev/null; then
if grep -q '^ *\[scripts\]' %{_sysconfdir}/yate/extmodule.conf 2>/dev/null; then
awk '/^ *\[/{sect=0}
/^ *\[scripts\]/{sect=1}
/^ *gsm_auth\.sh/{if(sect==2)sect=3}
{if(sect==3){print ";; " $0;sect=2} else print;
if(sect==1){print "; Installed by yate-bts-nib, do not remove this comment line\ngsm_auth.sh\n";sect=2}
}' <%{_sysconfdir}/yate/extmodule.conf >%{_sysconfdir}/yate/extmodule.conf.tmp
mv -f %{_sysconfdir}/yate/extmodule.conf.tmp %{_sysconfdir}/yate/extmodule.conf
else
cat <<-EOF >>%{_sysconfdir}/yate/extmodule.conf
[scripts]
; Installed by yate-bts-nib, do not remove this comment line
gsm_auth.sh
EOF
fi
fi
chgrp -R apache %{_sysconfdir}/yate
chmod -R g+rw %{_sysconfdir}/yate
%package roaming
Summary: SIP based GSM roaming support for Yate-BTS
Group: Applications/Communications
Requires: %{name} = %{version}-%{release}
Requires(post): gawk
%description roaming
Scripts that implement SIP registration from YateBTS to a remote OpenVoLTE server.
%files roaming
%defattr(-, root, root)
%{_datadir}/yate/scripts/roaming.js
%{_datadir}/yate/scripts/handover.js
%{_datadir}/yate/scripts/lib_str_util.js
%post roaming
sed -i 's/^ *\(roaming\|nib\) *=.*$/;; \0/' %{_sysconfdir}/yate/javascript.conf
if ! grep -q '; Installed by yate-bts' %{_sysconfdir}/yate/ybts.conf 2>/dev/null; then
if grep -q '^ *\[ybts\]' %{_sysconfdir}/yate/ybts.conf 2>/dev/null; then
awk '/^ *\[/{sect=0}
/^ *\[ybts\]/{sect=1}
/^ *mode *=/{if(sect==2)sect=3}
{if(sect==3){print ";; " $0;sect=2} else print;
if(sect==1){print "; Installed by yate-bts-roaming, do not remove this comment line\nmode=roaming\n";sect=2}
}' <%{_sysconfdir}/yate/ybts.conf >%{_sysconfdir}/yate/ybts.conf.tmp
mv -f %{_sysconfdir}/yate/ybts.conf.tmp %{_sysconfdir}/yate/ybts.conf
fi
fi
if ! grep -q '; Installed by yate-bts-roaming +handover' %{_sysconfdir}/yate/ysipchan.conf 2>/dev/null; then
mv -f -n %{_sysconfdir}/yate/ysipchan.conf %{_sysconfdir}/yate/ysipchan.conf.rpmold
cat <<-EOF >%{_sysconfdir}/yate/ysipchan.conf
; Installed by yate-bts-roaming +handover, do not remove this comment line
[general]
lazy100=yes
transfer=no
privacy=yes
generate=yes
rtp_start=yes
auth_foreign=yes
autochangeparty=yes
update_target=yes
body_encoding=hex
async_generic=yes
sip_req_trans_count=5
useragent=YateBTS/5.0.0
[codecs]
default=disable
gsm=enable
[message]
enable=yes
auth_required=false
[options]
enable=no
[methods]
options=no
info=no
EOF
fi
%if "%{no_rad1}" != "1"
%package rad1
Summary: RAD1 transceiver support for Yate-BTS
Group: Applications/Communications
Provides: %{name}-transceiver
Requires: %{name} = %{version}-%{release}
%description rad1
RAD1 transceiver executable and support files for Yate-BTS.
%files rad1
%defattr(-, root, root)
%{btsdir}/transceiver-rad1
%{btsdir}/ezusb.ihx
%{btsdir}/fpga.rbf
%post rad1
test -f %{btsdir}/transceiver || ln -sf transceiver-rad1 %{btsdir}/transceiver
%postun rad1
test -f %{btsdir}/transceiver || rm -f %{btsdir}/transceiver
%define conf_rad1 --enable-rad1
%else
%define conf_rad1 --disable-rad1
%endif
%if "%{no_blade}" != "1"
%package bladerf
Summary: bladeRF transceiver support for Yate-BTS
Group: Applications/Communications
Provides: %{name}-transceiver
Requires: %{name} = %{version}-%{release}
%description bladerf
bladeRF transceiver executable and support files for Yate-BTS.
%files bladerf
%defattr(-, root, root)
%{btsdir}/transceiver-bladerf
%{btsdir}/firmware.img
%{btsdir}/hostedx40.rbf
%{btsdir}/hostedx115.rbf
%post bladerf
test -f %{btsdir}/transceiver || ln -sf transceiver-bladerf %{btsdir}/transceiver
%postun bladerf
test -f %{btsdir}/transceiver || rm -f %{btsdir}/transceiver
%define conf_blade --enable-bladerf
%else
%define conf_blade --disable-bladerf
%endif
%if "%{no_usrp1}" != "1"
%package usrp1
Summary: USRP1 transceiver support for Yate-BTS
Group: Applications/Communications
Provides: %{name}-transceiver
Requires: %{name} = %{version}-%{release}
%description usrp1
USRP1 transceiver executable and support files for Yate-BTS.
%files usrp1
%defattr(-, root, root)
%{btsdir}/transceiver-usrp1
%{btsdir}/std_inband.rbf
%post usrp1
test -f %{btsdir}/transceiver || ln -sf transceiver-usrp1 %{btsdir}/transceiver
%postun usrp1
test -f %{btsdir}/transceiver || rm -f %{btsdir}/transceiver
%define conf_usrp1 --enable-usrp1
%else
%define conf_usrp1 --disable-usrp1
%endif
%if "%{no_uhd}" != "1"
%package uhd
Summary: UHD transceiver support for Yate-BTS
Group: Applications/Communications
Provides: %{name}-transceiver
Requires: %{name} = %{version}-%{release}
%description uhd
UHD transceiver executable and support files for Yate-BTS.
%files uhd
%defattr(-, root, root)
%{btsdir}/bts/transceiver-uhd
%post uhd
test -f %{btsdir}/transceiver || ln -sf transceiver-uhd %{btsdir}/transceiver
%postun uhd
test -f %{btsdir}/transceiver || rm -f %{btsdir}/transceiver
%define conf_uhd --enable-uhd
%else
%define conf_uhd --disable-uhd
%endif
%prep
%setup -q -n %{name}
%define local_find_requires %{_builddir}/%{name}/local-find-requires
#
%{__cat} <<EOF >%{local_find_requires}
#! /bin/sh
grep -v '\.yate$' | %{__find_requires} | grep -v '^\(perl\|pear\)'
exit 0
EOF
#
chmod +x %{local_find_requires}
%define __find_requires %{local_find_requires}
%if "%{no_auto_deps}" == "1"
%define local_find_provides %{_builddir}/%{name}/local-find-provides
#
%{__cat} <<EOF >%{local_find_provides}
#! /bin/sh
%{__find_provides} | grep -v '\.yate$'
exit 0
EOF
#
chmod +x %{local_find_provides}
%define _use_internal_dependency_generator 0
%define __find_provides %{local_find_provides}
%define __perl_requires /bin/true
%endif
%build
./configure --prefix=%{prefix} --sysconfdir=/etc --mandir=%{prefix}/share/man \
%{conf_usrp1} %{conf_uhd} %{conf_rad1} %{conf_blade}
make %{stripped}
%install
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}/var/www/html
ln -sf %{_datadir}/yate/nib_web %{buildroot}/var/www/html/nib
%clean
rm -rf %{buildroot}
%changelog
* Thu Apr 24 2014 Paul Chitescu <[email protected]>
- Added bladerf subpackage
* Mon Mar 17 2014 Paul Chitescu <[email protected]>
- Added NIB Web interface files
* Mon Dec 09 2013 Paul Chitescu <[email protected]>
- Created specfile