blob: 13136843ef6ec9c2a3e52522a6083031d89baca5 (
plain)
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
|
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Autogenerated by pycargoebuild 0.15.1
EAPI=8
CRATES=""
declare -A GIT_CRATES=(
[async-channel]='https://github.com/matrix-construct/async-channel;debb93f14a20fa7c1989042c2f07f53654d75908;async-channel-%commit%'
[axum-server-dual-protocol]='https://github.com/matrix-construct/axum-server-dual-protocol;76c782fa6f129f83ffdca59e903093e798d4a82f;axum-server-dual-protocol-%commit%'
[core_affinity]='https://github.com/matrix-construct/core_affinity_rs;ff148c2985cbaff3e6e953d45cda4d7696f38d75;core_affinity_rs-%commit%'
[event-listener]='https://github.com/matrix-construct/event-listener;f2a3389999cbcb2bdda52dbf5493635a027e7d94;event-listener-%commit%'
[hyper-util]='https://github.com/matrix-construct/hyper-util;0510e3a3cba7aedd504b4ee0d69fbf41e76a524f;hyper-util-%commit%'
[jevmalloc-sys]='https://github.com/matrix-construct/jevmalloc;0f6de6abd9d9731a29c2032f54ee5bd40628d849;jevmalloc-%commit%/jevmalloc-sys'
[jevmalloc]='https://github.com/matrix-construct/jevmalloc;0f6de6abd9d9731a29c2032f54ee5bd40628d849;jevmalloc-%commit%/jevmalloc'
[resolv-conf]='https://github.com/matrix-construct/resolv-conf;ab5c3e44016bc76b8798ec837a5a9cf9d88bf233;resolv-conf-%commit%'
[ruma-appservice-api]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-appservice-api'
[ruma-client-api]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-client-api'
[ruma-common]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-common'
[ruma-events]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-events'
[ruma-federation-api]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-federation-api'
[ruma-identifiers-validation]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-identifiers-validation'
[ruma-identity-service-api]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-identity-service-api'
[ruma-macros]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-macros'
[ruma-push-gateway-api]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-push-gateway-api'
[ruma-signatures]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma-signatures'
[ruma]='https://github.com/matrix-construct/ruma;fc0d9808182aa013a8f0f1b8f0e9963a89acdcfc;ruma-%commit%/crates/ruma'
[rust-librocksdb-sys]='https://github.com/matrix-construct/rust-rocksdb;24dad4d15b47d932b9f060c1b9520c0d1e6b1fe5;rust-rocksdb-%commit%/librocksdb-sys'
[rust-rocksdb]='https://github.com/matrix-construct/rust-rocksdb;24dad4d15b47d932b9f060c1b9520c0d1e6b1fe5;rust-rocksdb-%commit%'
[rustls-platform-verifier-android]='https://github.com/matrix-construct/rustls-platform-verifier;c68093b6ac7d739e6b3aefb809c646a5e0210306;rustls-platform-verifier-%commit%/android-release-support'
[rustls-platform-verifier]='https://github.com/matrix-construct/rustls-platform-verifier;c68093b6ac7d739e6b3aefb809c646a5e0210306;rustls-platform-verifier-%commit%/rustls-platform-verifier'
[rustyline-async]='https://github.com/matrix-construct/rustyline-async;879968ba99c2558ae234fd67a057b7ea6f761fd3;rustyline-async-%commit%'
[synapse-admin-api]='https://github.com/matrix-construct/synapse-admin-api;9e509d6c68274c7852034d0df913c1874329a691;synapse-admin-api-%commit%'
)
LLVM_COMPAT=( 21 )
# grep rust-version Cargo.toml
RUST_MIN_VER="1.95.0"
inherit cargo llvm-r2 linux-info
DESCRIPTION="High Performance Matrix Homeserver in Rust!"
HOMEPAGE="
https://tuwunel.chat
https://github.com/matrix-construct/tuwunel
"
# Copy this from the GIT_CRATES[rust-rocksdb] entry.
RUST_ROCKSB_GIT_COMMIT=24dad4d15b47d932b9f060c1b9520c0d1e6b1fe5
# cat flake.lock | jq '.nodes.rocksdb.locked.rev'
ROCKSDB_GIT_COMMIT=d8a89161c6a53e79d61694289d2b78be36e6ca12
SRC_URI="
${CARGO_CRATE_URIS}
https://github.com/matrix-construct/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
https://github.com/gentoo-crate-dist/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
https://github.com/matrix-construct/rocksdb/archive/${ROCKSDB_GIT_COMMIT}.tar.gz
-> rocksdb-${ROCKSDB_GIT_COMMIT}.tar.gz
"
# The repository's root directory is a "workspace root".
# It's easier and less error prone to work in src/main.
S="${WORKDIR}/${P}/src/main"
LICENSE="Apache-2.0"
# Dependent crate licenses
LICENSE+="
0BSD Apache-2.0 BSD-2 BSD BlueOak-1.0.0 CDLA-Permissive-2.0 ISC MIT
MPL-2.0 Unicode-3.0 Unlicense ZLIB
"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE="jemalloc gzip zstd lz4 bzip2 systemd brotli ldap io-uring"
# bzip2 looks difficult to un-bundle:
# https://wiki.gentoo.org/wiki/Project:Rust/sys_crates#bzip2-sys
# lz4 cannot be un-bundled:
# https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds#Unbundling_C_libraries
COMMON_DEPEND="
io-uring? ( sys-libs/liburing:= )
jemalloc? ( dev-libs/jemalloc:= )
app-arch/snappy:=
zstd? (
app-arch/zstd:=
)
"
RDEPEND="
${COMMON_DEPEND}
acct-user/tuwunel
app-misc/ca-certificates
"
# clang needed for bindgen
DEPEND="
${COMMON_DEPEND}
$(llvm_gen_dep '
llvm-core/clang:${LLVM_SLOT}
llvm-core/llvm:${LLVM_SLOT}
')
"
# Required for pkg-config crate:
# https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds#pkg-config_crate
BDEPEND="virtual/pkgconfig"
# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"
DOCS=( ../../{README,RELEASE,CONTRIBUTING,CODE_OF_CONDUCT}.md )
pkg_setup() {
CONFIG_CHECK=""
# IO-Uring requires kernel support.
if use io-uring; then
CONFIG_CHECK+=" ~IO_URING"
ERROR_IO_URING="${P} requires io-uring in-kernel support."
fi
if [[ -n ${CONFIG_CHECK} ]]; then
linux-info_pkg_setup
fi
llvm-r2_pkg_setup
rust_pkg_setup
}
src_prepare() {
# See https://bugs.gentoo.org/977089
# Get a list of patched crates from the project's Cargo.toml:
patched_crates=$(
grep '^\[patch\.' "${WORKDIR}"/"${P}"/Cargo.toml \
| cut --delimiter='.' --fields=3 \
| tr --delete ']'
)
for patched_crate in ${patched_crates}; do
# Retrieve the crate's GIT hash from the GIT_CRATES array:
local commit_hash=$(
echo ${GIT_CRATES[${patched_crate}]} \
| cut --delimiter=';' --fields=2
)
# Retrieve the crate's path from the GIT_CRATES array, replacing the
# '%commit%' placeholder with the GIT hash retrieved above:
local crate_path=$(
echo ${GIT_CRATES[${patched_crate}]} \
| cut --delimiter=';' --fields=3 \
| sed --expression="s/%commit%/${commit_hash}/g"
)
# Add an entry to config.toml, configuring the correct location for
# retrieving the patched crate.
echo "" >> "${ECARGO_HOME}/config.toml" || die
echo "[patch.crates-io.${patched_crate}]" >> "${ECARGO_HOME}/config.toml" || die
echo "path = \"${WORKDIR}/${crate_path}\"" >> "${ECARGO_HOME}/config.toml" || die
done
local rocksdb_path="${WORKDIR}"/rust-rocksdb-${RUST_ROCKSB_GIT_COMMIT}/librocksdb-sys/rocksdb
rmdir "${rocksdb_path}" || die
mv "${WORKDIR}"/rocksdb-${ROCKSDB_GIT_COMMIT} "${rocksdb_path}" || die
eapply_user
}
src_configure() {
# Required for pkg-config crate:
# https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds#pkg-config_crate
export PKG_CONFIG_ALLOW_CROSS=1
# Required to un-bundle jemalloc:
# https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds#Common_-sys_crates
export JEMALLOC_OVERRIDE="${ESYSROOT}/usr/$(get_libdir)/libjemalloc.so"
if use zstd; then
# Required to un-bundle zstd:
# https://wiki.gentoo.org/wiki/Project:Rust/sys_crates#zstd-sys
export ZSTD_SYS_USE_PKG_CONFIG=1
fi
# The project maintains their own fork of rocksdb. Because of that,
# unbundling it is not an option at this point.
local myfeatures=(
element_hacks
media_thumbnail
release_max_log_level
url_preview
$(usev io-uring io_uring)
$(usev systemd)
$(usev jemalloc)
$(usev ldap)
$(usev jemalloc jemalloc_conf)
$(usev zstd zstd_compression)
$(usev lz4 lz4_compression)
$(usev gzip gzip_compression)
$(usev bzip2 bzip2_compression)
$(usev brotli brotli_compression)
)
rust_pkg_setup
cargo_src_configure --no-default-features --offline
}
src_install() {
cargo_src_install
keepdir /var/lib/tuwunel
fowners tuwunel:tuwunel /var/lib/tuwunel
fperms 750 /var/lib/tuwunel
keepdir /var/log/tuwunel
fowners tuwunel:tuwunel /var/log/tuwunel
fperms 750 /var/log/tuwunel
insinto /etc/tuwunel
newins "${WORKDIR}"/"${P}"/tuwunel-example.toml tuwunel.toml
insinto /etc/logrotate.d
newins "${FILESDIR}"/tuwunel.logrotate-r2 tuwunel
newinitd "${FILESDIR}"/tuwunel.init-r1 tuwunel
newconfd "${FILESDIR}"/tuwunel.conf-r1 tuwunel
# TODO: Add systemd service.
}
src_test() {
mkdir -p "${T}/var/lib/tuwunel" || die
TUWUNEL_DATABASE_PATH="${T}/var/lib/tuwunel" cargo_src_test
}
|