From sem@stable-5.sem-home.ciam.ru  Mon Mar  7 19:27:23 2005
Return-Path: <sem@stable-5.sem-home.ciam.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B73B416A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Mar 2005 19:27:23 +0000 (GMT)
Received: from stable-5.sem-home.ciam.ru (ppp83-237-98-120.pppoe.mtu-net.ru [83.237.98.120])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 96E7843D31
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Mar 2005 19:27:22 +0000 (GMT)
	(envelope-from sem@stable-5.sem-home.ciam.ru)
Received: from sem by stable-5.sem-home.ciam.ru with local (Exim 4.43 (FreeBSD))
	id 1D8NtA-000JXC-Q1
	for FreeBSD-gnats-submit@freebsd.org; Mon, 07 Mar 2005 22:27:36 +0300
Message-Id: <E1D8NtA-000JXC-Q1@stable-5.sem-home.ciam.ru>
Date: Mon, 07 Mar 2005 22:27:36 +0300
From: Sergey Matveychuk <sem@FreeBSD.org>
Sender: Sergey Matveychuk <sem@stable-5.sem-home.ciam.ru>
Reply-To: Sergey Matveychuk <sem@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] bsd.port.mk: allow install port with the same version in different PREFIX
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         78554
>Category:       ports
>Synopsis:       [patch] bsd.port.mk: allow install port with the same version in different 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:   Mon Mar 07 19:30:02 GMT 2005
>Closed-Date:    Fri May 25 03:16:07 GMT 2007
>Last-Modified:  Fri May 25 03:16:07 GMT 2007
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 5.3-RELEASE-p4 i386
>Organization:
>Environment:
System: FreeBSD stable-5.sem-home.ciam.ru 5.3-RELEASE-p4 FreeBSD 5.3-RELEASE-p4 #13: Fri Jan 14 04:39:21 MSK 2005 root@stable-5.sem-home.ciam.ru:/usr/obj/usr/src/sys/CURRENT i386


	
>Description:
	
	Now days we can install port with different PREFIX only if
	PKGNAME differ. But it really discouraged.
	Two ports with different PREFIX can't have conflicts (ideally).
	The reason for it is simple: package meta info saves in
	PKG_DBDIR/PKGNAME. This patch solves it.

	Packages are another thing. I think most packages will not work
	is they installed with other PREFIX (pkg_add -p) than it was
	compiled. So I did not touch pkg_install tools. But they can be
	changed similarly.
>How-To-Repeat:
	
	Do it in any port:
	make install
	make PREFIX=/some_place install
>Fix:

	

--- bsd.port.mk.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.510
diff -u -r1.510 bsd.port.mk
--- bsd.port.mk	28 Feb 2005 21:09:04 -0000	1.510
+++ bsd.port.mk	7 Mar 2005 18:52:07 -0000
@@ -879,13 +879,16 @@
 # PKG_DBDIR		- Where package installation is recorded; this directory
 #				  must not contain anything else.
 #				  Default: /var/db/pkg
+# DBNAME		- Directory name in ${PKG_DBDIR} where package metadata stored.
+# 				  Default: ${PKGNAME} if user use default PREFIX,
+# 				  ${PKGNAME}:${PREFIX:S/\//_/g} otherwise.
 # PORT_DBDIR	- Where port configuration options are recorded.
 #				  Default: /var/db/ports
 # NO_PKG_REGISTER
 #				- Don't register a port installation as a package.
 # FORCE_PKG_REGISTER
 #				- If set, it will overwrite any existing package
-#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
+#				  registration information in ${PKG_DBDIR}/${DBNAME}.
 # NO_DEPENDS	- Don't verify build of dependencies.
 # NO_CHECKSUM	- Don't verify the checksum.  Typically used when
 #				  when you noticed the distfile you just fetched has
@@ -1202,6 +1205,11 @@
 .if defined(USE_X_PREFIX)
 USE_XLIB=		yes
 .endif
