pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/mk
Module Name: pkgsrc
Committed By: rillig
Date: Sun Sep 8 09:06:06 UTC 2019
Modified Files:
pkgsrc/mk: subst.mk
Log Message:
mk/subst.mk: document variables used in the file, remove SUBST_TARGETS
All variables that are used or defined in the file are now listed in the
_VARGROUPS section.
The "is text file" command variable has been renamed since pkglint
thought the former variable name would specify a filename, not a shell
command.
The "is text file" command has been rewritten to only rely on tr(1)
instead of both tr(1) and wc(1). This makes it both simpler and maybe
also a little faster, since the file only has to be read once.
The SUBST_TARGETS variable has been removed since it is used nowhere
else. To get the list of all subst targets (should that ever be
necessary), use the expression ${SUBST_CLASSES:S,^,subst-,}.
To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 pkgsrc/mk/subst.mk
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.60 pkgsrc/mk/subst.mk:1.61
--- pkgsrc/mk/subst.mk:1.60 Sun Apr 28 12:31:15 2019
+++ pkgsrc/mk/subst.mk Sun Sep 8 09:06:06 2019
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.60 2019/04/28 12:31:15 rillig Exp $
+# $NetBSD: subst.mk,v 1.61 2019/09/08 09:06:06 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -73,19 +73,17 @@ _PKG_VARS.subst= SUBST_CLASSES
_PKG_VARS.subst+= ${pv}.${c}
. endfor
.endfor
+_DEF_VARS.subst= ECHO_SUBST_MSG
+_USE_VARS.subst= WRKDIR WRKSRC
+_IGN_VARS.subst= _SUBST_IS_TEXT_FILE_CMD
_SORTED_VARS.subst= SUBST_CLASSES SUBST_FILES.* SUBST_VARS.*
_LISTED_VARS.subst= SUBST_SED.* SUBST_FILTER_CMD.*
ECHO_SUBST_MSG?= ${STEP_MSG}
-# _SUBST_IS_TEXT_FILE returns 0 if $${file} is a text file.
-_SUBST_IS_TEXT_FILE?= \
- { nchars=`${WC} -c < "$$file"`; \
- notnull=`LC_ALL=C ${TR} -d '\\0' < "$$file" | ${WC} -c`; \
- [ "$$nchars" = "$$notnull" ] || ${FALSE} ; \
- }
-
-_SUBST_BACKUP_SUFFIX= .subst.sav
+# _SUBST_IS_TEXT_FILE_CMD returns 0 if $$file is a text file.
+_SUBST_IS_TEXT_FILE_CMD?= \
+ [ -z "`${TR} -cd '\\0' < "$$file" | ${TR} '\\0' 'x'`" ]
.for _class_ in ${SUBST_CLASSES}
_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
@@ -103,13 +101,11 @@ _SUBST_KEEP.${_class_}?= ${DO_NADA}
SUBST_SKIP_TEXT_CHECK.${_class_}?= no
.if !empty(SUBST_SKIP_TEXT_CHECK.${_class_}:M[Yy][Ee][Ss])
-_SUBST_IS_TEXT_FILE.${_class_}= ${TRUE}
+_SUBST_IS_TEXT_FILE_CMD.${_class_}= ${TRUE}
.else
-_SUBST_IS_TEXT_FILE.${_class_}= ${_SUBST_IS_TEXT_FILE}
+_SUBST_IS_TEXT_FILE_CMD.${_class_}= ${_SUBST_IS_TEXT_FILE_CMD}
.endif
-SUBST_TARGETS+= subst-${_class_}
-
. if defined(SUBST_STAGE.${_class_})
${SUBST_STAGE.${_class_}}: subst-${_class_}
. else
@@ -128,10 +124,10 @@ ${_SUBST_COOKIE.${_class_}}:
files=${SUBST_FILES.${_class_}:Q}; \
for file in $$files; do \
case $$file in /*) ;; *) file="./$$file";; esac; \
- tmpfile="$$file"${_SUBST_BACKUP_SUFFIX:Q}; \
+ tmpfile="$$file.subst.sav"; \
if [ ! -f "$$file" ]; then \
${WARNING_MSG} "[subst.mk:${_class_}] Ignoring non-existent file \"$$file\"."; \
- elif ${_SUBST_IS_TEXT_FILE.${_class_}}; then \
+ elif ${_SUBST_IS_TEXT_FILE_CMD.${_class_}}; then \
${SUBST_FILTER_CMD.${_class_}} \
< "$$file" \
> "$$tmpfile"; \
Home |
Main Index |
Thread Index |
Old Index