Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 373139 - ruby-ng.eclass should support optional dependencies on the ruby interpreter/implementation (for RUBY_OPTIONAL=yes)
Summary: ruby-ng.eclass should support optional dependencies on the ruby interpreter/i...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-26 19:08 UTC by Nathan Phillip Brink (binki) (RETIRED)
Modified: 2011-07-22 09:41 UTC (History)
0 users

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


Attachments
ruby-ng.eclass-optional-implementations-depend.patch (ruby-ng.eclass-optional-implementations-depend.patch,2.40 KB, patch)
2011-06-26 19:08 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-06-26 19:08:17 UTC
Created attachment 278261 [details, diff]
ruby-ng.eclass-optional-implementations-depend.patch

When an ebuild sets RUBY_OPTIONAL=yes, it is suddenly responsible to run the following loop in the global scope on its own:

    for _ruby_implementation in ${USE_RUBY}; do
        DEPEND+=" ruby? ( ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) ) )"
        RDEPEND+=" ruby? ( ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) ) )"
    done

(This example assumes a library which provides a ruby interface wrapper which can be optionally installed if USE=ruby is enabled).

As seen above, this (untested, sorry) code should be correct: it only uses the publically exposed ruby_implementation_depend() function. However, it depends on something that is slightly internal to the ruby-ng.eclass -- the use of ruby_targets_${ruby_target} which is normally hidden by ruby_add_rdepend() and ruby_add_bdepend(). Also, this sort of code would likely be needed by certain ebuilds and/or ebuild authors will consider hardcoding the results of running this code to provide optional ruby support.

I propose the function ruby_implementations_depend(). This function unfortunately has a very similar name to ruby_implementation_depend(). This function outputs the string which ruby-ng.eclass normally appends to RDEPEND and DEPEND when RUBY_OPTIONAL is unset. Use example:

    EAPI=4

    RUBY_OPTIONAL=yes
    USE_RUBY=ruby18\ ruby19

    inherit ruby-ng

    IUSE="ruby"
    DEPEND="ruby? ( $(ruby_implementations_depend) )"
    RDEPEND="${RDEPEND}"

Patch was tested by examining ${T}/environment to confirm that RUBY_OPTIONAL=yes has the same effect, having RUBY_OPTIONAL unset has the same effect, and that using $(ruby_implementations_depend) have expected effects upon DEPEND and RDEPEND.
Comment 1 Hans de Graaff gentoo-dev Security 2011-06-26 19:15:25 UTC
I discussed this briefly with Nathan on IRC already. Patch looks good to me.

Alex, Diego: please review also and provide feedback.
Comment 2 Diego Elio Pettenò (RETIRED) gentoo-dev 2011-07-14 08:52:40 UTC
LGTM.
Comment 3 Hans de Graaff gentoo-dev Security 2011-07-22 09:41:38 UTC
Applied to ruby-ng.eclass. Thanks!