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

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Sat, 17 Dec 2022 00:03:22 UTC
Mel Pilgrim wrote on 2022/12/17 06:49:
> On 2022-12-13 19:34, Tatsuki Makino wrote:
>> 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.

Okay.
This is, after all, just like llvm-devel flavor of my earlier email.
It's time to pass the baton to people-familiar-with-flavor@FreeBSD :)

> 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?

For python, Mk/bsd.default-versions.mk is the way to fix the FLAVOR, but is there any way to know the FLAVOR of postfix or other pre-installed stuff?
I can only think of the following methods.

POSTFIX_PKGNAME!= pkg query %n mail/postfix || echo postfix-sqlite # use flavor @sqlite
.if empty(POSTFIX_PKGNAME:Mpostfix-*)
RUN_DEPENDS+= postfix>0:mail/postfix
.else
RUN_DEPENDS+= ${POSTFIX_PKGNAME}>0:mail/postfix@${POSTFIX_PKGNAME:S/postfix-//}
.endif

If that fails, it need to use other methods.
Using the same flavors as postfix, OPTIONS to choose postfix flavor or split into m@ster and sl@ve...

Regards.