-
Notifications
You must be signed in to change notification settings - Fork 13
/
yate-bts.spec.in
387 lines (345 loc) · 10.6 KB
/
yate-bts.spec.in
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
# 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 build a standalone (not yate-sdr) package run rpmbuild --define 'nosdr 1'
%{!?dist:%define dist %{nil}}
%{!?revision:%define revision %{nil}}
%{!?_unitdir:%define _unitdir /usr/lib/systemd/system}
%{?nodeps:%define no_auto_deps 1}
%{!?nosdr:%define nosdr 0}
%if %{nosdr}
%define serv_name yate
%define cfgdir @YATE_CFG@
%define xtra_stat nosdr.
%else
%define serv_name yate-sdr
%define cfgdir %{_sysconfdir}/yate/sdr
%define xtra_stat %{nil}
%endif
%{!?debuginfo:%define debuginfo %{nil}}
%if "%{debuginfo}"
%define stripped debug
%else
%define stripped strip
%define debug_package ${nil}
%endif
%if "%{revision}" == "svn"
%define revision @PACKAGE_REVISION@svn
%endif
%if "%{dist}" == ""
%define dist %{?distsuffix:%distsuffix}%{?product_version:%product_version}
%endif
%if "%{dist}" == ""
%define dist %(test -f /etc/mageia-release && echo mga)
%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: @PACKAGE_TARNAME@
Version: @PACKAGE_VERSION@
Release: %{xtra_stat}@PACKAGE_STATUS@%{revision}@PACKAGE_RELEASE@%{?status:_%{status}}%{dist}
License: GPL
Packager: Paul Chitescu <paulc@null.ro>
Source: https://yatebts.com/%{name}-%{version}-@PACKAGE_STATUS@@PACKAGE_RELEASE@.tar.gz
Group: Applications/Communication
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: https://yatebts.com/
%{?extra_prov:Provides: %{?extra_prov}}
%{?extra_reqs:Requires: %{?extra_reqs}}
BuildRequires: gcc-c++
BuildRequires: yate-devel >= @YATE_REQ@
Requires: yate = @YATE_VER@
Requires: yate-gsm = @YATE_VER@
Requires: yate-radio = @YATE_VER@
%if %{nosdr}
Conflicts: yate-enb
%else
Requires: yate-sdr
%endif
Conflicts: yate-bts-transceiver
%define prefix /usr
%define moddir %{_libdir}/yate/server
%define btsdir %{moddir}/bts
%define shrdir @YATE_SHR@
%define scrdir @YATE_SCR@
%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 Yate radio device package must also be installed.
%files
%defattr(-, root, root)
%docdir %{_defaultdocdir}/%{name}-%{version}
%doc %{_defaultdocdir}/%{name}-%{version}/*
%dir %{btsdir}
%{moddir}/*.yate
%{btsdir}/mbts
%if %{nosdr}
%config(noreplace) %{cfgdir}/ybts.conf
%else
%{shrdir}/api/*
%{scrdir}/bts_config.js
%{scrdir}/nipc_config.js
%{scrdir}/nipc_validations.js
%{scrdir}/ybts_fields.js
%{cfgdir}/bts-jscript.conf
%endif
%post
%if ! %{nosdr}
test "X$1" = "X1" && %{_datadir}/yate/scripts/rpm_restore.sh %{name}
%endif
if grep -q '^ *Radio.C0 *= *[0-9]' %{cfgdir}/ybts.conf 2>/dev/null; then
if [ -s %{_unitdir}/%{serv_name}.service ]; then
systemctl condrestart %{serv_name}.service
else
if [ -s /etc/init.d/%{serv_name} ]; then
service %{serv_name} condrestart
fi
fi
fi
%postun
if [ -s %{_unitdir}/%{serv_name}.service ]; then
systemctl condrestart %{serv_name}.service
else
if [ -s /etc/init.d/%{serv_name} ]; then
service %{serv_name} condrestart
fi
fi
%package nipc
Summary: GSM Network In a PC based on YateBTS
Group: Applications/Communication
Requires: %{name} = %{version}-%{release}
Requires: yate-scripts = @YATE_VER@
Requires: apache-mod_php
%if %{nosdr}
Requires(post): gawk
Suggests: pysim
%endif
Obsoletes: yate-bts-nib
Conflicts: yate-bts-nib
%description nipc
Scripts and support executables that implement a GSM Network In a PC.
%files nipc
%defattr(-, root, root)
%{scrdir}/nipc_auth.sh
%{scrdir}/do_*
%{scrdir}/nipc.js
%{scrdir}/welcome.js
%{scrdir}/custom_sms.js
%{shrdir}/sounds/*
/var/www/html/nipc
%if %{nosdr}
%dir %{shrdir}/nipc_web
%{shrdir}/nipc_web/*
%config(noreplace) %{shrdir}/nipc_web/.htaccess
%config(noreplace) %{shrdir}/nipc_web/config.php
%else
%{cfgdir}/bts-extmod.conf
%endif
%config(noreplace) %{cfgdir}/subscribers.conf
%post nipc
%if %{nosdr}
sed -i 's/^ *\(roaming\|nipc\) *=.*$/;; \0/' %{cfgdir}/javascript.conf
if ! grep -q '; Installed by yate-bts-nipc' %{cfgdir}/javascript.conf 2>/dev/null; then
if grep -q '^ *\[general\]' %{cfgdir}/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-nipc, do not remove this comment line\nrouting=welcome.js\n";sect=2}
}' <%{cfgdir}/javascript.conf >%{cfgdir}/javascript.conf.tmp
mv -f %{cfgdir}/javascript.conf.tmp %{cfgdir}/javascript.conf
else
cat <<-EOF >>%{cfgdir}/javascript.conf
[general]
; Installed by yate-bts-nipc, do not remove this comment line
routing=welcome.js
EOF
fi
fi
if ! grep -q '^ *mode *=' %{cfgdir}/ybts.conf 2>/dev/null; then
if grep -q '^ *\[ybts\]' %{cfgdir}/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-nipc, do not remove this comment line\nmode=nipc\n";sect=2}
}' <%{cfgdir}/ybts.conf >%{cfgdir}/ybts.conf.tmp
mv -f %{cfgdir}/ybts.conf.tmp %{cfgdir}/ybts.conf
fi
fi
if ! grep -q '; Installed by yate-bts-nipc' %{cfgdir}/extmodule.conf 2>/dev/null; then
if grep -q '^ *\[scripts\]' %{cfgdir}/extmodule.conf 2>/dev/null; then
awk '/^ *\[/{sect=0}
/^ *\[scripts\]/{sect=1}
/^ *gsm_auth\.sh/{if(sect==2)sect=3}
/^ *nipc_auth\.sh/{if(sect==2)sect=3}
{if(sect==3){print ";; " $0;sect=2} else print;
if(sect==1){print "; Installed by yate-bts-nipc, do not remove this comment line\nnipc_auth.sh\n";sect=2}
}' <%{cfgdir}/extmodule.conf >%{cfgdir}/extmodule.conf.tmp
mv -f %{cfgdir}/extmodule.conf.tmp %{cfgdir}/extmodule.conf
else
cat <<-EOF >>%{cfgdir}/extmodule.conf
[scripts]
; Installed by yate-bts-nipc, do not remove this comment line
nipc_auth.sh
EOF
fi
fi
chgrp -R apache %{cfgdir}
chmod -R g+rw %{cfgdir}
%else
test "X$1" = "X1" && %{_datadir}/yate/scripts/rpm_restore.sh %{name}-nipc
%endif
%package roaming
Summary: SIP based GSM roaming support for YateBTS
Group: Applications/Communication
Requires: %{name} = %{version}-%{release}
Requires: yate-scripts = @YATE_VER@
%if %{nosdr}
Requires(post): gawk
%endif
%description roaming
Scripts that implement SIP registration from YateBTS to a remote YateUCN server.
%files roaming
%defattr(-, root, root)
%{scrdir}/roaming.js
%{scrdir}/handover.js
%if %{nosdr}
%{scrdir}/lib_str_util.js
%endif
%post roaming
%if %{nosdr}
sed -i 's/^ *\(roaming\|nipc\) *=.*$/;; \0/' %{cfgdir}/javascript.conf
if ! grep -q '^ *mode *=' %{cfgdir}/ybts.conf 2>/dev/null; then
if grep -q '^ *\[ybts\]' %{cfgdir}/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}
}' <%{cfgdir}/ybts.conf >%{cfgdir}/ybts.conf.tmp
mv -f %{cfgdir}/ybts.conf.tmp %{cfgdir}/ybts.conf
fi
fi
%endif
if ! grep -q '; Installed by yate-bts-roaming +handover\|updated=\|locked=' %{cfgdir}/ysipchan.conf 2>/dev/null; then
mv -f -n %{cfgdir}/ysipchan.conf %{cfgdir}/ysipchan.conf.rpmold
cat <<-EOF >%{cfgdir}/ysipchan.conf
; Installed by yate-bts-roaming +handover, do not remove this comment line
[general]
updated=`date -u '+%%A, %%d-%%b-%%y %%H:%%M:%%S GMT'` from package installer
locked=false
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/@PACKAGE_VERSION@
[codecs]
default=disable
gsm=enable
[message]
enable=yes
auth_required=false
[options]
enable=no
[methods]
options=no
info=no
EOF
fi
%prep
%setup -q -n %{name}
# older rpmbuild uses these macro basic regexps
%define _requires_exceptions pear
# newer rpmbuild needs these global extended regexps
%global __requires_exclude pear
%define local_find_requires %{_builddir}/%{name}/local-find-requires
#
%{__cat} <<EOF >%{local_find_requires}
#! /bin/sh
%{__find_requires} | grep -v '^\(perl\|pear\)' | grep -v '.php'
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 \
--with-conf=%{cfgdir} %{?extra_conf}
make %{stripped} %{?extra_make}
%{?extra_step}
%install
make install DESTDIR=%{buildroot} %{?extra_make}
mkdir -p %{buildroot}/var/www/html
%if %{nosdr}
ln -sf %{shrdir}/nipc_web %{buildroot}/var/www/html/nipc
%else
cp -rp nipc/redir %{buildroot}/var/www/html/nipc
cp -p scripts/*.js* %{buildroot}%{scrdir}/
echo -e '[scripts]\nbts_config=bts_config.js' > %{buildroot}%{cfgdir}/bts-jscript.conf
echo -e '[scripts]\nnipc_auth.sh' > %{buildroot}%{cfgdir}/bts-extmod.conf
mkdir -p %{buildroot}%{shrdir}/api
echo '<?php global $bts_version; $bts_version = "%{version}-%{release}"; ?>' > %{buildroot}%{shrdir}/api/bts_version.php
rm %{buildroot}%{cfgdir}/ybts.conf
rm %{buildroot}%{scrdir}/lib_str_util.js
rm -rf %{buildroot}%{shrdir}/nipc_web
%endif
%if "%{?extra_inst}"
export DESTDIR=%{buildroot}
%{?extra_inst}
%endif
%clean
rm -rf %{buildroot}
%changelog
* Wed Mar 29 2017 Paul Chitescu <paulc@null.ro>
- Added support for extra build steps
* Mon Aug 24 2015 Paul Chitescu <paulc@null.ro>
- Removed hardware support subpackages
* Thu Apr 24 2014 Paul Chitescu <paulc@null.ro>
- Added bladerf subpackage
* Mon Mar 17 2014 Paul Chitescu <paulc@null.ro>
- Added NiPC Web interface files
* Mon Dec 09 2013 Paul Chitescu <paulc@null.ro>
- Created specfile