-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, After some discussion on good ways to communicate optional dependencies to users, I was shown the optfeature() function in net-misc/netctl. Gentoo contributor Andrew Hamilton and I came up with a cleaned up and expanded version of it, and I would like to add it to eutils.eclass to provide a standard way of notifying users of optional dependencies. The patch to eutils.eclass is attached.
Chris Reffett -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iKYEARECAGYFAlLhQklfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl bnBncC5maWZ0aGhvcnNlbWFuLm5ldEM2NzU5RjUyMDczREJDQkVDQTBDRkE1NERC Nzk1QThBNDI2MTgzNTQACgkQ23laikJhg1TDkwCeJ7MQliIiI6ViSkZzD+eIYM/J 0F4AoIVMP32HenJcjOkTIJkd6vGniiSi =+oIe -----END PGP SIGNATURE-----
--- eutils.eclass 2014-01-22 23:36:35.819000000 -0500 +++ eutils.eclass.patched 2014-01-23 00:37:07.907000000 -0500 @@ -1729,4 +1729,49 @@ check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } +# @FUNCTION: optfeature +# @USAGE: <short description> <package atom to match> [other atoms] +# @DESCRIPTION: +# Print out a message suggesting an optional package (or packages) which +# provide 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 +# +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="${msg} ${j} and" + done + msg="${msg:0: -4} for ${desc}" + elog "${msg}" + done + fi +} + fi