public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] font.eclass: Don't assign FONT_S in global scope, allow an array.
@ 2020-02-14 15:32 Ulrich Müller
  2020-02-15  5:37 ` [gentoo-dev] [PATCH v2] " Ulrich Müller
  2020-03-20 15:54 ` [gentoo-dev] [PATCH] " Ulrich Mueller
  0 siblings, 2 replies; 3+ messages in thread
From: Ulrich Müller @ 2020-02-14 15:32 UTC (permalink / raw
  To: gentoo-dev; +Cc: fonts

[-- Attachment #1: Type: text/plain, Size: 3601 bytes --]

Accessing ${S} in global scope is not allowed by PMS, therefore remove
the global variable assignment of FONT_S which uses it. Add a fallback
to ${S} in font_src_install() instead.

Allow FONT_S to be an array, if there are multiple directories.
Support for whitespace-separated lists will be kept for some time,
and a QA warning will be shown.

Die if pushd or popd fails.

Closes: https://bugs.gentoo.org/613108
Closes: https://bugs.gentoo.org/709578
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
This will be committed in 60 days from now. The backwards compatibility
code for whitespace-separated FONT_S will be removed in one year.

***** ATTENTION OVERLAY USERS *****
If your ebuilds currently output error messages like:
/var/tmp/portage/media-fonts/foo/temp/environment: line 1036: pushd: /var/tmp/portage/media-fonts/foo/work/foo: No such file or directory
/var/tmp/portage/media-fonts/foo/temp/environment: line 1043: popd: directory stack empty
then in future these will be caught by the added "|| die" statements
after pushd and popd. So make sure to fix such breakage before the
updated eclass will be committed.

 eclass/font.eclass | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/eclass/font.eclass b/eclass/font.eclass
index 1287f2273454..8418edf24ebb 100644
--- a/eclass/font.eclass
+++ b/eclass/font.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: font.eclass
@@ -25,10 +25,10 @@ EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
 FONT_SUFFIX=${FONT_SUFFIX:-}
 
 # @ECLASS-VARIABLE: FONT_S
-# @REQUIRED
+# @DEFAULT_UNSET
 # @DESCRIPTION:
-# Space delimited list of directories containing the fonts.
-FONT_S=${FONT_S:-${S}}
+# Directory containing the fonts.  If unset, ${S} is used instead.
+# Can also be an array of several directories.
 
 # @ECLASS-VARIABLE: FONT_PN
 # @DESCRIPTION:
@@ -159,27 +159,38 @@ font_pkg_setup() {
 font_src_install() {
 	local dir suffix commondoc
 
-	set -- ${FONT_S:-${S}}
-	if [[ $# -gt 1 ]]; then
-		# if we have multiple FONT_S elements then we want to recreate the dir
-		# structure
+	if [[ $(declare -p FONT_S) == "declare -a "* ]]; then
+		# recreate the directory structure if FONT_S is an array
+		for dir in "${FONT_S[@]}"; do
+			pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
+			insinto "${FONTDIR}${dir#${S}}"
+			for suffix in ${FONT_SUFFIX}; do
+				doins *.${suffix}
+			done
+			font_xfont_config "${dir}"
+			popd > /dev/null || die
+		done
+	elif [[ ${FONT_S/ } != "${FONT_S}" ]]; then
+		# backwards compatibility code, can be removed after 2021-02-14
+		eqawarn "Using a space-separated list for FONT_S is deprecated."
+		eqawarn "Use a bash array instead if there are multiple directories."
 		for dir in ${FONT_S}; do
-			pushd "${dir}" > /dev/null
+			pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
 			insinto "${FONTDIR}/${dir//${S}/}"
 			for suffix in ${FONT_SUFFIX}; do
 				doins *.${suffix}
 			done
 			font_xfont_config "${dir}"
-			popd > /dev/null
+			popd > /dev/null || die
 		done
 	else
-		pushd "${FONT_S}" > /dev/null
+		pushd "${FONT_S:-${S}}" > /dev/null || die "pushd ${dir} failed"
 		insinto "${FONTDIR}"
 		for suffix in ${FONT_SUFFIX}; do
 			doins *.${suffix}
 		done
 		font_xfont_config
-		popd > /dev/null
+		popd > /dev/null || die
 	fi
 
 	font_fontconfig
-- 
2.25.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-20 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-14 15:32 [gentoo-dev] [PATCH] font.eclass: Don't assign FONT_S in global scope, allow an array Ulrich Müller
2020-02-15  5:37 ` [gentoo-dev] [PATCH v2] " Ulrich Müller
2020-03-20 15:54 ` [gentoo-dev] [PATCH] " Ulrich Mueller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox