pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/regress/env-vars regress/env-vars: demonstrate where a...
details: https://anonhg.NetBSD.org/pkgsrc/rev/e6e78d572329
branches: trunk
changeset: 387071:e6e78d572329
user: rillig <rillig%pkgsrc.org@localhost>
date: Fri Nov 09 06:46:03 2018 +0000
description:
regress/env-vars: demonstrate where and how the *_ENV variables are set
diffstat:
regress/env-vars/DESCR | 2 +
regress/env-vars/Makefile | 49 ++++++++++++++++++++++++++++++
regress/env-vars/PLIST | 2 +
regress/env-vars/files/Makefile | 6 +++
regress/env-vars/files/configure | 5 +++
regress/env-vars/spec | 65 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 129 insertions(+), 0 deletions(-)
diffs (153 lines):
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/DESCR Fri Nov 09 06:46:03 2018 +0000
@@ -0,0 +1,2 @@
+Demonstrate how the various *_ENV variables fit together and where they
+are available.
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/Makefile Fri Nov 09 06:46:03 2018 +0000
@@ -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"
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/PLIST Fri Nov 09 06:46:03 2018 +0000
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2018/11/09 06:46:03 rillig Exp $
+@comment intentionally empty
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/files/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/files/Makefile Fri Nov 09 06:46:03 2018 +0000
@@ -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"
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/files/configure
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/files/configure Fri Nov 09 06:46:03 2018 +0000
@@ -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"
diff -r 804a83f2b1b9 -r e6e78d572329 regress/env-vars/spec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/env-vars/spec Fri Nov 09 06:46:03 2018 +0000
@@ -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"
+}
Home |
Main Index |
Thread Index |
Old Index