Date: Thu, 16 Jan 2003 19:15:18 +0300 From: Sergey Matveychuk <sem@ciam.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/47146: Port conflict Checking for bsd.port.mk Message-ID: <E18ZCfm-0002Tu-00@mail.ciam.ru>
next in thread | raw e-mail | index | archive | help
>Number: 47146 >Category: ports >Synopsis: Port conflict Checking for bsd.port.mk >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jan 16 08:20:02 PST 2003 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E18ZCfm-0002Tu-00>