Page MenuHomeFreeBSD

Simplify CONFLICTS definitions
Needs ReviewPublic

Authored by se on Jul 12 2021, 3:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 15, 2:46 PM
Unknown Object (File)
Mon, Apr 15, 1:56 PM
Unknown Object (File)
Mon, Apr 15, 1:54 PM
Unknown Object (File)
Mar 19 2024, 11:37 PM
Unknown Object (File)
Feb 11 2024, 8:50 PM
Unknown Object (File)
Jan 24 2024, 2:46 AM
Unknown Object (File)
Dec 20 2023, 2:53 AM
Unknown Object (File)
Dec 12 2023, 4:43 AM

Details

Reviewers
None
Group Reviewers
portmgr
Summary

The conflicts check historically treated packages from the same origin as generally non-conflicting.
The reason might have been that packages built from the same origin for different FLAVORs might have matching package names, but might be able to co-exist.

There have been 2 changes that cause this assumption to no longer be valid:

  • FLAVORS lead to conflicting packages that can not co-exist, e.g. "git" and "git-lite".
  • Package names have been made unique for each FLAVOR.

As a result, the same origin exception from the conflicts tests voids CONFLICTS definitions in a port's Makefile with conflicting FLAVORs.
E.g. devel/git has a CONFLICTS definition that excludes all other FLAVORS, but the conflict is not reported due to the same origin exception.

The patch replaces the exclusion of ports from the same origin by exclusion of ports with the same basename.
This is required, since there are ports that conflict with themselves, but this was not reported due to the same origin exclusion.

Excluding ports with the same basename instead of from the same origin has another advantage:

After the introduction of FLAVORs, many ports got FLAVOR dependent CONFLICT definitions, e.g. in devel/git:

FLAVORS=        default gui lite svn tiny
default_CONFLICTS_INSTALL=      git-gui git-lite git-svn git-tiny
gui_CONFLICTS_INSTALL=          git git-lite git-svn git-tiny
lite_CONFLICTS_INSTALL=         git git-gui git-svn git-tiny
svn_CONFLICTS_INSTALL=          git git-gui git-lite git-tiny
tiny_CONFLICTS_INSTALL=         git git-gui git-svn git-lite

Each of these CONFLICTS definitions covers all FLAVORs except the one selected to be built, and this is a common schema found in many ports, e.g. here the one from editors/emacs, but there are ports that support more flavors and thus have longer lists of CONFLICTS definitions:

FLAVORS=                        full canna nox
canna_CONFLICTS_INSTALL=        emacs emacs-nox
full_CONFLICTS_INSTALL=         emacs-canna emacs-nox
nox_CONFLICTS_INSTALL=          emacs emacs-canna

The suggested patch simplifies the CONFLICTS definitions by allowing the ${PKGBASE} of the port being built to be specified in the list, but not excluded from the conflicts that are reported.

FLAVORS=                default gui lite svn tiny
CONFLICTS_INSTALL=      git git-gui git-lite git-svn git-tiny

Or:

FLAVORS=                  full canna nox
CONFLICTS_INSTALL=        emacs emacs-canna emacs-nox

A conflict of a package with itself does not make sense and is caught in other parts of the ports system (e.g. when trying to install a new version of a package without prior de-installation of an old version). Insofar a package is always conflicting with (all versions) of itself, but due to the fact that it is generally de-installed before the new installation is performed, this is not an issue at port build time.

The proposed patch removes the "conflicts with itself" case from check-build-conflicts, too. It is possible to only apply the chunks that correspond to the install conflicts change, since most ports that I looked at actually use CONFLICTS_INSTALL, not CONFLICTS or CONFLICTS_BUILD in this way.

The change would not have any immediate effect, since ports already use these complex CONFLICTS definitions. It is a pre-requisite for a later simplification of the CONFLICTS definitions when a port is upgraded.

Test Plan

Apply test and verify that with the patch:

  • git and git-lite are reported as conflicting with each other (without the patch suppressed by the "same origin exclusion")
  • git is not reported as conflicting with itself

See D30891 for further comments and details (but that patch was incomplete and did not exclude self-conflicting ports).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

se requested review of this revision.Jul 12 2021, 3:09 PM
se created this revision.

Thanks for all the work you put into this, Stefan!
Having done it the way it's always been done all these years.
This all seemed initially unintuitive. But it's elegant in it's
simplicity, and simplicity is something I can easily get used to. ;-)
Everything looks right to me. So if I have anything to say about
this; consider this an approval. I'm looking forward to it's adoption.

Updated patch that takes advantage of the extended functionality of pkg-1.17.2 with regard to the combination of "query -e" and additional port or package names.

This allows to convert the while loop that filters out some of the results (e.g. with mismatched prefix) into a -e filter condition.

se edited the summary of this revision. (Show Details)
se edited the test plan for this revision. (Show Details)

Revert import of a patch that uses the new "pkg query -e" feature of pkg-1.17.2 and newer.

The now reverted patch had the required functionality to fix the CONFLICTS checks, but works with any version of the pkg command that was usable without this patch.
The patch that requires pkg>=1.17.2 has been submitted for review as https://reviews.freebsd.org/D32694 .
It is functionally identical, but replaces the while loop with a -e condition option of the query command.

0mp added inline comments.
Mk/bsd.port.mk
3344

I've not really reviewed the patch but set -x here is probably not needed.

Mk/bsd.port.mk
3344

Yes, this is a remnant from testing and not to be committed.
Thanks for reporting - I'll update the patch.

Remove "set -x" that should have been deleted after testing the change.

se marked an inline comment as done.Jan 12 2022, 12:08 PM

The previous upload did not only remove the left over "set -x", but accidentally also the "do" keyword preceding it.

The previous update contained another typo ...