File PKGBUILD of Package conduit

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

pkgname=conduit
pkgver=0.10.9
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=('c224102e3c71b19556d9d2b4854b26bb9378756b1585f24096a49a154563d5b92aa276b090c8cb88792bbdd88ca6dda45374ca54f8b2e6ac836699e7fc82af3c'
        'd5e071601feb8d74273fd5727dd84755b9234e9849b23ee37ede796ea04c77abd7f5c17fe21abe0506dff980d4f8338672a0b923247af39054360f2ceea3026d'
        '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