Re: [gentoo-dev] [PATCH v2 2/3] ruby-ng.eclass: don't quote IUSE in has test

2023-03-29 Thread Sam James

Ulrich Mueller  writes:

>> On Wed, 29 Mar 2023, Sam James wrote:
>
>> -if ! has test "$IUSE"; then
>> +if ! has test ${IUSE}; then
>
> You cannot reliably test for a flag in IUSE with code like this.
> PMS defines the function in_iuse() for this (unless the above is
> in global scope, in which case you're out of luck).

Yep, it is, unfortunately. I can try ripping it out entirely given it's
not reliable, depending on how others feel about it.


signature.asc
Description: PGP signature


Re: [gentoo-dev] [PATCH v2 2/3] ruby-ng.eclass: don't quote IUSE in has test

2023-03-29 Thread Ulrich Mueller
> On Wed, 29 Mar 2023, Sam James wrote:

> - if ! has test "$IUSE"; then
> + if ! has test ${IUSE}; then

You cannot reliably test for a flag in IUSE with code like this.
PMS defines the function in_iuse() for this (unless the above is
in global scope, in which case you're out of luck).

Ulrich



[gentoo-dev] [PATCH v2 2/3] ruby-ng.eclass: don't quote IUSE in has test

2023-03-29 Thread Sam James
I was looking at the generated metadata for nokogiri and noticed several
instances of 'test' in IUSE & RESTRICT. Ended up finding that the quoting
of 'IUSE' in has is wrong here.

This isn't explicitly wrong, but it's a bit ugly in the generated metadata,
and I'm not convinced Portage handles duplicates correctly (see e.g.
the duplicate || ( ... ) issue in *DEPEND).

This doesn't fix all instances and to be honest, it's a bit dubious given 
has_iuse
doesn't work in global scope, but let's just fix the thing which is definitely
wrong (the quoting).

This does change the metadata generated in the way I expected, but it doesn't
remove *all* duplicates.

Signed-off-by: Sam James 
---
 eclass/ruby-ng.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
index b81038237a6b..b63dd19e18f2 100644
--- a/eclass/ruby-ng.eclass
+++ b/eclass/ruby-ng.eclass
@@ -234,7 +234,7 @@ ruby_add_rdepend() {
6) DEPEND="${DEPEND} test? ( ${dependency} )" ;;
*) BDEPEND="${BDEPEND} test? ( ${dependency} )" ;;
esac
-   if ! has test "$IUSE"; then
+   if ! has test ${IUSE}; then
IUSE+=" test"
RESTRICT+=" !test? ( test )"
fi
-- 
2.40.0