Gentoo Archives: gentoo-dev

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH] optfeature.eclass: Introduce optfeature header
Date: Sat, 03 Apr 2021 10:17:56
Message-Id: 4434463.vXUDI8C0e8@tuxbrain
1 Before this change, optfeature() will print a list of optional dependencies,
2 or nothing if deps are installed. Ebuilds commonly print their own elog
3 ahead of optfeature, which then may not be followed up by any list at all.
4
5 This change adds a default header text, which may be changed by the ebuild,
6 that is only printed if optfeature is about to list at least one dependency.
7
8 Signed-off-by: Andreas Sturmlechner <asturm@g.o>
9 ---
10 eclass/optfeature.eclass | 18 +++++++++++++++++-
11 1 file changed, 17 insertions(+), 1 deletion(-)
12
13 diff --git a/eclass/optfeature.eclass b/eclass/optfeature.eclass
14 index e13fc3eba81..46f8012b2c3 100644
15 --- a/eclass/optfeature.eclass
16 +++ b/eclass/optfeature.eclass
17 @@ -1,4 +1,4 @@
18 -# Copyright 1999-2020 Gentoo Authors
19 +# Copyright 1999-2021 Gentoo Authors
20 # Distributed under the terms of the GNU General Public License v2
21
22 # @ECLASS: optfeature.eclass
23 @@ -14,6 +14,18 @@ esac
24 if [[ -z ${_OPTFEATURE_ECLASS} ]]; then
25 _OPTFEATURE_ECLASS=1
26
27 +# @ECLASS-VARIABLE: OPTFEATURE_HEADER
28 +# @DESCRIPTION:
29 +# Overridable default header printed ahead of the first optfeature output.
30 +# Will remain silent if all optional dependencies are present.
31 +: ${OPTFEATURE_HEADER:="Install additional packages for optional runtime features:"}
32 +
33 +# @ECLASS-VARIABLE: _OPTFEATURE_DOHEADER
34 +# @INTERNAL
35 +# @DESCRIPTION:
36 +# If true, print header ahead of the first optfeature output.
37 +_OPTFEATURE_DOHEADER=true
38 +
39 # @FUNCTION: optfeature
40 # @USAGE: <short description> <package atom to match> [other atoms]
41 # @DESCRIPTION:
42 @@ -51,6 +63,10 @@ optfeature() {
43 fi
44 done
45 if [[ ${flag} -eq 0 ]]; then
46 + if [[ ${_OPTFEATURE_DOHEADER} == true ]]; then
47 + elog ${OPTFEATURE_HEADER}
48 + _OPTFEATURE_DOHEADER=false
49 + fi
50 for i; do
51 read -r -d '' -a arr <<<"${i}"
52 msg=" "
53 --
54 2.31.1

Attachments

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