From root@gabby.gsicomp.on.ca  Fri Dec 15 21:52:01 2000
Return-Path: <root@gabby.gsicomp.on.ca>
Received: from xena.gsicomp.on.ca (cr677933-a.ktchnr1.on.wave.home.com [24.43.230.149])
	by hub.freebsd.org (Postfix) with ESMTP
	id 12EAF37B400; Fri, 15 Dec 2000 21:52:00 -0800 (PST)
Received: from gabby.gsicomp.on.ca (root@gabby.gsicomp.on.ca [192.168.0.2])
	by xena.gsicomp.on.ca (8.9.3/8.9.3) with ESMTP id AAA87597;
	Sat, 16 Dec 2000 00:51:59 -0500 (EST)
	(envelope-from root@gabby.gsicomp.on.ca)
Received: (from root@localhost)
	by gabby.gsicomp.on.ca (8.9.3/8.9.3) id AAA52571;
	Sat, 16 Dec 2000 00:51:59 -0500 (EST)
	(envelope-from root)
Message-Id: <200012160551.AAA52571@gabby.gsicomp.on.ca>
Date: Sat, 16 Dec 2000 00:51:59 -0500 (EST)
From: matt@gsicomp.on.ca
Sender: root@gabby.gsicomp.on.ca
Reply-To: matt@gsicomp.on.ca
To: FreeBSD-gnats-submit@freebsd.org, asami@freebsd.org
Subject: Updates to bsd.port.mk to detect changing values of ${PREFIX}
X-Send-Pr-Version: 3.2

>Number:         23581
>Category:       ports
>Synopsis:       Updates to bsd.port.mk to detect changing values of ${PREFIX}
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 15 22:00:01 PST 2000
>Closed-Date:    Sun Jul 06 16:58:35 PDT 2003
>Last-Modified:  Sun Jul 06 16:58:35 PDT 2003
>Originator:     Matt Emmerton
>Release:        FreeBSD 4.1-RELEASE i386
>Organization:
GSI Computer Services
>Environment:

FreeBSD 4.1-RELEASE (GABBY.20001124.01) #0: Fri Nov 24 00:46:27 EST 2000

>Description:

	Any port which uses GNU configure, Perl's MakeMaker, IMake, 
	or a custom 'configure' script in order to generate Makefiles
	will be passed ${PREFIX}, which will then be hardcoded into
	the resulting Makefiles.

	Many such ports also rely on post-install targets to install
	documentation, sample configurations or startup scripts which
	are not installed by the Makefiles generated above.

	In these cases, most components of the port will be installed
	under the ${PREFIX} given during the initial make, with any
	files installed by the post-install target using the ${PREFIX}
	given during installation.

	Unfortunately, there is no mechanism to prevent ports being
	built with one choice of ${PREFIX}, and then being installed
	with another.

	This patch addresses this issue.

>How-To-Repeat:

	1.  Select a port that uses one of the above configuration
	    mechanisms. (I used ftp/cftp during testing of this patch).
	2.  Do a 'make PREFIX=/some/dir'
	3.  Do a 'make install PREFIX=/some/other/dir' 

>Fix:

--- bsd.port.mk.orig	Sat Dec 16 00:03:42 2000
+++ bsd.port.mk	Sat Dec 16 00:33:58 2000
@@ -1760,6 +1760,9 @@
 
 .if !target(do-configure)
 do-configure:
+.if defined(GNU_CONFIGURE) || defined(PERL_CONFIGURE) || defined(USE_IMAKE) 
+	@echo ${PREFIX} > ${WRKDIR}/.configure_dir
+.endif
 .if defined(USE_AUTOMAKE)
 	@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOMAKE_ENV} ${AUTOMAKE} \
 		${AUTOMAKE_ARGS})
@@ -1769,6 +1772,7 @@
 		${AUTOCONF_ARGS})
 .endif
 	@if [ -f ${SCRIPTDIR}/configure ]; then \
