Re: How do I depend on a port regardless of its flavor?

From: Mel Pilgrim <list_freebsd_at_bluerosetech.com>
Date: Fri, 16 Dec 2022 21:49:16 UTC
On 2022-12-13 19:34, Tatsuki Makino wrote:
> Mel Pilgrim wrote on 2022/12/12 02:52:
>> But I need to also specify a version spec.  However, if I do this:
>> 
>> RUN_DEPENDS= foo>=1.2:devel/foo
>> 
>> That only works if the default flavor is installed.  If one of the 
>> non-default flavors is installed, the Ports System doesn't find it 
>> and tries to build the port.  Similarly, pkg thinks I need to 
>> install the default flavor.
>> 
>> The flavors aren't part of a framework like Python, so I don't
>> have a set of variables I can use to construct a universal pkg
>> name.
>> 
>> How do I add a version-limited dependency on a flavored port?
> 
> Is this simply about the following?
> 
> RUN_DEPENDS= foo>=1.2:devel/foo@nondefaultflavor

No, that makes the port depend on that specific flavor.  I need to allow 
any flavor to be installed.

> The majority of the Python module is like this.

Yes and, per my original post, this is about depending on a port that 
doesn't have such a framework around it.

For example, let's say I have a run dependency on postfix.  It has six 
flavors:

# pkg search -qL pkg-name mail/postfix$
postfix-sqlite-3.7.3_1,1
postfix-sasl-3.7.3_1,1
postfix-pgsql-3.7.3_1,1
postfix-3.7.3_1,1
postfix-ldap-3.7.3_1,1
postfix-mysql-3.7.3_1,1

As all six flavors will provide what is needed in this example 
situation, there is no reason to limit which one the user can install.

If I have this:

RUN_DEPENDS= postfix>=3.7.3:mail/postfix

and the user has, say, postfix-sqlite-3.7.3_1,1 installed, then the 
Ports System will think the dependency isn't met and try to build 
mail/postfix.  Pkg will similarly not see postfix-sqlite-3.7.3_1,1 as a 
viable dependency due to the pkgname mismatch, try to install postfix, 
and fail on the conflict.

However, if I have this:

RUN_DEPENDS= postfix:mail/postfix

and user has postfix-sqlite-3.7.3_1,1 installed, the Ports System will 
see that as meeting the depedency because the lack of version spec 
reduces the check to seeing if "postfix" is a file.  Since all flavors 
of postfix install that program, all of them meet it.  But now I can't 
specify a version restriction.

So, in this specific example, the question becomes:

What format does the RUN_DEPENDS line need to take to declare that any 
flavor of postfix will meet the requirement so that the user can install 
any flavor they want either via Ports or pkg?

I'm asking because, given this problem was created by the FLAVORS 
implementation modifying pkgname, it must be just a matter of outdated 
documentation that the Porter's Handbook doesn't say how to handle this 
case.

I mean, no one would be mad enough to choose that approach and not 
update the dependency solver(s) to handle it, right?