|
| 1 | +# Copyright 2022-2023 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +PYTHON_COMPAT=( python3_{9..11} ) |
| 7 | +DISTUTILS_USE_PEP517=poetry |
| 8 | + |
| 9 | +CRATES=" |
| 10 | + aho-corasick-0.7.19 |
| 11 | + anyhow-1.0.69 |
| 12 | + arc-swap-1.5.1 |
| 13 | + autocfg-1.1.0 |
| 14 | + bitflags-1.3.2 |
| 15 | + blake2-0.10.6 |
| 16 | + block-buffer-0.10.3 |
| 17 | + cfg-if-1.0.0 |
| 18 | + crypto-common-0.1.6 |
| 19 | + digest-0.10.5 |
| 20 | + generic-array-0.14.6 |
| 21 | + hex-0.4.3 |
| 22 | + indoc-1.0.7 |
| 23 | + itoa-1.0.4 |
| 24 | + lazy_static-1.4.0 |
| 25 | + libc-0.2.135 |
| 26 | + lock_api-0.4.9 |
| 27 | + log-0.4.17 |
| 28 | + memchr-2.5.0 |
| 29 | + memoffset-0.6.5 |
| 30 | + once_cell-1.15.0 |
| 31 | + parking_lot-0.12.1 |
| 32 | + parking_lot_core-0.9.3 |
| 33 | + proc-macro2-1.0.46 |
| 34 | + pyo3-0.17.3 |
| 35 | + pyo3-build-config-0.17.3 |
| 36 | + pyo3-ffi-0.17.3 |
| 37 | + pyo3-log-0.8.1 |
| 38 | + pyo3-macros-0.17.3 |
| 39 | + pyo3-macros-backend-0.17.3 |
| 40 | + pythonize-0.17.0 |
| 41 | + quote-1.0.21 |
| 42 | + redox_syscall-0.2.16 |
| 43 | + regex-1.7.1 |
| 44 | + regex-syntax-0.6.27 |
| 45 | + ryu-1.0.11 |
| 46 | + scopeguard-1.1.0 |
| 47 | + serde-1.0.152 |
| 48 | + serde_derive-1.0.152 |
| 49 | + serde_json-1.0.93 |
| 50 | + smallvec-1.10.0 |
| 51 | + subtle-2.4.1 |
| 52 | + syn-1.0.104 |
| 53 | + target-lexicon-0.12.4 |
| 54 | + typenum-1.15.0 |
| 55 | + unicode-ident-1.0.5 |
| 56 | + unindent-0.1.10 |
| 57 | + version_check-0.9.4 |
| 58 | + windows-sys-0.36.1 |
| 59 | + windows_aarch64_msvc-0.36.1 |
| 60 | + windows_i686_gnu-0.36.1 |
| 61 | + windows_i686_msvc-0.36.1 |
| 62 | + windows_x86_64_gnu-0.36.1 |
| 63 | + windows_x86_64_msvc-0.36.1 |
| 64 | +" |
| 65 | + |
| 66 | +inherit cargo distutils-r1 multiprocessing optfeature systemd |
| 67 | + |
| 68 | +MY_PV="${PV/_rc/rc}" |
| 69 | + |
| 70 | +DESCRIPTION="Reference implementation of Matrix homeserver" |
| 71 | +HOMEPAGE=" |
| 72 | + https://matrix.org/ |
| 73 | + https://github.com/matrix-org/synapse/ |
| 74 | +" |
| 75 | +SRC_URI=" |
| 76 | + https://github.com/matrix-org/${PN}/archive/v${MY_PV}.tar.gz |
| 77 | + -> ${P}.gh.tar.gz |
| 78 | + $(cargo_crate_uris) |
| 79 | +" |
| 80 | +S="${WORKDIR}/${PN}-${MY_PV}" |
| 81 | + |
| 82 | +LICENSE="Apache-2.0" |
| 83 | +# Dependent crate licenses |
| 84 | +LICENSE+=" |
| 85 | + Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD MIT Unicode-DFS-2016 |
| 86 | +" |
| 87 | +SLOT="0" |
| 88 | +KEYWORDS="~amd64 ~ppc64" |
| 89 | +IUSE="postgres systemd test" |
| 90 | +RESTRICT="!test? ( test )" |
| 91 | + |
| 92 | +DEPEND=" |
| 93 | + acct-user/synapse |
| 94 | + acct-group/synapse |
| 95 | +" |
| 96 | +RDEPEND="${DEPEND} |
| 97 | + dev-python/attrs[${PYTHON_USEDEP}] |
| 98 | + dev-python/bcrypt[${PYTHON_USEDEP}] |
| 99 | + dev-python/bleach[${PYTHON_USEDEP}] |
| 100 | + dev-python/canonicaljson[${PYTHON_USEDEP}] |
| 101 | + dev-python/cryptography[${PYTHON_USEDEP}] |
| 102 | + dev-python/frozendict[${PYTHON_USEDEP}] |
| 103 | + dev-python/ijson[${PYTHON_USEDEP}] |
| 104 | + >=dev-python/jinja-3.0[${PYTHON_USEDEP}] |
| 105 | + dev-python/jsonschema[${PYTHON_USEDEP}] |
| 106 | + >=dev-python/matrix-common-1.3.0[${PYTHON_USEDEP}] |
| 107 | + dev-python/msgpack[${PYTHON_USEDEP}] |
| 108 | + dev-python/netaddr[${PYTHON_USEDEP}] |
| 109 | + dev-python/packaging[${PYTHON_USEDEP}] |
| 110 | + dev-python/phonenumbers[${PYTHON_USEDEP}] |
| 111 | + dev-python/pillow[${PYTHON_USEDEP},webp] |
| 112 | + dev-python/prometheus_client[${PYTHON_USEDEP}] |
| 113 | + dev-python/pyasn1-modules[${PYTHON_USEDEP}] |
| 114 | + dev-python/pyasn1[${PYTHON_USEDEP}] |
| 115 | + dev-python/pydantic[${PYTHON_USEDEP}] |
| 116 | + dev-python/pymacaroons[${PYTHON_USEDEP}] |
| 117 | + dev-python/pyopenssl[${PYTHON_USEDEP}] |
| 118 | + dev-python/pyyaml[${PYTHON_USEDEP}] |
| 119 | + dev-python/service_identity[${PYTHON_USEDEP}] |
| 120 | + dev-python/signedjson[${PYTHON_USEDEP}] |
| 121 | + dev-python/sortedcontainers[${PYTHON_USEDEP}] |
| 122 | + dev-python/treq[${PYTHON_USEDEP}] |
| 123 | + dev-python/twisted[${PYTHON_USEDEP}] |
| 124 | + dev-python/typing-extensions[${PYTHON_USEDEP}] |
| 125 | + dev-python/unpaddedbase64[${PYTHON_USEDEP}] |
| 126 | + postgres? ( dev-python/psycopg:2[${PYTHON_USEDEP}] ) |
| 127 | + systemd? ( dev-python/python-systemd[${PYTHON_USEDEP}] ) |
| 128 | +" |
| 129 | +BDEPEND=" |
| 130 | + dev-python/setuptools-rust[${PYTHON_USEDEP}] |
| 131 | + test? ( |
| 132 | + dev-python/idna[${PYTHON_USEDEP}] |
| 133 | + dev-python/parameterized[${PYTHON_USEDEP}] |
| 134 | + postgres? ( dev-db/postgresql[server] ) |
| 135 | + ) |
| 136 | +" |
| 137 | + |
| 138 | +PATCHES=( |
| 139 | + "${FILESDIR}/${P}-frozendict-version.patch" |
| 140 | +) |
| 141 | + |
| 142 | +# Rust extension |
| 143 | +QA_FLAGS_IGNORED="usr/lib/python3.*/site-packages/synapse/synapse_rust.abi3.so" |
| 144 | + |
| 145 | +src_test() { |
| 146 | + if use postgres; then |
| 147 | + initdb --pgdata="${T}/pgsql" || die |
| 148 | + pg_ctl --wait --pgdata="${T}/pgsql" start \ |
| 149 | + --options="-h '' -k '${T}'" || die |
| 150 | + createdb --host="${T}" synapse_test || die |
| 151 | + |
| 152 | + # See https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#running-tests-under-postgresql |
| 153 | + local -x SYNAPSE_POSTGRES=1 |
| 154 | + local -x SYNAPSE_POSTGRES_HOST="${T}" |
| 155 | + fi |
| 156 | + |
| 157 | + # This move is necessary otherwise python is not able to locate |
| 158 | + # synapse_rust.abi3.so. |
| 159 | + mv synapse{,.hidden} || die |
| 160 | + |
| 161 | + distutils-r1_src_test |
| 162 | + |
| 163 | + if use postgres; then |
| 164 | + pg_ctl --wait --pgdata="${T}/pgsql" stop || die |
| 165 | + fi |
| 166 | +} |
| 167 | + |
| 168 | +python_test() { |
| 169 | + "${EPYTHON}" -m twisted.trial -j "$(makeopts_jobs)" tests || die "Tests failed with ${EPYTHON}" |
| 170 | +} |
| 171 | + |
| 172 | +python_install() { |
| 173 | + distutils-r1_python_install |
| 174 | + keepdir /var/{lib,log}/synapse /etc/synapse |
| 175 | + fowners synapse:synapse /var/{lib,log}/synapse /etc/synapse |
| 176 | + fperms 0750 /var/{lib,log}/synapse /etc/synapse |
| 177 | + newinitd "${FILESDIR}/${PN}.initd" "${PN}" |
| 178 | + systemd_dounit "${FILESDIR}/synapse.service" |
| 179 | +} |
| 180 | + |
| 181 | +pkg_postinst() { |
| 182 | + optfeature "Improve user search for international display names" dev-python/pyicu |
| 183 | + optfeature "VoIP relaying on your homeserver with turn" net-im/coturn |
| 184 | + |
| 185 | + if [[ -z "${REPLACING_VERSIONS}" ]]; then |
| 186 | + einfo |
| 187 | + elog "In order to generate initial configuration run:" |
| 188 | + elog "sudo -u synapse synapse_homeserver \\" |
| 189 | + elog " --server-name matrix.domain.tld \\" |
| 190 | + elog " --config-path /etc/synapse/homeserver.yaml \\" |
| 191 | + elog " --generate-config \\" |
| 192 | + elog " --data-directory /var/lib/synapse \\" |
| 193 | + elog " --report-stats=no" |
| 194 | + einfo |
| 195 | + else |
| 196 | + einfo |
| 197 | + einfo "Please refer to upgrade notes if any special steps are required" |
| 198 | + einfo "to upgrade from the version you currently have installed:" |
| 199 | + einfo |
| 200 | + einfo " https://github.com/matrix-org/synapse/blob/develop/docs/upgrade.md" |
| 201 | + einfo |
| 202 | + fi |
| 203 | +} |
0 commit comments