pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/regress/env-vars



Module Name:    pkgsrc
Committed By:   rillig
Date:           Fri Nov  9 06:46:03 UTC 2018

Added Files:
        pkgsrc/regress/env-vars: DESCR Makefile PLIST spec
        pkgsrc/regress/env-vars/files: Makefile configure

Log Message:
regress/env-vars: demonstrate where and how the *_ENV variables are set


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/env-vars/DESCR \
    pkgsrc/regress/env-vars/Makefile pkgsrc/regress/env-vars/PLIST \
    pkgsrc/regress/env-vars/spec
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/env-vars/files/Makefile \
    pkgsrc/regress/env-vars/files/configure

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/regress/env-vars/DESCR
diff -u /dev/null pkgsrc/regress/env-vars/DESCR:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/DESCR       Fri Nov  9 06:46:03 2018
@@ -0,0 +1,2 @@
+Demonstrate how the various *_ENV variables fit together and where they
+are available.
Index: pkgsrc/regress/env-vars/Makefile
diff -u /dev/null pkgsrc/regress/env-vars/Makefile:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/Makefile    Fri Nov  9 06:46:03 2018
@@ -0,0 +1,49 @@
+# $NetBSD: Makefile,v 1.1 2018/11/09 06:46:03 rillig Exp $
+#
+
+DISTNAME=      env-vars-1.0
+CATEGORIES=    regress
+MASTER_SITES=  # none
+DISTFILES=     # none
+
+MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
+COMMENT=       Demonstrates the various *_ENV variables
+LICENSE=       2-clause-bsd
+
+USE_TOOLS+=    printf env sed sort
+NO_CHECKSUM=   yes
+HAS_CONFIGURE= yes
+WRKSRC=                ${WRKDIR}
+
+ENV_VARS+=     PKGSRC_MAKE_ENV
+ENV_VARS+=     EXTRACT_ENV
+ENV_VARS+=     CONFIGURE_ENV
+ENV_VARS+=     ALL_ENV
+ENV_VARS+=     MAKE_ENV
+ENV_VARS+=     BSD_MAKE_ENV
+ENV_VARS+=     INSTALL_ENV
+
+.for v in ${ENV_VARS}
+${v}+=                 ${v}_set=yes
+.endfor
+
+do-extract:
+       ${CP} ${FILESDIR}/configure ${FILESDIR}/Makefile ${WRKSRC}
+
+.include "../../mk/bsd.pkg.mk"
+
+# These definitions must be below bsd.pkg.mk, or their pkgsrc default
+# actions will not be run.
+#
+pre-fetch      do-fetch        post-fetch \
+pre-extract    do-extract      post-extract \
+pre-patch      do-patch        post-patch \
+pre-configure  do-configure    post-configure \
+pre-build      do-build        post-build \
+pre-install    do-install      post-install: \
+save-env-vars
+
+save-env-vars: .USE .PHONY
+       ${RUN}                                                          \
+       env | sed -n -e '/^[^=]*_set=yes$$/p' | LC_ALL=C sort           \
+       > "$$REGRESS_TMPDIR/${.TARGET}.vars"
Index: pkgsrc/regress/env-vars/PLIST
diff -u /dev/null pkgsrc/regress/env-vars/PLIST:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/PLIST       Fri Nov  9 06:46:03 2018
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2018/11/09 06:46:03 rillig Exp $
+@comment intentionally empty
Index: pkgsrc/regress/env-vars/spec
diff -u /dev/null pkgsrc/regress/env-vars/spec:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/spec        Fri Nov  9 06:46:03 2018
@@ -0,0 +1,65 @@
+# $NetBSD: spec,v 1.1 2018/11/09 06:46:03 rillig Exp $
+#
+
+tmpdir=${TMPDIR:-/tmp}/pkgsrc-env-vars
+rm -rf "$tmpdir"
+mkdir -p "$tmpdir"
+
+require_file_has_lines() { # filename line...
+       rfhl_expected="$tmpdir/expected"
+       rfhl_actual=$1
+       shift
+
+       printf '%s\n' "$@" > "$rfhl_expected"
+
+       if diff -u "$rfhl_expected" "$rfhl_actual" > /dev/null; then
+               :
+       else
+               regress_fail "Expected files to be equal."
+               diff -u "$rfhl_expected" "$rfhl_actual" || true
+       fi
+
+       rm -f "$rfhl_expected"
+}
+
+
+do_test() {
+       env REGRESS_TMPDIR="$tmpdir" $TEST_MAKE clean
+       env REGRESS_TMPDIR="$tmpdir" $TEST_MAKE update
+}
+
+check_result() {
+
+       # In the {pre,do,post}-* targets, only the PKGSRC_MAKE_ENV
+       # variables are set.
+       #
+       require_file_has_lines "$tmpdir/do-build.vars" \
+               "PKGSRC_MAKE_ENV_set=yes"
+
+       # In the configure script of the package, some more variables
+       # are set.
+       #
+       require_file_has_lines "$tmpdir/configure.vars" \
+               "ALL_ENV_set=yes" \
+               "CONFIGURE_ENV_set=yes" \
+               "PKGSRC_MAKE_ENV_set=yes"
+
+       # In the build phase, when the default do-build commands are
+       # run, the Makefiles from the package have access to these
+       # variables:
+       #
+       require_file_has_lines "$tmpdir/make-all.vars" \
+               "ALL_ENV_set=yes" \
+               "MAKE_ENV_set=yes" \
+               "PKGSRC_MAKE_ENV_set=yes"
+
+       # In the install phase, when the default do-install commands are
+       # run, the Makefiles from the package have access to these
+       # variables:
+       #
+       require_file_has_lines "$tmpdir/make-install.vars" \
+               "ALL_ENV_set=yes" \
+               "INSTALL_ENV_set=yes" \
+               "MAKE_ENV_set=yes" \
+               "PKGSRC_MAKE_ENV_set=yes"
+}

Index: pkgsrc/regress/env-vars/files/Makefile
diff -u /dev/null pkgsrc/regress/env-vars/files/Makefile:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/files/Makefile      Fri Nov  9 06:46:03 2018
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.1 2018/11/09 06:46:03 rillig Exp $
+
+all install:
+       @set -eu; \
+       env | sed -n -e '/^.*_set=yes$$/p' | LC_ALL=C sort \
+       > "$$REGRESS_TMPDIR/make-${.TARGET}.vars"
Index: pkgsrc/regress/env-vars/files/configure
diff -u /dev/null pkgsrc/regress/env-vars/files/configure:1.1
--- /dev/null   Fri Nov  9 06:46:03 2018
+++ pkgsrc/regress/env-vars/files/configure     Fri Nov  9 06:46:03 2018
@@ -0,0 +1,5 @@
+# $NetBSD: configure,v 1.1 2018/11/09 06:46:03 rillig Exp $
+set -eu
+
+env | sed -n -e '/^.*_set=yes$/p' | LC_ALL=C sort \
+> "$REGRESS_TMPDIR/configure.vars"



Home | Main Index | Thread Index | Old Index