# 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;92e5e74063bf2a3b10414bcc8a0d68b235644280;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;fe4aebeeaae435af60087ddd56b573a2e0be671d;event-listener-%commit%' [hyper-util]='https://github.com/matrix-construct/hyper-util;a3f59c4e51af19570a9f92839ecfe0ad6482e9e5;hyper-util-%commit%' [jevmalloc-sys]='https://github.com/matrix-construct/jevmalloc;93795449913f65ab533b7fa482333eef63fc3ae0;jevmalloc-%commit%/jevmalloc-sys' [jevmalloc]='https://github.com/matrix-construct/jevmalloc;93795449913f65ab533b7fa482333eef63fc3ae0;jevmalloc-%commit%/jevmalloc' [lber]='https://github.com/matrix-construct/ldap3;fdfbba2bf916b53e5f73cdb1a495ebb649978079;ldap3-%commit%/lber' [ldap3]='https://github.com/matrix-construct/ldap3;fdfbba2bf916b53e5f73cdb1a495ebb649978079;ldap3-%commit%' [resolv-conf]='https://github.com/matrix-construct/resolv-conf;200e958941d522a70c5877e3d846f55b5586c68d;resolv-conf-%commit%' [ruma-appservice-api]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-appservice-api' [ruma-client-api]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-client-api' [ruma-common]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-common' [ruma-events]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-events' [ruma-federation-api]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-federation-api' [ruma-identifiers-validation]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-identifiers-validation' [ruma-identity-service-api]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-identity-service-api' [ruma-macros]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-macros' [ruma-push-gateway-api]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-push-gateway-api' [ruma-signatures]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma-signatures' [ruma]='https://github.com/matrix-construct/ruma;0b7aad2371a7b51a8226d819b544c1ca9edeb696;ruma-%commit%/crates/ruma' [rust-librocksdb-sys]='https://github.com/matrix-construct/rust-rocksdb;c11395350bc1f2090a0152f2d15c8c5847821eba;rust-rocksdb-%commit%/librocksdb-sys' [rust-rocksdb]='https://github.com/matrix-construct/rust-rocksdb;c11395350bc1f2090a0152f2d15c8c5847821eba;rust-rocksdb-%commit%' [rustyline-async]='https://github.com/matrix-construct/rustyline-async;ba743cae940659e95d7b8604bbd6fdd755171c8c;rustyline-async-%commit%' [synapse-admin-api]='https://github.com/matrix-construct/synapse-admin-api;d8e73952506a09f280a7c253003fafc131206612;synapse-admin-api-%commit%' ) LLVM_COMPAT=( 21 ) RUST_MIN_VER="1.94.0" inherit cargo llvm-r2 linux-info DESCRIPTION="High Performance Matrix Homeserver in Rust!" HOMEPAGE=" https://tuwunel.chat https://github.com/matrix-construct/tuwunel " ROCKSDB_GIT_COMMIT=9a3a213b55df0b11408102c899a940675c0d90e4 RUST_ROCKSB_GIT_COMMIT=c11395350bc1f2090a0152f2d15c8c5847821eba 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+=" 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=" 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() { local patched_crates=( async-channel rustyline-async resolv-conf hyper-util core_affinity event-listener ) for patched_crate in ${patched_crates[@]}; do local commit_hash=$( echo ${GIT_CRATES[${patched_crate}]} \ | cut --delimiter=';' --fields=2 ) local directory_prefix=$( echo ${GIT_CRATES[${patched_crate}]} \ | cut --delimiter=';' --fields=3 \ | cut --delimiter='%' --fields=1 ) echo "" >> "${ECARGO_HOME}/config.toml" || die echo "[patch.crates-io.${patched_crate}]" >> "${ECARGO_HOME}/config.toml" || die echo "path = \"${WORKDIR}/${directory_prefix}${commit_hash}\"" >> "${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-r1 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 }