pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc
Module Name: pkgsrc
Committed By: rillig
Date: Sat Mar 21 13:30:35 UTC 2020
Modified Files:
pkgsrc/mk: subst.mk
pkgsrc/regress/infra-unittests: subst.sh
Log Message:
mk/subst.mk: add global SUBST_SHOW_DIFF variable
This is useful in bulk builds or when trying to understand what happens
under the hood, since the SUBST code leaves no .orig files around.
To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 pkgsrc/mk/subst.mk
cvs rdiff -u -r1.9 -r1.10 pkgsrc/regress/infra-unittests/subst.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/mk/subst.mk
diff -u pkgsrc/mk/subst.mk:1.66 pkgsrc/mk/subst.mk:1.67
--- pkgsrc/mk/subst.mk:1.66 Sat Mar 21 12:22:31 2020
+++ pkgsrc/mk/subst.mk Sat Mar 21 13:30:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.66 2020/03/21 12:22:31 rillig Exp $
+# $NetBSD: subst.mk,v 1.67 2020/03/21 13:30:35 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -15,6 +15,12 @@
# SUBST_FILES.prefix= ./configure doc/*.html
# SUBST_SED.prefix= -e 's,/usr/local,${PREFIX},g'
#
+# User-settable variables:
+#
+# SUBST_SHOW_DIFF
+# Whether to log each changed file as a unified diff, for all
+# SUBST classes. Defaults to "no".
+#
# Package-settable variables:
#
# SUBST_CLASSES
@@ -82,6 +88,7 @@
_VARGROUPS+= subst
_PKG_VARS.subst= SUBST_CLASSES
+SUBST_SHOW_DIFF?= no
.for c in ${SUBST_CLASSES}
. for pv in SUBST_STAGE SUBST_MESSAGE SUBST_FILES SUBST_SED SUBST_VARS \
SUBST_FILTER_CMD SUBST_SKIP_TEXT_CHECK SUBST_NOOP_OK
@@ -113,7 +120,7 @@ SUBST_MESSAGE.${_class_}?= Substituting
. for v in ${SUBST_VARS.${_class_}}
SUBST_FILTER_CMD.${_class_}+= -e s,@${v:C|[^A-Za-z0-9_]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
. endfor
-. if !empty(SUBST_SHOW_DIFF.${_class_}:Uno:M[Yy][Ee][Ss])
+. if ${SUBST_SHOW_DIFF.${_class_}:U${SUBST_SHOW_DIFF}:tl} == yes
_SUBST_KEEP.${_class_}?= ${DIFF} -u "$$file" "$$tmpfile" || true
. endif
_SUBST_KEEP.${_class_}?= ${DO_NADA}
Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.9 pkgsrc/regress/infra-unittests/subst.sh:1.10
--- pkgsrc/regress/infra-unittests/subst.sh:1.9 Sat Mar 21 12:47:13 2020
+++ pkgsrc/regress/infra-unittests/subst.sh Sat Mar 21 13:30:35 2020
@@ -627,3 +627,44 @@ EOF
test_case_end
fi
+
+
+if test_case_begin "global show diff"; then
+
+ create_file_lines "file" "one" "two" "three"
+
+ create_file "testcase.mk" <<EOF
+SUBST_CLASSES+= two
+SUBST_STAGE.two= pre-configure
+SUBST_FILES.two= file
+SUBST_SED.two= -e 's,two,II,'
+SUBST_SHOW_DIFF= yes
+
+.include "prepare-subst.mk"
+.include "mk/subst.mk"
+EOF
+
+ LC_ALL=C \
+ test_file "testcase.mk" "pre-configure" \
+ 1> "$tmpdir/stdout" \
+ 2> "$tmpdir/stderr" \
+ && exitcode=0 || exitcode=$?
+
+ awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
+ < "$tmpdir/stdout" > "$tmpdir/stdout-filtered"
+
+ assert_that "file" --file-is-lines "one" "II" "three"
+ assert_that "stdout-filtered" --file-is-lines \
+ "=> Substituting \"two\" in file" \
+ "--- ./file (filtered timestamp)" \
+ "+++ ./file.subst.sav (filtered timestamp)" \
+ "@@ -1,3 +1,3 @@" \
+ " one" \
+ "-two" \
+ "+II" \
+ " three"
+ assert_that "stderr" --file-is-empty
+ assert_that "$exitcode" --equals 0
+
+ test_case_end
+fi
Home |
Main Index |
Thread Index |
Old Index