[gentoo-dev] [PATCH] optfeature.eclass: Introduce optfeature header

2021-04-03 Thread Andreas Sturmlechner
Before this change, optfeature() will print a list of optional dependencies,
or nothing if deps are installed. Ebuilds commonly print their own elog
ahead of optfeature, which then may not be followed up by any list at all.

This change adds a default header text, which may be changed by the ebuild,
that is only printed if optfeature is about to list at least one dependency.

Signed-off-by: Andreas Sturmlechner 
---
 eclass/optfeature.eclass | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/eclass/optfeature.eclass b/eclass/optfeature.eclass
index e13fc3eba81..46f8012b2c3 100644
--- a/eclass/optfeature.eclass
+++ b/eclass/optfeature.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: optfeature.eclass
@@ -14,6 +14,18 @@ esac
 if [[ -z ${_OPTFEATURE_ECLASS} ]]; then
 _OPTFEATURE_ECLASS=1
 
+# @ECLASS-VARIABLE: OPTFEATURE_HEADER
+# @DESCRIPTION:
+# Overridable default header printed ahead of the first optfeature output.
+# Will remain silent if all optional dependencies are present.
+: ${OPTFEATURE_HEADER:="Install additional packages for optional runtime 
features:"}
+
+# @ECLASS-VARIABLE: _OPTFEATURE_DOHEADER
+# @INTERNAL
+# @DESCRIPTION:
+# If true, print header ahead of the first optfeature output.
+_OPTFEATURE_DOHEADER=true
+
 # @FUNCTION: optfeature
 # @USAGE:   [other atoms]
 # @DESCRIPTION:
@@ -51,6 +63,10 @@ optfeature() {
fi
done
if [[ ${flag} -eq 0 ]]; then
+   if [[ ${_OPTFEATURE_DOHEADER} == true ]]; then
+   elog ${OPTFEATURE_HEADER}
+   _OPTFEATURE_DOHEADER=false
+   fi
for i; do
read -r -d '' -a arr <<<"${i}"
msg=" "
-- 
2.31.1



signature.asc
Description: This is a digitally signed message part.


[gentoo-dev] [PATCH v2] optfeature.eclass: Introduce optfeature header

2021-04-03 Thread Andreas Sturmlechner
Before this change, optfeature() would print a list of optional dependencies,
or nothing if deps are installed. Ebuilds commonly print their own elog
ahead of optfeature, which then may not be followed up by any list at all.

This change adds a default header text, which may be changed by the ebuild,
that is only printed if optfeature is about to list at least one dependency.

v2: Introduce optfeature_header() function
Set a custom header for follow-up optfeature calls, or reset to default
header by calling it without argument. This can not only be used to customize
the header but also to distinguish optfeature "groups", e.g. to list a number
of different possible database backends, and then a number of optional
regular runtime features.

Signed-off-by: Andreas Sturmlechner 

--- a/eclass/optfeature.eclass
+++ b/eclass/optfeature.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: optfeature.eclass
@@ -14,6 +14,56 @@ esac
 if [[ -z ${_OPTFEATURE_ECLASS} ]]; then
 _OPTFEATURE_ECLASS=1
 
+# @ECLASS-VARIABLE: _OPTFEATURE_DEFAULT_HEADER
+# @INTERNAL
+# @DESCRIPTION:
+# Default header printed ahead of optfeature output. Can be overridden
+# by calling optfeature_header function. Will not be displayed if all optional
+# dependencies are present.
+_OPTFEATURE_DEFAULT_HEADER="Install additional packages for optional runtime 
features:"
+
+readonly _OPTFEATURE_DEFAULT_HEADER
+
+# @ECLASS-VARIABLE: _OPTFEATURE_HEADER
+# @INTERNAL
+# @DESCRIPTION:
+# Default empty. Custom header printed ahead of optfeature output.
+# Set by calling optfeature_header function with the desired output, or reset
+# by optfeature_header without argument. Will not be displayed if all optional
+# dependencies are present.
+_OPTFEATURE_HEADER=
+
+# @ECLASS-VARIABLE: _OPTFEATURE_DOHEADER
+# @INTERNAL
+# @DESCRIPTION:
+# If true, print header ahead of the first optfeature output.
+_OPTFEATURE_DOHEADER=true
+
+# @FUNCTION: optfeature_header
+# @USAGE: [custom header for follow-up optfeature calls]
+# @DESCRIPTION:
+# Set a custom header for follow-up optfeature calls, or reset to default
+# header by calling it without argument. This can not only be used to customize
+# the header but also to distinguish optfeature "groups", e.g. to list a number
+# of different possible database backends, and then a number of optional
+# regular runtime features.
+#
+# The following snippet will leave the default header untouched for the first
+# two optfeature calls. Then a custom header is set that is going to be
+# displayed in case dev-db/a or dev-db/b are not installed.
+# @CODE
+#  optfeature "foo support" app-misc/foo
+#  optfeature "bar support" app-misc/bar
+#  optfeature_header "Install optional database backends:"
+#  optfeature "a DB backend" dev-db/a
+#  optfeature "b DB backend" dev-db/b
+# @CODE
+optfeature_header() {
+   debug-print-function ${FUNCNAME} "$@"
+   _OPTFEATURE_HEADER="${1}"
+   _OPTFEATURE_DOHEADER=true
+}
+
 # @FUNCTION: optfeature
 # @USAGE:   [other atoms]
 # @DESCRIPTION:
@@ -51,6 +101,10 @@ optfeature() {
fi
done
if [[ ${flag} -eq 0 ]]; then
+   if [[ ${_OPTFEATURE_DOHEADER} == true ]]; then
+   elog 
${_OPTFEATURE_HEADER:-${_OPTFEATURE_DEFAULT_HEADER}}
+   _OPTFEATURE_DOHEADER=false
+   fi
for i; do
read -r -d '' -a arr <<<"${i}"
msg=" "


signature.asc
Description: This is a digitally signed message part.


[gentoo-dev] [PATCH 2/2] profiles/info_pkgs: print rust{,-bin} versions

2021-04-03 Thread Georgy Yakovlev
Bug: https://bugs.gentoo.org/756340
Signed-off-by: Georgy Yakovlev 
---
 profiles/info_pkgs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/profiles/info_pkgs b/profiles/info_pkgs
index 9c12cc958ac7..650516bcf853 100644
--- a/profiles/info_pkgs
+++ b/profiles/info_pkgs
@@ -17,6 +17,8 @@ sys-devel/libtool
 sys-devel/make
 dev-lang/python
 dev-lang/perl
+dev-lang/rust
+dev-lang/rust-bin
 sys-apps/sandbox
 dev-util/ccache
 sys-devel/gcc
-- 
2.31.1




[gentoo-dev] [PATCH 1/2] profiles/info_vars: print RUSTFLAGS as well

2021-04-03 Thread Georgy Yakovlev
Bug:  https://bugs.gentoo.org/756340
Signed-off-by: Georgy Yakovlev 
---
 profiles/info_vars | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/info_vars b/profiles/info_vars
index b578103d116a..051948c1e8ef 100644
--- a/profiles/info_vars
+++ b/profiles/info_vars
@@ -34,6 +34,7 @@ PORTAGE_CONFIGROOT
 PORTAGE_TMPDIR
 PORTDIR
 PORTDIR_OVERLAY
+RUSTFLAGS
 SYNC
 USE
 PORTAGE_RSYNC_OPTS
-- 
2.31.1