public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
@ 2014-01-23 16:24 Chris Reffett
  2014-01-23 16:28 ` Michał Górny
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Reffett @ 2014-01-23 16:24 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

-----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-----

[-- Attachment #2: eutils_add_optfeature_v6.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]

--- 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-25 13:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 16:24 [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function Chris Reffett
2014-01-23 16:28 ` Michał Górny
2014-01-23 16:36   ` Chris Reffett
2014-01-23 16:48     ` Michał Górny
2014-01-25 10:12       ` Markos Chandras
2014-01-25 10:35         ` Michał Górny
2014-01-25 13:09         ` Chris Reffett
2014-01-25 13:27           ` Markos Chandras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox