Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Oct 2015 23:41:36 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r399170 - head/Mk/Scripts
Message-ID:  <201510122341.t9CNfaMK085997@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Mon Oct 12 23:41:36 2015
New Revision: 399170
URL: https://svnweb.freebsd.org/changeset/ports/399170

Log:
  Add a function to export vars that bsd.port.mk generates from fork/exec.
  
  This will be useful in Poudriere to avoid needless fork/exec for every
  port when gathering dependencies.
  
  Example usage:
  
    MAKE=make sh -c '. Mk/Scripts/functions.sh; export_index_env; export PACKAGE_BUILDING=1; truss -f make -C sysutils/zfstools -V BUILD_DEPENDS 2>&1' | grep exec
  
  This eliminates 14 exec/fork calls for this example, when PACKAGE_BUILDING
  is also set during -V.
  
  Care should be taken with UID not being passed down into actual builds as it
  may conflict with non-root builds.
  
  With hat:	portmgr

Modified:
  head/Mk/Scripts/functions.sh

Modified: head/Mk/Scripts/functions.sh
==============================================================================
--- head/Mk/Scripts/functions.sh	Mon Oct 12 23:39:33 2015	(r399169)
+++ head/Mk/Scripts/functions.sh	Mon Oct 12 23:41:36 2015	(r399170)
@@ -158,3 +158,54 @@ validate_env() {
 		exit 1
 	fi
 }
+
+export_index_env() {
+	local export_vars make_cmd make_env var results value
+
+	validate_env MAKE PORTSDIR
+
+	make_env="\
+		PACKAGE_BUILDING=1 \
+		GNU_CONFIGURE=1 \
+		USE_JAVA=1 \
+		USE_LINUX=1 \
+	"
+
+	make_cmd="${make_env}"
+
+	export_vars="\
+		ARCH \
+		CONFIGURE_MAX_CMD_LEN \
+		HAVE_COMPAT_IA32_KERN \
+		LINUX_OSRELEASE \
+		OPSYS \
+		OSREL \
+		OSVERSION \
+		UID \
+		_JAVA_OS_LIST_REGEXP \
+		_JAVA_PORTS_INSTALLED \
+		_JAVA_VENDOR_LIST_REGEXP \
+		_JAVA_VERSION_LIST_REGEXP \
+		_OSRELEASE \
+		_PKG_CHECKED \
+		_SMP_CPUS \
+	"
+
+	for var in ${export_vars}; do
+		make_cmd="${make_cmd}${make_cmd:+ }-V ${var}=\${${var}}"
+	done
+
+	# Bring in all the vars, but not empty ones.
+	eval $(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk ${make_cmd} | grep -v '=$')
+	for var in ${export_vars}; do
+		# Export and display non-empty ones.  This is not redundant
+		# with above since we're looping on all vars here; do not
+		# export a var we didn't eval in.
+		value="$(eval echo \$${var})"
+
+		if [ -n "${value}" ]; then
+			export ${var}
+			echo "export ${var}=${value}"
+		fi
+	done
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510122341.t9CNfaMK085997>