Subject: Re: pkg/16133: patch to enable OBJOPSYS in WORKDIR for pkgsrc packages
To: None <salo@Xtrmntr.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 03/30/2002 17:42:15
[ On Saturday, March 30, 2002 at 21:38:01 (+0100), Lubomir Sedlacik wrote: ]
> Subject: pkg/16133: patch to enable OBJOPSYS in WORKDIR for pkgsrc packages
>
> 
> imagine a environment where you have dual-booted machine with different
> operating systems, both using pkgsrc mounted from remote nfs server.
> currently there is no way to define non-colliding WRKDIR for each of these
> systems because you can only specify OBJMACHINE, which is for both of them
> identical and OBJHOSTNAME, which can be identical too (as it is in my case).

Certainly there's an easy way to solve this!  You just have to go back
one level to use a switchable WRKOBJDIR -- i.e. a common setting of
WRKOBJDIR that points to a location where a unique-per-system symlink
can be used.

All you'll need is a startup script run automatically at boot in each
system to swap the target of a single local symlink.  That symlink is of
course pointed to by the setting of WRKOBJDIR.  Eg. like this (line
numbers approximate):

Index: bsd.pkg.defaults.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.defaults.mk,v
retrieving revision 1.47
diff -c -r1.47 bsd.pkg.defaults.mk
*** bsd.pkg.defaults.mk 26 Mar 2002 08:24:59 -0000      1.47
--- bsd.pkg.defaults.mk 28 Mar 2002 05:19:26 -0000
***************
*** 66,75 ****
  # Possible: defined, not defined
  # Default: not defined
  
! #WRKOBJDIR=   /usr/tmp
  # build here instead of in pkgsrc
! # Possible: any path
! # Default: not defined
  
  LOCALBASE?=   /usr/pkg
  # Where non-X-based packages will be installed
--- 77,87 ----
  # Possible: defined, not defined
  # Default: not defined
  
! WRKOBJDIR?=   /var/package-obj
  # build here instead of in pkgsrc
! # Possible: any path you like (can be a symlink)
! # Note: must remain constant for all hosts sharing 
! # Default: /var/package-obj
  
  LOCALBASE?=   /usr/pkg
  # Where non-X-based packages will be installed


Then during boot just make the /var/package-obj symlink point to the
(local?) heirarchy that's appropriate for the currently booting system.


Using just a single symlink pointed to by WRKOBJDIR also means that
there only has to be one common shared convenience symlinks in the
source tree (i.e. in /usr/pkgsrc) even if you use the same pkgsrc tree
simultaneously via NFS on multiple systems.

However if you do simultaneous builds on multiple system from a shared
NFS server you will also need this patch (as I discussed a while back in
tech-pkg) (line numbers are very approximate):

Index: bsd.pkg.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.954
diff -c -r1.954 bsd.pkg.mk
*** bsd.pkg.mk  26 Mar 2002 16:31:27 -0000      1.954
--- bsd.pkg.mk  28 Mar 2002 05:48:43 -0000
***************
*** 1516,1529 ****
  .endif
        ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${WRKDIR}
  .ifdef WRKOBJDIR
- .  if ${PKGSRC_LOCKTYPE} == "sleep" || ${PKGSRC_LOCKTYPE} == "once"
- .    if !exists(${LOCKFILE})
-       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
-       ${RM} -f ${WRKDIR_BASENAME} || ${TRUE}
- .    endif
- .  endif
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
!       if ${LN} -s ${WRKDIR} ${WRKDIR_BASENAME} 2>/dev/null; then      \
                ${ECHO} "${WRKDIR_BASENAME} -> ${WRKDIR}";              \
        fi
  .endif # WRKOBJDIR
--- 1594,1603 ----
  .endif
        ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${WRKDIR}
  .ifdef WRKOBJDIR
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
!       if [ ! -h ${WRKDIR_BASENAME} ]; then                            \
!               ${RM} -rf ${WRKDIR_BASENAME};                           \
!               ${LN} -s ${WRKDIR} ${WRKDIR_BASENAME};                  \
                ${ECHO} "${WRKDIR_BASENAME} -> ${WRKDIR}";              \
        fi
  .endif # WRKOBJDIR
***************
*** 2744,2752 ****
                fi;                                                     \
        fi
  .  ifdef WRKOBJDIR
!       -${_PKG_SILENT}${_PKG_DEBUG}                                    \
!       ${RMDIR} ${BUILD_DIR} 2>/dev/null;                              \
!       ${RM} -f ${WRKDIR_BASENAME}
  .  endif
  .endif
  
--- 2847,2853 ----
                fi;                                                     \
        fi
  .  ifdef WRKOBJDIR
!       -${_PKG_SILENT}${_PKG_DEBUG}${RMDIR} ${BUILD_DIR} 2>/dev/null;
  .  endif
  .endif
  


-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods@acm.org>;  <g.a.woods@ieee.org>;  <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>