From sem@ciam.ru  Thu Jan 16 08:15:22 2003
Return-Path: <sem@ciam.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5D57437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Jan 2003 08:15:22 -0800 (PST)
Received: from mail.ciam.ru (main.ciam.ru [213.147.57.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BAED843F18
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Jan 2003 08:15:20 -0800 (PST)
	(envelope-from sem@ciam.ru)
Received: from exim by mail.ciam.ru with drweb-scanned (Exim 3.36 #1)
	id 18ZCfm-0002U5-00
	for FreeBSD-gnats-submit@freebsd.org; Thu, 16 Jan 2003 19:15:18 +0300
Received: from sem by mail.ciam.ru with local (Exim 3.36 #1)
	id 18ZCfm-0002Tu-00
	for FreeBSD-gnats-submit@freebsd.org; Thu, 16 Jan 2003 19:15:18 +0300
Message-Id: <E18ZCfm-0002Tu-00@mail.ciam.ru>
Date: Thu, 16 Jan 2003 19:15:18 +0300
From: Sergey Matveychuk <sem@ciam.ru>
Reply-To: Sergey Matveychuk <sem@ciam.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Port conflict Checking for bsd.port.mk
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         47146
>Category:       ports
>Synopsis:       Port conflict Checking for bsd.port.mk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 16 08:20:02 PST 2003
>Closed-Date:    Mon May 05 22:16:19 PDT 2003
>Last-Modified:  Mon May 05 22:16:19 PDT 2003
>Originator:     Sergey Matveychuk <sem@ciam.ru>
>Release:        FreeBSD 4.7-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD proxy.ciam.ru 4.7-RELEASE-p3 FreeBSD 4.7-RELEASE-p3 #0: Wed Jan 8 16:30:29 MSK 2003 root@orion.ciam.ru:/usr/obj/usr/src/sys/PROXY i386


	
>Description:
	

This patch is based on Scot W. Hetzel PR ports/13650 and rewriten by me.

Currently, we have no way of checking our installed ports for conflicting 
files when a port/package is being installed.

With the attached patch to bsd.port.mk and pr bin/47145 (5.0-CURRENT)
applied to pkg_install tools or ports collection will be able to check 
the system for conflicting ports.

Place the following into a port's Makefile:

CONFLICTS=      apache*-1.2* apache*-1.3.[012345] apache-*+ssl_*

The CONFLICTS variable uses shell meta characters ( []*? ), to do
pattern matching on conflicting ports.

will result in @pkgcfl directives in its packing list.

@pkgcfl apache*-1.2*
@pkgcfl apache*-1.3.[012345]
@pkgcfl apache-*+ssl_*

bsd.port.mk will check for conflicting packages during the install of the
port.  If it detects a conflict, it will not install the port until the
offending port is removed from the system.

NOTE: By setting ENABLE_CONFLICTS to NO, it will disable conflict checking
      for the port install and for the building of the port's package.

Currently, the patch is set to allow Conflict checking for 5.0-CURRENT
but harmless with older versions because of checking ${PKGINSTALLVER} variable.

>How-To-Repeat:
	
>Fix:

	

--- /usr/ports/Mk/bsd.port.mk	Wed Nov 27 19:40:36 2002
+++ bsd.port.mk	Sun Dec  1 22:11:05 2002
@@ -39,6 +39,7 @@
 # OSREL			- The release version (numeric) of the operating system.
 # OSVERSION		- The value of __FreeBSD_version.
 # PORTOBJFORMAT	- The object format ("aout" or "elf").
+# PKGINSTALLVER - Version of pkg_install tool (-CURRENT only, empty for -STABLE)
 #
 # These variables are used to identify your port.
 #
@@ -297,6 +298,13 @@
 # DEPENDS_TARGET - The default target to execute when a port is calling a
 #				  dependency (default: "install").
 #
+# Conflict checking. Use if your port conflicts with annother port or version.
+#
+# CONFLICTS      - A list of package name patterns that the port conflicts with.
+#                  It's possible to use any shell metacharacters for pattern
+#                  matching. 
+#                  E.g. apache*-1.2* apache*-1.3.[012345] apache-*+ssl_*
+#
 # Various directory definitions and variables to control them.
 # You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
 #
@@ -1430,12 +1438,26 @@
 PKG_CMD?=		/usr/sbin/pkg_create
 PKG_DELETE?=	/usr/sbin/pkg_delete
 PKG_INFO?=		/usr/sbin/pkg_info
+
+# Does the pkg_install tools support Conflict Checking?
+# FIXME: Where should this code belong ([pre]/post/someother location)?
+PKGINSTALLVER!= ${PKG_INFO} -P 2>/dev/null | ${SED} -e 's/.*: //'
+.if ${PKGINSTALLVER} >= 20021201
+ENABLE_CONFLICTS?=	YES
+.else
+ENABLE_CONFLICTS=	NO
+.endif
+
 .if !defined(PKG_ARGS)
 .if exists(${COMMENT})
 PKG_ARGS=		-v -c ${COMMENT} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`" ${EXTRA_PKG_ARGS}
 .else
 PKG_ARGS=		-v -c -"${PORTCOMMENT}" -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`" ${EXTRA_PKG_ARGS}
 .endif
+# Only allow those systems that have the new pkg_create utility to use the CONFLICTS option
+.if defined(CONFLICTS) && ${ENABLE_CONFLICTS} == YES
+PKG_ARGS+=		-C "${CONFLICTS}"
+.endif
 .if exists(${PKGINSTALL})
 PKG_ARGS+=		-i ${PKGINSTALL}
 .endif
@@ -2226,6 +2248,7 @@
 	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
 	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
 	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
+	  CONFLICTS="${CONFLICTS}" \
 	${ALL_HOOK}
 .endif
 
@@ -2563,6 +2586,33 @@
 .endif
 .endif
 
+# Check conflicts
+
+.if !target(check-conflicts)
+check-conflicts:
+.if defined(CONFLICTS) && ${ENABLE_CONFLICTS} == YES
+	@${RM} -f ${WRKDIR}/.CONFLICTS
+.for conflict in ${CONFLICTS}
+	@found="`${LS} -d ${PKG_DBDIR}/${conflict} 2>/dev/null || ${TRUE}`"; \
+	if [ X"$$found" != X"" ]; then \
+		${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS; \
+	fi
+.endfor
+	@if [ -s ${WRKDIR}/.CONFLICTS ]; then \
+		found=`cat ${WRKDIR}/.CONFLICTS | ${SED} -e s'|${PKG_DBDIR}/||g' | tr '\012' ' '`; \
+		${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
+		for entry in $$found; do \
+				${ECHO_MSG} "                $$entry"; \
+		done; \
+		${ECHO_MSG}; \
+		${ECHO_MSG} "      They install the same files into the same place."; \
+		${ECHO_MSG} "      Please remove them first with pkg_delete(1)."; \
+		${RM} -f ${WRKDIR}/.CONFLICTS; \
+		exit 1;	\
+	fi
+.endif	# CONFLICTS
+.endif
+
 # Install
 
 .if !target(do-install)
@@ -2842,10 +2892,10 @@
 				post-build post-build-script
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-categories check-already-installed \
-				check-umask run-depends lib-depends install-mtree pre-install \
-				pre-install-script do-install generate-plist post-install \
-				post-install-script compress-man run-ldconfig fake-pkg \
-				security-check
+			    check-conflicts check-umask run-depends lib-depends \
+				install-mtree pre-install pre-install-script do-install \
+				generate-plist post-install post-install-script compress-man \
+				run-ldconfig fake-pkg security-check
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: arved 
Responsible-Changed-When: Thu Jan 16 11:13:32 PST 2003 
Responsible-Changed-Why:  
Over to Maintainers 

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

From: Sergey Matveychuk <sem@ciam.ru>
To: freebsd-gnats-submit@FreeBSD.org, sem@ciam.ru
Cc:  
Subject: Re: ports/47146: Port conflict Checking for bsd.port.mk
Date: Thu, 06 Mar 2003 00:16:04 +0300

 This is a multi-part message in MIME format.
 --------------040006050802030501040503
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Here is a new version of patch adapted to new version of bsd.port.mk.
 
 --------------040006050802030501040503
 Content-Type: text/plain;
  name="bsd.port.mk.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="bsd.port.mk.patch"
 
 --- /usr/ports/Mk/bsd.port.mk	Mon Feb 17 00:22:15 2003
 +++ bsd.port.mk	Mon Feb 17 02:19:30 2003
 @@ -309,6 +309,14 @@
  # DEPENDS_TARGET - The default target to execute when a port is calling a
  #				  dependency (default: "install").
  #
 +# Conflict checking. Use if your port conflicts with annother port or version.
 +#
 +# CONFLICTS      - A list of package name patterns that the port conflicts with.
 +#                  It's possible to use any shell metacharacters for pattern
 +#                  matching.
 +#                  E.g. apache*-1.2* apache*-1.3.[012345] apache-*+ssl_*
 +#
 +#
  # Various directory definitions and variables to control them.
  # You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
  #
 @@ -1454,6 +1462,12 @@
  PKG_CMD?=		/usr/sbin/pkg_create
  PKG_DELETE?=	/usr/sbin/pkg_delete
  PKG_INFO?=		/usr/sbin/pkg_info
 +
 +# Does the pkg_install tools support Conflict Checking?
 +PKGINSTALLVER!= ${PKG_INFO} -P 2>/dev/null | ${SED} -e 's/.*: //'
 +.if ${PKGINSTALLVER} < 20030217
 +DISABLE_CONFLICTS=     YES
 +.endif
  .if !defined(PKG_ARGS)
  PKG_ARGS=		-v -c ${COMMENTFILE} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`" ${EXTRA_PKG_ARGS}
  .if exists(${PKGINSTALL})
 @@ -1474,6 +1488,9 @@
  .if defined(PKGORIGIN)
  PKG_ARGS+=		-o ${PKGORIGIN}
  .endif
 +.if defined(CONFLICTS) && !defined(DISABLE_CONFLICTS)
 +PKG_ARGS+=      -C "${CONFLICTS}"
 +.endif
  .endif
  .if defined(PKG_NOCOMPRESS)
  PKG_SUFX?=		.tar
 @@ -2276,6 +2293,7 @@
  	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
  	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
  	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
 +      CONFLICTS="${CONFLICTS}" \
  	${ALL_HOOK}
  .endif
  
 @@ -2613,6 +2631,33 @@
  .endif
  .endif
  
 +# Check conflicts
 +
 +.if !target(check-conflicts)
 +check-conflicts:
 +.if defined(CONFLICTS) && !defined(DISABLE_CONFLICTS)
 +	@${RM} -f ${WRKDIR}/.CONFLICTS
 +.for conflict in ${CONFLICTS}
 +	@found="`${LS} -d ${PKG_DBDIR}/${conflict} 2>/dev/null || ${TRUE}`"; \
 +	if [ X"$$found" != X"" ]; then \
 +		${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS; \
 +	fi
 +.endfor
 +	@if [ -s ${WRKDIR}/.CONFLICTS ]; then \
 +		found=`cat ${WRKDIR}/.CONFLICTS | ${SED} -e s'|${PKG_DBDIR}/||g' | tr '\012' ' '`; \
 +		${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
 +		for entry in $$found; do \
 +			${ECHO_MSG} "                $$entry"; \
 +		done; \
 +		${ECHO_MSG}; \
 +		${ECHO_MSG} "      They install the same files into the same place."; \
 +		${ECHO_MSG} "      Please remove them first with pkg_delete(1)."; \
 +		${RM} -f ${WRKDIR}/.CONFLICTS; \
 +		exit 1; \
 +	fi
 +.endif  # CONFLICTS
 +.endif
 +
  # Install
  
  .if !target(do-install)
 @@ -2892,10 +2937,10 @@
  				post-build post-build-script
  _INSTALL_DEP=	build
  _INSTALL_SEQ=	install-message check-categories check-already-installed \
 -				check-umask run-depends lib-depends install-mtree pre-install \
 -				pre-install-script do-install generate-plist post-install \
 -				post-install-script compress-man run-ldconfig fake-pkg \
 -				security-check
 +				check-conflicts check-umask run-depends lib-depends \
 +				install-mtree pre-install pre-install-script do-install \
 +				generate-plist post-install post-install-script compress-man \
 +				run-ldconfig fake-pkg security-check
  _PACKAGE_DEP=	install
  _PACKAGE_SEQ=	package-message pre-package pre-package-script \
  				do-package post-package-script
 
 --------------040006050802030501040503--
 
State-Changed-From-To: open->analyzed 
State-Changed-By: kris 
State-Changed-When: Sat Apr 12 18:39:36 PDT 2003 
State-Changed-Why:  
Currently undergoing pre-commit testing 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47146 
State-Changed-From-To: analyzed->closed 
State-Changed-By: kris 
State-Changed-When: Mon May 5 22:16:08 PDT 2003 
State-Changed-Why:  
Patch committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47146 
>Unformatted:
