Subject: Re: how can we create PATCHFILES that are not DISTFILES?
To: Alan Barrett <apb@cequrux.com>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 05/02/2002 19:01:48
[ On Monday, April 22, 2002 at 10:27:06 (+0200), Alan Barrett wrote: ]
> Subject: Re: how can we create PATCHFILES that are not DISTFILES?
>
> Sorry, I forget what Greg's proposed mechanism is.
Concrete, tested, updated, version appended below....
> Perhaps you could a patch to place @YOUR_MAGIC_VARIABLE@ into the
> relevant config file, and a post-patch target using sed to replace
> @YOUR_MAGIC_VARIABLE@ with the desired value. This way, the patch
> command can worry about context, and the sed command can blindly make
> the substitution without worrying about context. You could probably
> use the existing FILES_SUBST framework. (Oops, FILES_SUBST is not
> documented in Packages.txt.)
Yes, that could work. It's not very elegant -- I really don't like
creating a build mechanism outside of the package's build system proper
when a simple patch will do just fine.... :-)
Here's an updated version of my proposal, complete with documentation to
drop into the relevant part of Packages.txt and a diff against rev 1.971
of mk/bsd.pkg.mk:
--------------------------------------------------
Patch files which are optional and will depend on local site configuration
can be included with names matching the pattern "patches/patch-optional-*".
Their suffixes should match the configuration options. The selected
optional patch file names should be assigned to the variable
$OPTIONAL_PATCHFILES. They will not be applied by default.
For example if a package data file needs patching to indicate the default
local printer paper size as specified in the $PAPERSIZE file you can
include patches for all the possible paper sizes other than the one the
package comes configured for by default. In this case you might have a
patch called "patch-optional-Letter-papersize" and/or another patch called
"patch-optional-A4-papersize". In your Makefile you would select between
them with the following construct:
PATCHDIR= ${.CURDIR}/patches
.if exists(${PATCHDIR}/patch-optional-${PAPERSIZE}-papersize)
OPTIONAL_PATCHFILES+= ${PATCHDIR}/patch-optional-${PAPERSIZE}-papersize
.endif
Note that you have to define the value of $PATCHDIR in order to use it in a
".if" statement like this as otherwise it's not defined until too late
during the processing of the Makefile. You should use a ".if" statement in
order to avoid problems should the configuration item ($PAPERSIZE in this
example) be set to an unexpected value.
--------------------------------------------------
***************
*** 1686,1692 ****
${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
fi; \
else \
! patchlist=`${ECHO} ${PATCHDIR}/patch-*`; \
fi; \
fi; \
if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
--- 1780,1786 ----
${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
fi; \
else \
! patchlist=`${LS} -1 ${PATCHDIR}/patch-* | ${SED} 's|^${PATCHDIR}/patch-optional-.*$$||'`; \
fi; \
fi; \
if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
***************
*** 1697,1702 ****
--- 1791,1797 ----
else \
patchlist=`${ECHO} $${patchlist} ${_LOCALPATCHFILES}`; \
fi; \
+ patchlist="$${patchlist} $${OPTIONAL_PATCHFILES}"; \
if [ -n "$${patchlist}" ]; then \
${ECHO_MSG} "${_PKGSRC_IN}> Applying ${OPSYS} patches for ${PKGNAME}" ; \
fail=""; \
--
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>