From nobody@FreeBSD.org  Wed Nov 14 01:59:37 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 91DC56E
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Nov 2012 01:59:37 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 7859E8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Nov 2012 01:59:37 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qAE1xaB6034819
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Nov 2012 01:59:36 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qAE1xaqc034818;
	Wed, 14 Nov 2012 01:59:36 GMT
	(envelope-from nobody)
Message-Id: <201211140159.qAE1xaqc034818@red.freebsd.org>
Date: Wed, 14 Nov 2012 01:59:36 GMT
From: Mamoru Sakaue <sakaue.mamoru@mwghennndo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Recovery of the functionality of COFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         173620
>Category:       ports
>Synopsis:       [bsd.port.mk] Recovery of the functionality of CONFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 14 02:00:00 UTC 2012
>Closed-Date:    
>Last-Modified:  Sat Jan 12 10:30:00 UTC 2013
>Originator:     Mamoru Sakaue
>Release:        8.3-RELEASE
>Organization:
MwGhennndo
>Environment:
FreeBSD Grubstake.EmpireNmw 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #0: Mon Jun 11 23:52:38 UTC 2012     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
CONFLICTS, CONFLICTS_BUILD and CONFLICTS_INSTALL don't work between ports with different default PREFIXs. For example, this problem arises between KDE4-related ports and the other ports. 

The current implementation of confliction check in bsd.port.mk is based on matching PREFIXs of the installing port and installed package as well as matching of the package name pattern given by CONFLICTS, CONFLICTS_BUILD and CONFLICTS_INSTALL with installed ones.

As the original intention, this mechanism will assume that PREFIX is customized only for manual relocation of installtion paths. However this rule is practically violated by some ports like KDE4-related ones which redefine PREFIX as /usr/local/kde4 by default.

In this patchwork, I propose a change of the macthing rule in bsd.port.mk so as to make it work correctly with the default configuration of the system.

Please note that this modification makes the matching rule stricter for packages installed in environments where PREFIX or LOCALBASE is explicitly customized, for example, temporal environment in "port test" command of ports-mgmt/porttools. In that case, DISABLE_CONFLICTS may be given as a make argument for countermeasure.
>How-To-Repeat:
With qt-3.* installed, try insallation of editors/calligra which defines "CONFLICTS_BUILD=qt-3.*"

# pkg_info -I qt-3.\*                                                                                                                                                             
qt-3.3.8_14         Multiplatform C++ application framework                                                                                                                         
# cd /usr/ports/editors/calligra
# make

Then no confliction is reported and the process continues to the build stage.
>Fix:
The current implementation gives conclusion of a conflicting package by macthing of the current PREFIX with PREFIX registered for the package whose package name matches any of patterns in CONFLICTS* variables.

I propose a new implementation that gives conclusion of a conflicting package by macthing of the default PREFIX of the package with the registered PREFIX of the package. If the default PREFIX cannot be evaluated because of moving or abolishment of the origin for the package, the conclusion is given as true.

This solution is not fundamental as well, but makes the situation more practical.


Patch attached with submission follows:

*** /usr/ports/Mk/bsd.port.mk.orig	2012-10-26 17:16:17.000000000 +0900
--- /usr/ports/Mk/bsd.port.mk	2012-11-14 09:14:23.000000000 +0900
***************
*** 3786,3792 ****
  		if ${PKG_INFO} -e $${entry} ; then \
  			prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
  			orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
! 			if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
  				conflicts_with="$${conflicts_with} $${entry}"; \
  			fi; \
  		fi; \
--- 3786,3793 ----
  		if ${PKG_INFO} -e $${entry} ; then \
  			prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
  			orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
