pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files The shell commands ${SED} and $...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3118cd6a59bb
branches:  trunk
changeset: 514712:3118cd6a59bb
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jun 17 09:51:19 2006 +0000

description:
The shell commands ${SED} and ${TR} should not be used in the install
phase.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  45 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r ae056932c1ba -r 3118cd6a59bb pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sat Jun 17 09:08:47 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sat Jun 17 09:51:19 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.622 2006/06/15 22:50:31 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.623 2006/06/17 09:51:19 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -3325,6 +3325,45 @@
        }
 }
 
+# Some shell commands should not be used in the install phase.
+#
+sub checkline_mk_shellcmd_use($$) {
+       my ($line, $shellcmd) = @_;
+
+       use constant allowed_install_commands => array_to_hash(qw(
+               ${INSTALL}
+               ${INSTALL_DATA} ${INSTALL_DATA_DIR}
+               ${INSTALL_LIB} ${INSTALL_LIB_DIR}
+               ${INSTALL_MAN} ${INSTALL_MAN_DIR}
+               ${INSTALL_PROGRAM} ${INSTALL_PROGRAM_DIR}
+               ${INSTALL_SCRIPT}
+               ${LIBTOOL}
+               ${LN}
+               ${PAX}
+       ));
+       use constant discouraged_install_commands => array_to_hash(qw(
+               ${SED}
+               ${TR}
+       ));
+
+       if (defined($mkctx_target) && $mkctx_target =~ qr"^(?:pre|do|post)-install") {
+
+               if (exists(allowed_install_commands->{$shellcmd})) {
+                       # Fine.
+
+               } elsif (exists(discouraged_install_commands->{$shellcmd})) {
+                       $line->log_warning("The shell command \"${shellcmd}\" should not be used in the install phase.");
+                       $line->explain_warning(
+                               "In the install phase, the only thing that should be done is to install",
+                               "the prepared files to their final location. The file's contents should",
+                               "not be changed anymore.");
+
+               } else {
+                       $opt_debug_misc and $line->log_debug("May \"${shellcmd}\" be used in the install phase?");
+               }
+       }
+}
+
 sub checkline_mk_shelltext($$) {
        my ($line, $text) = @_;
        my ($vartools, $state, $rest, $set_e_mode);
@@ -3458,10 +3497,10 @@
                                $line->log_error("${shellword} is forbidden and must not be used.");
 
                        } elsif (exists(get_tool_names()->{$shellword})) {
-                               # Fine.
+                               checkline_mk_shellcmd_use($line, $shellword);
 
                        } elsif ($shellword =~ qr"^\$\{([\w_]+)\}$" && (exists($vartools->{$1}) || defined(get_variable_type($line, $1)))) {
-                               # Fine.
+                               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|unset|while)$") {
                                # Shell builtins are fine.



Home | Main Index | Thread Index | Old Index