summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig>2006-11-09 10:52:21 +0000
committerrillig <rillig>2006-11-09 10:52:21 +0000
commitfb9b1e60df3e437999f79e6bf3da23400bc5f527 (patch)
tree63b130754bf11c1709368c255671fee9788087fb /mk
parentbf11ba3f2b6b79cf5348cf209bb025b33b386ad7 (diff)
downloadpkgsrc-fb9b1e60df3e437999f79e6bf3da23400bc5f527.tar.gz
Added a function cs_explain() to check-subr.sh that prints an
explanation for an error message, nicely formatted. Added explanations for the checks in check-portability.sh.
Diffstat (limited to 'mk')
-rw-r--r--mk/check/check-headers.sh6
-rw-r--r--mk/check/check-portability.sh35
-rw-r--r--mk/check/check-subr.sh16
3 files changed, 51 insertions, 6 deletions
diff --git a/mk/check/check-headers.sh b/mk/check/check-headers.sh
index 937ddfb755f..db36345997d 100644
--- a/mk/check/check-headers.sh
+++ b/mk/check/check-headers.sh
@@ -1,4 +1,4 @@
-# $NetBSD: check-headers.sh,v 1.4 2006/11/09 10:31:54 rillig Exp $
+# $NetBSD: check-headers.sh,v 1.5 2006/11/09 10:52:21 rillig Exp $
#
# This program checks the header files for possible problems.
#
@@ -45,8 +45,7 @@ find * -type f -print 2>/dev/null \
done
if [ $found_unresolved_variable = yes ]; then
- cat 1>&2 <<EOF
-===========================================================================
+ cs_explain <<EOF
The above macros may contain references to shell variables.
The cause of this problem is usually that in a configure.ac or
@@ -69,7 +68,6 @@ something like this:
If this check is wrong and the package really wants to have "\${" in the
macros, append the above filenames to the CHECK_HEADERS_SKIP variable in
the package Makefile.
-===========================================================================
EOF
fi
diff --git a/mk/check/check-portability.sh b/mk/check/check-portability.sh
index c3bb798f098..a7320e0daef 100644
--- a/mk/check/check-portability.sh
+++ b/mk/check/check-portability.sh
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.sh,v 1.1 2006/11/09 02:53:15 rillig Exp $
+# $NetBSD: check-portability.sh,v 1.2 2006/11/09 10:52:21 rillig Exp $
#
# This program checks the extracted files for portability issues that
# are likely to result in false assumptions by the package.
@@ -12,6 +12,9 @@ set -eu
. "${PKGSRCDIR}/mk/check/check-subr.sh"
cs_setprogname "$0"
+found_random=no
+found_test_eqeq=no
+
# usage: check_shell <fname>
check_shell() {
# See the end of the loop for the redirection.
@@ -37,6 +40,7 @@ check_shell() {
;;
*\$RANDOM*)
+ found_random=yes
cs_warning_heading "Found \$RANDOM:"
cs_warning_msg "$fname: $line"
;;
@@ -50,6 +54,7 @@ check_shell() {
case "$1" in
"test" | "[")
if [ "==" = "$3" ]; then
+ found_test_eqeq=yes
cs_error_heading "Found test ... == ...:"
cs_error_msg "$fname: $line"
fi
@@ -74,5 +79,33 @@ find * -type f -print 2>/dev/null \
;;
esac
done
+
+ if [ $found_random = yes ]; then
+ cs_explain <<EOF
+The variable \$RANDOM is not required for a POSIX-conforming shell, and
+many implementations of /bin/sh do not support it. It should therefore
+not be used in shell programs that are meant to be portable across a
+large number of POSIX-like systems.
+EOF
+ fi
+
+ if [ $found_test_eqeq = yes ]; then
+ cs_explain <<EOF
+The "test" command, as well as the "[" command, are not required to know
+the "==" operator. Only a few implementations like bash and some
+versions of ksh support it.
+
+When you run "test foo == foo" on a platform that does not support the
+"==" operator, the result will be "false" instead of "true". This can
+lead to unexpected behavior.
+
+There are two ways to fix this error message. If the file that contains
+the "test ==" is needed for building the package, you should create a
+patch for it, replacing the "==" operator with "=". If the file is not
+needed, add its name to the CHECK_PORTABILITY_SKIP variable in the
+package Makefile.
+EOF
+ fi
+
cs_exit
}
diff --git a/mk/check/check-subr.sh b/mk/check/check-subr.sh
index 6e9a7364584..2ec44f7ee2a 100644
--- a/mk/check/check-subr.sh
+++ b/mk/check/check-subr.sh
@@ -1,4 +1,4 @@
-# $NetBSD: check-subr.sh,v 1.1 2006/11/09 02:53:15 rillig Exp $
+# $NetBSD: check-subr.sh,v 1.2 2006/11/09 10:52:21 rillig Exp $
#
# This file contains shell functions that are used by the various shell
# programs that check things in pkgsrc. All these programs must be
@@ -75,6 +75,20 @@ cs_warning_msg() {
echo "WARNING: [$cs_progname] $*" 1>&2
}
+cs_hline=\
+"==========================================================================="
+
+# usage: cs_explain <<EOF
+cs_explain() {
+ { echo ""
+ echo "Explanation:"
+ echo "$cs_hline"
+ cat
+ echo "$cs_hline"
+ echo ""
+ } 1>&2
+}
+
# usage: cs_exit
#
# At the end of the program, cs_exit should be called to return the