File matrix-synapse.spec of Package matrix-synapse
%global unmangled_version 1.116.0
Summary: Reference Synapse Home Server
Name: matrix-synapse
Version: %{unmangled_version}%{?unmangled_release:.%{unmangled_release}}
Release: 1%{?dist}
Source0: https://github.com/element-hq/synapse/archive/v%{unmangled_version}%{?unmangled_release?-r%{unmangled_release}}/synapse-%{unmangled_version}%{?unmangled_release:-r%{unmangled_release}}.tar.gz
Source1: synapse-tmpfile.conf
Source2: synapse.sysconfig
Source3: synapse.service
Source4: synapse-postgresql.conf
Patch0: matrix-synapse-proper-paths.patch
Patch2: matrix-synapse-test-paths.patch
Patch3: matrix-synapse-cryptography-version.patch
Patch5: matrix-synapse-older-pillow.patch
License: AGPL-3.0
Group: Development/Libraries
Prefix: %{_prefix}
BuildRequires: systemd-units
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: rust-packaging
BuildRequires: xmlsec1
BuildRequires: xmlsec1-openssl
%systemd_requires
Requires: python3-matrix-synapse = %{version}
Recommends: %{name}-postgresql
Provides: %{name}+systemd
%description
Matrix is an ambitious new ecosystem for open federated Instant Messaging and
VoIP. The basics you need to know to get up and running are:
- Everything in Matrix happens in a room. Rooms are distributed and do not
exist on any single server. Rooms can be located using convenience aliases
like ``#matrix:matrix.org`` or ``#test:localhost:8448``.
- Matrix user IDs look like ``@matthew:matrix.org`` (although in the future
you will normally refer to yourself and others using a 3PID: email
address, phone number, etc rather than manipulating Matrix user IDs)
The overall architecture is::
client <----> homeserver <=====================> homeserver <----> client
https://somewhere.org/_matrix https://elsewhere.net/_matrix
``#matrix:matrix.org`` is the official support room for Matrix, and can be
accessed by the web client at http://matrix.org/beta or via an IRC bridge at
irc://irc.freenode.net/matrix.
Synapse is currently in rapid development, but as of version 0.5 we believe it
is sufficiently stable to be run as an internet-facing service for real usage!
%package -n python3-matrix-synapse
Summary: Python 3 Libraries For Reference Synapse Home Server
%{?python_provide:%python_provide python3-matrix-synapse}
Requires: %{name}
Requires: xmlsec1
%description -n python3-matrix-synapse
Matrix is an ambitious new ecosystem for open federated Instant Messaging and
VoIP.
This package provides Python 3 libraries implementing Synapse homeserver.
%package postgresql
Summary: PostgreSQL Support For Reference Synapse Home Server
Provides: %{name}+postgres
Requires: %{name}
Requires: python3dist(matrix-synapse[postgres])
%description postgresql
Matrix is an ambitious new ecosystem for open federated Instant Messaging and
VoIP.
This package provides PostgreSQL database dupport for Synapse homeserver.
You must use Synapse with PostgreSQL database if your homeserver federates
with other homeservers.
%pyproject_extras_subpkg -n python3-matrix-synapse matrix-synapse-ldap3 postgres saml2 oidc systemd url-preview jwt cache-memory
%prep
%autosetup -n synapse-%{unmangled_version}%{?unmangled_release?:-r%{unmangled_release}} -p1
%cargo_prep
%generate_buildrequires
# Missing: sentry,opentracing,redis,cache-memory
%pyproject_buildrequires -x test,matrix-synapse-ldap3,postgres,saml2,oidc,systemd,url-preview,jwt
# Real Cargo.toml file is located in rust subdirectory
pushd rust >/dev/null 2>&1
%cargo_generate_buildrequires
popd >/dev/null 2>&1
%build
%pyproject_wheel
%install
%pyproject_install
chmod a-x %{buildroot}%{python3_sitearch}/synapse/_scripts/*.py
mkdir -p %{buildroot}%{_libexecdir}
mv %{buildroot}%{_bindir} %{buildroot}%{_libexecdir}/%{name}
%pyproject_save_files synapse
# For some strange reason, shared object files are not included in .whl file
ls -1 build/lib/synapse/*.so | sed 's|^build/lib/||' | while read file; do
if [ ! -f "%{buildroot}%{python3_sitearch}/$file" ]; then
install -m755 "build/lib/$file" "%{buildroot}%{python3_sitearch}/$file"
echo "%{python3_sitearch}/$file" >> %{pyproject_files}
fi
done
%{__cat} > %{buildroot}%{_libexecdir}/%{name}/synapse <<EOF
#!/bin/sh
exec %{__python3} -m synapse.app.homeserver --config-path=%{_sysconfdir}/synapse/homeserver.yaml
EOF
%{__chmod} a+x %{buildroot}%{_libexecdir}/%{name}/synapse
%{__rm} -rf %{buildroot}%{python3_sitelib}/synmark
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_sbindir}"
%{__ln_s} "%{_libexecdir}/%{name}/synctl" \
"%{_libexecdir}/%{name}/register_new_matrix_user" \
"%{_libexecdir}/%{name}/synapse" \
"${RPM_BUILD_ROOT}%{_sbindir}"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_sysconfdir}/synapse"
%{__install} -m 0644 contrib/systemd/log_config.yaml \
"${RPM_BUILD_ROOT}%{_sysconfdir}/synapse"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_unitdir}"
%{__install} -m 0644 %{SOURCE3} "${RPM_BUILD_ROOT}%{_unitdir}"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_unitdir}/synapse.service.d"
%{__install} -m 0644 %{SOURCE4} \
"${RPM_BUILD_ROOT}%{_unitdir}/synapse.service.d/postgresql.conf"
%{__install} -m 0644 contrib/systemd/override-hardened.conf \
"${RPM_BUILD_ROOT}%{_unitdir}/synapse.service.d/hardened.conf"
%{__sed} -i -e 's/matrix-synapse/synapse/g' \
"${RPM_BUILD_ROOT}%{_unitdir}/synapse.service.d/hardened.conf"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_prefix}/lib/tmpfiles.d"
%{__install} -m0644 %{SOURCE1} \
"${RPM_BUILD_ROOT}%{_prefix}/lib/tmpfiles.d/synapse.conf"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig"
%{__install} -m0644 %{SOURCE2} \
"${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/synapse"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_localstatedir}/run/synapse"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_localstatedir}/lib/synapse"
%{__mkdir_p} "${RPM_BUILD_ROOT}%{_localstatedir}/log/synapse"
%check
PYTHONPATH=%{buildroot}%{python3_sitearch}:. %{_bindir}/trial-3 tests
%pre
getent group synapse &>/dev/null || groupadd -r synapse
getent passwd synapse &>/dev/null || \
/usr/sbin/useradd -r -g synapse -s /sbin/nologin -c 'Matrix Synapse' \
-d %{_localstatedir}/lib/synapse synapse
%post
%systemd_post synapse.service
%preun
%systemd_preun synapse.service
%postun
%systemd_postun_with_restart synapse.service
%files
%defattr(-,root,root)
%doc *.rst
%license LICENSE
%attr(0710,root,synapse) %dir %{_sysconfdir}/synapse
%config %{_sysconfdir}/synapse/*
%config %{_sysconfdir}/sysconfig/synapse
%{_sbindir}/*
%{_libexecdir}/matrix-synapse
%{_unitdir}/synapse.service
%dir %{_unitdir}/synapse.service.d
%{_unitdir}/synapse.service.d/hardened.conf
%{_prefix}/lib/tmpfiles.d/synapse.conf
%attr(0710,synapse,synapse) %{_localstatedir}/run/synapse
%attr(0710,synapse,synapse) %{_localstatedir}/lib/synapse
%attr(0750,synapse,synapse) %{_localstatedir}/log/synapse
%files -n python3-matrix-synapse -f %{pyproject_files}
%defattr(-,root,root)
%doc *.rst
%license LICENSE
%files postgresql
%defattr(-,root,root)
%dir %{_unitdir}/synapse.service.d
%{_unitdir}/synapse.service.d/postgresql.conf