Updated pkglint to 4.45.3.

- Added detection of redirection operators and comments to the
  regex_shellword constant.
- Changed the naming conventions for list data types. Now List simply
  means a list. List+ means a list that should only be modified using
  "+=", not "=". List! means an internal list. And List!+ is the
  combination of both.

  The distinction is necessary because of the introduction of
  redirection operators in the regex_shellword. When checking the data
  type of list elements, the lists are split up into shell words instead
  of simply using split(). This leads to much better results.
- When splitting a variable value or shell command into words, anchor the
  regular expression at the beginning of the string.
This commit is contained in:
rillig 2005-11-24 08:05:01 +00:00
parent d343b5f5fb
commit 681277d002
3 changed files with 111 additions and 85 deletions

View file

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.307 2005/11/23 22:12:03 rillig Exp $
# $NetBSD: Makefile,v 1.308 2005/11/24 08:05:01 rillig Exp $
#
DISTNAME= pkglint-4.45.2
DISTNAME= pkglint-4.45.3
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty

View file

@ -1,4 +1,4 @@
# $NetBSD: makevars.map,v 1.37 2005/11/23 05:18:46 rillig Exp $
# $NetBSD: makevars.map,v 1.38 2005/11/24 08:05:01 rillig Exp $
#
# This file contains the guessed type of some variables, according to
@ -10,8 +10,11 @@
# The type Yes is used for variables that are checked using
# .if defined(VAR)
#
# Type type List is used for variables that should only be initialized
# Type type List is used for lists of things. There are two modifiers
# for lists: The "+" means that this variable should only be initialized
# to the empty list or have some values appended using the "+=" operator.
# The "!" means that the list is an internal list. See the pkgsrc guide,
# chapter "Makefiles" for a detailed explanation.
# some variables from mk/defaults/mk.conf, 1.27
@ -45,30 +48,30 @@ USE_XFACE YesNo
ALTERNATIVES_FILE Filename
BDB185_DEFAULT Userdefined
BDBBASE Readonly
BDB_ACCEPTED List* of { db1 db2 db3 db4 }
BDB_ACCEPTED List of { db1 db2 db3 db4 }
BDB_DEFAULT Userdefined
BDB_LIBS Readonly
BDB_TYPE Readonly
BUILDLINK_DEPENDS List of Dependency
BUILDLINK_DEPENDS List!+ of Dependency
BUILDLINK_PKGSRCDIR RelativePkgDir
BUILDLINK_RECOMMENDED List of Dependency
BUILDLINK_TRANSFORM List
BUILD_DEFS List of Varname
BUILD_DEPENDS List of DependencyWithPath
BUILD_DIRS List* of WrksrcSubdirectory
BUILDLINK_RECOMMENDED List!+ of Dependency
BUILDLINK_TRANSFORM List+
BUILD_DEFS List+ of Varname
BUILD_DEPENDS List!+ of DependencyWithPath
BUILD_DIRS List of WrksrcSubdirectory
BUILD_USES_MSGFMT Yes
BUILTIN_X11_TYPE Readonly
BUILTIN_X11_VERSION Readonly
CATEGORIES List* of Category
CATEGORIES List of Category
CC_VERSION Readonly
CFLAGS List
CFLAGS List+
COMMENT Comment
CONFIGURE_ARGS List of ShellWord
CONFIGURE_DIRS List* of WrksrcSubdirectory
CONFIGURE_ENV List of ShellWord
CPPFLAGS List
DEPENDS List of DependencyWithPath
DISTFILES List* of Filename
CONFIGURE_ARGS List+ of ShellWord
CONFIGURE_DIRS List of WrksrcSubdirectory
CONFIGURE_ENV List+ of ShellWord
CPPFLAGS List+
DEPENDS List!+ of DependencyWithPath
DISTFILES List of Filename
DISTNAME Filename
EMACS_BIN Readonly
EMACS_ETCPREFIX Readonly
@ -78,53 +81,53 @@ EMACS_LISPPREFIX Readonly
EMACS_PKGNAME_PREFIX Readonly
EMACS_TYPE Userdefined
EMACS_USE_LEIM Yes
EMACS_VERSIONS_ACCEPTED List* of { emacs21 emacs21nox emacs20 xemacs215 xemacs214 }
EXTRACT_ELEMENTS List* of Pathmask
EXTRACT_ONLY List* of Pathname
EMACS_VERSIONS_ACCEPTED List of { emacs21 emacs21nox emacs20 xemacs215 xemacs214 }
EXTRACT_ELEMENTS List of Pathmask
EXTRACT_ONLY List of Pathname
EXTRACT_SUFX DistSuffix
EXTRACT_USING { gtar nbtar pax }
FAMBASE Readonly
FAM_ACCEPTED List* of { fam gamin }
FAM_ACCEPTED List of { fam gamin }
FAM_DEFAULT Userdefined
FAM_TYPE Readonly
FILES_SUBST List of ShellWord
GCC_REQD List
FILES_SUBST List+ of ShellWord
GCC_REQD List+
GNU_CONFIGURE Yes
HOMEPAGE URL
INCOMPAT_CURSES List* of PlatformTuple
INSTALL_DIRS List* of WrksrcSubdirectory
INCOMPAT_CURSES List of PlatformTuple
INSTALL_DIRS List of WrksrcSubdirectory
INSTALL_UNSTRIPPED YesNo
KRB5BASE Readonly
KRB5_ACCEPTED List* of { heimdal mit-krb5 }
KRB5_ACCEPTED List of { heimdal mit-krb5 }
KRB5_DEFAULT Userdefined
KRB5_TYPE Readonly
LDFLAGS List
LIBS List
LDFLAGS List+
LIBS List+
MAINTAINER Mail_Address
MAKEFLAGS List of ShellWord
MAKEVARS List of Varname
MAKE_ENV List of ShellWord
MAKE_FLAGS List of ShellWord
MAKEFLAGS List+ of ShellWord
MAKEVARS List+ of Varname
MAKE_ENV List+ of ShellWord
MAKE_FLAGS List+ of ShellWord
MANZ Yes
MASTER_SITES List* of URL
MYSQL_VERSIONS_ACCEPTED List* of { 40 41 50 }
MASTER_SITES List of URL
MYSQL_VERSIONS_ACCEPTED List of { 40 41 50 }
MYSQL_VERSION_DEFAULT Userdefined
NOT_FOR_COMPILER List* of { ccc gcc icc ido mipspro mipspro-ucode sunpro xlc }
NOT_FOR_PLATFORM List* of PlatformTuple
NOT_FOR_COMPILER List of { ccc gcc icc ido mipspro mipspro-ucode sunpro xlc }
NOT_FOR_PLATFORM List of PlatformTuple
NO_BUILD Yes
NO_CHECKSUM Yes
NO_CONFIGURE Yes
NO_MTREE Yes
NO_PKGTOOLS_REQD_CHECK Yes
NO_PKG_REGISTER Yes
ONLY_FOR_COMPILER List* of { ccc gcc icc ido mipspro mipspro-ucode sunpro xlc }
ONLY_FOR_PLATFORM List* of PlatformTuple
ONLY_FOR_COMPILER List of { ccc gcc icc ido mipspro mipspro-ucode sunpro xlc }
ONLY_FOR_PLATFORM List of PlatformTuple
PAMBASE Readonly
PAM_ACCEPTED List* of { linux-pam openpam solaris-pam }
PAM_ACCEPTED List of { linux-pam openpam solaris-pam }
PAM_DEFAULT Userdefined
PAM_TYPE Readonly
PERL5_PACKLIST Perl5Packlist
PGSQL_VERSIONS_ACCEPTED List* of { 73 74 80 }
PGSQL_VERSIONS_ACCEPTED List of { 73 74 80 }
PGSQL_VERSION_DEFAULT Userdefined
PKGBASE Readonly
PKGNAME PkgName
@ -136,58 +139,58 @@ PKGSRC_COMPILER Userdefined
PKGVERSION Readonly
PKGWILDCARD Readonly
PKG_APACHE Readonly
PKG_APACHE_ACCEPTED List* of { apache13 apache2 }
PKG_APACHE_ACCEPTED List of { apache13 apache2 }
PKG_APACHE_DEFAULT Userdefined
PKG_DEBUG_LEVEL Userdefined
PKG_DEFAULT_OPTIONS Userdefined
PKG_FAIL_REASON List of ShellWord
PKG_INSTALLATION_TYPES List* of { overwrite pkgviews }
PKG_FAIL_REASON List+ of ShellWord
PKG_INSTALLATION_TYPES List of { overwrite pkgviews }
PKG_JAVA_HOME Readonly
PKG_JVM Readonly
PKG_JVMS_ACCEPTED List* of { blackdown-jdk13 jdk jdk14 kaffe sun-jdk13 sun-jdk14 sun-jdk15 }
PKG_JVMS_ACCEPTED List of { blackdown-jdk13 jdk jdk14 kaffe sun-jdk13 sun-jdk14 sun-jdk15 }
PKG_JVM_DEFAULT Userdefined
PKG_LEGACY_OPTIONS List* of Option
PKG_LEGACY_OPTIONS List of Option
PKG_OPTIONS Readonly
PKG_OPTIONS_DEPRECATED_WARNINGS List* of ShellWord
PKG_OPTIONS_GROUP List*
PKG_OPTIONS_LEGACY_OPTS List*
PKG_OPTIONS_LEGACY_VARS List*
PKG_OPTIONS_NONEMPTY_SETS List*
PKG_OPTIONS_OPTIONAL_GROUPS List*
PKG_OPTIONS_REQUIRED_GROUPS List*
PKG_OPTIONS_SET List*
PKG_OPTIONS_DEPRECATED_WARNINGS List of ShellWord
PKG_OPTIONS_GROUP List
PKG_OPTIONS_LEGACY_OPTS List
PKG_OPTIONS_LEGACY_VARS List
PKG_OPTIONS_NONEMPTY_SETS List
PKG_OPTIONS_OPTIONAL_GROUPS List
PKG_OPTIONS_REQUIRED_GROUPS List
PKG_OPTIONS_SET List
PKG_OPTIONS_VAR Varname
PKG_PRESERVE Yes
PKG_SKIP_REASON List of ShellWord
PKG_SKIP_REASON List+ of ShellWord
PKG_SUFX Userdefined
PKG_SUGGESTED_OPTIONS List* of Option
PKG_SUPPORTED_OPTIONS List* of Option
PLIST_SRC List* of Pathname
PLIST_SUBST List of ShellWord
PKG_SUGGESTED_OPTIONS List of Option
PKG_SUPPORTED_OPTIONS List of Option
PLIST_SRC List of Pathname
PLIST_SUBST List+ of ShellWord
PLIST_TYPE { dynamic static }
PTHREAD_AUTO_VARS YesNo
PTHREAD_OPTS List of { native optional require }
PTHREAD_OPTS List+ of { native optional require }
PTHREAD_TYPE Readonly
REPLACE_EMACS List of Pathname
SUBST_CLASSES List
SUBST_FILES List* of Pathmask
SUBST_SED List*
# ^^ This may be changed to a List later.
REPLACE_EMACS List+ of Pathname
SUBST_CLASSES List+
SUBST_FILES List of Pathmask
SUBST_SED List
# ^^ This may be changed to a List+ later.
SUBST_STAGE Stage
TOOLS_ALIASES List of Filename
TOOLS_BROKEN List of Tool
TOOLS_CREATE List of Tool
TOOLS_GNU_MISSING List of Tool
TOOLS_NOOP List of Tool
TOOLS_ALIASES List+ of Filename
TOOLS_BROKEN List+ of Tool
TOOLS_CREATE List+ of Tool
TOOLS_GNU_MISSING List+ of Tool
TOOLS_NOOP List+ of Tool
TOOLS_PATH Pathname
USE_JAVA { run yes }
USE_JAVA2 { YES yes 1.4 1.5 }
USE_LANGUAGES List* of { c c++ fortran java objc }
USE_LANGUAGES List of { c c++ fortran java objc }
USE_LIBTOOL Yes
USE_PKGINSTALL Yes
USE_PKGLOCALEDIR YesNo
USE_PKGSRC_GCC Userdefined
USE_TOOLS List of Tool
USE_TOOLS List+ of Tool
USE_X11 Yes
WRKSRC WrkdirSubdirectory
X11_PKGSRCDIR Readonly

