diff options
author | bapt <bapt@FreeBSD.org> | 2015-07-02 04:08:26 +0800 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-07-02 04:08:26 +0800 |
commit | 09e8e0cdcd340808495fc581ec755f721f4085a8 (patch) | |
tree | 547865d24c61eef4ed9006ed0a91e025c11beda8 /Mk | |
parent | 05ac1f9b312e77f09cfcb099dba9c87a32cab0e9 (diff) | |
download | freebsd-ports-gnome-09e8e0cdcd340808495fc581ec755f721f4085a8.tar.gz freebsd-ports-gnome-09e8e0cdcd340808495fc581ec755f721f4085a8.tar.zst freebsd-ports-gnome-09e8e0cdcd340808495fc581ec755f721f4085a8.zip |
Factorize the function to validate env
Reviewed by: antoine
Differential Revision: https://reviews.freebsd.org/D2966
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Scripts/check-stagedir.sh | 16 | ||||
-rw-r--r-- | Mk/Scripts/do-depends.sh | 13 | ||||
-rw-r--r-- | Mk/Scripts/functions.sh | 14 |
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 +} |