RUN_PRECMD hook

Jonathan Perkin <[email protected]> Sun, 12 Apr 2026 15:01:46 +0100
Newsgroups gmane.os.netbsd.devel.packages
Message-ID <[email protected]>
One final part of my bulk build migration is support for cputime limits 
to stop spinning processes from hanging builds indefinitely.  In pbulk I 
simply had this line in pbulk.conf:

   ulimit -S -t 3600

which then applied to all child build scripts.  I was about to add a new 
feature to bob to support arbitrary precmds, but on reflection felt that 
this would actually be better as a native pkgsrc feature so that it 
works everywhere and not just in bulk builds.

My initial draft is to add a RUN_PRECMD hook to ${RUN}, so that I can 
set e.g.

   RUN_PRECMD=	ulimit -S -t 3600

in mk.conf and everything should Just Work.

   --- a/mk/misc/common.mk
   +++ b/mk/misc/common.mk
   @@ -10,0 +11,5 @@
   +# RUN_PRECMD
   +#      Commands that are placed at the end of the expanded ${RUN} and before
   +#      the main body of commands.  This is a helpful place to insert e.g.
   +#      'ulimit' to avoid hung processes causing builds to run indefinitely.
   +#
   @@ -30,0 +36 @@ PKG_DEBUG_LEVEL?=       0
   +RUN_PRECMD?=           :
   @@ -44 +50 @@ _PKG_DEBUG_SCRIPT=        ${SH} -x
   -RUN=                   ${_PKG_SILENT}${_PKG_DEBUG} set -e;
   +RUN=                   ${_PKG_SILENT}${_PKG_DEBUG} set -e; ${RUN_PRECMD};

Any better ideas?  Would a more specific LIMIT_RESOURCES feature that is 
analogous to UNLIMIT_RESOURCES be more appropriate, or just too complex?

-- 
Jonathan Perkin                    pkgsrc.smartos.org
Open Source Complete Cloud   www.tritondatacenter.com