aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-06-24 13:03:34 +0800
committerbdrewery <bdrewery@FreeBSD.org>2016-06-24 13:03:34 +0800
commitf2a268bff6d03e6829142057d8417620d6627619 (patch)
tree6b3097ccd15aae8771b691721b6707a22a4cd781
parent9cdce655ddaab3bbcdd840de95e95017794ea1cd (diff)
downloadfreebsd-ports-gnome-f2a268bff6d03e6829142057d8417620d6627619.tar.gz
freebsd-ports-gnome-f2a268bff6d03e6829142057d8417620d6627619.tar.zst
freebsd-ports-gnome-f2a268bff6d03e6829142057d8417620d6627619.zip
Add a function port_var_fetch() for fetching multiple variables from a port.
This is taken from Poudriere (uncommitted)
-rw-r--r--Mk/Scripts/functions.sh29
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
+}