! 			prfx_default=`${MAKE} -C "${PORTSDIR}/$${orgn}" -V PREFIX 2> /dev/null || :`; \
! 			if [ \( -z "$${prfx_default}" -o "/$${prfx_default}" = "/$${prfx}" \) -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
  				conflicts_with="$${conflicts_with} $${entry}"; \
  			fi; \
  		fi; \
***************
*** 3843,3849 ****
  		if ${PKG_INFO} -e $${entry} ; then \
  			prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
  			orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
! 			if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
  				conflicts_with="$${conflicts_with} $${entry}"; \
  			fi; \
  		fi; \
--- 3844,3851 ----
  		if ${PKG_INFO} -e $${entry} ; then \
  			prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
  			orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
! 			prfx_default=`${MAKE} -C "${PORTSDIR}/$${orgn}" -V PREFIX 2> /dev/null || :`; \
! 			if [ \( -z "$${prfx_default}" -o "/$${prfx_default}" = "/$${prfx}" \) -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
  				conflicts_with="$${conflicts_with} $${entry}"; \
  			fi; \
  		fi; \


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: arved 
Responsible-Changed-When: Wed Nov 21 17:06:44 UTC 2012 
Responsible-Changed-Why:  
bsd.port.mk patch 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173620 

From: Max Brazhnikov <makc@freebsd.org>
To: bug-followup@freebsd.org, sakaue.mamoru@mwghennndo.com
Cc:  
Subject: Re: ports/173620: [bsd.port.mk] Recovery of the functionality of CONFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
Date: Thu, 22 Nov 2012 13:58:45 +0000

 I agree about proposed changes for CONFLICTS_BUILD, but not for _INSTALL.
 CONFLICTS_INSTALL is intended for ports that install files in the same place.
 Obviously, such ports don't really conflict when installed into different prefixes.
 
 Max

From: SAKAUE Mamoru <sakaue.mamoru@mwghennndo.com>
To: bug-followup@freebsd.org, sakaue.mamoru@mwghennndo.com
Cc:  
Subject: Re: ports/173620: [bsd.port.mk] Recovery of the functionality of CONFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
Date: Fri, 23 Nov 2012 03:39:53 +0900

 I agree. Then only the first half of the patch should be applied.
 
 P.S.
 I revise the last paragraph of Description:
 -----------------------------------------------
 > Please note that this modification makes the matching rule stricter for
 > packages installed in environments where PREFIX or LOCALBASE is explicitly
 > customized, for example, temporal environment in "port test" command of
 > ports-mgmt/porttools. In that case, DISABLE_CONFLICTS may be given as a make
 > argument for countermeasure.
 ===>
 Please note that this modification makes the matching rule LOOSER among 
 packages installed in environments where PREFIX or LOCALBASE is explicitly 
 customized, for example, temporal environment in "port test" command of ports-
 mgmt/porttools. Another side effect is that the matching rule becomes stricter 
 for packages whose origins are moved or deleted. In that case, 
 DISABLE_CONFLICTS may be given as a make argument for countermeasure.
 -----------------------------------------------
 
 Mamoru Sakaue
 
 

From: Alberto Villa <avilla@FreeBSD.org>
To: bug-followup@freebsd.org, sakaue.mamoru@mwghennndo.com
Cc:  
Subject: Re: ports/173620: [bsd.port.mk] Recovery of the functionality of
 CONFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
Date: Wed, 9 Jan 2013 15:22:20 +0100

 > I agree about proposed changes for CONFLICTS_BUILD, but not for _INSTALL.
 > CONFLICTS_INSTALL is intended for ports that install files in the same place.
 > Obviously, such ports don't really conflict when installed into different prefixes.
 
 Ports that explicitly install in a prefix via @cwd are going to fail
 even with different PREFIX, anyway.

From: SAKAUE Mamoru <sakaue.mamoru@mwghennndo.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: ports/173620: [bsd.port.mk] Recovery of the functionality of CONFLICTS among ports with different default PREFIXs, ex., between KDE4 and others
Date: Sat, 12 Jan 2013 19:20:09 +0900

 Anyway, since PREFIX is redefined in several places of bsd.(gnustep|kde|kde4|
 python).mk so as NOT to inherit the predefined value as "grand" prefix, it 
 should not be recommended for users to control the installation paths by 
 giving a explicit PREFIX value to a make command unless they are really aware 
 of what to occur and are going to do everything on their own responsibilities.
 
 Only LOCALBASE and LINUXBASE will be favorable for such purposes because they 
 are defined in only one place at the head of bsd.ports.mk and LOCALBASE is 
 inherited for the redefinitions of PREFIX. Therefore, as an ideal solution, 
 the package database should record the values of LOCALBASE and LINUXBASE 
 rather than PREFIX for further judgment of confliction.
 
 I think that the current goal as a workaround should be to make CONFLICTS* 
 work as intended by the specification in the default configuration.
 
 
>Unformatted:
