Subject: tools.mk/bsd.pkg.mk include GNU patch from pkgsrc unnecessarily
To: None <tech-pkg@NetBSD.org>
From: Klaus Heinz <k.heinz.maer.vier@onlinehome.de>
List: tech-pkg
Date: 03/08/2004 00:49:27
Hi,

bsd.pk.mk tries to decide, whether we need GNU patch. Maybe I do not
quite understand the test; it seems to look for _any_ patches in the
directory patches/. Why this  should be a reason to need GNU patch from
pkgsrc escapes me.

  # determine if we need GNU patch from pkgsrc.
  _NEED_PATCH!=           if [ -d ${PATCHDIR} ]; then \
                                  if [ "`${ECHO} ${PATCHDIR}/patch-*`" != "${PATCHDIR}/patch-*" ]; then \
                                          ${ECHO} YES; \
                                  else \
                                          ${ECHO} NO; \
                                  fi \
                          else \
                                  ${ECHO} NO; \
                          fi

  .if ${_NEED_PATCH} == "YES"
  USE_GNU_TOOLS+=         patch
  .endif


tools.mk defines

  _TOOLS_REPLACE_OPSYS.patch+=    SunOS-*-*

and the descriptions says, SunOS/Solaris has a "GNUish" version of patch
(ie /usr/bin/gpatch, used in defs.SunOS.mk), so there is _no_ need to
pull in the pkgsrc version.


In contrast to that, the following fragments in tools.mk come to
the conclusion that every package with patches (according to the test
above in bsd.pkg.mk) needs a dependence on GNU patch from pkgsrc,
although it's already available in /usr/bin/.

  .for _tool_ in ${USE_GNU_TOOLS}  
  #
  # What GNU tools did the package or user ask for, and does the base
  # system already have it?
  #
  _TOOLS_NEED_GNU.${_tool_}=      YES
  ...
  .endfor

...

  .if (${_TOOLS_NEED_GNU.patch} == "YES") && empty(PKGPATH:Mdevel/patch)
  BUILD_DEPENDS+=         patch>=2.2:../../devel/patch
  _TOOLS_OVERRIDE.patch=  YES
  _TOOLS_PROGNAME.patch=  ${LOCALBASE}/bin/gpatch # "gpatch" always exists
  .  if exists(${_TOOLS_PROGNAME.patch})
  PATCH:=                 ${_TOOLS_PROGNAME.patch}
  .  endif
  .endif


This is also confirmed by my test:

  $ cd /opt/pkgsrc/games
  $ make show-var VARNAME=PATCH
...
Here, PATCH is /usr/bin/gpatch if the package has no patches, otherwise
it is /opt/pkg/bin/gpatch.

ciao
     Klaus