Bug 250335 - ports-mgmt/portmaster: tries to build devel/git@lite even if devel/git@default is already installed
Summary: ports-mgmt/portmaster: tries to build devel/git@lite even if devel/git@defaul...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
Depends on:
Reported: 2020-10-14 10:44 UTC by Martin Birgmeier
Modified: 2021-06-01 13:28 UTC (History)
5 users (show)

See Also:
fernape: maintainer-feedback? (se)

Part of script script.log sh -x `which \portmaster` -n java/eclipse (3.20 KB, text/plain)
2020-10-15 05:37 UTC, Tatsuki Makino
no flags Details
Remove Flavor git@lite (456 bytes, patch)
2021-05-05 12:53 UTC, Gian-Simon Purkert
no flags Details | Diff
Patch to make conflicts check not ignore same origin packages (1.73 KB, patch)
2021-06-01 13:28 UTC, Stefan Eßer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2020-10-14 10:44:42 UTC
- FreeBSD 12.1
- Ports at head
- devel/git is installed
- all other dependencies for java/eclipse are installed (note that java/eclipse depends on devel/git@lite)
- execute "portmaster java/eclipse"

- portmaster tries to build and install devel/git@lite and java/eclipse
- Not unexpectedly, this fails with

----------------------------------- snip -----------------------------------
===>>> eclipse-4.16 >> devel/git@lite (1/1)

===>  Installing for git-lite-2.28.0
===>  Checking if git-lite is already installed
===>   Registering installation for git-lite-2.28.0 as automatic
Installing git-lite-2.28.0...
pkg-static: git-lite-2.28.0 conflicts with git-2.28.0 (installs files into the same place).  Problematic file: /usr/local/bin/git
*** Error code 70

make[1]: stopped in /a/SRC/FreeBSD-ports/head/devel/git
*** Error code 1

make: stopped in /a/SRC/FreeBSD-ports/head/devel/git

===>>> Installation of git-lite-2.28.0 (devel/git@lite) failed
===>>> Aborting update

===>>> Update for devel/git@lite failed
===>>> Aborting update

===>>> You can restart from the point of failure with this command line:
       portmaster <flags> java/eclipse devel/git@lite 

This command has been saved to ~/portmasterfail.txt
----------------------------------- snip -----------------------------------

Expected result:
- portmaster detects that devel/git is already installed and compiles java/eclipse without building devel/git@lite first.

- This might also be a problem in the way flavors are used in the devel/git port. It does not seem they are used quite correctly because different flavors should install into different locations. It does not seem that flavors are intended to distinguish between different default port options as done in that port.

-- Martin
Comment 1 Tatsuki Makino 2020-10-15 04:14:18 UTC
> - devel/git is installed

/usr/bin/which -s git is executed to determine this.
Which line of "depends on executable: git" outside of snip is "- found" or "- not found"?
Comment 2 Tatsuki Makino 2020-10-15 05:37:43 UTC
Created attachment 218750 [details]
Part of script script.log sh -x `which \portmaster` -n java/eclipse

comment #1 had nothing to do with it at all...
So I'll provide a log of script that may be relevant :)
Comment 3 Fernando Apesteguía freebsd_committer 2020-10-27 08:21:39 UTC
^Triage: notify maintainer
Comment 4 Gian-Simon Purkert 2021-04-14 10:30:38 UTC
Have exactly the same problem with FB12.2

Install eclipse with portmaster but eclipse wants git@lite even when git is already installed.

Maybe remove flavor in Makefile?
Comment 5 Stefan Eßer freebsd_committer 2021-04-19 11:03:00 UTC
This should have been fixed with commit a18733148a22a230caabc9295ef99c5840bdc43d on 2020-04-08. Please text again and re-open the PR if the issue persists.

The cause was an optimization in portmaster, which made it skip the expensive conflicts check if there were no lines starting with "CONFLICTS" in the Makefile.

In devel/git/Makefile there are CONFLICTS definitions for each FLAVOR, prefixed by the flavor name, e.g. "lite_CONFLICTS_INSTALL", which did not match the regular expression ^CONFLICTS.

This used to work in a pre-FLAVORs world, and while the regular expression could be made less strict, this would not have solved an issue in some other port, which got its CONFLICTS definitions only by including another port's Makefile.

Therefore the optimization had to be removed, somewhat slowing down portmaster since it now has to invoke a complex shell script to test for conflicts with installed packages even for ports that do not have any CONFLICTS defined.
Comment 6 Gian-Simon Purkert 2021-05-05 12:52:54 UTC
Still the same Problem:

Installing git-lite-2.31.1_1...
pkg-static: git-lite-2.31.1_1 conflicts with git-2.31.1_1 (installs files into the same place).  Problematic file: /usr/local/bin/git
*** Error code 1

make[1]: stopped in /usr/ports/devel/git
*** Error code 1

make: stopped in /usr/ports/devel/git

===>>> Installation of git-lite-2.31.1_1 (devel/git@lite) failed
===>>> Aborting update

===>>> Update for devel/git@lite failed
===>>> Aborting update

===>>> You can restart from the point of failure with this command line:
       portmaster <flags> java/eclipse devel/git@lite
Comment 7 Gian-Simon Purkert 2021-05-05 12:53:39 UTC
Created attachment 224691 [details]
Remove Flavor git@lite
Comment 8 Stefan Eßer freebsd_committer 2021-05-05 14:58:43 UTC
I guess I see what's going on: normally the conflict is due to a different port providing the same functionality (e.g. the different samba4xx ports).

Here the conflict is due to the FLAVOR, and the match from package name to the FLAVOR that leads to some package name prefix cannot easily be queried from the port. (I.e. there is no mechanism that lets me identify FLAVOR=lite as the condition for the git-lite package name, it is not correct to assume that the flavor is generally the last part of a package name, for example.)

A possible fix could be to look for a conflicting port with the same origin (port directory) registered in the package database. It could then be assumed that the conflicting port already satisfies the dependency requirement (which may or may not be true - and there is no heuristic that I can think of that might always give a reasonable answer to this question).

I have been working on a portmaster rewrite for quite some time, and the new implementation will be able to deal with this issue. Therefore I do not want to spend a lot of effort trying to get it fixed in this portmaster implementation - it would only take time away from the re-implementation project.
Comment 9 Stefan Eßer freebsd_committer 2021-06-01 13:28:19 UTC
Created attachment 225451 [details]
Patch to make conflicts check not ignore same origin packages

Another comment regarding the root cause of this issue:

CONFLICTS_INSTALL is treated differently in bsd.port.mk and by the pkg command.

In bsd.port.mk no output is generated by "make check-install-conflicts" for conflicting packages, if the origin is the same. This is despite all other variants than for the currently built FLAVOR are listed in the *_INSTALL_CONFLICTS variables for each FLAVOR.

And since "git" and "git-lite" both have the same origin, "make check-install-conflicts" does not list them as conflicting.

The pkg command does not care for the origin, and it detects the conflict.

IMHO, the test in bsd.port.mk should be aligned with the one in the pkg command to give an early indication of the conflict that else will only be detected during the install phase.

The attached patch does only remove the comparison with $orgn - a more complete patch would remove %o from the pkg query string and orgn from the while loop.
This patch is only meant to demonstrate the effect on the output of "make check-install-conflicts" and to show that it fixes the issue reported in this PR.