From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1543417-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 (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 8BD7A15800A
	for <garchives@archives.gentoo.org>; Fri,  4 Aug 2023 07:26:56 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id D67CC2BC023;
	Fri,  4 Aug 2023 07:26:55 +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 C23392BC023
	for <gentoo-commits@lists.gentoo.org>; Fri,  4 Aug 2023 07:26:55 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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 13F0B335D6E
	for <gentoo-commits@lists.gentoo.org>; Fri,  4 Aug 2023 07:26:55 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 2DAA6EFA
	for <gentoo-commits@lists.gentoo.org>; Fri,  4 Aug 2023 07:26:52 +0000 (UTC)
From: "Florian Schmaus" <flow@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Florian Schmaus" <flow@gentoo.org>
Message-ID: <1691133955.252e74e80c0d3497de0d2d9b2324f364b30a8b01.flow@gentoo>
Subject: [gentoo-commits] repo/proj/guru:master commit in: eclass/
X-VCS-Repository: repo/proj/guru
X-VCS-Files: eclass/R-packages.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: flow
X-VCS-Committer-Name: Florian Schmaus
X-VCS-Revision: 252e74e80c0d3497de0d2d9b2324f364b30a8b01
X-VCS-Branch: master
Date: Fri,  4 Aug 2023 07:26:52 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: caccc65e-d209-4929-805a-c55a61573780
X-Archives-Hash: 16bc9b09cb9943e0348aa3495a144c63
Message-ID: <20230804072652.RlUbXnrk-oJaSZ9OKMEKvhgbXDpzPSTiZpqPjxTxZBw@z>

commit:     252e74e80c0d3497de0d2d9b2324f364b30a8b01
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  4 07:24:32 2023 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Fri Aug  4 07:25:55 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=252e74e8

R-packages.eclass: simplify code, inline movelink function

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 eclass/R-packages.eclass | 53 +++++++++++++++++++++---------------------------
 1 file changed, 23 insertions(+), 30 deletions(-)

diff --git a/eclass/R-packages.eclass b/eclass/R-packages.eclass
index 6dac19a161..f55cb9e417 100644
--- a/eclass/R-packages.eclass
+++ b/eclass/R-packages.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: R-packages.eclass
@@ -59,23 +59,6 @@ SLOT="0"
 DEPEND="dev-lang/R"
 RDEPEND="${DEPEND}"
 
-# @FUNCTION: _movelink
-# @INTERNAL
-# @USAGE: <source> <dest>
-# @DESCRIPTION:
-# <dest> will contain symlinks to everything in <source>
-_movelink() {
-	local source=${1}
-	local dest=${2}
-	if [[ -e "${source}" ]]; then
-		local rdir=/usr/$(get_libdir)/R/site-library/${CRAN_PN}
-		local rp_source="${rdir}/${source}"
-		insinto ${rdir}
-		doins -r ${source}
-		ln -s "${rp_source}" "${dest}" || die
-	fi
-}
-
 # @FUNCTION: R-packages_src_unpack
 # @DEPRECATED: none
 # @DESCRIPTION:
@@ -134,7 +117,6 @@ R-packages_src_compile() {
 		edo R CMD INSTALL . -d -l "${T}"/R --byte-compile
 }
 
-
 # @FUNCTION: R-packages_src_install
 # @DESCRIPTION:
 # Move files into right folders.
@@ -150,22 +132,33 @@ R-packages_src_install() {
 	local EDOCDIR="${ED}${DOCDIR}"
 	mkdir -p "${EDOCDIR}" || die
 
+	# _maybe_movelink <target> <link_name>
+	# If target exists, installs everything under target into R's
+	# site-library for the package and creates a link with the name
+	# <link_name> to it.
+	_maybe_movelink() {
+		local target=${1}
+		local link_name=${2}
+		if [[ ! -e "${target}" ]]; then
+			return
+		fi
+
+		local rdir=/usr/$(get_libdir)/R/site-library/${CRAN_PN}
+		local rp_source="${rdir}/${target}"
+		insinto ${rdir}
+		doins -r ${target}
+		ln -s "${rp_source}" "${link_name}" || die
+	}
+
 	for i in {NEWS,README}.md DESCRIPTION CITATION INDEX NEWS WORDLIST News.Rd; do
-		_movelink "${i}" "${EDOCDIR}/${i}"
+		_maybe_movelink "${i}" "${EDOCDIR}/${i}"
 	done
 
-	if [[ -e html ]]; then
-		_movelink html "${EDOCDIR}"/html
-	fi
+	_maybe_movelink html "${EDOCDIR}"/html
 
-	if [[ -e examples ]]; then
-		_movelink examples "${EDOCDIR}"/examples
-		docompress -x "${DOCDIR}"/examples
-	fi
+	_maybe_movelink examples "${EDOCDIR}"/examples
 
-	if [[ -e doc ]]; then
-		_movelink doc "${EDOCDIR}"/doc
-	fi
+	_maybe_movelink doc "${EDOCDIR}"/doc
 
 	rm -f LICENSE || die
 	rm -rf tests test || die