Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Cc: fonts@g.o
Subject: [gentoo-dev] [PATCH] font.eclass: Don't assign FONT_S in global scope, allow an array.
Date: Fri, 14 Feb 2020 15:32:15
Message-Id: upnehkwwa@kph.uni-mainz.de
1 Accessing ${S} in global scope is not allowed by PMS, therefore remove
2 the global variable assignment of FONT_S which uses it. Add a fallback
3 to ${S} in font_src_install() instead.
4
5 Allow FONT_S to be an array, if there are multiple directories.
6 Support for whitespace-separated lists will be kept for some time,
7 and a QA warning will be shown.
8
9 Die if pushd or popd fails.
10
11 Closes: https://bugs.gentoo.org/613108
12 Closes: https://bugs.gentoo.org/709578
13 Signed-off-by: Ulrich Müller <ulm@g.o>
14 ---
15 This will be committed in 60 days from now. The backwards compatibility
16 code for whitespace-separated FONT_S will be removed in one year.
17
18 ***** ATTENTION OVERLAY USERS *****
19 If your ebuilds currently output error messages like:
20 /var/tmp/portage/media-fonts/foo/temp/environment: line 1036: pushd: /var/tmp/portage/media-fonts/foo/work/foo: No such file or directory
21 /var/tmp/portage/media-fonts/foo/temp/environment: line 1043: popd: directory stack empty
22 then in future these will be caught by the added "|| die" statements
23 after pushd and popd. So make sure to fix such breakage before the
24 updated eclass will be committed.
25
26 eclass/font.eclass | 35 +++++++++++++++++++++++------------
27 1 file changed, 23 insertions(+), 12 deletions(-)
28
29 diff --git a/eclass/font.eclass b/eclass/font.eclass
30 index 1287f2273454..8418edf24ebb 100644
31 --- a/eclass/font.eclass
32 +++ b/eclass/font.eclass
33 @@ -1,4 +1,4 @@
34 -# Copyright 1999-2019 Gentoo Authors
35 +# Copyright 1999-2020 Gentoo Authors
36 # Distributed under the terms of the GNU General Public License v2
37
38 # @ECLASS: font.eclass
39 @@ -25,10 +25,10 @@ EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
40 FONT_SUFFIX=${FONT_SUFFIX:-}
41
42 # @ECLASS-VARIABLE: FONT_S
43 -# @REQUIRED
44 +# @DEFAULT_UNSET
45 # @DESCRIPTION:
46 -# Space delimited list of directories containing the fonts.
47 -FONT_S=${FONT_S:-${S}}
48 +# Directory containing the fonts. If unset, ${S} is used instead.
49 +# Can also be an array of several directories.
50
51 # @ECLASS-VARIABLE: FONT_PN
52 # @DESCRIPTION:
53 @@ -159,27 +159,38 @@ font_pkg_setup() {
54 font_src_install() {
55 local dir suffix commondoc
56
57 - set -- ${FONT_S:-${S}}
58 - if [[ $# -gt 1 ]]; then
59 - # if we have multiple FONT_S elements then we want to recreate the dir
60 - # structure
61 + if [[ $(declare -p FONT_S) == "declare -a "* ]]; then
62 + # recreate the directory structure if FONT_S is an array
63 + for dir in "${FONT_S[@]}"; do
64 + pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
65 + insinto "${FONTDIR}${dir#${S}}"
66 + for suffix in ${FONT_SUFFIX}; do
67 + doins *.${suffix}
68 + done
69 + font_xfont_config "${dir}"
70 + popd > /dev/null || die
71 + done
72 + elif [[ ${FONT_S/ } != "${FONT_S}" ]]; then
73 + # backwards compatibility code, can be removed after 2021-02-14
74 + eqawarn "Using a space-separated list for FONT_S is deprecated."
75 + eqawarn "Use a bash array instead if there are multiple directories."
76 for dir in ${FONT_S}; do
77 - pushd "${dir}" > /dev/null
78 + pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
79 insinto "${FONTDIR}/${dir//${S}/}"
80 for suffix in ${FONT_SUFFIX}; do
81 doins *.${suffix}
82 done
83 font_xfont_config "${dir}"
84 - popd > /dev/null
85 + popd > /dev/null || die
86 done
87 else
88 - pushd "${FONT_S}" > /dev/null
89 + pushd "${FONT_S:-${S}}" > /dev/null || die "pushd ${dir} failed"
90 insinto "${FONTDIR}"
91 for suffix in ${FONT_SUFFIX}; do
92 doins *.${suffix}
93 done
94 font_xfont_config
95 - popd > /dev/null
96 + popd > /dev/null || die
97 fi
98
99 font_fontconfig
100 --
101 2.25.0

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies