# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# File was automatically generated by automatic-ebuild-maker
# https://github.com/BlueManCZ/automatic-ebuild-maker

EAPI=7
inherit unpacker xdg

DESCRIPTION="A simple, clean and cross-platform music player, written with Node.js, Electron and React.js."
HOMEPAGE="https://github.com/martpie/museeks#readme"
SRC_URI="amd64? ( https://github.com/martpie/museeks/releases/download/${PV}/museeks-amd64.deb -> ${P}-amd64.deb )
	x86? ( https://github.com/martpie/museeks/releases/download/${PV}/museeks-i386.deb -> ${P}-i386.deb )"

LICENSE="MIT"
SLOT="0"
KEYWORDS="-* ~amd64 ~x86"
RESTRICT="bindist mirror"
IUSE="doc system-mesa"

RDEPEND="dev-libs/glib:2
	sys-apps/dbus
	system-mesa? ( media-libs/mesa )"

QA_PREBUILT="*"

S=${WORKDIR}

src_prepare() {
	default

	if use doc ; then
		unpack "usr/share/doc/museeks/changelog.gz" || die "unpack failed"
		rm -f "usr/share/doc/museeks/changelog.gz" || die "rm failed"
		mv "changelog" "usr/share/doc/museeks" || die "mv failed"
	fi

	if use system-mesa ; then
		rm -fr "opt/Museeks/swiftshader" || die "rm failed"
		rm -f  "opt/Museeks/libEGL.so" || die "rm failed"
		rm -f  "opt/Museeks/libGLESv2.so" || die "rm failed"
		rm -f  "opt/Museeks/libvk_swiftshader.so" || die "rm failed"
		rm -f  "opt/Museeks/libvulkan.so.1" || die "rm failed"
		rm -f  "opt/Museeks/vk_swiftshader_icd.json" || die "rm failed"
	fi
}

src_install() {
	cp -a . "${ED}" || die "cp failed"

	rm -r "${ED}/usr/share/doc/museeks" || die "rm failed"

	if use doc ; then
		dodoc -r "usr/share/doc/museeks/"* || die "dodoc failed"
	fi

	dosym "/opt/Museeks/museeks" "/usr/bin/museeks" || die "dosym failed"
}