HomeFreeBSD

Mk/bsd.port.mk: simplify conflicts checks logic

Description

Mk/bsd.port.mk: simplify conflicts checks logic

I had added support for the specification of a condition and package
name patterns to Version 1.17.2 of the pkg command. This change allows
to simplify the conflicts checks: instead of listing all packages that
match a name pattern and then apply a filter to select the relevant
values, the filter condition is now passed to the pkg command.

This update includes a change to the semantics of the conflicts check
which aligns the output with current package naming practices:

After the introduction of flavors a "same origin exclusion" was
introduced, which removed packages from the conflicts list when
they shared the same origin (without considering the flavor).
This was required to allow the installation of e.g. python modules
for different interpreter versions (which typically use interpreter
version specific sub-directories to store their files), at a time
when there was no strict requirement to have non-colliding package
base names.

The "same origin exclusion" is wrong for ports with conflicting
flavors, e.g. devel/git where only one flavor may be installed at
any time - but the conflict is ignored due to the same origin of
all the different git packages.

Since all packages are now required to have a distinct base name
(e.g. by using a prefix like "py38-" instead of the prior "py-"),
a "same package base name exclusion" can be used to make the
conflicts check stricter and to correctly report the conflict if
for example some git flavor is installed and the installation of
another one is attempted.

An update of the documentation of the CONFLICTS* variables that
describes the "same package base name exclusion" has been committed to
the porter's handbook.

The Makefiles of many flavored ports could be simplified as described
in review D31303 (https://reviews.freebsd.org/D31303), since the
complexity of those definitions results from the exclusion of the
currently built package base name from the CONFLICTS definition,
which was unneeded before (due to the "same origin exclusion",
which made all these CONFLICTS definitions void, anyway) and is now
correctly dealt with after this commit (due to the "same package
base name exclusion").

This patch has been first put up for review in October of 2021, with
a comment that it should not be applied before pkg-1.17.2 (or newer)
can be assumed to be generally used.

Bapt@ accepted the change but later requested the MINIMAL_PKG_VERSION
to be adjusted to require pkg-1.17.2 (as included in this commit).

Due to recent white-space changes in bsd.port.mk the latest patch
uploaded for review does no longer cleanly apply. This commit contains
an updated version that matches the white-space changes (indentation
of .if / .else / .endif and other elements).

Approved by: portmgr (bapt)
Differential Revision: https://reviews.freebsd.org/D32694