aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Scripts/check-stagedir.sh16
-rw-r--r--Mk/Scripts/do-depends.sh13
-rw-r--r--Mk/Scripts/functions.sh14
3 files changed, 17 insertions, 26 deletions
diff --git a/Mk/Scripts/check-stagedir.sh b/Mk/Scripts/check-stagedir.sh
index 289e295bf59e..c1a5baf88f43 100644
--- a/Mk/Scripts/check-stagedir.sh
+++ b/Mk/Scripts/check-stagedir.sh
@@ -224,20 +224,8 @@ case "$1" in
esac
# validate environment
-envfault=
-for i in STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE \
- TMPPLIST PLIST_SUB_SED SCRIPTSDIR \
- PORT_OPTIONS NO_PREFIX_RMDIR
-do
- if ! ( eval ": \${${i}?}" ) 2>/dev/null ; then
- envfault="${envfault}${envfault:+" "}${i}"
- fi
-done
-if [ -n "$envfault" ] ; then
- echo "Environment variables $envfault undefined. Aborting." \
- | fmt >&2
- exit 1
-fi
+validate_env STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE \
+ TMPPLIST PLIST_SUB_SED SCRIPTSDIR PORT_OPTIONS NO_PREFIX_RMDIR
set -u
diff --git a/Mk/Scripts/do-depends.sh b/Mk/Scripts/do-depends.sh
index b3f3fb097d67..613ea0cff634 100644
--- a/Mk/Scripts/do-depends.sh
+++ b/Mk/Scripts/do-depends.sh
@@ -7,22 +7,11 @@ set -e
. ${dp_SCRIPTSDIR}/functions.sh
-envfault=
-for i in dp_RAWDEPENDS dp_DEPTYPE dp_DEPENDS_TARGET dp_DEPENDS_PRECLEAN \
+validate_env dp_RAWDEPENDS dp_DEPTYPE dp_DEPENDS_TARGET dp_DEPENDS_PRECLEAN \
dp_DEPENDS_CLEAN dp_DEPENDS_ARGS dp_USE_PACKAGE_DEPENDS \
dp_USE_PACKAGE_DEPENDS_ONLY dp_PKG_ADD dp_PKG_INFO dp_WRKDIR \
dp_PKGNAME dp_STRICT_DEPENDS dp_LOCALBASE dp_LIB_DIRS dp_SH \
dp_SCRIPTSDIR dp_PORTSDIR dp_MAKE
-do
- if ! (eval ": \${${i}?}" ) >/dev/null; then
- envfault="${envfault}${envfault:+" "}${i}"
- fi
-done
-if [ -n "${envfault}" ]; then
- echo "Environment variable ${envfault} undefined. Aborting." \
- | fmt >&2
- exit 1
-fi
set -u
diff --git a/Mk/Scripts/functions.sh b/Mk/Scripts/functions.sh
index 1633fbfe4d51..7f3de680c4a4 100644
--- a/Mk/Scripts/functions.sh
+++ b/Mk/Scripts/functions.sh
@@ -139,3 +139,17 @@ parse_plist() {
esac
done
}
+
+validate_env() {
+ local envfault
+ for i ; do
+ if ! (eval ": \${${i}?}" ) >/dev/null; then
+ envfault="${envfault}${envfault:+" "}${i}"
+ fi
+ done
+ if [ -n "${envfault}" ]; then
+ echo "Environment variable ${envfault} undefined. Aborting." \
+ | fmt >&2
+ exit 1
+ fi
+}