+.if defined(PREFIX)
+DBNAME=			${PKGNAME}:${PREFIX:S/\//_/g}
+.else
+DBNAME=			${PKGNAME}
+.endif
 .if defined(USE_X_PREFIX)
 PREFIX?=		${X11BASE}
 .elif defined(USE_LINUX_PREFIX)
@@ -3467,8 +3475,8 @@
 						fi; \
 				done; \
 		fi; \
-		if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
-				if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
+		if [ -d ${PKG_DBDIR}/${DBNAME} -o -n "$${found_package}" ]; then \
+				if [ -d ${PKG_DBDIR}/${DBNAME} ]; then \
 						${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
 				else \
 						${ECHO_CMD} "===>   An older version of ${PKGORIGIN} is already installed ($${found_package})"; \
@@ -4909,28 +4917,28 @@
 	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
 	@${RM} -f /tmp/${PKGNAME}-required-by
 .if defined(FORCE_PKG_REGISTER)
-	@if [ -e ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY ]; then \
-		${CP} ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY /tmp/${PKGNAME}-required-by; \
+	@if [ -e ${PKG_DBDIR}/${DBNAME}/+REQUIRED_BY ]; then \
+		${CP} ${PKG_DBDIR}/${DBNAME}/+REQUIRED_BY /tmp/${PKGNAME}-required-by; \
 	fi
-	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
+	@${RM} -rf ${PKG_DBDIR}/${DBNAME}
 .endif
-	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
+	@if [ ! -d ${PKG_DBDIR}/${DBNAME} ]; then \
 		${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
-		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
-		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
-		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
-		${ECHO_CMD} ${COMMENT:Q} > ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
+		${MKDIR} ${PKG_DBDIR}/${DBNAME}; \
+		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${DBNAME}/+CONTENTS; \
+		${CP} ${DESCR} ${PKG_DBDIR}/${DBNAME}/+DESC; \
+		${ECHO_CMD} ${COMMENT:Q} > ${PKG_DBDIR}/${DBNAME}/+COMMENT; \
 		if [ -f ${PKGINSTALL} ]; then \
-			${CP} ${PKGINSTALL} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
+			${CP} ${PKGINSTALL} ${PKG_DBDIR}/${DBNAME}/+INSTALL; \
 		fi; \
 		if [ -f ${PKGDEINSTALL} ]; then \
-			${CP} ${PKGDEINSTALL} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
+			${CP} ${PKGDEINSTALL} ${PKG_DBDIR}/${DBNAME}/+DEINSTALL; \
 		fi; \
 		if [ -f ${PKGREQ} ]; then \
-			${CP} ${PKGREQ} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
+			${CP} ${PKGREQ} ${PKG_DBDIR}/${DBNAME}/+REQUIRE; \
 		fi; \
 		if [ -f ${PKGMESSAGE} ]; then \
-			${CP} ${PKGMESSAGE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
+			${CP} ${PKGMESSAGE} ${PKG_DBDIR}/${DBNAME}/+DISPLAY; \
 		fi; \
 		for dep in `${PKG_INFO} -qf ${PKGNAME} | ${GREP} -w ^@pkgdep | ${AWK} '{print $$2}' | ${SORT} -u`; do \
 			if [ -d ${PKG_DBDIR}/$$dep -a -z `${ECHO_CMD} $$dep | ${GREP} -E ${PKG_IGNORE_DEPENDS}` ]; then \
@@ -4943,11 +4951,11 @@
 	fi
 .if !defined(NO_MTREE)
 	@if [ -f ${MTREE_FILE} ]; then \
-		${CP} ${MTREE_FILE} ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS; \
+		${CP} ${MTREE_FILE} ${PKG_DBDIR}/${DBNAME}/+MTREE_DIRS; \
 	fi
 .endif
 	@if [ -e /tmp/${PKGNAME}-required-by ]; then \
-		${CAT} /tmp/${PKGNAME}-required-by >> ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY; \
+		${CAT} /tmp/${PKGNAME}-required-by >> ${PKG_DBDIR}/${DBNAME}/+REQUIRED_BY; \
 		${RM} -f /tmp/${PKGNAME}-required-by; \
 	fi
 .else
--- bsd.port.mk.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: sem 
Responsible-Changed-When: Mon Mar 7 19:31:20 GMT 2005 
Responsible-Changed-Why:  
portmgr territhory 

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

From: Kirill Ponomarew <krion@voodoo.oberon.net>
To: Sergey Matveychuk <sem@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the same version in different PREFIX
Date: Mon, 7 Mar 2005 20:47:51 +0100

 On Mon, Mar 07, 2005 at 10:27:36PM +0300, Sergey Matveychuk wrote:
 > 	Now days we can install port with different PREFIX only if
 > 	PKGNAME differ. But it really discouraged.
 > 	Two ports with different PREFIX can't have conflicts (ideally).
 > 	The reason for it is simple: package meta info saves in
 > 	PKG_DBDIR/PKGNAME. This patch solves it.
 > 
 > 	Packages are another thing. I think most packages will not work
 > 	is they installed with other PREFIX (pkg_add -p) than it was
 > 	compiled. So I did not touch pkg_install tools. But they can be
 > 	changed similarly.
 
 What about ports which install dirs/files in /var ?
 
 -Kirill

From: Sergey Matveychuk <sem@FreeBSD.org>
To: Kirill Ponomarew <krion@voodoo.oberon.net>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the
 same version in different PREFIX
Date: Tue, 08 Mar 2005 21:46:01 +0300

 Kirill Ponomarew wrote:
 
 > 
 > What about ports which install dirs/files in /var ?
 
 Just the same as if install two port with a different PREFIX (different 
 PKGNAME and the same ORIGIN) now.
 
 -- 
 Sem.

From: Kirill Ponomarew <krion@voodoo.oberon.net>
To: Sergey Matveychuk <sem@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the same version in different PREFIX
Date: Tue, 8 Mar 2005 19:47:35 +0100

 On Tue, Mar 08, 2005 at 09:46:01PM +0300, Sergey Matveychuk wrote:
 > >What about ports which install dirs/files in /var ?
 > 
 > Just the same as if install two port with a different PREFIX (different 
 > PKGNAME and the same ORIGIN) now.
 
 That's _very_ bad idea, you know, since many ports just won't run
 with ${PREFIX}/var
 
 -Kirill

From: Sergey Matveychuk <sem@FreeBSD.org>
To: Kirill Ponomarew <krion@voodoo.oberon.net>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the
 same version in different PREFIX
Date: Tue, 08 Mar 2005 22:09:17 +0300

 Kirill Ponomarew wrote:
 > On Tue, Mar 08, 2005 at 09:46:01PM +0300, Sergey Matveychuk wrote:
 > 
 >>>What about ports which install dirs/files in /var ?
 >>
 >>Just the same as if install two port with a different PREFIX (different 
 >>PKGNAME and the same ORIGIN) now.
 > 
 > 
 > That's _very_ bad idea, you know, since many ports just won't run
 > with ${PREFIX}/var
 
 Well, about two year ago I've rised the question. I said about different 
 problems that could be arised with ports with different PREFIX. But 
 marcus and kris reject my arguments and said it's a useful feature. I've 
 noticed it's weird behaviour - to allow install port with different 
 PKGNAME (PKGVERSION or PKGNAMEPREFIX may differ) and to disallow install 
 ports with different PREFIX but with the same PKGNAME.
 
 We should be consistent. Or we should allow install ports with the same 
 PKGNAME on we should remove PREFIX feature at all as it can rise problems.
 
 -- 
 Sem.

From: Kirill Ponomarew <krion@voodoo.oberon.net>
To: Sergey Matveychuk <sem@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the same version in different PREFIX
Date: Tue, 8 Mar 2005 20:30:38 +0100

 On Tue, Mar 08, 2005 at 10:09:17PM +0300, Sergey Matveychuk wrote:
 > >That's _very_ bad idea, you know, since many ports just won't run
 > >with ${PREFIX}/var
 > 
 > Well, about two year ago I've rised the question. I said about different 
 > problems that could be arised with ports with different PREFIX. But 
 > marcus and kris reject my arguments and said it's a useful feature.
 
 Maybe it's a useful feature, but /var remains a pitfall for running
 many ports, debugging which will be broken and which won't, can be
 PITA.
 
 Let's consider the situation when you install port-1.1 in
 PREFIX=/somewhere and you have already installed port-1.1 in
 ${LOCALBASE}, and --localstatedir=/var is defined in ports'
 Makefile.  You understand, of course, what will happen.  Sadly, but
 we still have these ports with hardcoded localstatedir,
 mysql41-server is the best example.
 
 It's interesting to know how NetBSD folks resolved it, if they did,
 of course.
 
 > I've noticed it's weird behaviour - to allow install port with
 > different PKGNAME (PKGVERSION or PKGNAMEPREFIX may differ) and to
 > disallow install ports with different PREFIX but with the same
 > PKGNAME.
 > 
 > We should be consistent. Or we should allow install ports with the
 > same PKGNAME on we should remove PREFIX feature at all as it can
 > rise problems.
 
 -Kirill

From: Sergey Matveychuk <sem@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, sem@FreeBSD.org
Cc:  
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the
 same version in different PREFIX
Date: Sat, 12 Mar 2005 12:51:41 +0300

 The patch don't work for ports that set PREFIX themself. I was wonder 
 how many them are.
 -- 
 Sem.

From: Sergey Matveychuk <sem@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, sem@FreeBSD.org
Cc:  
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the
 same version in different PREFIX
Date: Sun, 20 Mar 2005 14:28:58 +0300

 I'd like to hear some comments on the PR from portmgrs other than krion.
 
 Thank you.
 -- 
 Sem.

From: Florent Thoumie <flz@xbsd.org>
To: sem@FreeBSD.org, krion@FreeBSD.org,
	freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: ports/78554
Date: Sat, 09 Apr 2005 20:10:41 +0200

 	This patch is a quite good idea IMHO. However it lacks some 
 	work to be sure nothing will break.
 
 	You definitely need pkg_install support, and a script to 
 	convert old-style DBDIR (that's simple, but needed).
 
 	One shouldn't make the assumption that a port will work in two
 	different prefixes before having tried to get it effectively
 	working, so this should be off by default and activated with
 	a special variable (eg. ALLOW_MULTIPLES_PREFIXES=yes) and with
 	something in pkg_install side (@comment multiple-prefixes or a
 	new @cmd).
 
 	Did you investigate how pkgsrc handle this ?
 

From: Sergey Matveychuk <sem@FreeBSD.org>
To: Florent Thoumie <flz@xbsd.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: ports/78554
Date: Sun, 10 Apr 2005 12:57:50 +0400

 Florent Thoumie wrote:
 > 	This patch is a quite good idea IMHO. However it lacks some 
 > 	work to be sure nothing will break.
 
 It breaks only ports that set PREFIX. I thought it's prohibited, but 112 
 ports do so. KDE stuff and linuxlator among them.
 
 > 
 > 	You definitely need pkg_install support, and a script to 
 > 	convert old-style DBDIR (that's simple, but needed).
 
 I'm not sure what do you mean as 'pkg_install support'?
 For the patch it's unnecessary. It changes DBNAME only if PREFIX changed.
 
 > 
 > 	One shouldn't make the assumption that a port will work in two
 > 	different prefixes before having tried to get it effectively
 > 	working, so this should be off by default and activated with
 > 	a special variable (eg. ALLOW_MULTIPLES_PREFIXES=yes) and with
 > 	something in pkg_install side (@comment multiple-prefixes or a
 > 	new @cmd).
 > 
 > 	Did you investigate how pkgsrc handle this ?
 > 
 
 I'll see.
 
 -- 
 Sem.
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Wed May 16 22:07:01 UTC 2007 
State-Changed-Why:  
Is it possible that DESTDIR (if not in its current implementation, then 
the one that is being reworked during SoC) will fix this same problem? 

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

From: Sergey Matveychuk <sem@FreeBSD.org>
To: bug-followup@FreeBSD.org,  sem@FreeBSD.org
Cc:  
Subject: Re: ports/78554: [patch] bsd.port.mk: allow install port with the
 same version in different PREFIX
Date: Thu, 17 May 2007 09:55:56 +0400

 Yes, DESTDIR should resolve the problem when it'll be implemented well.
 
 The patch just remove inconsistence between two cases: you can install 
 one port with the different PREFIX if they have different version, but 
 you can't do it with the same version.
 
 Sure, DESTDIR is more correct for this.
 -- 
 Dixi.
 Sem.
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Fri May 25 03:15:38 UTC 2007 
State-Changed-Why:  
Submitter agrees that the way forward on this is a properly implemented 
DESTDIR. 

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