git: d21825d73a9c - main - Mk/bsd.port.mk: simplify conflicts checks logic
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 24 Apr 2022 11:43:08 UTC
The branch main has been updated by se: URL: https://cgit.FreeBSD.org/ports/commit/?id=d21825d73a9c3421e28a7bf6fcf1b342bb692315 commit d21825d73a9c3421e28a7bf6fcf1b342bb692315 Author: Stefan Eßer <se@FreeBSD.org> AuthorDate: 2022-04-24 11:40:03 +0000 Commit: Stefan Eßer <se@FreeBSD.org> CommitDate: 2022-04-24 11:40:03 +0000 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). [This change had previously been applied as commit e03f85dbc9c, but during a last minute white space adjustment 1 line had been lost. This commit applies the change as has been accepted in the review, updated to match the recent white-space changes.] Approved by: portmgr (bapt) Differential Revision: https://reviews.freebsd.org/D32694 --- Mk/bsd.port.mk | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk index f1e258672484..e060d8fbf747 100644 --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -1047,7 +1047,7 @@ _FLAVOR:= ${FLAVOR} .if !defined(PORTS_FEATURES) && empty(${PORTS_FEATURES:MFLAVORS}) PORTS_FEATURES+= FLAVORS .endif -MINIMAL_PKG_VERSION= 1.15.9 +MINIMAL_PKG_VERSION= 1.17.2 _PORTS_DIRECTORIES+= ${PKG_DBDIR} ${PREFIX} ${WRKDIR} ${EXTRACT_WRKDIR} \ ${STAGEDIR}${PREFIX} ${WRKDIR}/pkg ${BINARY_LINKDIR} @@ -3294,13 +3294,7 @@ check-conflicts: check-build-conflicts check-install-conflicts . if !target(check-build-conflicts) check-build-conflicts: . if ( defined(CONFLICTS) || defined(CONFLICTS_BUILD) ) && !defined(DISABLE_CONFLICTS) && !defined(DEFER_CONFLICTS_CHECK) - @conflicts_with=$$( \ - { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \ - | while read pkgname prfx orgn; do \ - if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \ - ${ECHO_CMD} -n " $${pkgname}"; \ - fi; \ - done); \ + @conflicts_with=$$(${PKG_QUERY} -ge "%n != ${PKGBASE}" "%n-%v" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; ) ; \ if [ -n "$${conflicts_with}" ]; then \ ${ECHO_MSG}; \ ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \ @@ -3319,13 +3313,7 @@ check-build-conflicts: CONFLICT_WARNING_WAIT?= 10 identify-install-conflicts: . if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) ) && !defined(DISABLE_CONFLICTS) - @conflicts_with=$$( \ - { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \ - | while read pkgname prfx orgn; do \ - if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \ - ${ECHO_CMD} -n " $${pkgname}"; \ - fi; \ - done); \ + @conflicts_with=$$(${PKG_QUERY} -ge "%n != ${PKGBASE}" "%n-%v" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; ) ; \ if [ -n "$${conflicts_with}" ]; then \ ${ECHO_MSG}; \ ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \ @@ -3344,13 +3332,7 @@ identify-install-conflicts: check-install-conflicts: . if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) || ( defined(CONFLICTS_BUILD) && defined(DEFER_CONFLICTS_CHECK) ) ) && !defined(DISABLE_CONFLICTS) . if defined(DEFER_CONFLICTS_CHECK) - @conflicts_with=$$( \ - { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \ - | while read pkgname prfx orgn; do \ - if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \ - ${ECHO_CMD} -n " $${pkgname}"; \ - fi; \ - done); \ + @conflicts_with=$$(${PKG_QUERY} -ge "%n != ${PKGBASE}" "%n-%v" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; ) ; \ if [ -n "$${conflicts_with}" ]; then \ ${ECHO_MSG}; \ ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \ @@ -3362,13 +3344,7 @@ check-install-conflicts: exit 1; \ fi . else - @conflicts_with=$$( \ - { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \ - | while read pkgname prfx orgn; do \ - if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \ - ${ECHO_CMD} -n " $${pkgname}"; \ - fi; \ - done); \ + @conflicts_with=$$(${PKG_QUERY} -ge "%n != ${PKGBASE}" "%n-%v" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; ) ; \ if [ -n "$${conflicts_with}" ]; then \ ${ECHO_MSG}; \ ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \