* [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
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
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
0 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2014-01-23 16:28 UTC (permalink / raw
To: gentoo-dev; +Cc: creffett
[-- Attachment #1: Type: text/plain, Size: 622 bytes --]
Dnia 2014-01-23, o godz. 11:24:41
Chris Reffett <creffett@gentoo.org> napisał(a):
> 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.
This was discussed already:
http://thread.gmane.org/gmane.linux.gentoo.devel/72162
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
2014-01-23 16:28 ` Michał Górny
@ 2014-01-23 16:36 ` Chris Reffett
2014-01-23 16:48 ` Michał Górny
0 siblings, 1 reply; 8+ messages in thread
From: Chris Reffett @ 2014-01-23 16:36 UTC (permalink / raw
To: gentoo-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/23/2014 11:28 AM, Michał Górny wrote:
> Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
> <creffett@gentoo.org> napisał(a):
>
>> 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.
>
> This was discussed already:
>
> http://thread.gmane.org/gmane.linux.gentoo.devel/72162
>
First of all, this is a short patch for a function, not a full eclass.
Further, people are doing this sort of thing already (printing
messages to say "if you want support for x, install y," this is just
making it easier to do so. Of course full support for an SDEPEND
variable would be much better, but unless you have a patch for that
ready to go for the next EAPI I don't see that happening anytime soon,
so a short function in eutils seems like a reasonable choice to me.
Chris Reffett
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iKYEARECAGYFAlLhRPZfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl
bnBncC5maWZ0aGhvcnNlbWFuLm5ldEM2NzU5RjUyMDczREJDQkVDQTBDRkE1NERC
Nzk1QThBNDI2MTgzNTQACgkQ23laikJhg1QaawCeM3GnYAc83Czei2r1l2XHFFB4
sAgAn21yARrui9E+ZsNnk75UCk0j0oEp
=VTT0
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
2014-01-23 16:36 ` Chris Reffett
@ 2014-01-23 16:48 ` Michał Górny
2014-01-25 10:12 ` Markos Chandras
0 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2014-01-23 16:48 UTC (permalink / raw
To: gentoo-dev; +Cc: creffett
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
Dnia 2014-01-23, o godz. 11:36:06
Chris Reffett <creffett@gentoo.org> napisał(a):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 01/23/2014 11:28 AM, Michał Górny wrote:
> > Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
> > <creffett@gentoo.org> napisał(a):
> >
> >> 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.
> >
> > This was discussed already:
> >
> > http://thread.gmane.org/gmane.linux.gentoo.devel/72162
> >
> First of all, this is a short patch for a function, not a full eclass.
Ah, sorry, this changes *a lot*. Let's start the bikeshed again then,
whatever.
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
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
0 siblings, 2 replies; 8+ messages in thread
From: Markos Chandras @ 2014-01-25 10:12 UTC (permalink / raw
To: gentoo-dev
On 01/23/2014 04:48 PM, Michał Górny wrote:
> Dnia 2014-01-23, o godz. 11:36:06
> Chris Reffett <creffett@gentoo.org> napisał(a):
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 01/23/2014 11:28 AM, Michał Górny wrote:
>>> Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
>>> <creffett@gentoo.org> napisał(a):
>>>
>>>> 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.
>>>
>>> This was discussed already:
>>>
>>> http://thread.gmane.org/gmane.linux.gentoo.devel/72162
>>>
>> First of all, this is a short patch for a function, not a full eclass.
>
> Ah, sorry, this changes *a lot*. Let's start the bikeshed again then,
> whatever.
>
I haven't looked at the implementation, but I wonder if we need a
function for such trivial stuff. Most maintainers deal with this problem
using pkg_postinst() einfo/elog messages. Why do we need a dedicated
function for that? Just for consistency reasons...?
--
Regards,
Markos Chandras
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
2014-01-25 10:12 ` Markos Chandras
@ 2014-01-25 10:35 ` Michał Górny
2014-01-25 13:09 ` Chris Reffett
1 sibling, 0 replies; 8+ messages in thread
From: Michał Górny @ 2014-01-25 10:35 UTC (permalink / raw
To: gentoo-dev; +Cc: hwoarang
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
Dnia 2014-01-25, o godz. 10:12:26
Markos Chandras <hwoarang@gentoo.org> napisał(a):
> On 01/23/2014 04:48 PM, Michał Górny wrote:
> > Dnia 2014-01-23, o godz. 11:36:06
> > Chris Reffett <creffett@gentoo.org> napisał(a):
> >
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> On 01/23/2014 11:28 AM, Michał Górny wrote:
> >>> Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
> >>> <creffett@gentoo.org> napisał(a):
> >>>
> >>>> 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.
> >>>
> >>> This was discussed already:
> >>>
> >>> http://thread.gmane.org/gmane.linux.gentoo.devel/72162
> >>>
> >> First of all, this is a short patch for a function, not a full eclass.
> >
> > Ah, sorry, this changes *a lot*. Let's start the bikeshed again then,
> > whatever.
> >
> I haven't looked at the implementation, but I wonder if we need a
> function for such trivial stuff. Most maintainers deal with this problem
> using pkg_postinst() einfo/elog messages. Why do we need a dedicated
> function for that? Just for consistency reasons...?
The intent of the original optfeature implementation was to provide
users with nice, colorful '[installed]' messages whenever the optional
dependency was installed.
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
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
1 sibling, 1 reply; 8+ messages in thread
From: Chris Reffett @ 2014-01-25 13:09 UTC (permalink / raw
To: gentoo-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/25/2014 05:12 AM, Markos Chandras wrote:
> On 01/23/2014 04:48 PM, Michał Górny wrote:
>> Dnia 2014-01-23, o godz. 11:36:06 Chris Reffett
>> <creffett@gentoo.org> napisał(a):
>>
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>>
>>> On 01/23/2014 11:28 AM, Michał Górny wrote:
>>>> Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
>>>> <creffett@gentoo.org> napisał(a):
>>>>
>>>>> 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.
>>>>
>>>> This was discussed already:
>>>>
>>>> http://thread.gmane.org/gmane.linux.gentoo.devel/72162
>>>>
>>> First of all, this is a short patch for a function, not a full
>>> eclass.
>>
>> Ah, sorry, this changes *a lot*. Let's start the bikeshed again
>> then, whatever.
>>
> I haven't looked at the implementation, but I wonder if we need a
> function for such trivial stuff. Most maintainers deal with this
> problem using pkg_postinst() einfo/elog messages. Why do we need a
> dedicated function for that? Just for consistency reasons...?
>
Consistency, and because it removes the need for a bunch of "if
has_version" lines, instead only displaying if you don't satisfy the
deps (and supports both "and" and "or" groupings for packages
satisfying the dep). This also stems from a complaint I've seen a lot
about how optional dep messages should only display if the requisite
package isn't installed, this makes that job a little simpler. But
mostly consistency, this gives us one nice function that we can
standardize on.
Chris Reffett
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iKYEARECAGYFAlLjt6NfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl
bnBncC5maWZ0aGhvcnNlbWFuLm5ldEM2NzU5RjUyMDczREJDQkVDQTBDRkE1NERC
Nzk1QThBNDI2MTgzNTQACgkQ23laikJhg1SAZACgqLjfMMmvPNa/6Nwxzlpm5sde
kwQAniZMjvFkQ7H/1+wpYnDjyezplMud
=6E+E
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] eutils.eclass: add optfeature() function
2014-01-25 13:09 ` Chris Reffett
@ 2014-01-25 13:27 ` Markos Chandras
0 siblings, 0 replies; 8+ messages in thread
From: Markos Chandras @ 2014-01-25 13:27 UTC (permalink / raw
To: gentoo-dev
On 01/25/2014 01:09 PM, Chris Reffett wrote:
> On 01/25/2014 05:12 AM, Markos Chandras wrote:
>> On 01/23/2014 04:48 PM, Michał Górny wrote:
>>> Dnia 2014-01-23, o godz. 11:36:06 Chris Reffett
>>> <creffett@gentoo.org> napisał(a):
>>>
>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>>>
>>>> On 01/23/2014 11:28 AM, Michał Górny wrote:
>>>>> Dnia 2014-01-23, o godz. 11:24:41 Chris Reffett
>>>>> <creffett@gentoo.org> napisał(a):
>>>>>
>>>>>> 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.
>>>>>
>>>>> This was discussed already:
>>>>>
>>>>> http://thread.gmane.org/gmane.linux.gentoo.devel/72162
>>>>>
>>>> First of all, this is a short patch for a function, not a full
>>>> eclass.
>>>
>>> Ah, sorry, this changes *a lot*. Let's start the bikeshed again
>>> then, whatever.
>>>
>> I haven't looked at the implementation, but I wonder if we need a
>> function for such trivial stuff. Most maintainers deal with this
>> problem using pkg_postinst() einfo/elog messages. Why do we need a
>> dedicated function for that? Just for consistency reasons...?
>
> Consistency, and because it removes the need for a bunch of "if
> has_version" lines, instead only displaying if you don't satisfy the
> deps (and supports both "and" and "or" groupings for packages
> satisfying the dep). This also stems from a complaint I've seen a lot
> about how optional dep messages should only display if the requisite
> package isn't installed, this makes that job a little simpler. But
> mostly consistency, this gives us one nice function that we can
> standardize on.
>
> Chris Reffett
>
I am fine with that especially given it's an opt-in feature.
--
Regards,
Markos Chandras
^ 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