# Maintainer: Mumi Jim <echo "=02bj5yav9Gb0V3bA1Waq9VatVXb" | rev | base64 -d>
#Thanks Integral and Klaus
#only for x86_64

pkgname="oniux-git"
_appname="oniux"
pkgver=0.12.0.r4.g5d76788
pkgrel=1
pkgdesc='Written in Rust, this program uses the naming mechanism of the Linux kernel to encrypt traffic'
url='https://gitlab.torproject.org/tpo/core/oniux'
license=('MIT OR Apache-2.0')
options=('!lto')
makedepends=('git' 'cargo')
arch=('x86_64')
provides=('oniux')
conflicts=('oniux')
source=("git+$url.git")
sha512sums=('SKIP')

pkgver() {
	cd "${srcdir}/${_appname}"
	git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
	cd "${_appname}"
	export RUSTUP_TOOLCHAIN=stable
	# cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
	cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
	cd "${_appname}"
	export RUSTUP_TOOLCHAIN=stable
 	export CARGO_TARGET_DIR=target
	#Build oniux and all features
	cargo build --frozen --release --all-features
}

check() {
	cd "${_appname}"
	export RUSTUP_TOOLCHAIN=stable
	cargo test --frozen --all-features
}

package() {
	cd "${_appname}"
	#install it
	install -Dm0755 -t "${pkgdir}/usr/bin" "target/"${_target}"/release/${_appname}"
	install -Dm644 LICENSE-MIT "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT"
	install -Dm644 LICENSE-APACHE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-APACHE"
}
