diff options
| author | Bryan Drewery <bdrewery@FreeBSD.org> | 2016-06-24 05:03:34 +0000 |
|---|---|---|
| committer | Bryan Drewery <bdrewery@FreeBSD.org> | 2016-06-24 05:03:34 +0000 |
| commit | 5061f450c87cc736453e51ef48a768f0d17aeee0 (patch) | |
| tree | 6b3097ccd15aae8771b691721b6707a22a4cd781 /Mk/Scripts/functions.sh | |
| parent | Show proper variable in error. (diff) | |
Add a function port_var_fetch() for fetching multiple variables from a port.
This is taken from Poudriere (uncommitted)
Diffstat (limited to 'Mk/Scripts/functions.sh')
| -rw-r--r-- | Mk/Scripts/functions.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Mk/Scripts/functions.sh b/Mk/Scripts/functions.sh index 1aa1e8f5118c..7c6122afc5d0 100644 --- a/Mk/Scripts/functions.sh +++ b/Mk/Scripts/functions.sh @@ -250,3 +250,32 @@ escape() { unescape() { echo "$1" | sed -e 's/\\//g' } + +# Fetch vars from the Makefile and set them locally. +# port_var_fetch ports-mgmt/pkg "" PKGNAME pkgname PKGBASE pkgbase ... +# the 2nd variable is for passing any wanted make arguments, such as +# DEPENDS_ARGS. +port_var_fetch() { + local origin="$1" + local make_args="$2" + local _makeflags _vars + local _portvar _var _line + + _makeflags= + _vars= + shift 2 + while [ $# -ge 2 ]; do + _portvar="$1" + _var="$2" + _makeflags="${_makeflags}${_makeflags:+ }-V${_portvar}" + _vars="${_vars}${_vars:+ }${_var}" + shift 2 + done + set -- ${_vars} + while read -r _line; do + setvar "$1" "${_line}" + shift + done <<-EOF + $(${dp_MAKE} -C "${origin}" ${make_args} ${_makeflags} || echo) + EOF +} |