+		@echo ${PREFIX} > ${WRKDIR}/.configure_dir; \
 		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
 		  ${SCRIPTDIR}/configure; \
 	fi
@@ -2057,6 +2061,15 @@
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} configure
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} real-build
 ${INSTALL_COOKIE}:
+	if [ -f ${WRKDIR}/.configure_dir ]; then \
+		if [ "x${PREFIX}" != "x`${CAT} ${WRKDIR}/.configure_dir`" ]; then \
+			${ECHO} "===>  ${PKGNAME} has already been configured to install into `${CAT} ${WRKDIR}/.configure_dir`."; \
+			${ECHO} "      If you wish to install into another directory, you must first do a"; \
+			${ECHO} "      \`\`make clean'' followed by \`\`make PREFIX=${PREFIX}'' in order"; \
+			${ECHO} "      to install into ${PREFIX}."; \
+			exit 1; \
+		fi; \
+	fi
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} build
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} real-install
 # Scan PLIST for setugid files and startup scripts

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports->asami 
Responsible-Changed-By: mharo 
Responsible-Changed-When: Sun Jan 7 11:01:43 PST 2001 
Responsible-Changed-Why:  
over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23581 
Responsible-Changed-From-To: asami->portmgr 
Responsible-Changed-By: will 
Responsible-Changed-When: Wed Apr 4 01:18:23 PDT 2001 
Responsible-Changed-Why:  
Over to new maintainer. 

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

From: "Sergey Matveychuk" <sem@ciam.ru>
To: <freebsd-gnats-submit@FreeBSD.org>, <matt@gsicomp.on.ca>,
	<portmgr@FreeBSD.org>
Cc:  
Subject: Re: ports/23581: Updates to bsd.port.mk to detect changing values of ${PREFIX}
Date: Sun, 20 Apr 2003 19:37:21 +0400

 Looks good for making bsd.port.mk safer.
 
 ----
 Sem.
 

From: Sergey Matveychuk <sem@ciam.ru>
To: freebsd-gnats-submit@FreeBSD.org, matt@gsicomp.on.ca
Cc:  
Subject: Re: ports/23581: Updates to bsd.port.mk to detect changing values
 of ${PREFIX}
Date: Tue, 20 May 2003 03:42:59 +0400

 This is a multi-part message in MIME format.
 --------------080004070008080602040109
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Here is a patch reworked for new bsd.port.mk.
 For a very new bsd.ports.mk really - it's applied after reworked PR/51609.
 Kris know what does it mean.
 
 ----
 Sem.
 
 --------------080004070008080602040109
 Content-Type: text/plain;
  name="check-prefix.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="check-prefix.patch"
 
 --- bsd.port.mk.orig	Tue May 20 02:26:18 2003
 +++ bsd.port.mk	Tue May 20 03:31:58 2003
 @@ -1433,6 +1433,7 @@
  BUILD_COOKIE?=		${WRKDIR}/.build_done.${PKGNAME}
  PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PKGNAME}
  PACKAGE_COOKIE?=	${WRKDIR}/.package_done.${PKGNAME}
 +PREFIX_COOKIE?=		${WRKDIR}/.configure_prefix.${PKGNAME}
  
  # How to do nothing.  Override if you, for some strange reason, would rather
  # do something.
 @@ -2735,6 +2736,9 @@
  
  .if !target(do-configure)
  do-configure:
 +.if defined(GNU_CONFIGURE) || defined(PERL_CONFIGURE) || defined(USE_IMAKE)
 +	@echo ${PREFIX} > ${PREFIX_COOKIE}
 +.endif
  .if defined(USE_AUTOMAKE)
  	@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOMAKE_ENV} ${AUTOMAKE} \
  		${AUTOMAKE_ARGS})
 @@ -2744,6 +2748,7 @@
  		${AUTOCONF_ARGS})
  .endif
  	@if [ -f ${SCRIPTDIR}/configure ]; then \
 +		@echo ${PREFIX} > ${PREFIX_COOKIE} \
  		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
  		  ${SCRIPTDIR}/configure; \
  	fi
 @@ -2815,6 +2820,20 @@
  .endif  # CONFLICTS
  .endif
  
 +# Check PREFIX
 +
 +.if !target(check-prefix)
 +check-prefix:
 +	@if [ -f ${PREFIX_COOKIE} ]; then \
 +		if [ "x${PREFIX}" != "x`${CAT} ${PREFIX_COOKIE}`" ]; then \
 +			${ECHO_MSG} "===>  ${PKGNAME} has already been configured to install into `${CAT} ${PREFIX_COOKIE}`."; \
 +			${ECHO_MSG} "      If you wish to install into ${PREFIX} directory, you must first do"; \
 +			${ECHO_MSG} "      a \`\`make clean'' followed by \`\`make PREFIX=${PREFIX} install''"; \
 +			exit 1; \
 +		fi; \
 +	fi
 +.endif
 +
  # Install
  
  .if !target(do-install)
 @@ -3122,7 +3141,7 @@
  _INSTALL_DEP=	build
  _INSTALL_SEQ=	install-message check-categories check-conflicts \
  			    run-depends lib-depends pre-install pre-install-script \
 -				generate-plist check-already-installed
 +				generate-plist check-prefix check-already-installed
  _INSTALL_SUSEQ= check-umask install-mtree pre-su-install do-install \
  				post-install post-install-script compress-man run-ldconfig \
  				fake-pkg security-check
 
 --------------080004070008080602040109--
 

