Apocrypha

OpenTabletDriver-0.6.7guru

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

EAPI=8

DOTNET_PKG_COMPAT=8.0
NUGETS="
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
"

inherit desktop dotnet-pkg linux-info systemd udev xdg

DESCRIPTION="A cross-platform open-source tablet driver"
HOMEPAGE="https://opentabletdriver.net/"
SRC_URI="
	https://github.com/OpenTabletDriver/OpenTabletDriver/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${NUGET_URIS}
"

LICENSE="LGPL-3+"
# nuget licenses
LICENSE+=" Apache-2.0 ISC MIT"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
	dev-libs/libevdev
	virtual/udev
	x11-libs/gtk+:3
	x11-libs/libX11
	x11-libs/libXrandr
	x11-libs/libnotify
	!x11-drivers/OpenTabletDriver-bin
"
BDEPEND="app-misc/jq"

CONFIG_CHECK="~INPUT_UINPUT"
DOTNET_PKG_PROJECTS=(
	"${S}/OpenTabletDriver.Console/OpenTabletDriver.Console.csproj"
	"${S}/OpenTabletDriver.Daemon/OpenTabletDriver.Daemon.csproj"
	"${S}/OpenTabletDriver.UX.Gtk/OpenTabletDriver.UX.Gtk.csproj"
)

pkg_setup() {
	linux-info_pkg_setup
	dotnet-pkg_pkg_setup
}

src_prepare() {
	# Build doesn't need the solution file but eclass tries to use it.
	rm -f OpenTabletDriver.sln || die
	dotnet-pkg_src_prepare
}

src_configure() {
	dotnet-pkg_src_configure

	# These projects are only used at build time, should not be installed.
	dotnet-pkg-base_restore OpenTabletDriver.Tests
}

src_compile() {
	dotnet-pkg_src_compile
	./generate-rules.sh > 70-opentabletdriver.rules || die
}

src_install() {
	dotnet-pkg_src_install

	dotnet-pkg-base_dolauncher "/usr/share/${P}/${PN}.Console" otd
	dotnet-pkg-base_dolauncher "/usr/share/${P}/${PN}.Daemon" otd-daemon
	dotnet-pkg-base_dolauncher "/usr/share/${P}/${PN}.UX.Gtk" otd-gui

	doicon OpenTabletDriver.UX/Assets/otd.png
	doman docs/manpages/opentabletdriver.8
	make_desktop_entry otd-gui OpenTabletDriver otd Settings
	udev_dorules 70-opentabletdriver.rules

	cd "${S}/eng/bash/Generic/usr" || die
	insinto /lib/modprobe.d
	doins lib/modprobe.d/99-opentabletdriver.conf
	insinto /usr/lib/modules-load.d
	doins lib/modules-load.d/opentabletdriver.conf
	insinto /usr/share/libinput
	doins share/libinput/30-vendor-opentabletdriver.quirks
	systemd_douserunit lib/systemd/user/opentabletdriver.service
}

src_test() {
	dotnet-pkg-base_test OpenTabletDriver.Tests
}

pkg_postinst() {
	udev_reload
	xdg_pkg_postinst

	if [[ -z ${REPLACING_VERSIONS} ]]; then
		elog "Please replug your tablet before attempting to use the driver"
	fi
}

pkg_postrm() {
	udev_reload
	xdg_pkg_postrm
}