Subject: pkg/4820: Cannot easily share /usr/pkgsrc between architectures
To: None <gnats-bugs@gnats.netbsd.org>
From: None <abs@mono.org>
List: netbsd-bugs
Date: 01/14/1998 09:23:22
>Number:         4820
>Category:       pkg
>Synopsis:       Cannot easily share /usr/pkgsrc between architectures
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 14 09:35:01 1998
>Last-Modified:
>Originator:     David Brownlee
>Organization:
<a href="http://www.mono.org/">Monochrome</a>
>Release:        1.3
>Environment:
System: NetBSD lapton.anim.dreamworks.com 1.3 NetBSD 1.3 (_LAPTON_) #0: Fri Jan 9 11:10:00 PST 1998 root@lapton.anim.dreamworks.com:/usr/src/sys/arch/i386/compile/_LAPTON_ i386


>Description:
	/usr/pkgsrc cannot be simultaneously shared between multiple
	architectures. There are two conflicts:

		a) The 'work' subdirectory of each package.
		b) The 'package' directory containing built pasckages.

	I think this is broken enough to warrent being classified as a sw-bug
	rather than a change-request. Feel free to reclassify it if you do
	not agree :)

>How-To-Repeat:
	Try to build packages on a sparc & i386 at the same time.
>Fix:
	The following patch always uses 'work.$ARCH' under NetBSD, plus
	(under NetBSD) places built packages in 'package/$ARCH/...' rather
	than 'packages/...'. There is a little bit of hair associated with
	handling the case where 'packages' exists, but 'packages/$ARCH' does
	not.

	I have been using this setup for the past week sharing /usr/pkgsrc
	between an i386 & sparc box without trouble. (I've only just
	added the aformentioned hair, but have tested it OK).

diff -u /usr/src/share/mk/bsd.port.mk ./bsd.port.mk
--- /usr/src/share/mk/bsd.port.mk	Tue Jan  6 23:55:53 1998
+++ ./bsd.port.mk	Wed Jan 14 09:12:23 1998
@@ -60,6 +60,8 @@
 #				  MASTER_SITES.
 # PACKAGES		- A top level directory where all packages go (rather than
 #				  going locally to each port). (default: ${PORTSDIR}/packages).
+# PACKAGES_ARCH	- Top level directory for current ARCH. Can be identical to
+#				  PACKAGES, or should be subdir of same.
 # GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
 # XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
 # MAINTAINER	- The e-mail address of the contact person for this port
@@ -343,9 +345,14 @@
 DISTDIR?=		${PORTSDIR}/distfiles
 _DISTDIR?=		${DISTDIR}/${DIST_SUBDIR}
 PACKAGES?=		${PORTSDIR}/packages
+.if (${OPSYS} == "NetBSD")
+PACKAGES_ARCH?=	${PACKAGES}/${MACHINE_ARCH}
+.else
+PACKAGES_ARCH?=	${PACKAGES}
+.endif
 TEMPLATES?=		${PORTSDIR}/templates
 .if !defined(NO_WRKDIR)
-.if defined(OBJMACHINE)
+.if (${OPSYS} == "NetBSD") || defined(OBJMACHINE)
 WRKDIR?=		${.CURDIR}/work.${MACHINE_ARCH}
 .else
 WRKDIR?=		${.CURDIR}/work
@@ -732,7 +739,7 @@
 # Note this has to start with a capital letter (or more accurately, it
 #  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
 PKGREPOSITORYSUBDIR?=	All
-PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
+PKGREPOSITORY?=		${PACKAGES_ARCH}/${PKGREPOSITORYSUBDIR}
 .if exists(${PACKAGES})
 PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
 .else
@@ -1126,6 +1133,12 @@
 	@if [ -e ${PLIST} ]; then \
 		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
 		if [ -d ${PACKAGES} ]; then \
+			if [ ! -d ${PACKAGES_ARCH} ]; then \
+				if ! ${MKDIR} ${PACKAGES_ARCH}; then \
+					${ECHO_MSG} ">> Can't create directory ${PACKAGES_ARCH}."; \
+					exit 1; \
+				fi; \
+			fi; \
 			if [ ! -d ${PKGREPOSITORY} ]; then \
 				if ! ${MKDIR} ${PKGREPOSITORY}; then \
 					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
@@ -1150,13 +1163,13 @@
 package-links:
 	@${MAKE} ${.MAKEFLAGS} delete-package-links
 	@for cat in ${CATEGORIES}; do \
-		if [ ! -d ${PACKAGES}/$$cat ]; then \
-			if ! ${MKDIR} ${PACKAGES}/$$cat; then \
-				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
+		if [ ! -d ${PACKAGES_ARCH}/$$cat ]; then \
+			if ! ${MKDIR} ${PACKAGES_ARCH}/$$cat; then \
+				${ECHO_MSG} ">> Can't create directory ${PACKAGES_ARCH}/$$cat."; \
 				exit 1; \
 			fi; \
 		fi; \
-		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
+		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES_ARCH}/$$cat; \
 	done;
 .endif
 
>Audit-Trail:
>Unformatted: