-
Notifications
You must be signed in to change notification settings - Fork 1
/
signal-cli.spec
402 lines (279 loc) · 11.6 KB
/
signal-cli.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
### *** signal-cli
###
### see also:
### - https://github.com/pbiering/signal-cli-rpm
### - description (below)
###
### Step 1: create source package by
### download required packages and store to ~/rpmbuild/SOURCES
### $ rpmbuild -bp --undefine=_disable_source_fetch signal-cli.spec
###
### Step 2: rebuild
### $ rpmbuild -bb signal-cli.spec
# do not create debug packages
%define debug_package %{nil}
%define pname signal-cli
## MAIN VERSIONS+RELEASE
%global version_signal_cli 0.13.10
# EL8: since 0.12.0 bundled libsignal_jni.so requires GLIBC_2.33 while has only 2.28 -> build from https://github.com/exquo/signal-libs-build/ is required
%global version_libsignal 0.62.0
# required major JAVA version
%global version_java_major 21
%global release_token 2
%global basedir /usr/lib/%{pname}
%global bindir %{basedir}/bin
%global vardir %{_localstatedir}/lib/%{pname}
%global builddir %{_builddir}/%{pname}-%{version_signal_cli}
# The user and group signal-cli will run as
# user/group system id will be autogenerated by using -r
%global scuser signal-cli
%global scgroup signal-cli
Name: %{pname}
Summary: signal-cli commandline, dbus and JSON-RPC interface for the Signal messenger
Version: %{version_signal_cli}
Release: %{release_token}%{?dist}
License: GPLv3
URL: https://github.com/AsamK/signal-cli
Source0: https://github.com/AsamK/signal-cli/releases/download/v%{version}/signal-cli-%{version}.tar.gz
# only used on EL8 since 0.12.0
#Source1: https://github.com/exquo/signal-libs-build/releases/download/libsignal_v%{version_libsignal}/libsignal_jni.so-v%{version_libsignal}-x86_64-unknown-linux-gnu.tar.gz
# only used on EL8 since 0.52.1
Source1: https://media.projektzentrisch.de/temp/signal-cli/tests/libsignal_jni_so%(echo "%{version_libsignal}" | awk -F. '{ printf "%01d%02d%01d", $1, $2, $3 }')_ubuntu1804_amd64.gz
## config files taken+adjusted from https://github.com/AsamK/signal-cli/tree/master/data
# dbus
Source100: org.asamk.Signal.conf
Source101: org.asamk.Signal.service
# systemd
Source200: signal-cli.service
# wrapper
Source300: signal-cli
Source301: signal-cli-dbus
%{?systemd_requires}
BuildRequires: systemd
Requires(pre): shadow-utils
Requires: java-%{version_java_major}-openjdk-headless
# for downloading sources
BuildRequires: curl
BuildRequires: rpmdevtools
# for testing the build
BuildRequires: java-%{version_java_major}-openjdk-headless
# for dbus
Requires: dbus-common dbus-tools
%description
signal-cli provides an unofficial commandline, dbus and JSON-RPC interface for the Signal messenger.
user/group : %{scuser}/%{scgroup}
home directory : %{vardir}
binary for native interface: %{_bindir}/signal-cli
binary for dbus interface: %{_bindir}/signal-cli-dbus
%prep
%{__rm} -rf %{builddir}
%{__mkdir} %{builddir}
cd %{builddir}
# nothing to build -> nothing to extract
## SELinux
# (currently no policy)
%build
# nothing to build
%install
cd %{builddir}
install -d -p %{buildroot}%{basedir}
# extract
%{__tar} xf %{SOURCE0} -C %{buildroot}%{basedir} --strip-components=1
# remove non Linux files
%{__rm} -f %{buildroot}%{basedir}/bin/%{pname}.bat
# replace libsignal_jni.so
%if 0%{?rhel} == 8
#%{__tar} xf %{SOURCE1} -C %{buildroot}%{basedir}
gunzip -c %{SOURCE1} >%{buildroot}%{basedir}/libsignal_jni.so
# check compatibility
if ldd %{buildroot}%{basedir}/libsignal_jni.so | grep "not found"; then
echo "ERROR : libsignal_jni.so is not compatible"
exit 1
fi
# check for file is existing
if [ ! -f %{buildroot}%{basedir}/lib/libsignal-client-%{version_libsignal}.jar ]; then
echo "ERROR : on implant libsignal_jni.so because of version mismatch"
%define version_jar $(ls -1 %{buildroot}%{basedir}/lib/libsignal-client-*.jar | %{__sed} 's/.*-\\([0-9.]*\\).jar/\\1/g')
echo "ERROR : SOURCE0 contains: %{version_jar} (signal-cli-%{version}.tar.gz)"
echo "ERROR : SOURCE1 contains: %{version_libsignal} (libsignal_jni.so-v%{version_libsignal}-x86_64-unknown-linux-gnu.tar.gz)"
echo "ERROR : fix version in SPEC file: version_libsignal"
exit 1
fi
# implant libsignal
echo "INFO : implant libsignal_jni.so (libsignal_jni.so-v%{version_libsignal}-x86_64-unknown-linux-gnu.tar.gz) into libsignal-client-%{version_libsignal}.jar"
zip -j %{buildroot}%{basedir}/lib/libsignal-client-%{version_libsignal}.jar %{buildroot}%{basedir}/libsignal_jni.so
# remove
%{__rm} %{buildroot}%{basedir}/libsignal_jni.so
%endif
### wrapper scripts
install -d -p %{buildroot}%{_bindir}
install -D -m 0755 %{SOURCE300} %{buildroot}%{_bindir}
install -D -m 0755 %{SOURCE301} %{buildroot}%{_bindir}
## dbus files
install -d -p %{buildroot}%{_prefix}/share/dbus-1/system.d/
install -D -m 0644 %{SOURCE100} %{buildroot}%{_prefix}/share/dbus-1/system.d/
install -d -p %{buildroot}%{_prefix}/share/dbus-1/system-services/
install -D -m 0644 %{SOURCE101} %{buildroot}%{_prefix}/share/dbus-1/system-services/
# systemd files
install -d -p %{buildroot}%{_unitdir}/
install -D -m 0644 %{SOURCE200} %{buildroot}%{_unitdir}
# home directory setup
install -d -p -m 700 %{buildroot}/var/lib/%{pname}
for d in data avatars; do
install -d -p -m 700 %{buildroot}%{vardir}/.local/share/%{pname}/$d
%{__ln_s} .local/share/%{pname}/$d %{buildroot}%{vardir}/$d
done
## SELinux
# (currently no policy)
# replace placeholders
find %{buildroot}%{_unitdir} %{buildroot}%{_bindir} -type f | while read file; do
# replace directories
sed -i -e 's,@BINDIR@,%{bindir},g;s,@BASEDIR@,%{basedir},g;s,@VARDIR@,%{vardir},g;s,@SCUSER@,%{scuser},g;s,@SCGROUP@,%{scgroup},g;s,@JAVAMAJOR@,%{version_java_major},g' $file
done
%check
export JAVA_HOME=/etc/alternatives/jre_%{version_java_major}
%{buildroot}%{basedir}/bin/signal-cli --version
%pre
# User & Group
if getent group %{scgroup} >/dev/null; then
echo "system group for %{pname} already exists: %{scgroup}"
else
echo "system group for %{pname} needs to be created: %{scgroup}"
groupadd -r %{scgroup} >/dev/null
fi
if getent passwd %{scuser} >/dev/null; then
echo "system user for %{pname} already exists: %{scuser}"
homedir=$(getent passwd %{scuser} | awk -F: '{ print $6 }')
if [ "$homedir" != "%{vardir}" ]; then
echo "system user for %{pname} already exists: %{scuser} bu has not required home directory: %{vardir} (current: $homedir)"
exit 1
fi
else
echo "system user for %{pname} needs to be created: %{scuser}"
useradd -r -g %{scgroup} -d %{vardir} -s /bin/bash -c "signal-cli commandline, dbus and JSON-RPC interface for the Signal messenger" %{scuser} >/dev/null
fi
# move files from a manual installation
for file in /etc/dbus-1/system.d/org.asamk.Signal.conf /etc/systemd/system/signal-cli.service; do
if [ -e $file ]; then
echo "file found from manual installation, renamed: $file -> $file.rpmunknown"
mv $file $file.rpmunknown
fi
done
# SELinux
# (currently no policy)
%post
# SELinux
# (currently no policy)
## systemd/service
%systemd_post %{pname}.service
%preun
## systemd/service
%systemd_preun %{pname}.service
# SELinux
# (currently no policy)
%postun
## systemd/service
%systemd_postun %{pname}.service
%posttrans
# SELinux
# (currently no policy)
systemctl daemon-reload
systemctl condrestart %{pname}.service
%files
%attr(755,-,-) %{_bindir}/*
%{_unitdir}/*.service
%{_prefix}/share/dbus-1/system.d/org.asamk.Signal.conf
%{_prefix}/share/dbus-1/system-services/org.asamk.Signal.service
%dir %attr(770,%{scuser},%{scgroup}) %{vardir}
%dir %attr(770,%{scuser},%{scgroup}) %{vardir}/.local
%dir %attr(770,%{scuser},%{scgroup}) %{vardir}/.local/share
%dir %attr(770,%{scuser},%{scgroup}) %{vardir}/.local/share/%{pname}
%dir %attr(770,%{scuser},%{scgroup}) %{vardir}/.local/share/%{pname}/*
%{vardir}/*
%{basedir}
## SELinux
# (currently no policy)
%changelog
* Mon Dec 02 2024 Peter Bieringer <[email protected]> - 0.13.10-1
- New upstream version 0.13.10
- EL8: update libsignal_jni.so to 0.62.0
* Tue Nov 12 2024 Peter Bieringer <[email protected]> - 0.13.9-2
- Shell wrapper switches to signal client user if executed by root
* Tue Oct 29 2024 Peter Bieringer <[email protected]> - 0.13.9-1
- New upstream version 0.13.9
* Sun Oct 27 2024 Peter Bieringer <[email protected]> - 0.13.8-1
- New upstream version 0.13.8
- EL8: update libsignal_jni.so to 0.58.2
* Sun Sep 30 2024 Peter Bieringer <[email protected]> - 0.13.7-1
- New upstream version 0.13.7
- EL8: update libsignal_jni.so to 0.58.0
* Mon Sep 09 2024 Peter Bieringer <[email protected]> - 0.13.6-1
- New upstream version 0.13.6
- EL8: update libsignal_jni.so to 0.56.0
* Mon Jul 29 2024 Peter Bieringer <[email protected]> - 0.13.5-2
- EL8: change source of bundled libsignal_jni.so
* Sun Jul 28 2024 Peter Bieringer <[email protected]>
- EL8: improve check of libsignal_jni.so before implanting
* Fri Jul 26 2024 Peter Bieringer <[email protected]> - 0.13.5-1
- New upstream version 0.13.5
- EL8: update libsignal_jni.so to 0.52.2
- signal-cli.service: increase startup timeout to 180 sec
* Thu Jun 06 2024 Peter Bieringer <[email protected]> - 0.13.4-1
- New upstream version 0.13.4
- EL8: update libsignal_jni.so to 0.47.0
* Wed May 15 2024 Peter Bieringer <[email protected]> - 0.13.3-2
- Apply user/group for all folders in .local
* Sat Apr 20 2024 Peter Bieringer <[email protected]> - 0.13.3-1
- New upstream version 0.13.3
- EL8: update libsignal_jni.so to 0.44.0
* Sat Mar 23 2024 Peter Bieringer <[email protected]> - 0.13.2-1
- New upstream version 0.13.2
- EL8: update libsignal_jni.so to 0.40.1
* Tue Feb 27 2024 Peter Bieringer <[email protected]> - 0.13.1-1
- New upstream version 0.13.1
* Tue Feb 20 2024 Peter Bieringer <[email protected]> - 0.13.0-2
- Carve out from spec file: signal-cli signal-cli-dbus wrapper scripts
- Replace hardcoded JAVA major version by variable
- Add JAVA_HOME to systemd unit file
* Mon Feb 19 2024 Peter Bieringer <[email protected]> - 0.13.0-1
- New upstream version 0.13.0
- Update requirement to Java 21
- Enforce use of Java 21 in wrapper scripts
- EL8: update libsignal_jni.so to 0.39.2
* Tue Feb 06 2024 Frank Wall <[email protected]> - 0.12.8-1
- New upstream version 0.12.8
* Sat Dec 30 2023 Peter Bieringer <[email protected]>
- Add requirements: dbus-common dbus-tools
* Sun Dec 17 2023 Peter Bieringer <[email protected]> - 0.12.7-5
- EL8: update libsignal_jni.so to 0.36.1
* Sat Dec 16 2023 Peter Bieringer <[email protected]> - 0.12.7-4
- New upstream version 0.12.7
* Tue Dec 12 2023 Peter Bieringer <[email protected]> - 0.12.6-4
- New upstream version 0.12.6
* Mon Oct 23 2023 Peter Bieringer <[email protected]> - 0.12.5-4
- New upstream version 0.12.5
* Mon Oct 23 2023 Peter Bieringer <[email protected]> - 0.12.4-4
- New upstream version 0.12.4
* Tue Oct 17 2023 Peter Bieringer <[email protected]> - 0.12.3-4
- New upstream version 0.12.3
* Sat Oct 07 2023 Peter Bieringer <[email protected]> - 0.12.2-4
- New upstream version 0.12.2
- EL8: update libsignal_jni.so to 0.32.1
* Sun Aug 27 2023 Peter Bieringer <[email protected]> - 0.12.1-4
- New upstream version 0.12.1
* Sun Aug 20 2023 Peter Bieringer <[email protected]> - 0.12.0-4
- EL8: implant libsignal_jni.so 0.30.0 from https://github.com/exquo/signal-libs-build/ to fix minimum required GLIBC_2.33 by upstream
- Add check section
* Sat Aug 19 2023 Peter Bieringer <[email protected]> - 0.12.0-3
- New upstream version 0.12.0
* Sun May 28 2023 Peter Bieringer <[email protected]> - 0.11.11-3
- New upstream version 0.11.11
* Sat May 13 2023 Peter Bieringer <[email protected]> - 0.11.10-3
- systemd unit file: specify PrivateTmp to avoid files with insecure permissions in /tmp
- wrapper scripts: quote arguments
* Thu May 11 2023 Peter Bieringer <[email protected]> - 0.11.10-2
- Conditional restart after update
* Thu May 11 2023 Peter Bieringer <[email protected]> - 0.11.10-1
- New upstream version 0.11.10
* Sun Apr 23 2023 Peter Bieringer <[email protected]> - 0.11.9.1-1
- Initial version