pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Policy change: Instead of the t...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/67e693fbe818
branches:  trunk
changeset: 516514:67e693fbe818
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 22 06:47:40 2006 +0000

description:
Policy change: Instead of the tool variables (for example ${CP}), the
simple commands (for example "cp") should be used, since the tools
framework provides wrappers for them. This applies only to the cases
where the tool variables appears as the first word in a shell command.
When doing substitutions in files that are later installed, the full
name should still be used.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  52 ++++++++++++++++++++++++++++----------
 1 files changed, 38 insertions(+), 14 deletions(-)

diffs (90 lines):

diff -r 9e3f63bdcb4b -r 67e693fbe818 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sat Jul 22 05:54:52 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sat Jul 22 06:47:40 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.660 2006/07/22 05:28:45 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.661 2006/07/22 06:47:40 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2476,6 +2476,22 @@
        return $load_tool_names_varname_to_toolname;
 }
 
+# Returns the set of tool variable names that may not be converted to
+# their "direct" form, that is: ${CP} => cp.
+sub get_required_vartool_varnames() {
+       use constant required_vartool_varnames => array_to_hash(qw(ECHO ECHO_N FALSE TEST TRUE));
+
+       return required_vartool_varnames;
+}
+
+# Returns the set of tools that must be used by their variable name.
+sub get_required_vartools() {
+       use constant required_vartools => array_to_hash(qw(echo false test true));
+
+       return required_vartools;
+}
+
+
 # Returns the set of user-defined variables that are added to BUILD_DEFS
 # within the bsd.pkg.mk file.
 sub get_system_build_defs() {
@@ -4145,17 +4161,6 @@
                # and the symbol on the "input tape".
                #
 
-               if (($state == SCST_START || $state == SCST_COND) && exists($vartools->{$shellword})) {
-                       my $addition = "";
-
-                       if (!exists(get_predefined_vartool_names()->{$shellword})) {
-                               my $toolvarname = get_vartool_names->{$shellword};
-                               my $toolname = get_varname_to_toolname->{$toolvarname};
-                               $addition = " and add USE_TOOLS+=${toolname} before this line";
-                       }
-                       $line->log_warning("Direct use of tool \"${shellword}\". Please use \$\{$vartools->{$shellword}\} instead${addition}.");
-               }
-
                if ($state == SCST_START || $state == SCST_COND) {
                        my ($type);
 
@@ -4163,9 +4168,28 @@
                                $line->log_error("${shellword} is forbidden and must not be used.");
 
                        } elsif (exists(get_tool_names()->{$shellword})) {
+                               # TODO: Check if the tool is mentioned in USE_TOOLS.
+
+                               if (exists(get_required_vartools()->{$shellword})) {
+                                       $line->log_warning("Please use \"\${" . get_vartool_names()->{$shellword} . "}\" instead of \"${shellword}\".");
+                               }
+
                                checkline_mk_shellcmd_use($line, $shellword);
 
-                       } elsif ($shellword =~ qr"^\$\{([\w_]+)\}$" && (exists($vartools->{$1}) || (defined($type = get_variable_type($line, $1)) && $type->basic_type eq "ShellCommand"))) {
+                       } elsif ($shellword =~ qr"^\$\{([\w_]+)\}$" && exists(get_varname_to_toolname()->{$1})) {
+                               my ($vartool) = ($1);
+                               my $plain_tool = get_varname_to_toolname()->{$vartool};
+
+                               # TODO: Check if the tool is mentioned in USE_TOOLS.
+
+                               if (!exists(get_required_vartool_varnames()->{$vartool})) {
+                                       $opt_warn_extra and $line->log_note("You can write \"${plain_tool}\" instead of \"${shellword}\".");
+                                       $opt_warn_extra and $line->explain_note(
+                                               "The wrapper framework from pkgsrc takes care that a sufficiently",
+                                               "capable implementation of that tool will be selected.");
+                               }
+
+                       } elsif ($shellword =~ qr"^\$\{([\w_]+)\}$" && defined($type = get_variable_type($line, $1)) && $type->basic_type eq "ShellCommand") {
                                checkline_mk_shellcmd_use($line, $shellword);
 
                        } elsif ($shellword =~ 
qr"^(?:\(|\)|:|;|;;|&&|\|\||\{|\}|break|case|cd|continue|do|done|elif|else|esac|eval|exec|exit|export|fi|for|if|read|set|shift|then|umask|unset|while)$") {
@@ -4190,7 +4214,7 @@
 
                                if ($semicolon || $multiline) {
                                        $line->explain_warning(
-                                               "When you split a shell command into multiple lines that are continues",
+                                               "When you split a shell command into multiple lines that are continued",
                                                "with a backslash, they will nevertheless be converted to a single line",
                                                "before the shell sees them. That means that even if it _looks_ like that",
                                                "the comment only spans one line in the Makefile, in fact it spans until",



Home | Main Index | Thread Index | Old Index