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

EAPI=8

inherit go-module systemd udev

DESCRIPTION="HTTP reverse proxy, backed by IPP-over-USB connection to device"
HOMEPAGE="https://github.com/OpenPrinting/ipp-usb"
SRC_URI="https://github.com/OpenPrinting/ipp-usb/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD-2"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="
	net-dns/avahi
	virtual/libusb:1"
RDEPEND="${DEPEND}"

PATCHES="
	${FILESDIR}/${PN}-systemd.patch
"

src_compile() {
	ego build -tags nethttpomithttp2 -mod=vendor
}

src_install() {
	dosbin ${PN}

	# install udev rules and systemd service
	udev_dorules systemd-udev/*.rules
	systemd_dounit systemd-udev/*.service

	# install conf
	insinto /etc/ipp-usb
	doins ipp-usb.conf
	# install man page
	doman ipp-usb.8
	# install quirks
	insinto /usr/share/ipp-usb/quirks
	doins ipp-usb-quirks/*
}

pkg_postinst() {
	udev_reload
}

pkg_postrm() {
	udev_reload
}