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 8EEAE15808E for ; Sun, 24 Apr 2022 16:47:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 58F32E0896; Sun, 24 Apr 2022 16:47:05 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 A9978E0896 for ; Sun, 24 Apr 2022 16:46:57 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4678C341260 for ; Sun, 24 Apr 2022 16:46:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DABA12F9 for ; Sun, 24 Apr 2022 16:46:47 +0000 (UTC) From: "Nicola Smaniotto" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Nicola Smaniotto" Message-ID: <1650818806.2e47c02ef7a5d60b4dc5a42bd0ca80b21bb8b88d.smaniotto.nicola@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/mpv-plugin.eclass X-VCS-Directories: eclass/ X-VCS-Committer: smaniotto.nicola X-VCS-Committer-Name: Nicola Smaniotto X-VCS-Revision: 2e47c02ef7a5d60b4dc5a42bd0ca80b21bb8b88d X-VCS-Branch: dev Date: Sun, 24 Apr 2022 16:46:47 +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: 0bdebaec-4f9a-4fdc-8e8c-0eb11174f258 X-Archives-Hash: 3945d6a72d54b9feedaa8d90ca6cfc53 commit: 2e47c02ef7a5d60b4dc5a42bd0ca80b21bb8b88d Author: Nicola Smaniotto gmail com> AuthorDate: Sun Apr 24 16:43:02 2022 +0000 Commit: Nicola Smaniotto gmail com> CommitDate: Sun Apr 24 16:46:46 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=2e47c02e mpv-plugin.eclass: handle multi-file scripts The eclass behaves differently if a "main" file is present, since mpv should only execute that one. Also fix indentation to use tabs only. Signed-off-by: Nicola Smaniotto gmail.com> eclass/mpv-plugin.eclass | 74 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/eclass/mpv-plugin.eclass b/eclass/mpv-plugin.eclass index 01212adec..5c077e6d1 100644 --- a/eclass/mpv-plugin.eclass +++ b/eclass/mpv-plugin.eclass @@ -59,22 +59,22 @@ _mpv-plugin_set_globals() { MPV_PKG_DEP="media-video/mpv" case ${USE_MPV:-depend} in - rdepend) - ;; - depend) - MPV_PKG_DEP+=":=" - ;; - *) - die "Invalid USE_MPV=${USE_MPV}" - ;; + rdepend) + ;; + depend) + MPV_PKG_DEP+=":=" + ;; + *) + die "Invalid USE_MPV=${USE_MPV}" + ;; esac if [ ${MPV_REQ_USE} ]; then - MPV_PKG_DEP+="[${MPV_REQ_USE}]" + MPV_PKG_DEP+="[${MPV_REQ_USE}]" fi RDEPEND="${MPV_PKG_DEP}" if [[ ${USE_MPV} == depend ]]; then - DEPEND="${MPV_PKG_DEP}" + DEPEND="${MPV_PKG_DEP}" fi } _mpv-plugin_set_globals @@ -85,6 +85,16 @@ _mpv-plugin_set_globals # @DESCRIPTION: # Array containing the list of files to be installed. +# @FUNCTION: _mpv-plugin_has_main +# @INTERNAL +# @USAGE: +# @DESCRIPTION: +# Checks for the existance of a file named main. This means the plugin needs +# all files to be installed together, and mpv will only run the one called main. +_mpv-plugin_has_main() { + [[ " ${MPV_PLUGIN_FILES[*]} " =~ " main."[[:alnum:]]+" " ]] +} + # @FUNCTION: mpv-plugin_src_install # @USAGE: # @DESCRIPTION: @@ -93,15 +103,27 @@ _mpv-plugin_set_globals # 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" + die "${ECLASS}: no files specified in MPV_PLUGIN_FILES, cannot install" fi - insinto /usr/$(get_libdir)/mpv + local MPV_INSTALL_DIR="/usr/$(get_libdir)/mpv" + if _mpv-plugin_has_main; then + MPV_INSTALL_DIR+="/${PN}" + fi + insinto "${MPV_INSTALL_DIR}" + for f in "${MPV_PLUGIN_FILES[@]}"; do - doins "${f}" - use autoload && dosym -r "/usr/$(get_libdir)/mpv/${f}" "/etc/mpv/scripts/${f}" + doins "${f}" done + use autoload && if _mpv-plugin_has_main; then + dosym -r "${MPV_INSTALL_DIR}" "/etc/mpv/scripts/${PN}" + else + for f in "${MPV_PLUGIN_FILES[@]}"; do + dosym -r "${MPV_INSTALL_DIR}/${f}" "/etc/mpv/scripts/${f}" + done + fi + einstalldocs } @@ -111,16 +133,20 @@ mpv-plugin_src_install() { # 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 + elog + elog "The plugin has not been installed to /etc/mpv/scripts for autoloading." + elog "You have to activate it manually by passing" + if _mpv-plugin_has_main; then + elog " \"${EPREFIX}/usr/$(get_libdir)/mpv/${PN}\"" + else + for f in "${MPV_PLUGIN_FILES[@]}"; do + elog " \"${EPREFIX}/usr/$(get_libdir)/mpv/${f}\"" + done + fi + 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 }