# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

RUST_MIN_VER="1.71.1"

CRATES="
"

inherit cargo

DESCRIPTION="Gnirehtet provides reverse tethering for Android"
HOMEPAGE="https://github.com/Genymobile/gnirehtet"
SRC_URI="
	https://github.com/Genymobile/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/ingenarel/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
"
S="${WORKDIR}/${P}/relay-rust"
LICENSE="Apache-2.0"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD MIT Unicode-DFS-2016"
SLOT="0"
KEYWORDS="~amd64"
# needs adb to run
RDEPEND="dev-util/android-tools"
DOCS=(
	"${WORKDIR}/${P}/README.md"
)

src_install(){
	dobin "${S}/$(cargo_target_dir)/${PN}"
	einstalldocs
	exeinto /etc/user/init.d || die
	newexe "${FILESDIR}/${PN}.user.initd" "${PN}" || die
}

pkg_postinst() {
	elog "After starting the service, and connecting your phone via USB,"
	elog "do 'gnirehtet install' to install the APK on your Android device."
	elog "'gnirehtet start' to start the reverse tethering,"
	elog "and 'gnirehtet stop' to stop the reverse tethering."
}