pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/configure Added some common script interpreters (aw...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2ff6be7bec4e
branches:  trunk
changeset: 516153:2ff6be7bec4e
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 15 09:52:00 2006 +0000

description:
Added some common script interpreters (awk, bash, sh) that can be
replaced automatically by defining REPLACE_AWK, REPLACE_BASH or
REPLACE_SH and an appropriate addition to USE_TOOLS.

The replace-interpreter.mk file is included unconditionally because the
number of variables that would trigger the inclusion of this file is
quite large.

diffstat:

 mk/configure/configure.mk           |    6 +-
 mk/configure/replace-interpreter.mk |  100 ++++++++++++++++++++++++++++-------
 2 files changed, 82 insertions(+), 24 deletions(-)

diffs (142 lines):

diff -r 62691fa61b34 -r 2ff6be7bec4e mk/configure/configure.mk
--- a/mk/configure/configure.mk Sat Jul 15 07:31:45 2006 +0000
+++ b/mk/configure/configure.mk Sat Jul 15 09:52:00 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: configure.mk,v 1.4 2006/07/07 21:24:28 jlam Exp $
+# $NetBSD: configure.mk,v 1.5 2006/07/15 09:52:00 rillig Exp $
 #
 # CONFIGURE_SCRIPT is the path to the script to run in order to
 #      configure the software for building.  If the path is relative,
@@ -28,9 +28,7 @@
 .if defined(PKGCONFIG_OVERRIDE)
 .  include "${PKGSRCDIR}/mk/configure/pkg-config-override.mk"
 .endif
-.if defined(REPLACE_INTERPRETER) || defined(REPLACE_PERL)
-.  include "${PKGSRCDIR}/mk/configure/replace-interpreter.mk"
-.endif
+.include "${PKGSRCDIR}/mk/configure/replace-interpreter.mk"
 .if defined(USE_PKGLOCALEDIR)
 .  include "${PKGSRCDIR}/mk/configure/replace-localedir.mk"
 .endif
diff -r 62691fa61b34 -r 2ff6be7bec4e mk/configure/replace-interpreter.mk
--- a/mk/configure/replace-interpreter.mk       Sat Jul 15 07:31:45 2006 +0000
+++ b/mk/configure/replace-interpreter.mk       Sat Jul 15 09:52:00 2006 +0000
@@ -1,4 +1,33 @@
-# $NetBSD: replace-interpreter.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+# $NetBSD: replace-interpreter.mk,v 1.2 2006/07/15 09:52:00 rillig Exp $
+
+# This file provides common templates for replacing #! interpreters
+# in script files.
+#
+# The following variables may be set by a package:
+#
+# REPLACE_AWK          : List of Pathmask (default: none)
+# REPLACE_BASH         : List of Pathmask (default: none)
+# REPLACE_PERL         : List of Pathmask (default: none)
+# REPLACE_SH           : List of Pathmask (default: none)
+#      In these files the interpreter in the first line is replaced
+#      with the one that is available in pkgsrc. If any directory names
+#      appear in the lists, they are silenty skipped, assuming that
+#      they result from shell globbing expressions.
+#
+#      Use REPLACE_SH for shell programs that don't need any
+#      special features from bash, and REPLACE_BASH for the
+#      others.
+#
+#      Note that in all the above cases, you have to add the needed
+#      tools manually to USE_TOOLS, since there is no way to detect
+#      automatically whether a tool should be a build-time or a
+#      run-time dependency.
+#
+# Packages may also add their own interpreter replacements, which should
+# just look like the examples below. For the REPLACE_INTERPRETER
+# variable, all identifiers starting with "sys-" are reserved for the
+# pkgsrc infrastructure. All others may be used freely.
+#
 
 ######################################################################
 ### replace-interpreter (PRIVATE)
@@ -8,11 +37,38 @@
 ###
 do-configure-pre-hook: replace-interpreter
 
-.if defined(REPLACE_PERL)
-REPLACE_INTERPRETER+=  perl
-REPLACE.perl.old=      .*/bin/perl
-REPLACE.perl.new=      ${PERL5}
-REPLACE_FILES.perl=    ${REPLACE_PERL}
+REPLACE_INTERPRETER?=  # none
+REPLACE_AWK?=  # none
+REPLACE_BASH?= # none
+REPLACE_PERL?= # none
+REPLACE_SH?=   # none
+
+.if !empty(REPLACE_AWK:M*)
+REPLACE_INTERPRETER+=  sys-AWK
+REPLACE.sys-AWK.old=   .*awk
+REPLACE.sys-AWK.new=   ${AWK}
+REPLACE_FILES.sys-AWK= ${REPLACE_AWK}
+.endif
+
+.if !empty(REPLACE_BASH:M*)
+REPLACE_INTERPRETER+=  sys-bash
+REPLACE.sys-bash.old=  .*bash
+REPLACE.sys-bash.new=  ${BASH}
+REPLACE_FILES.sys-bash=        ${REPLACE_BASH}
+.endif
+
+.if !empty(REPLACE_PERL:M*)
+REPLACE_INTERPRETER+=  sys-Perl
+REPLACE.sys-Perl.old=  .*perl[^[:space:]]*
+REPLACE.sys-Perl.new=  ${PERL5}
+REPLACE_FILES.sys-Perl=        ${REPLACE_PERL}
+.endif
+
+.if !empty(REPLACE_SH:M*)
+REPLACE_INTERPRETER+=  sys-sh
+REPLACE.sys-sh.old=    [^[:space:]]*sh
+REPLACE.sys-sh.new=    ${SH}
+REPLACE_FILES.sys-sh=  ${REPLACE_SH}
 .endif
 
 # XXX After 2006Q2, all instances of _REPLACE.* and _REPLACE_FILES.* should
@@ -28,21 +84,25 @@
 .PHONY: replace-interpreter
 replace-interpreter:
 .for _lang_ in ${REPLACE_INTERPRETER}
-       @${STEP_MSG} "Replacing interpreter paths in scripts"
-.  for _pattern_ in ${REPLACE_FILES.${_lang_}}
-       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
+.  if defined(REPLACE_FILES.${_lang_}) && !empty(REPLACE_FILES.${_lang_}:M*)
+       @${STEP_MSG} "Replacing ${_lang_:S/^sys-//} interpreter in "${REPLACE_FILES.${_lang_}:M*:Q}"."
+       ${_PKG_SILENT}${_PKG_DEBUG} set -eu;                            \
        cd ${WRKSRC};                                                   \
-       for file in ${_pattern_}; do                                    \
-               if ${TEST} ! -f "$$file"; then                          \
-                       ${WARNING_MSG} "[replace-interpreter.mk] Skipping non-existent file \"$$file\"."; \
-                       continue;                                       \
+       for f in ${REPLACE_FILES.${_lang_}}; do                         \
+               if [ -f "$${f}" ]; then                                 \
+                       ${SED} -e '1s|^#!${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \
+                       < "$${f}" > "$${f}.new";                        \
+                       if [ -x "$${f}" ]; then                         \
+                               ${CHMOD} a+x "$${f}.new";               \
+                       fi;                                             \
+                       ${MV} -f "$${f}.new" "$${f}";                   \
+               elif [ -d "$$f" ]; then                                 \
+                       ${SHCOMMENT} "Ignore it, most probably comes from shell globs"; \
+               else                                                    \
+                       ${WARNING_MSG} "[replace-interpreter] Skipping non-existent file \"$$f\"."; \
                fi;                                                     \
-               ${SED} -e '1s|^#!${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \
-                       $$file > $$file.new;                            \
-               if ${TEST} -x $$file; then                              \
-                       ${CHMOD} a+x $$file.new;                        \
-               fi;                                                     \
-               ${MV} -f $$file.new $$file;                             \
        done
-.  endfor
+.  else
+       @${WARNING_MSG} "[replace-interpreter] Empty list of files for ${_lang_}."
+.  endif
 .endfor



Home | Main Index | Thread Index | Old Index