From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D70AA15808B for ; Thu, 14 Apr 2022 13:31:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 079AEE0896; Thu, 14 Apr 2022 13:31:44 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 99109E0896 for ; Thu, 14 Apr 2022 13:31:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B22C9341F1E for ; Thu, 14 Apr 2022 13:31:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EECB13A9 for ; Thu, 14 Apr 2022 13:31:37 +0000 (UTC) From: "Andrew Ammerlaan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Ammerlaan" Message-ID: <1649928390.ce3b957642e8aff38a6c923b8a5bc79ef9f20729.andrewammerlaan@gentoo> Subject: [gentoo-commits] repo/proj/guru:master commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/mpv-plugin.eclass X-VCS-Directories: eclass/ X-VCS-Committer: andrewammerlaan X-VCS-Committer-Name: Andrew Ammerlaan X-VCS-Revision: ce3b957642e8aff38a6c923b8a5bc79ef9f20729 X-VCS-Branch: master Date: Thu, 14 Apr 2022 13:31:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3f70dfee-0670-4bac-a80f-4a892248ebc6 X-Archives-Hash: c44687b69ef0d76064e35981eda58209 commit: ce3b957642e8aff38a6c923b8a5bc79ef9f20729 Author: Nicola Smaniotto gmail com> AuthorDate: Thu Apr 14 09:13:00 2022 +0000 Commit: Andrew Ammerlaan gentoo org> CommitDate: Thu Apr 14 09:26:30 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=ce3b9576 mpv-plugin.eclass: new eclass Signed-off-by: Nicola Smaniotto gmail.com> eclass/mpv-plugin.eclass | 128 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/eclass/mpv-plugin.eclass b/eclass/mpv-plugin.eclass new file mode 100644 index 000000000..01212adec --- /dev/null +++ b/eclass/mpv-plugin.eclass @@ -0,0 +1,128 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: mpv-plugin.eclass +# @MAINTAINER: +# Nicola Smaniotto +# @AUTHOR: +# Nicola Smaniotto +# @SUPPORTED_EAPIS: 8 +# @BLURB: install mpv plugins +# @DESCRIPTION: +# This eclass simplifies the installation of mpv plugins into system-wide +# directories. Also handles the mpv dependency and provides an USE flag +# for automatic loading of the plugin. + +case ${EAPI:-0} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} unsupported." +esac + +EXPORT_FUNCTIONS src_install pkg_postinst + +# @ECLASS_VARIABLE: USE_MPV +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# Controls adding media-video/mpv dependency. The allowed values are: +# +# - rdepend -- add it to RDEPEND +# +# - depend -- add it to DEPEND+RDEPEND with the binding slot operator (the +# default) + +# @ECLASS_VARIABLE: MPV_REQ_USE +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# The list of USE flags required to be enabled on mpv, formed as a +# USE-dependency string. +# +# Example: +# @CODE@ +# MPV_REQ_USE="lua" +# @CODE@ + +if [[ ! ${_MPV_PLUGIN_ECLASS} ]]; then + +# @FUNCTION: _mpv-plugin_set_globals +# @INTERNAL +# @USAGE: +# @DESCRIPTION: +# Sets all the global output variables provided by this eclass. +# This function must be called once, in global scope. +_mpv-plugin_set_globals() { + local MPV_PKG_DEP + + SLOT="0" + IUSE="+autoload" + + MPV_PKG_DEP="media-video/mpv" + case ${USE_MPV:-depend} in + rdepend) + ;; + depend) + MPV_PKG_DEP+=":=" + ;; + *) + die "Invalid USE_MPV=${USE_MPV}" + ;; + esac + if [ ${MPV_REQ_USE} ]; then + MPV_PKG_DEP+="[${MPV_REQ_USE}]" + fi + + RDEPEND="${MPV_PKG_DEP}" + if [[ ${USE_MPV} == depend ]]; then + DEPEND="${MPV_PKG_DEP}" + fi +} +_mpv-plugin_set_globals + +# @ECLASS_VARIABLE: MPV_PLUGIN_FILES +# @DEFAULT_UNSET +# @REQUIRED +# @DESCRIPTION: +# Array containing the list of files to be installed. + +# @FUNCTION: mpv-plugin_src_install +# @USAGE: +# @DESCRIPTION: +# Install the specified files in ${D} and symlink them if the autoload flag is +# set. +# The ebuild must specify the file list in the MPV_PLUGIN_FILES array. +mpv-plugin_src_install() { + if [[ ! ${MPV_PLUGIN_FILES} ]]; then + die "${ECLASS}: no files specified in MPV_PLUGIN_FILES, cannot install" + fi + + insinto /usr/$(get_libdir)/mpv + for f in "${MPV_PLUGIN_FILES[@]}"; do + doins "${f}" + use autoload && dosym -r "/usr/$(get_libdir)/mpv/${f}" "/etc/mpv/scripts/${f}" + done + + einstalldocs +} + +# @FUNCTION: mpv-plugin_pkg_postinst +# @USAGE: +# @DESCRIPTION: +# Warns the user of the existence of the autoload use flag. +mpv-plugin_pkg_postinst() { + if ! use autoload; then + elog + elog "The plugin has not been installed to /etc/mpv/scripts for autoloading." + elog "You have to activate it manually by passing" + for f in "${MPV_PLUGIN_FILES[@]}"; do + elog " \"${EPREFIX}/usr/$(get_libdir)/mpv/${f}\"" + done + elog "as script option to mpv or symlinking the library to \"scripts/\" in your mpv" + elog "config directory." + elog "Alternatively, activate the autoload use flag." + elog + fi +} + +_MPV_PLUGIN_ECLASS=1 +fi