summaryrefslogtreecommitdiff
path: root/eclass/optfeature.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-09-16 09:32:48 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-09-16 09:32:48 +0100
commit9ee6d97c2883d42f204a533a8bc1f4562df778fb (patch)
treeb690ddc0ca30f1472887edbb0b8313629bfcbbb2 /eclass/optfeature.eclass
parentb17a3ef12038de50228bade1f05502c74e135321 (diff)
gentoo resync : 16.09.2020
Diffstat (limited to 'eclass/optfeature.eclass')
-rw-r--r--eclass/optfeature.eclass63
1 files changed, 63 insertions, 0 deletions
diff --git a/eclass/optfeature.eclass b/eclass/optfeature.eclass
new file mode 100644
index 000000000000..1943ae37bf5e
--- /dev/null
+++ b/eclass/optfeature.eclass
@@ -0,0 +1,63 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: optfeature.eclass
+# @MAINTAINER:
+# base-system@gentoo.org
+# @BLURB: Advertise optional functionality that might be useful to users
+
+case ${EAPI:-0} in
+ [0-7]) ;;
+ *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;;
+esac
+
+if [[ -z ${_OPTFEATURE_ECLASS} ]]; then
+_OPTFEATURE_ECLASS=1
+
+# @FUNCTION: optfeature
+# @USAGE: <short description> <package atom to match> [other atoms]
+# @DESCRIPTION:
+# Print out a message suggesting an optional package (or packages)
+# not currently installed which provides the described functionality.
+#
+# The following snippet would suggest app-misc/foo for optional foo support,
+# app-misc/bar or app-misc/baz[bar] for optional bar support
+# and either both app-misc/a and app-misc/b or app-misc/c for alphabet support.
+# @CODE
+# optfeature "foo support" app-misc/foo
+# optfeature "bar support" app-misc/bar app-misc/baz[bar]
+# optfeature "alphabet support" "app-misc/a app-misc/b" app-misc/c
+# @CODE
+optfeature() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local i j msg
+ local desc=$1
+ local flag=0
+ shift
+ for i; do
+ for j in ${i}; do
+ if has_version "${j}"; then
+ flag=1
+ else
+ flag=0
+ break
+ fi
+ done
+ if [[ ${flag} -eq 1 ]]; then
+ break
+ fi
+ done
+ if [[ ${flag} -eq 0 ]]; then
+ for i; do
+ msg=" "
+ for j in ${i}; do
+ msg+=" ${j} and"
+ done
+ msg="${msg:0: -4} for ${desc}"
+ elog "${msg}"
+ done
+ fi
+}
+
+fi