File matrix-synapse.spec of Package matrix-synapse
#
# spec file for package matrix
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
## Package updates
#
# * Update version in _service and this file to the most recent released one
# * Call `osc service ra`
# * Update changelog manually from
# * https://github.com/matrix-org/synapse/releases
# * Commit+submit
# Define just "test" as a package in _multibuild file to distinguish test
# instructions here
%if "@BUILD_FLAVOR@" == ""
%define _test 0
%define name_ext %nil
%else
%define _test 1
%define name_ext -test
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define github_user matrix-org
%define short_name synapse
Name: matrix-%{short_name}%{?name_ext}
Version: 0.28.1
Release: 0
Summary: Matrix protocol reference homeserver
License: Apache-2.0
Group: Productivity/Networking/Instant Messenger
Source0: matrix-synapse-v%{version}.tar.xz
Patch1: boo1096833_event_visibility_rules_not_applied_correctly.patch
Url: https://github.com/matrix-org/synapse
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?_test}
BuildRequires: matrix-%{short_name}
%else
BuildRequires: %{python_module base}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: unzip
Requires(pre): shadow
%if 0%{?suse_version} >= 1330
# alternative: create a specific "synapse" group
Requires(pre): group(nogroup)
%endif
Requires: python-Twisted
Requires: python-bcrypt
Requires: python-canonicaljson >= 1.1.3
Requires: python-frozendict >= 0.4
Requires: python-jsonschema >= 2.5.1
Requires: python-msgpack-python
Requires: python-phonenumbers >= 8.2.0
Requires: python-signedjson >= 1.0.0
Requires: python-unpaddedbase64 >= 1.1.0
# original from python_requirements.py
#BuildRequires: python-PyNaCl == 0.3.0
Requires: python-Pillow
Requires: python-PyNaCl
Requires: python-PyYAML
Requires: python-Twisted >= 16.0.0
Requires: python-blist
Requires: python-daemonize
Requires: python-msgpack-python >= 0.3.0
Requires: python-pyOpenSSL >= 0.14
Requires: python-pyasn1
Requires: python-pydenticon
Requires: python-pymacaroons-pynacl
Requires: python-pysaml2 >= 3.0.0
Requires: python-service_identity >= 1.0.0
Requires: python-ujson
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
%if "%{python_flavor}" == "python2"
Provides: matrix-synapse = %{version}
%endif
%endif
%if 0%{?_test}
%else
%python_subpackages
%endif
%description
Synapse is a Python-based reference "homeserver" implementation of
Matrix. Matrix is a system for federated Instant Messaging and VoIP.
%prep
%if 0%{?_test}
# workaround to prevent post/install failing assuming this file for whatever
# reason
touch %{_sourcedir}/%{short_name}
%else
%setup -q -n %{name}-v%{version}
%patch1 -p1
for i in \
app/client_reader \
app/event_creator \
app/federation_sender \
app/synchrotron \
app/pusher \
app/media_repository \
app/homeserver \
app/appservice \
app/federation_reader \
app/frontend_proxy \
app/user_dir \
push/pusherpool \
util/versionstring
do
sed -i '1d' synapse/$i.py
done
# patch the version requirement as it would be hard to supply exactly this
# version as dependency
sed -i 's/nacl==0.3.0/nacl>=0.3.0/g' synapse/python_dependencies.py
for i in synapse/app/synctl.py scripts/move_remote_media_to_new_store.py
do
sed -i 's@#!/usr/bin/env python@#!/usr/bin/python@g' $i
done
sed -i '1 s@#!/usr/bin/env perl@#!/usr/bin/perl@g' scripts/sync_room_to_group.pl
%endif
%build
%if 0%{?_test}
python -m synapse.app.homeserver --generate-config --server localhost --config-path homeserver.yaml --report-stats=no
# Disable the web client which would need python-matrix-synapse-angular-client
# as a dependency for this test which is not available in all repos and we do
# not want to rely on it
# https://github.com/matrix-org/synapse/issues/2113
sed -e 's/\(web_client: \).*$/\1False/' -e '/- webclient # The bundled webclient/d' -e 's/- names: \[client, webclient\]/- names: [client]/' -i homeserver.yaml
synctl start
register_new_matrix_user --config homeserver.yaml --user opensuse --password opensuse --admin https://localhost:8448
%else
%python_build
chmod +x build/lib/synapse/app/synctl.py
%endif
%install
%if 0%{?_test}
# disable debug packages in package test to prevent error about missing files
%define debug_package %{nil}
%else
%python_install
mkdir -p "%{buildroot}%{_sysconfdir}/synapse"
install -m 0644 contrib/systemd/log_config.yaml \
"%{buildroot}%{_sysconfdir}/synapse"
mkdir -p %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcsynapse
mkdir -p "%{buildroot}%{_unitdir}"
install -m 0644 contrib/systemd/synapse.service \
"%{buildroot}%{_unitdir}"
mkdir -p "%{buildroot}%{_rundir}/synapse"
%python_expand %fdupes %{buildroot}%{$python_sitelib}
for p in hash_password register_new_matrix_user synapse_port_db synctl ; do
%python_clone -a %{buildroot}%{_bindir}/$p
done
%python_clone -a %{buildroot}%{_sbindir}/rcsynapse
%python_clone -a %{buildroot}%{_unitdir}/synapse.service
%python_clone -a %{buildroot}%{_sysconfdir}/synapse/log_config.yaml
%pre
getent passwd synapse >/dev/null || \
/usr/sbin/useradd -r -g nogroup -s /sbin/nologin -c 'Matrix Synapse' \
-d %{_localstatedir}/lib/synapse synapse
%service_add_pre synapse.service
%post
%{python_install_alternative synctl hash_password register_new_matrix_user synapse_port_db rcsynapse synapse.service log_config.yaml}
%service_add_post synapse.service
%preun
%service_del_preun synapse.service
%postun
%python_uninstall_alternative synctl
%service_del_postun synapse.service
%files %{python_files}
%defattr(-,root,root,-)
%doc *.rst
%doc LICENSE
%dir %{_sysconfdir}/synapse
%{python_sitelib}
%python_alternative %{_bindir}/hash_password
%python_alternative %{_bindir}/register_new_matrix_user
%python_alternative %{_bindir}/synapse_port_db
%python_alternative %{_bindir}/synctl
%python_alternative %{_sbindir}/rcsynapse
%python_alternative %{_unitdir}/synapse.service
%config %python_alternative %{_sysconfdir}/synapse/log_config.yaml
%python3_only %{_bindir}/sync_room_to_group.pl
%python3_only %{_bindir}/move_remote_media_to_new_store.py
%endif
%changelog