pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/check Added a function cs_explain() to check-subr.s...
details: https://anonhg.NetBSD.org/pkgsrc/rev/1971fb6e88c5
branches: trunk
changeset: 521321:1971fb6e88c5
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Nov 09 10:52:21 2006 +0000
description:
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:
mk/check/check-headers.sh | 6 ++----
mk/check/check-portability.sh | 35 ++++++++++++++++++++++++++++++++++-
mk/check/check-subr.sh | 16 +++++++++++++++-
3 files changed, 51 insertions(+), 6 deletions(-)
diffs (126 lines):
diff -r 0795c056aad6 -r 1971fb6e88c5 mk/check/check-headers.sh
--- a/mk/check/check-headers.sh Thu Nov 09 10:31:54 2006 +0000
+++ b/mk/check/check-headers.sh Thu Nov 09 10:52:21 2006 +0000
@@ -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 @@
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 @@
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 -r 0795c056aad6 -r 1971fb6e88c5 mk/check/check-portability.sh
--- a/mk/check/check-portability.sh Thu Nov 09 10:31:54 2006 +0000
+++ b/mk/check/check-portability.sh Thu Nov 09 10:52:21 2006 +0000
@@ -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 @@
. "${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 @@
;;
*\$RANDOM*)
+ found_random=yes
cs_warning_heading "Found \$RANDOM:"
cs_warning_msg "$fname: $line"
;;
@@ -50,6 +54,7 @@
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 @@
;;
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 -r 0795c056aad6 -r 1971fb6e88c5 mk/check/check-subr.sh
--- a/mk/check/check-subr.sh Thu Nov 09 10:31:54 2006 +0000
+++ b/mk/check/check-subr.sh Thu Nov 09 10:52:21 2006 +0000
@@ -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 @@
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
Home |
Main Index |
Thread Index |
Old Index