From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-guru+bounces-140-garchives=archives.gentoo.org@lists.gentoo.org>
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 (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 2658B15821F
	for <garchives@archives.gentoo.org>; Sun, 24 Nov 2024 22:47:45 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 9EDBCE0922
	for <garchives@archives.gentoo.org>; Sun, 24 Nov 2024 22:47:35 +0000 (UTC)
Received: from sysrq.in (sysrq.in [37.79.202.136])
	(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 pigeon.gentoo.org (Postfix) with ESMTPS id B0BBC2BC017
	for <gentoo-guru@lists.gentoo.org>; Fri, 12 Jul 2024 15:00:27 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=sysrq.in; bh=mh9DeCPYPgX
	N6/IxgEDAEYuZWiL/Ih2G+OhY5llKAF4=; h=references:in-reply-to:to:from;
	d=sysrq.in; b=bG1/0rj8vIHl3qoSeFsvzMNn+ueVvSxE48KBxxgCbkhGSe1kGBEeCIry
	iiP6EjV5fvammLb62Rn2crZqjd1HRiCk/jGmren92oxrWCsUBbUabWy9qmnmf9MBEZCfuL
	vbwZQ3sLA4VySy1x0X1Lyfkl+r4d42o9i/cZaERI9N6OBt/D5Ar2f2rzt++3O0KtW/wMtf
	vLK1CFmvdR+u/h8GGHpTJVg3MP87gG5m/ajlFbts+wXc/kVmSz/F5UV0nqTpfTNyjvlInW
	WZ6SSChP2RD70rqgehV48LQo9SJnSWuN4y9GyZC3ZrBof8kZ49SbXfzKYYtgPqxJ0Kr8a7
	aQ7Mqg==
Received: from sysrq.in (<unknown> [10.0.0.1])
	by sysrq.in (OpenSMTPD) with ESMTPS id ac63f2f5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO)
	for <gentoo-guru@lists.gentoo.org>;
	Fri, 12 Jul 2024 15:00:19 +0000 (UTC)
From: "Anna (cybertailor) Vyalkova" <cyber+gentoo@sysrq.in>
To: gentoo-guru@lists.gentoo.org
Subject: [gentoo-guru] [PATCH 2/9] boinc-app.eclass: rename boinc-wrapper_foreach_wrapper_job
Date: Fri, 12 Jul 2024 19:55:08 +0500
Message-ID: <20240712150015.29329-3-cyber+gentoo@sysrq.in>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20240712150015.29329-1-cyber+gentoo@sysrq.in>
References: <20240712150015.29329-1-cyber+gentoo@sysrq.in>
Precedence: bulk
List-Post: <mailto:gentoo-guru@lists.gentoo.org>
List-Help: <mailto:gentoo-guru+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-guru+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-guru+subscribe@lists.gentoo.org>
List-Id: Discussion on the GURU project and repository <gentoo-guru.gentoo.org>
X-BeenThere: gentoo-guru@gentoo.org
X-BeenThere: gentoo-guru@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Archives-Salt: 648f25de-88fe-43d8-a8a9-c8c97a708e6a
X-Archives-Hash: 8b366cd3a967f1d8ed3ed673f6bc9b50

This shouldn't have been like this in the first place. I must've been
really sleepy when I was writing this eclass.

Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
---
 eclass/boinc-app.eclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/eclass/boinc-app.eclass b/eclass/boinc-app.eclass
index 6a386bf2f..689be4992 100644
--- a/eclass/boinc-app.eclass
+++ b/eclass/boinc-app.eclass
@@ -1,358 +1,358 @@
 # Copyright 2021-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: boinc-app.eclass
 # @MAINTAINER:
 # Anna Vyalkova <cyber+gentoo@sysrq.in>
 # @SUPPORTED_EAPIS: 8
 # @BLURB: base functions for installing BOINC applications
 # @DESCRIPTION:
 # This eclass provides base functions for installation of software developed
 # for the BOINC platform.
 #
 # Do not package *-bin applications as BOINC can handle them itself better.
 #
 # Note that BOINC won't detect a custom application unless you provide it with
 # app_info.xml file (see https://boinc.berkeley.edu/wiki/Anonymous_platform).
 # Attach to a project of your interest and use values from
 # /var/lib/boinc/client_state.xml to write the file.
 #
 # BOINC.Italy did a great job discovering sources of many BOINC applications:
 # https://www.boincitaly.org/progetti/sorgenti-progetti.html
 
 case ${EAPI} in
 	8) ;;
 	*) die "${ECLASS}: EAPI ${EAPI} unsupported."
 esac
 
 # @ECLASS_VARIABLE: BOINC_APP_OPTIONAL
 # @DEFAULT_UNSET
 # @DESCRIPTION:
 # If set to a non-null value, BOINC part in the ebuild will be
 # considered optional and no phase functions will be exported.
 #
 # If you enable BOINC_APP_OPTIONAL, you have to call boinc-app
 # default phase functions and add dependencies manually.
 
 if [[ ! ${BOINC_APP_OPTIONAL} ]]; then
 	EXPORT_FUNCTIONS pkg_postinst pkg_postrm
 fi
 
 if [[ ! ${_BOINC_APP_ECLASS} ]]; then
 
 # @ECLASS_VARIABLE: BOINC_MASTER_URL
 # @REQUIRED
 # @DESCRIPTION:
 # Each project is publicly identified by a master URL. It also serves
 # as the home page of the project.
 #
 # You need to look it up using the following command:
 # @CODE
 #	grep "<master_url>" /var/lib/boinc/client_state.xml
 # @CODE
 
 # @ECLASS_VARIABLE: BOINC_INVITATION_CODE
 # @DEFAULT_UNSET
 # @DESCRIPTION:
 # Some projects restrict account creation to those who present an
 # "invitation code". Write it to BOINC_INVITATION_CODE variable if
 # it's published on project's website.
 
 # @ECLASS_VARIABLE: HOMEPAGE
 # @DESCRIPTION:
 # This variable defines the HOMEPAGE for BOINC projects if BOINC_MASTER_URL
 # was set before inherit.
 : ${HOMEPAGE:=${BOINC_MASTER_URL}}
 
 # @ECLASS_VARIABLE: BOINC_APP_HELPTEXT
 # @DESCRIPTION:
 # Help message to display during the pkg_postinst phase
 : ${BOINC_APP_HELPTEXT:=\
 You have to attach to the corresponding project
 in order to use this application with BOINC.}
 
 # @FUNCTION: boinc-app_add_deps
 # @USAGE: [--wrapper]
 # @DESCRIPTION:
 # Generate appropriate (R)DEPEND for wrapper-enabled or
 # native application.
 boinc-app_add_deps() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if [[ $1 == "--wrapper" ]]; then
 		RDEPEND="sci-misc/boinc-wrapper"
 	else
 		DEPEND="sci-misc/boinc"
 		RDEPEND="sci-misc/boinc"
 	fi
 
 	DEPEND="${DEPEND} acct-user/boinc"
 	RDEPEND="${RDEPEND} acct-user/boinc"
 }
 
 # @FUNCTION: boinc_master_url_check
 # @USAGE:
 # @DESCRIPTION:
 # Make sure BOINC_MASTER_URL has a value.
 boinc_master_url_check() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	[[ -n ${BOINC_MASTER_URL} ]] || \
 		die "BOINC_MASTER_URL is not set"
 	return 0
 }
 
 # @FUNCTION: get_boincdir
 # @USAGE:
 # @RETURN: non-prefixed default BOINC runtime directory
 get_boincdir() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	echo /var/lib/boinc
 }
 
 # @FUNCTION: get_project_dirname
 # @INTERNAL
 # @USAGE:
 # @RETURN: project's dirname, derived from BOINC_MASTER_URL
 # @DESCRIPTION:
 # Example:
 #
 # @CODE
 # BOINC_MASTER_URL="https://boinc.berkeley.edu/example/"
 # get_project_dirname
 # -> boinc.berkeley.edu_example
 # @CODE
 get_project_dirname() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	boinc_master_url_check
 
 	local dirname
 	dirname=${BOINC_MASTER_URL#*://}	# strip http[s]://
 	dirname=${dirname%/}			# strip trailing slash
 	dirname=${dirname////_}			# replace '/' with '_'
 
 	echo "${dirname}"
 }
 
 # @FUNCTION: get_project_root
 # @USAGE:
 # @RETURN: non-prefixed directory where applications and files should be installed
 get_project_root() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	echo "$(get_boincdir)/projects/$(get_project_dirname)"
 }
 
 # @FUNCTION: _boinc-app_fix_permissions
 # @USAGE:
 # @INTERNAL
 # @DESCRIPTION:
 # Fix owner and permissions for the project root.
 _boinc-app_fix_permissions() {
 	local paths=(
 		$(get_boincdir)
 		$(get_boincdir)/projects
 		$(get_project_root)
 	)
 	fowners boinc:boinc "${paths[@]}"
 	fperms 0771 "${paths[@]}"
 }
 
 # @FUNCTION: boinc-app_appinfo_prepare
 # @USAGE: <writable app_info.xml>
 # @DESCRIPTION:
 # The default appinfo_prepare(). It replaces all occurences
 # of @PV@ with its corresponding value.
 boinc-app_appinfo_prepare() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	sed -i "$1" \
 		-e "s:@PV@:${PV}:g" \
 		|| die "app_info.xml sed failed"
 }
 
 # @FUNCTION: doappinfo
 # @USAGE: <app_info.xml>
 # @DESCRIPTION:
 # Installs given app_info.xml file to the project root.
 #
 # Tip: implement appinfo_prepare() function for all your sed hacks.
 # It should recognize first argument as a file and edit it in place.
 #
 # Example:
 # @CODE
 # appinfo_prepare() {
 # 	if ! use cuda; then
 # 		sed "/<plan_class>cuda/d" -i "$1" || die
 # 	fi
 # 	boinc-app_appinfo_prepare "$1"
 # }
 #
 # src_install() {
 # 	doappinfo "${FILESDIR}"/app_info_${PV}.xml
 #
 #	exeinto $(get_project_root)
 # 	exeopts -m 0755 --owner root --group boinc
 # 	newexe bin/${PN} example_app_v${PV}
 # }
 # @CODE
 doappinfo() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	(( $# == 1 )) || \
 		die "${FUNCNAME} takes exactly one argument"
 
 	cp "$1" "${T}"/app_info.xml || die
 
 	if declare -f appinfo_prepare >/dev/null; then
 		appinfo_prepare "${T}"/app_info.xml
 	else
 		boinc-app_appinfo_prepare "${T}"/app_info.xml
 	fi
 
 	( # subshell to avoid pollution of calling environment
 		insinto $(get_project_root)
 		insopts -m 0644 --owner root --group boinc
 		doins "${T}"/app_info.xml
 	) || die "failed to install app_info.xml"
 
 	_boinc-app_fix_permissions
 }
 
-# @FUNCTION: boinc-wrapper_foreach_wrapper_job
-# @USAGE: <job.xml>
+# @FUNCTION: boinc-app_foreach_wrapper_job
+# @USAGE: <job>
 # @DESCRIPTION:
 # The default foreach_wrapper_job(). It replaces all occurences
 # of @PV@, @EPREFIX@ and @LIBDIR@ strings with their corresponding values.
-boinc-wrapper_foreach_wrapper_job() {
+boinc-app_foreach_wrapper_job() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	sed -i "$1" \
+	sed -i "${1:?}" \
 		-e "s:@PV@:${PV}:g" \
 		-e "s:@EPREFIX@:${EPREFIX}:g" \
 		-e "s:@LIBDIR@:$(get_libdir):g" \
-		|| die "$(basename "$1") sed failed"
+		|| die "$(basename "${1}") sed failed"
 }
 
 # @FUNCTION: boinc_install_wrapper
 # @USAGE: <bin> <job> [new name]
 # @DESCRIPTION:
 # This function provides a uniform way to install wrapper applications
 # for BOINC projects. It makes symlinks to the BOINC wrapper and also
 # installs respective job.xml files.
 #
 # When `dowrapper boinc-example_wrapper A.xml B.xml` is called, it:
 #
 # 1. Installs A.xml in the project's root directory, renaming it to B.xml
 #
 # 2. Installs boinc-example_wrapper symlink, which points
 #    to /usr/bin/boinc-wrapper, in the project's root directory
 #
 # Example:
 # @CODE
 # src_install() {
 # 	meson_src_install
 #
 # 	boinc_install_wrapper boinc-example_wrapper "${FILESDIR}"/job.xml
 #	doappinfo "${FILESDIR}"/app_info_${PV}.xml
 # }
 # @CODE
 #
 # Keep your job.xml files in sync with app_info.xml!
 boinc_install_wrapper() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	(( $# >= 2 && $# <= 3 )) || \
 		die "${FUNCNAME} got wrong number of arguments"
 
 	local exe="${1:?}"
 	local job="${2:?}"
 	local job_dest="${3:-$(basename "${job:?}")}"
 
 	cp "${job:?}" "${T:?}/${job_dest:?}" || die
 	if declare -f foreach_wrapper_job >/dev/null; then
 		foreach_wrapper_job "${T:?}/${job_dest:?}"
 	else
-		boinc-wrapper_foreach_wrapper_job "${T:?}/${job_dest:?}"
+		boinc-app_foreach_wrapper_job "${T:?}/${job_dest:?}"
 	fi
 
 	( # subshell to avoid pollution of calling environment
 		insinto "$(get_project_root)"
 		insopts -m 0644 --owner root --group boinc
 		doins "${T:?}/${job_dest:?}"
 	) || die "failed to install ${exe:?} wrapper job"
 	rm -f "${T:?}/${job_dest:?}"
 
 	dosym -r /usr/bin/boinc-wrapper "$(get_project_root)/${exe:?}"
 	_boinc-app_fix_permissions
 }
 
 # @FUNCTION: dowrapper
 # @DEPRECATED: boinc_install_wrapper
 # @DESCRIPTION:
 # Install BOINC wrappers and job definitions.
 dowrapper() {
 	die "${FUNCNAME} has been removed, please use boinc_install_wrapper instead"
 }
 
 # @FUNCTION: boinc-app_pkg_postinst
 # @DESCRIPTION:
 # Display helpful instructions on how to make the BOINC client use installed
 # applications.
 boinc-app_pkg_postinst() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if [[ -f "${EROOT}/$(get_boincdir)/master_$(get_project_dirname).xml" ]]; then
 		if [[ -z ${REPLACING_VERSIONS} ]]; then
 			# most likely replacing applications downloaded
 			# by the BOINC client from project's website
 			elog "Restart the BOINC daemon for changes to take place:"
 			elog "# rc-service boinc restart"
 			return
 		else
 			# applications are already in use
 			return
 		fi
 	fi
 
 	elog
 	while read h; do
 		elog "${h}"
 	done <<<"${BOINC_APP_HELPTEXT}"
 	elog
 
 	if [[ ! ${BOINC_INVITATION_CODE} ]]; then
 		elog "# rc-service boinc attach"
 		elog "    Enter the Project URL: ${BOINC_MASTER_URL}"
 	else
 		elog "- Master URL: ${BOINC_MASTER_URL}"
 		elog "- Invitation code: ${BOINC_INVITATION_CODE}"
 	fi
 }
 
 # @FUNCTION: boinc-app_pkg_postrm
 # @DESCRIPTION:
 # Display helpful instructions on how to cleanly uninstall unmerged
 # applications.
 boinc-app_pkg_postrm() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if [[ -z ${REPLACED_BY_VERSION} ]]; then
 		local gui_rpc_auth="$(get_boincdir)/gui_rpc_auth.cfg"
 		local passwd=$(cat "${EROOT}/${gui_rpc_auth}" 2>/dev/null)
 		if [[ -z ${passwd} ]]; then
 			passwd="\$(cat ${gui_rpc_auth})"
 		fi
 
 		elog "You should detach this project from the BOINC client"
 		elog "to stop current tasks and delete remaining project files:"
 		elog
 		elog "$ boinccmd --passwd ${passwd} --project ${BOINC_MASTER_URL} detach"
 		elog
 	fi
 }
 
 _BOINC_APP_ECLASS=1
 fi
-- 
2.45.2