tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: RUN_PRECMD hook
Am 12.04.2026 um 16:01 schrieb Jonathan Perkin:
> --- 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};
If you go this route of allowing arbitrary commands, I'd prefer to name
the variable RUN_PRECMDS, so that it can be used like this:
#RUN_PRECMDS+= echo cmd;
#RUN_PRECMDS+= ulimit -S -t 3600;
This way, it is possible to quickly enable or disable commands as needed.
RUN= ${_PKG_SILENT}${_PKG_DEBUG} set -e; ${RUN_PRECMDS}
# (Without a semicolon at the end.)
This may be a nitpick, but since that variable is expanded many times,
the absent semicolon may make a difference. Not sure how long the shell
parser takes for parsing a single semicolon.
Pkglint can already handle both variants equally fine.
> Any better ideas? Would a more specific LIMIT_RESOURCES feature that is
> analogous to UNLIMIT_RESOURCES be more appropriate, or just too complex?
As long as you need only the ulimit case, I prefer to have a more
specific API that only allows ulimit changes. That way, its purpose will
be clear even five years later.
Roland
Home |
Main Index |
Thread Index |
Old Index