Subject: the overloading of ${WRKSRC} in pkgsrc/mk/bsd.pkg.mk
To: NetBSD Packages Technical Discussion List <tech-pkg@NetBSD.ORG>
From: Greg A. Woods <woods@most.weird.com>
List: tech-pkg
Date: 12/09/1999 23:59:21
I've recently enountered a package which needs "/src" appended to
WRKSRC, but to which I would like to apply some patches to files outside
of the build directory (particularly to manual pages that will be
installed).

It didn't take me very long to figure out that package patches are
applied with "patch -d ${WRKSRC}", which of course makes it harder to
apply patches to files outside of ${WRKSRC}.

Although there are several work-arounds to this problem, I think the
mere existance of the problem speaks clearly to the fact that ${WRKSRC}
is overloaded in being used both for patches and build/install and it
really should not be used for the patch -d parameter, but rather a
separate variable should be used.

That is to say I'd like to propose a change something like the
following (line numbers may be off):

Index: bsd.pkg.mk
===================================================================
RCS file: /cvs/NetBSD/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1.1.17
diff -c -c -r1.1.1.17 bsd.pkg.mk
*** bsd.pkg.mk	1999/11/15 19:31:54	1.1.1.17
--- bsd.pkg.mk	1999/12/10 04:46:56
***************
*** 199,210 ****
  PATCH_DIST_STRIP?=	-p0
  .if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
  PATCH_DEBUG_TMP=	yes
! PATCH_ARGS?=		-d ${WRKSRC} -E ${PATCH_STRIP}
! PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
  .else
  PATCH_DEBUG_TMP=	no
! PATCH_ARGS?=		-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
! PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
  .endif
  .if defined(BATCH)
  PATCH_ARGS+=		--batch
--- 199,215 ----
  PATCH_DIST_STRIP?=	-p0
  .if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
  PATCH_DEBUG_TMP=	yes
! .if defined(NO_WRKSUBDIR)
! PATCHSRC?=		${WRKDIR}
! .else # NO_WRKSUBDIR
! PATCHSRC?=		${WRKDIR}/${DISTNAME}
! .endif # NO_WRKSUBDIR
! PATCH_ARGS?=		-d ${PATCHSRC} -E ${PATCH_STRIP}
! PATCH_DIST_ARGS?=	-d ${PATCHSRC} -E ${PATCH_DIST_STRIP}
  .else
  PATCH_DEBUG_TMP=	no
! PATCH_ARGS?=		-d ${PATCHSRC} --forward --quiet -E ${PATCH_STRIP}
! PATCH_DIST_ARGS?=	-d ${PATCHSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
  .endif
  .if defined(BATCH)
  PATCH_ARGS+=		--batch


Of course that's not the only change that's necessary....  every package
that requires the setting of WRKSRC may need the pathnames in its
patches updated too, and that's no small number of packages (about
340!).  So, this raises the question: Is it better to make the design
more elegant now while there are only 340 packages to check and fix, or
is this problem rare enough that it's better to document and employ one
of the two potential work-arounds only where necessary?

-- 
							Greg A. Woods

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