summaryrefslogtreecommitdiff
path: root/mk/check
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-03-13 08:04:08 +0000
committerrillig <rillig@pkgsrc.org>2020-03-13 08:04:08 +0000
commitabc339854d734519b6ea7528a062a89f9e163ec1 (patch)
tree9ec7efebdf6e205dcd0195a3c4d9c541daaaa5de /mk/check
parentf63e49bce39d9a92350ef7751f9671527a025947 (diff)
downloadpkgsrc-abc339854d734519b6ea7528a062a89f9e163ec1.tar.gz
mk/check/check-perms: allow packages to skip the check completely
When all files are skipped, the tool dependency is not added as well. This allows packages to skip the check without defining the user-settable variable CHECK_PERMS.
Diffstat (limited to 'mk/check')
-rw-r--r--mk/check/check-perms.mk4
-rw-r--r--mk/check/check-portability.awk89
-rw-r--r--mk/check/check-portability.mk21
-rw-r--r--mk/check/check-portability.sh14
4 files changed, 14 insertions, 114 deletions
diff --git a/mk/check/check-perms.mk b/mk/check/check-perms.mk
index 2d6ef6e9d31..526319a3c92 100644
--- a/mk/check/check-perms.mk
+++ b/mk/check/check-perms.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-perms.mk,v 1.21 2019/10/01 21:56:11 rillig Exp $
+# $NetBSD: check-perms.mk,v 1.22 2020/03/13 08:04:08 rillig Exp $
#
# This file checks that after installation of a package, all files and
# directories of that package have sensible permissions set.
@@ -53,7 +53,7 @@ _CHECK_PERMS_FLAGS= -cff
_CHECK_PERMS_FLAGS= -c
.endif
-.if !empty(CHECK_PERMS:M[Yy][Ee][Ss])
+.if ${CHECK_PERMS:tl} == yes && ${CHECK_PERMS_SKIP} != "*"
TOOL_DEPENDS+= checkperms>=1.1:../../sysutils/checkperms
privileged-install-hook: _check-perms
diff --git a/mk/check/check-portability.awk b/mk/check/check-portability.awk
deleted file mode 100644
index 277f0e67388..00000000000
--- a/mk/check/check-portability.awk
+++ /dev/null
@@ -1,89 +0,0 @@
-# $NetBSD: check-portability.awk,v 1.9 2016/02/24 08:54:23 jklos Exp $
-#
-# Checks a shell file for possible portability problems.
-#
-# ENVIRONMENT
-# (See check-subr.awk)
-#
-
-BEGIN {
- found_random = no;
- found_test_eqeq = no;
-}
-
-# Check for $RANDOM, which is specific to ksh and bash.
-function check_random(line) {
-
- # $RANDOM together with the PID is often found in GNU-style
- # configure scripts and is considered acceptable.
- if (line ~ /\$\$-\$RANDOM/ || line ~ /\$RANDOM-\$\$/) {
- # Assume that this is ok.
-
- } else if (line ~ /\$RANDOM[A-Z_]+/) {
- # That's ok, too.
-
- } else if (line ~ /\$RANDOM/) {
- found_random = yes;
- cs_warning_heading("Found $RANDOM:");
- cs_warning_msg(cs_fname ": " $0);
- }
-}
-
-function check_test_eqeq(line, n, word, i) {
-
- if (length(line) == 0)
- return;
- n = split(line, word);
- for (i = 3; i < n; i++) {
- if (word[i] == "==") {
- if (word[i-2] == "test" || word[i-2] == "[") {
- found_test_eqeq = yes;
- cs_error_heading("Found test ... == ...:");
- cs_error_msg(cs_fname ": " $0);
- }
- }
- }
-}
-
-/./ {
- # Note: This code does not find _all_ instances of
- # unportable code. If a single line contains an unsafe and
- # a safe usage of $RANDOM, it will pass the test.
-
- # Strip comments
- line = $0;
- gsub(/^#.*/, "", line);
- gsub(/[[:space:]]#.*/, "", line);
-
- check_random(line);
- check_test_eqeq(line);
-}
-
-END {
- if (found_random) {
- h = "The variable $RANDOM is not required for a POSIX-conforming shell, and\n";
- h = h "many implementations of /bin/sh do not support it. It should therefore\n";
- h = h "not be used in shell programs that are meant to be portable across a\n";
- h = h "large number of POSIX-like systems.\n"
- cs_explain(h);
- }
-
- if (found_test_eqeq) {
- h = "The \"test\" command, as well as the \"[\" command, are not required to know\n";
- h = h "the \"==\" operator. Only a few implementations like bash and some\n";
- h = h "versions of ksh support it.\n";
- h = h "\n";
- h = h "When you run \"test foo == foo\" on a platform that does not support the\n";
- h = h "\"==\" operator, the result will be \"false\" instead of \"true\". This can\n";
- h = h "lead to unexpected behavior.\n";
- h = h "\n";
- h = h "There are two ways to fix this error message. If the file that contains\n";
- h = h "the \"test ==\" is needed for building the package, you should create a\n";
- h = h "patch for it, replacing the \"==\" operator with \"=\". If the file is not\n";
- h = h "needed, add its name to the CHECK_PORTABILITY_SKIP variable in the\n";
- h = h "package Makefile.\n";
- cs_explain(h);
- }
-
- cs_exit();
-}
diff --git a/mk/check/check-portability.mk b/mk/check/check-portability.mk
index 3a86e2c64d6..79b61b2932a 100644
--- a/mk/check/check-portability.mk
+++ b/mk/check/check-portability.mk
@@ -1,40 +1,39 @@
-# $NetBSD: check-portability.mk,v 1.12 2020/03/13 06:31:43 rillig Exp $
+# $NetBSD: check-portability.mk,v 1.13 2020/03/13 08:04:08 rillig Exp $
#
-# This file contains some checks that are applied to the configure
-# scripts to check for certain constructs that are known to cause
-# problems on some platforms. The detailed checks are in
-# check-portability.sh.
+# This file checks that the extracted shell programs don't contain
+# bashisms and other constructs that only work on some platforms.
#
# User-settable variables:
#
# CHECK_PORTABILITY
-# Whether to enable some portability checks for the configure
-# scripts before they are run.
+# Whether to enable the portability checks.
#
# Default value: yes for PKG_DEVELOPERs, no otherwise.
#
# Package-settable variables:
#
# CHECK_PORTABILITY_SKIP
-# The list of files that should be skipped in the portability
-# check.
+# The shell patterns that should not be checked.
+# Note that a * in a pattern also matches a slash in a pathname.
#
# Default value: ${REPLACE_BASH}
-# Example: debian/*
+# Examples: debian/* test/* *.bash
_VARGROUPS+= check-portability
_USER_VARS.check-portability= CHECK_PORTABILITY
_PKG_VARS.check-portability= CHECK_PORTABILITY_SKIP
-.if ${PKG_DEVELOPER:Uno} != "no"
+.if ${PKG_DEVELOPER:Uno} != no
CHECK_PORTABILITY?= yes
.endif
CHECK_PORTABILITY?= no
CHECK_PORTABILITY_SKIP?= ${REPLACE_BASH}
.if ${CHECK_PORTABILITY:tl} == yes && ${CHECK_PORTABILITY_SKIP} != "*"
+TOOL_DEPENDS+= check-portability>=19.4.1:../../pkgtools/check-portability
pre-configure-checks-hook: _check-portability
.endif
+
.PHONY: _check-portability
_check-portability:
@${STEP_MSG} "Checking for portability problems in extracted files"
diff --git a/mk/check/check-portability.sh b/mk/check/check-portability.sh
index fe969688a5e..6ed117d5a6a 100644
--- a/mk/check/check-portability.sh
+++ b/mk/check/check-portability.sh
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.sh,v 1.17 2020/03/12 19:09:41 rillig Exp $
+# $NetBSD: check-portability.sh,v 1.18 2020/03/13 08:04:08 rillig Exp $
#
# This program checks all files in the current directory and any
# subdirectories for portability issues that are likely to result in
@@ -20,18 +20,8 @@ cs_setprogname "$0"
# usage: check_shell <fname>
check_shell() {
- env \
- CK_FNAME="$1" \
- CK_PROGNAME="check-portability.awk" \
- awk -f "$checkdir/check-subr.awk" \
- -f "$checkdir/check-portability.awk" \
- < "$1" 1>&2 \
+ ${PREFIX}/bin/check-portability "$1" 1>&2 \
|| cs_exitcode=1
-
- if test -f "${PREFIX}/bin/check-portability"; then
- ${PREFIX}/bin/check-portability "$1" 1>&2 \
- || cs_exitcode=1
- fi
}
find ./* -type f -print 2>/dev/null \