View file

@ -11,7 +11,7 @@
# Freely redistributable. Absolutely no warranty.
#
# From Id: portlint.pl,v 1.64 1998/02/28 02:34:05 itojun Exp
# $NetBSD: pkglint.pl,v 1.380 2005/11/24 01:22:35 rillig Exp $
# $NetBSD: pkglint.pl,v 1.381 2005/11/24 08:05:01 rillig Exp $
#
# This version contains lots of changes necessary for NetBSD packages
# done by:
@ -715,8 +715,8 @@ my $regex_shellword = qr"\s*(
| \"(?:\\.|[^\"\\])*\"
| \`[^\`]*\`
| \\.
| [^'\"\\\s;&\|]
)+ | ;;? | &&? | \|\|? )"sx;
| [^'\"\\\s;&\|<>\#]
)+ | ;;? | &&? | \|\|? | <<? | >>? | \#.*)"sx;
#
# Global variables.
@ -845,7 +845,7 @@ sub load_make_vars_typemap() {
if ($line->text =~ qr"^(?:#.*|\s*)$") {
# ignore empty and comment lines
} elsif ($line->text =~ qr"^([\w\d_.]+)\s+([-.+\w\d_* \{\}]+)$") {
} elsif ($line->text =~ qr"^([\w\d_.]+)\s+([-!\+.\w\d_ \{\}]+)$") {
$vartypes->{$1} = $2;
} else {
@ -1820,14 +1820,18 @@ sub checkline_basic_vartype($$$$$) {
} elsif ($type eq "ShellWord") {
if ($value =~ qr"^[\w_]+=(([\"']?)\$\{([\w_]+)\}\2)$") {
my ($vexpr, undef, $vname) = ($1, $2, $3);
# XXX: The following heuristics are too simple (example: OPSYS is not a plural).
my $mod = ($vname =~ get_regex_plurals()) ? ":M*:Q" : ":Q";
$line->log_warning("Please use \${${vname}${mod}} instead of ${vexpr}.");
} elsif ($value =~ qr"^[\w_]+=(\$\{([\w_]+):Q\})$") {
my ($vexpr, $vname) = ($1, $2);
# XXX: The following heuristics are too simple (example: OPSYS is not a plural).
if ($vname =~ get_regex_plurals()) {
$line->log_warning("Please use \${${vname}:M*:Q} instead of ${vexpr}.");
}
} elsif ($value ne "" && $value !~ qr"^${regex_shellword}$") {
$line->log_warning("Invalid shell word \"${value}\".");
}
} elsif ($type eq "Stage") {
@ -1956,20 +1960,37 @@ sub checkline_Makefile_vartype($$) {
$line->log_info("[checkline_Makefile_vartype] Unchecked variable ${varname}.");
}
} elsif ($type =~ qr"^List(\*?)(?: of (.*))?$") {
my ($append_only, $element_type) = ($1 eq "", $2);
my (@values) = split(qr"\s+", $value); # XXX: This may be too simple
} elsif ($type =~ qr"^List(!?)(\+?)(?: of (.*))?$") {
my ($internal_list, $append_only, $element_type) = ($1 eq "!", $2 eq "+", $3);
my (@words, $rest);
if ($append_only && $op ne "+=" && !($value eq "" && defined($comment) && $comment =~ qr"^#")) {
$line->log_warning("${varname} should be modified using \"+=\".");
}
if (defined($element_type)) {
foreach my $v (@values) {
checkline_basic_vartype($line, $varname, $element_type, $v, $comment);
if ($internal_list) {
@words = split(qr"\s+", $value);
$rest = "";
} else {
@words = ();
$rest = $value;
while ($rest =~ s/^$regex_shellword//) {
my ($word) = ($1);
last if ($word =~ qr"^#");
push(@words, $1);
}
}
foreach my $word (@words) {
if (defined($element_type)) {
checkline_basic_vartype($line, $varname, $element_type, $word, $comment);
}
}
if ($rest !~ qr"^\s*$") {
$line->log_warning("Invalid shell word \"${value}\" at the end.");
}
} else {
checkline_basic_vartype($line, $varname, $type, $value, $comment);
}
@ -2411,10 +2432,12 @@ sub checklines_package_Makefile($) {
}
$line->log_debug("ShellCmd: $shellcmd");
while ($shellcmd =~ /$regex_shellword/g) {
while ($shellcmd =~ s/^$regex_shellword//) {
$line->log_debug("ShellWord: $1");
}
if ($shellcmd !~ qr"^\s*$") {
$line->log_warning("Invalid shell word \"${shellcmd}\".");
}
}
}