diff options
-rw-r--r-- | mk/bsd.pkg.check.mk | 47 | ||||
-rw-r--r-- | mk/bsd.pkg.mk | 5 |
2 files changed, 50 insertions, 2 deletions
diff --git a/mk/bsd.pkg.check.mk b/mk/bsd.pkg.check.mk index 1c4bf8604fa..3e6c6d6d468 100644 --- a/mk/bsd.pkg.check.mk +++ b/mk/bsd.pkg.check.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.check.mk,v 1.23 2006/01/09 18:00:04 schmonz Exp $ +# $NetBSD: bsd.pkg.check.mk,v 1.24 2006/01/12 00:40:19 rillig Exp $ # # This Makefile fragment is included by bsd.pkg.mk and defines the # relevant variables and targets for the various install-time "check" @@ -31,6 +31,8 @@ # check-wrkref checks whether a package's installed files contain # references to ${WRKDIR}. # +# check-interpreter checks whether a script's interpreter exists. +# # For PKG_DEVELOPERs, cause some checks to be run automatically by default. .if defined(PKG_DEVELOPER) @@ -40,6 +42,7 @@ CHECK_WRKREF?= tools CHECK_FILES?= no CHECK_FILES_STRICT?= no CHECK_WRKREF?= no +CHECK_INTERPRETER?= no USE_TOOLS+= awk cat cmp diff echo find grep rm sed test \ touch true @@ -407,3 +410,45 @@ check-wrkref: exit 1; \ fi; } .endif + +########################################################################### +### check-interpreter ##################################################### +########################################################################### + +########################################################################### +# CHECK_INTERPRETER_SKIP is a list of shell globs. Installed files that +# match these globs are skipped when running the check-interpreter target. +# +_CHECK_INTERP_SKIP_FILTER= case $$file in +.for _pattern_ in ${CHECK_INTERPRETER_SKIP:U} +_CHECK_INTERP_SKIP_FILTER+= ${_pattern_}) continue ;; +.endfor +_CHECK_INTERP_SKIP_FILTER+= *) ;; +_CHECK_INTERP_SKIP_FILTER+= esac + +########################################################################### +# check-interpreter target +# +.PHONY: check-interpreter +check-interpreter: + ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \ + "${_PKGSRC_IN}> Checking for non-existent script interpreters in ${PKGNAME}" + ${_PKG_SILENT}${_PKG_DEBUG} \ + ${PKG_INFO} -qL ${PKGNAME:Q} | ${SORT} | ${SED} 's,\\,\\\\,g' | \ + { exitcode=0; \ + while read file; do \ + ${_CHECK_INTERP_SKIP_FILTER}; \ + ${SHCOMMENT} "[$$file]"; \ + interp=`${SED} -n -e '1s/^#! *\([^ ]*\).*/\1/p' -e '2q' < "$$file"` \ + || { ${ECHO} "[bsd.pkg.check.mk] WARNING: sed(1) failed for \"$$file\"." 1>&2; \ + continue; \ + }; \ + case $$interp in \ + "") continue; \ + esac; \ + if ${TEST} ! -f "$$interp"; then \ + ${ECHO} "[bsd.pkg.check.mk] ERROR: File \"$$file\"'s interpreter \"$$interp\" does not exist." 1>&2; \ + exitcode=1; \ + fi; \ + done; \ + exit $$exitcode; } diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index 3ab3ccd800e..d4190dd1431 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.1786 2006/01/11 05:48:19 schmonz Exp $ +# $NetBSD: bsd.pkg.mk,v 1.1787 2006/01/12 00:40:19 rillig Exp $ # # This file is in the public domain. # @@ -2179,6 +2179,9 @@ real-su-install: ${MESSAGE} .if empty(CHECK_FILES:M[nN][oO]) ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-files .endif +.if empty(CHECK_INTERPRETER:M[nN][oO]) + ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-interpreter +.endif |