Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 498988 - eutils.eclass: optfeature function
Summary: eutils.eclass: optfeature function
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2014-01-23 02:28 UTC by Chris Reffett (RETIRED)
Modified: 2023-05-20 08:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
eutils_add_optfeature.patch (eutils_add_optfeature.patch,933 bytes, patch)
2014-01-23 02:28 UTC, Chris Reffett (RETIRED)
Details | Diff
eutils_add_optfeature_v2.patch (eutils_add_optfeature.patch,1004 bytes, patch)
2014-01-23 03:41 UTC, Chris Reffett (RETIRED)
Details | Diff
eutils_add_optfeature_v2.patch (eutils_add_optfeature.patch,1004 bytes, patch)
2014-01-23 04:20 UTC, Chris Reffett (RETIRED)
Details | Diff
eutils_add_optfeature_v2.patch (eutils_add_optfeature.patch,1006 bytes, patch)
2014-01-23 04:30 UTC, Chris Reffett (RETIRED)
Details | Diff
eutils_add_optfeature_v3.patch (eutils_add_optfeature_v3.patch,1.80 KB, patch)
2014-01-23 04:43 UTC, Andrew Hamilton
Details | Diff
eutils_add_optfeature_v4.patch (eutils_add_optfeature_v4.patch,1.35 KB, patch)
2014-01-23 05:23 UTC, Andrew Hamilton
Details | Diff
eutils_add_optfeature_v6.patch (eutils_add_optfeature_v5.patch,1.31 KB, patch)
2014-01-23 05:42 UTC, Andrew Hamilton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Reffett (RETIRED) gentoo-dev Security 2014-01-23 02:28:44 UTC
Created attachment 368498 [details, diff]
eutils_add_optfeature.patch

Attached is a patch to add the function "optfeature()" to eutils. The function is tweaked from one that floppym uses in net-misc/netctl, which apparently was in turn borrowed and tweaked from one mgorny wrote.
The general idea is that you call optfeature "description" cat-egory/package and if package isn't installed it will suggest cat-egory/package for (description). It can take multiple packages as arguments for when one of several packages would meet the optional dependency as well. This would be used in conjunction with an elog message saying something like "This package has several optional dependencies, consider installing:". I could also see this being handled as some sort of bash array (say, OPTDEPENDS), but I'm not proficient enough in bash to figure out how that might work out.
Comment 1 Mike Gilbert gentoo-dev 2014-01-23 02:44:13 UTC
If I pass multiple atoms and one of the latter ones is installed, the function will still print the ones preceding it, but not any that come after.

For example, if I have cat/b installed, and I make this call:

optfeature foobar cat/a cat/b cat/c

The output would be:

  cat/a for foobar
Comment 2 Chris Reffett (RETIRED) gentoo-dev Security 2014-01-23 03:41:20 UTC
Created attachment 368506 [details, diff]
eutils_add_optfeature_v2.patch

Updated to test whether any of the packages are installed, and only display if none are.
Comment 3 Chris Reffett (RETIRED) gentoo-dev Security 2014-01-23 04:20:25 UTC
Created attachment 368508 [details, diff]
eutils_add_optfeature_v2.patch

Fixed typo as well
Comment 4 Chris Reffett (RETIRED) gentoo-dev Security 2014-01-23 04:30:53 UTC
Created attachment 368510 [details, diff]
eutils_add_optfeature_v2.patch

And put the function within the if/fi preventing multiple inherits
Comment 5 Andrew Hamilton 2014-01-23 04:43:39 UTC
Created attachment 368514 [details, diff]
eutils_add_optfeature_v3.patch

I've expanded the optfeature function a bit so that a feature can be provided by a set of multiple packages. Currently a set of packages is indicated with \( (the escaping is required by bash), however, I'm open to a better way of defining sets.
Comment 6 Andrew Hamilton 2014-01-23 05:23:21 UTC
Created attachment 368516 [details, diff]
eutils_add_optfeature_v4.patch

This patch modifies the previous patch so that sets are indicated by quoted strings (eg: "app-misc/foo app-misc/bar") rather than escaped parenthesis.
Comment 7 Andrew Hamilton 2014-01-23 05:42:23 UTC
Created attachment 368518 [details, diff]
eutils_add_optfeature_v6.patch

cleanup variable definitions
Comment 8 SpanKY gentoo-dev 2014-01-23 06:18:56 UTC
please post this to the gentoo-dev@ list for review
Comment 9 Chris Reffett (RETIRED) gentoo-dev Security 2014-01-29 17:01:42 UTC
Reopening since we seem to have nothing more to say on -dev. Comments consisted of a non-substantive complaint about having discussed this before and a "I'm fine with this as long as it's opt-in." Is that enough review for the patch to be added?
Comment 10 William Hubbs gentoo-dev 2014-03-12 23:37:17 UTC
I looked at the patch and it looks good to me. Does anyone else in
base-system have an objection to this going in?
Comment 11 William Hubbs gentoo-dev 2014-03-12 23:40:54 UTC
@creffett:
I would commit the patch sometime tomorrow if no one objects.
Comment 12 Chris Reffett (RETIRED) gentoo-dev Security 2014-03-15 00:47:56 UTC
In the absence of any objections, this has been committed.
Comment 13 SpanKY gentoo-dev 2014-04-27 18:59:55 UTC
the documentation was broken (invalid use of @CODE).  the style was broken (missing braces with vars).  i've fixed those:
http://sources.gentoo.org/eclass/eutils.eclass?r1=1.432&r2=1.433

however, the current code still has bad expansion logic.  when you do:

 optfeature "bar support" app-misc/bar app-misc/baz[bar]
 ...
 for i; do
   for j in ${i}; do

that will wrongly try to do expansion on ${i}.  you can disable shell options to avoid it (like path expansion), but i'd just say drop the support entirely.  is it really necessary to pack it into one call ?
Comment 14 Larry the Git Cow gentoo-dev 2021-01-11 20:33:23 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c584e31cf0861c94332a5350614912b073616bc

commit 1c584e31cf0861c94332a5350614912b073616bc
Author:     David Seifert <soap@gentoo.org>
AuthorDate: 2021-01-11 20:33:09 +0000
Commit:     David Seifert <soap@gentoo.org>
CommitDate: 2021-01-11 20:33:09 +0000

    optfeature.eclass: [QA] Fix unwanted globbing
    
    Closes: https://bugs.gentoo.org/498988
    Reported-by: Mike Frysinger <vapier@gentoo.org>
    Suggested-by: Ulrich Müller <ulm@gentoo.org>
    Signed-off-by: David Seifert <soap@gentoo.org>

 eclass/optfeature.eclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)