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

EAPI=8

inherit go-module systemd

DESCRIPTION="A forwarder from WhatsApp to Telegram"
HOMEPAGE="https://github.com/akshettrj/watgbridge"
SRC_URI="https://github.com/akshettrj/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		https://git.millerson.name/alex/gentoo-artifacts/releases/download/${P}-vendor/${P}-vendor.tar.xz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND=""

src_prepare() {
	sed -i "s@^ExecStart=.*@ExecStart=/usr/bin/${PN}@g" watgbridge.service.sample || die
	sed -i "s@^User=.*@User=nobody@g" watgbridge.service.sample
}

src_compile() {
	ego build || die
}

src_install() {
	dobin ${PN}

	systemd_newunit watgbridge.service.sample watgbridge.service

	insinto /etc
	newins sample_config.yaml ${PN}.yaml

	default
}
