summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint
diff options
context:
space:
mode:
authorrillig <rillig>2006-06-17 09:51:19 +0000
committerrillig <rillig>2006-06-17 09:51:19 +0000
commitab75cb0e8ae39147e4bcd6d42b1362b59bc4d680 (patch)
treeed18f273b224b674bc6b03f97d20ee999911622c /pkgtools/pkglint
parentd258b70611f3728a6192387d08cab45f2f14f7e6 (diff)
downloadpkgsrc-ab75cb0e8ae39147e4bcd6d42b1362b59bc4d680.tar.gz
The shell commands ${SED} and ${TR} should not be used in the install
phase.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r--pkgtools/pkglint/files/pkglint.pl45
1 files changed, 42 insertions, 3 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index ddc07326e46..71e1c67ff6d 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -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 @@ sub checkline_mk_shellword($$$) {
}
}
+# 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 @@ sub checkline_mk_shelltext($$) {
$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.