# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=lighthouse
pkgver=7.0.1
pkgrel=0
pkgdesc="Ethereum 2.0 Client"
url="https://lighthouse.sigmaprime.io/"
arch="x86_64 aarch64"  # limited by upstream
license="Apache-2.0"
makedepends="
	cargo
	cargo-auditable
	clang15-dev
	cmake
	openssl-dev
	protobuf-dev
	zlib-dev
	"
options="net !check" # disable check as it takes too long
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/sigp/lighthouse/archive/v$pkgver/lighthouse-$pkgver.tar.gz"

# secfixes:
#   2.2.0-r0:
#     - CVE-2022-0778

export OPENSSL_NO_VENDOR=true
export RUSTFLAGS="$RUSTFLAGS -L /usr/lib/"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build \
		--release --frozen \
		--package lighthouse \
		--features "portable"
}

check() {
	cargo test \
		--release --frozen \
		--workspace \
			--exclude ef_tests \
			--exclude eth1 \
			--exclude genesis
}

package() {
	install -D -m755 "target/release/lighthouse" "$pkgdir/usr/bin/lighthouse"

	install -Dm 644 -t "$pkgdir/usr/share/doc/lighthouse" README.md
}

sha512sums="
54448084aa1449b5585a150b608ac4098f1a243dfacb15c30ba42fb23dd2fa3b99f67ccf2fc4357595643f5fc0dc72e11325c2305000b1b310a80e9aa08cfcd5  lighthouse-7.0.1.tar.gz
"
