File PKGBUILD of Package conduit

# Maintainer: Oleksandr Natalenko <oleksandr@natalenko.name>

pkgname=conduit
pkgver=0.10.11
pkgrel=1
pkgdesc="Simple, fast and reliable chat server powered by Matrix"
arch=(x86_64)
url=https://conduit.rs
license=(Apache-2.0)
makedepends=(cargo clang)

# https://github.com/briansmith/ring/issues/1444
options=(!lto)

backup=(etc/conduit/conduit.toml)
source=(https://gitlab.com/famedly/conduit/-/archive/v${pkgver}/conduit-v${pkgver}.tar.gz
		vendor.tar.zst
		conduit.service)
b2sums=('a96c34625148500fc1842d8919f44dc754d9f98a7388709f1475b2e126844f243c9b49378fb18f3d1b71f18f41c21c0f5368053ea680cf9fb05a11b4cec87fbd'
        '8168b5b4f8f10a731fff0347847ddefc825f0368a083049a996b4222577a08d5ca43583dc827015aa3d500392c33b85635eae9fe5697b69242ab4e884ade2f59'
        '7563ed58ce7de7bd137e9ee47781c38f6bcc8666ef99a5c539a2af8af8edcb7fc17d224f0fd750014d5d2a555531b4e7687afd02f2097c2797f618fe5378abec')

prepare() {
	cd ${pkgname}-v${pkgver}

	ln -sf ../vendor vendor

	cat >>.cargo/config.toml << EOF
[source.crates-io]
replace-with = "vendored-sources"

[source."git+https://github.com/ruma/ruma.git"]
git = "https://github.com/ruma/ruma.git"
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF
}

build() {
	cd ${pkgname}-v${pkgver}

	# https://github.com/rust-rocksdb/rust-rocksdb/issues/991
	export CXXFLAGS="${CXXFLAGS} -include cstdint"

	cargo build --frozen --release --target-dir target
}

package() {
	cd ${pkgname}-v${pkgver}

	install -Dt "${pkgdir}"/usr/bin -m0755 target/release/conduit
	install -Dm0644 conduit-example.toml "${pkgdir}"/etc/conduit/conduit.toml
	sed -i 's|database_path = "/var/lib/matrix-conduit/"|database_path = "/var/lib/conduit/"|g' "${pkgdir}"/etc/conduit/conduit.toml
	install -Dt "${pkgdir}"/usr/lib/systemd/system -m0644 ../conduit.service
}
openSUSE Build Service is sponsored by