# Template file for 'mullvadvpn'
pkgname=mullvadvpn
version=2026.6
revision=1
build_style=cargo
build_helper=qemu
make_build_args="
 -p mullvad-daemon --bin mullvad-daemon
 -p mullvad-cli --bin mullvad
 -p mullvad-setup --bin mullvad-setup
 -p mullvad-problem-report --bin mullvad-problem-report
 -p mullvad-exclude --bin mullvad-exclude
 -p mullvad-api --bin relay_list"
hostmakedepends="pkgconf protobuf protobuf-devel git"
# drop git after mullvadvpn-app/pull/10845 is released
makedepends="dbus-devel libnftnl-devel libmnl-devel"
# drop dbus after mullvadvpn-app/pull/11537
short_desc="Mullvad VPN client app (cli only)"
maintainer="dkwo <npiazza@disroot.org>"
license="GPL-3.0-or-later"
homepage="https://mullvad.net/"
changelog="https://raw.githubusercontent.com/mullvad/mullvadvpn-app/refs/heads/main/CHANGELOG.md"
distfiles="https://github.com/mullvad/mullvadvpn-app/archive/refs/tags/${version}.tar.gz"
checksum=9ddbc4596c0a5b2729449c3da3b01ecb6c19ae9ec1c6b841ef26d84e38b851e0

do_install() {
	for _bin in mullvad-daemon mullvad mullvad-problem-report mullvad-setup mullvad-exclude; do
		vbin target/${RUST_TARGET}/release/${_bin}
	done
}

post_install() {
	vtargetrun target/${RUST_TARGET}/release/relay_list > dist-assets/relays.json
	vinstall dist-assets/relays.json 644 usr/share/mullvad

	compdir=$(mktemp -d)
	for _shell in bash zsh fish; do
		vtargetrun ${DESTDIR}/usr/bin/mullvad shell-completions ${_shell} ${compdir}
	done

	vcompletion ${compdir}/mullvad.bash bash mullvad
	vcompletion ${compdir}/_mullvad zsh mullvad
	vcompletion ${compdir}/mullvad.fish fish mullvad

	vsv mullvad
}