From: Sergey Matveychuk <sem@ciam.ru>
To: freebsd-gnats-submit@FreeBSD.org, matt@gsicomp.on.ca
Cc:  
Subject: Re: ports/23581: Updates to bsd.port.mk to detect changing values
 of ${PREFIX}
Date: Fri, 23 May 2003 16:59:20 +0400

 This is a multi-part message in MIME format.
 --------------050000030700050305010105
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Here a patch from sobomax. It's very good-looking and simple.
 
 Thank you Maxim!
 
 --------------050000030700050305010105
 Content-Type: text/plain;
  name="bsd.port.mk.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="bsd.port.mk.diff"
 
 --- bsd.port.mk	2003/05/21 08:13:14	1.1
 +++ bsd.port.mk	2003/05/21 08:16:16
 @@ -1417,12 +1417,12 @@
  .endif
  
  # Names of cookies used to skip already completed stages
 -EXTRACT_COOKIE?=	${WRKDIR}/.extract_done.${PKGNAME}
 -CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done.${PKGNAME}
 -INSTALL_COOKIE?=	${WRKDIR}/.install_done.${PKGNAME}
 -BUILD_COOKIE?=		${WRKDIR}/.build_done.${PKGNAME}
 -PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PKGNAME}
 -PACKAGE_COOKIE?=	${WRKDIR}/.package_done.${PKGNAME}
 +EXTRACT_COOKIE?=	${WRKDIR}/.extract_done.${PKGNAME}.${PREFIX:S/\//_/g}
 +CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done.${PKGNAME}.${PREFIX:S/\//_/g}
 +INSTALL_COOKIE?=	${WRKDIR}/.install_done.${PKGNAME}.${PREFIX:S/\//_/g}
 +BUILD_COOKIE?=		${WRKDIR}/.build_done.${PKGNAME}.${PREFIX:S/\//_/g}
 +PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PKGNAME}.${PREFIX:S/\//_/g}
 +PACKAGE_COOKIE?=	${WRKDIR}/.package_done.${PKGNAME}.${PREFIX:S/\//_/g}
  
  # How to do nothing.  Override if you, for some strange reason, would rather
  # do something.
 
 --------------050000030700050305010105--
 
 
State-Changed-From-To: open->closed 
State-Changed-By: kris 
State-Changed-When: Sun Jul 6 16:58:27 PDT 2003 
State-Changed-Why:  
Patch committed, thanks! 

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