diff options
author | rillig <rillig@pkgsrc.org> | 2016-07-10 11:37:27 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2016-07-10 11:37:27 +0000 |
commit | 89f2ff25b2529dc1bd3c72b341b0a35c38d8c28d (patch) | |
tree | 2aeac5d7ff1d014af01d39e16988a95aec4a55b2 /pkgtools/pkglint | |
parent | e24c752e98287b2d1f0e2e23525ef76160b3d736 (diff) | |
download | pkgsrc-89f2ff25b2529dc1bd3c72b341b0a35c38d8c28d.tar.gz |
Updated pkglint to 5.4.6.
Changes since 5.4.5:
* Fixed shell command parser to correctly parse redirections
* Added type definitions for several variables
* Allowed version numbers to be single digits
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkshparser.go | 3 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkshparser_test.go | 48 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vardefs.go | 25 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vartypecheck.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vartypecheck_test.go | 11 |
6 files changed, 81 insertions, 12 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index cba8b85f841..3eaab137338 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.490 2016/07/09 13:16:43 rillig Exp $ +# $NetBSD: Makefile,v 1.491 2016/07/10 11:37:27 rillig Exp $ -PKGNAME= pkglint-5.4.5 +PKGNAME= pkglint-5.4.6 DISTFILES= # none CATEGORIES= pkgtools diff --git a/pkgtools/pkglint/files/mkshparser.go b/pkgtools/pkglint/files/mkshparser.go index 600e0c92de9..583bf1d22d4 100644 --- a/pkgtools/pkglint/files/mkshparser.go +++ b/pkgtools/pkglint/files/mkshparser.go @@ -190,9 +190,6 @@ func (lex *ShellLexer) Lex(lval *shyySymType) (ttype int) { } switch { - case matches(token, `^\d+$`) && len(lex.remaining) != 0 && matches(lex.remaining[0], `^[<>]`): - ttype = tkIO_NUMBER - lval.IONum, _ = strconv.Atoi(token) case lex.sinceFor == 2 && token == "in": ttype = tkIN lex.atCommandStart = false diff --git a/pkgtools/pkglint/files/mkshparser_test.go b/pkgtools/pkglint/files/mkshparser_test.go index e0d6bbd2a71..21b7f0bf1c9 100644 --- a/pkgtools/pkglint/files/mkshparser_test.go +++ b/pkgtools/pkglint/files/mkshparser_test.go @@ -25,7 +25,7 @@ func (s *ShSuite) Test_ShellParser_program(c *check.C) { b.List().AddCommand(b.SimpleCommand("echo"))) s.test(""+ - "cd ${WRKSRC} && ${FIND} ${${_list_}} -type f ! -name '*.orig' 2 > /dev/null "+ + "cd ${WRKSRC} && ${FIND} ${${_list_}} -type f ! -name '*.orig' 2> /dev/null "+ "| pax -rw -pm ${DESTDIR}${PREFIX}/${${_dir_}}", b.List().AddAndOr(b.AndOr( b.Pipeline(false, b.SimpleCommand("cd", "${WRKSRC}"))).Add("&&", @@ -163,20 +163,20 @@ func (s *ShSuite) Test_ShellParser_command(c *check.C) { s.test("simple_command", b.List().AddAndOr(b.AndOr(b.Pipeline(false, b.SimpleCommand("simple_command"))))) - s.test("while 1 ; do 2 ; done", + s.test("while 1; do 2; done", b.List().AddAndOr(b.AndOr(b.Pipeline(false, b.While( b.List().AddCommand(b.SimpleCommand("1")).AddSeparator(";"), b.List().AddCommand(b.SimpleCommand("2")).AddSeparator(";")))))) - s.test("while 1 ; do 2 ; done 1 >& 2", + s.test("while 1; do 2; done 1>&2", b.List().AddAndOr(b.AndOr(b.Pipeline(false, b.While( b.List().AddCommand(b.SimpleCommand("1")).AddSeparator(";"), b.List().AddCommand(b.SimpleCommand("2")).AddSeparator(";"), b.Redirection(1, ">&", "2")))))) - s.test("func ( ) { echo hello ; } 2 >& 1", + s.test("func(){ echo hello;} 2>&1", b.List().AddCommand(b.Function( "func", b.Brace(b.List().AddCommand(b.SimpleCommand("echo", "hello")).AddSeparator(";")).Compound, @@ -439,6 +439,15 @@ func (s *ShSuite) Test_ShellParser_io_redirect(c *check.C) { {4, ">&", b.Token("5")}, {6, "<", b.Token("input")}, {-1, ">>", b.Token("append")}}}})) + + s.test("${MAKE} print-summary-data 2>&1 > /dev/stderr", + b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{ + Assignments: nil, + Name: b.Token("${MAKE}"), + Args: []*ShToken{b.Token("print-summary-data")}, + Redirections: []*MkShRedirection{ + {2, ">&", b.Token("1")}, + {-1, ">", b.Token("/dev/stderr")}}}})) } func (s *ShSuite) Test_ShellParser_io_here(c *check.C) { @@ -479,6 +488,37 @@ func (s *ShSuite) test(program string, expected *MkShList) { } } +func (s *ShSuite) Test_ShellLexer_Lex__redirects(c *check.C) { + tokens, rest := splitIntoShellTokens(dummyLine, "${MAKE} print-summary-data 2>&1 > /dev/stderr") + + c.Check(tokens, deepEquals, []string{"${MAKE}", "print-summary-data", "2>&", "1", ">", "/dev/stderr"}) + c.Check(rest, equals, "") + + lexer := NewShellLexer(tokens, rest) + var llval shyySymType + + c.Check(lexer.Lex(&llval), equals, tkWORD) + c.Check(llval.Word.MkText, equals, "${MAKE}") + + c.Check(lexer.Lex(&llval), equals, tkWORD) + c.Check(llval.Word.MkText, equals, "print-summary-data") + + c.Check(lexer.Lex(&llval), equals, tkIO_NUMBER) + c.Check(llval.IONum, equals, 2) + + c.Check(lexer.Lex(&llval), equals, tkGTAND) + + c.Check(lexer.Lex(&llval), equals, tkWORD) + c.Check(llval.Word.MkText, equals, "1") + + c.Check(lexer.Lex(&llval), equals, tkGT) + + c.Check(lexer.Lex(&llval), equals, tkWORD) + c.Check(llval.Word.MkText, equals, "/dev/stderr") + + c.Check(lexer.Lex(&llval), equals, 0) +} + type MkShBuilder struct { } diff --git a/pkgtools/pkglint/files/vardefs.go b/pkgtools/pkglint/files/vardefs.go index a1ce2d26f13..303bfa36b81 100644 --- a/pkgtools/pkglint/files/vardefs.go +++ b/pkgtools/pkglint/files/vardefs.go @@ -152,6 +152,7 @@ func (gd *GlobalData) InitVartypes() { acl("BUILDLINK_TRANSFORM.*", lkShell, CheckvarWrapperTransform, "*: append") acl("BUILDLINK_TREE", lkShell, CheckvarIdentifier, "buildlink3.mk: append") acl("BUILD_DEFS", lkShell, CheckvarVariableName, "Makefile, Makefile.common, options.mk: append") + pkglist("BUILD_DEFS_EFFECTS", lkShell, CheckvarVariableName) acl("BUILD_DEPENDS", lkSpace, CheckvarDependencyWithPath, "Makefile, Makefile.common, *.mk: append") pkglist("BUILD_DIRS", lkShell, CheckvarWrksrcSubdirectory) pkglist("BUILD_ENV", lkShell, CheckvarShellWord) @@ -223,6 +224,7 @@ func (gd *GlobalData) InitVartypes() { sys("CXX", lkNone, CheckvarShellCommand) pkglist("CXXFLAGS", lkShell, CheckvarCFlag) pkglist("CXXFLAGS.*", lkShell, CheckvarCFlag) + pkglist("CWRAPPERS_APPEND.*", lkShell, CheckvarShellWord) acl("DEINSTALL_FILE", lkNone, CheckvarPathname, "Makefile: set") acl("DEINSTALL_SRC", lkShell, CheckvarPathname, "Makefile: set; Makefile.common: default, set") acl("DEINSTALL_TEMPLATES", lkShell, CheckvarPathname, "Makefile: set, append; Makefile.common: set, default, append") @@ -297,6 +299,7 @@ func (gd *GlobalData) InitVartypes() { sys("EXPORT_SYMBOLS_LDFLAGS", lkShell, CheckvarLdFlag) sys("EXTRACT_CMD", lkNone, CheckvarShellCommand) pkg("EXTRACT_DIR", lkNone, CheckvarPathname) + pkg("EXTRACT_DIR.*", lkNone, CheckvarPathname) pkglist("EXTRACT_ELEMENTS", lkShell, CheckvarPathmask) pkglist("EXTRACT_ENV", lkShell, CheckvarShellWord) pkglist("EXTRACT_ONLY", lkShell, CheckvarPathname) @@ -333,6 +336,7 @@ func (gd *GlobalData) InitVartypes() { pkg("GITHUB_TAG", lkNone, CheckvarIdentifier) pkg("GITHUB_RELEASE", lkNone, CheckvarFilename) pkg("GITHUB_TYPE", lkNone, enum("tag release")) + pkg("GMAKE_REQD", lkNone, CheckvarVersion) acl("GNU_ARCH", lkNone, enum("mips"), "") acl("GNU_CONFIGURE", lkNone, CheckvarYes, "Makefile, Makefile.common: set") acl("GNU_CONFIGURE_INFODIR", lkNone, CheckvarPathname, "Makefile, Makefile.common: set") @@ -402,6 +406,7 @@ func (gd *GlobalData) InitVartypes() { pkg("LICENSE_FILE", lkNone, CheckvarPathname) sys("LINKER_RPATH_FLAG", lkNone, CheckvarShellWord) sys("LOWER_OPSYS", lkNone, CheckvarIdentifier) + sys("LOWER_VENDOR", lkNone, CheckvarIdentifier) acl("LTCONFIG_OVERRIDE", lkShell, CheckvarPathmask, "Makefile: set, append; Makefile.common: append") sys("MACHINE_ARCH", lkNone, enumMachineArch) sys("MACHINE_GNU_ARCH", lkNone, enumMachineGnuArch) @@ -467,6 +472,7 @@ func (gd *GlobalData) InitVartypes() { sys("NM", lkNone, CheckvarShellCommand) sys("NONBINMODE", lkNone, CheckvarFileMode) pkg("NOT_FOR_COMPILER", lkShell, enum("ccache ccc clang distcc f2c gcc hp icc ido mipspro mipspro-ucode pcc sunpro xlc")) + pkglist("NOT_FOR_BULK_PLATFORM", lkSpace, CheckvarMachinePlatformPattern) pkglist("NOT_FOR_PLATFORM", lkSpace, CheckvarMachinePlatformPattern) pkg("NOT_FOR_UNPRIVILEGED", lkNone, CheckvarYesNo) acl("NO_BIN_ON_CDROM", lkNone, CheckvarRestricted, "Makefile, Makefile.common: set") @@ -502,9 +508,10 @@ func (gd *GlobalData) InitVartypes() { acl("PATCH_DIST_STRIP*", lkNone, CheckvarShellWord, "buildlink3.mk, builtin.mk:; Makefile, Makefile.common, *.mk: set") acl("PATCH_SITES", lkShell, CheckvarFetchURL, "Makefile, Makefile.common, options.mk: set") acl("PATCH_STRIP", lkNone, CheckvarShellWord, "") - pkg("PERL5_USE_PACKLIST", lkNone, CheckvarYesNo) acl("PERL5_PACKLIST", lkShell, CheckvarPerl5Packlist, "Makefile: set; options.mk: set, append") acl("PERL5_PACKLIST_DIR", lkNone, CheckvarPathname, "") + pkg("PERL5_REQD", lkShell, CheckvarVersion) + pkg("PERL5_USE_PACKLIST", lkNone, CheckvarYesNo) sys("PGSQL_PREFIX", lkNone, CheckvarPathname) acl("PGSQL_VERSIONS_ACCEPTED", lkShell, enum("91 92 93 94"), "") usr("PGSQL_VERSION_DEFAULT", lkNone, CheckvarVersion) @@ -576,6 +583,7 @@ func (gd *GlobalData) InitVartypes() { acl("PKG_SHLIBTOOL", lkNone, CheckvarPathname, "") pkglist("PKG_SKIP_REASON", lkShell, CheckvarShellWord) acl("PKG_SUGGESTED_OPTIONS", lkShell, CheckvarOption, "Makefile, Makefile.common, options.mk: set, append") + acl("PKG_SUGGESTED_OPTIONS.*", lkShell, CheckvarOption, "Makefile, Makefile.common, options.mk: set, append") acl("PKG_SUPPORTED_OPTIONS", lkShell, CheckvarOption, "Makefile: set, append; Makefile.common: set; options.mk: set, append, use") pkg("PKG_SYSCONFDIR*", lkNone, CheckvarPathname) pkglist("PKG_SYSCONFDIR_PERMS", lkShell, CheckvarPerms) @@ -613,7 +621,8 @@ func (gd *GlobalData) InitVartypes() { pkglist("PYTHON_VERSIONED_DEPENDENCIES", lkShell, CheckvarPythonDependency) sys("RANLIB", lkNone, CheckvarShellCommand) pkglist("RCD_SCRIPTS", lkShell, CheckvarFilename) - acl("RCD_SCRIPT_SRC.*", lkShell, CheckvarPathname, "Makefile: set") + acl("RCD_SCRIPT_SRC.*", lkNone, CheckvarPathname, "Makefile: set") + acl("RCD_SCRIPT_WRK.*", lkNone, CheckvarPathname, "Makefile: set") acl("REPLACE.*", lkNone, CheckvarString, "Makefile: set") pkglist("REPLACE_AWK", lkShell, CheckvarPathmask) pkglist("REPLACE_BASH", lkShell, CheckvarPathmask) @@ -640,6 +649,7 @@ func (gd *GlobalData) InitVartypes() { sys("RUN_LDCONFIG", lkNone, CheckvarYesNo) acl("SCRIPTS_ENV", lkShell, CheckvarShellWord, "Makefile, Makefile.common: append") usr("SETUID_ROOT_PERMS", lkShell, CheckvarShellWord) + pkg("SET_LIBDIR", lkNone, CheckvarYes) sys("SHAREGRP", lkNone, CheckvarUserGroupName) sys("SHAREMODE", lkNone, CheckvarFileMode) sys("SHAREOWN", lkNone, CheckvarUserGroupName) @@ -648,6 +658,14 @@ func (gd *GlobalData) InitVartypes() { acl("SHLIBTOOL", lkNone, CheckvarShellCommand, "Makefile: use") acl("SHLIBTOOL_OVERRIDE", lkShell, CheckvarPathmask, "Makefile: set, append; Makefile.common: append") acl("SITES.*", lkShell, CheckvarFetchURL, "Makefile, Makefile.common, options.mk: set, append, use") + usr("SMF_PREFIS", lkNone, CheckvarPathname) + pkg("SMF_SRCDIR", lkNone, CheckvarPathname) + pkg("SMF_NAME", lkNone, CheckvarFilename) + pkg("SMF_MANIFEST", lkNone, CheckvarPathname) + pkg("SMF_INSTANCES", lkShell, CheckvarIdentifier) + pkg("SMF_METHODS", lkShell, CheckvarFilename) + pkg("SMF_METHOD_SRC.*", lkNone, CheckvarPathname) + pkg("SMF_METHOD_SHELL", lkNone, CheckvarShellCommand) pkglist("SPECIAL_PERMS", lkShell, CheckvarPerms) sys("STEP_MSG", lkNone, CheckvarShellCommand) acl("SUBDIR", lkShell, CheckvarFilename, "Makefile: append; *:") @@ -683,6 +701,7 @@ func (gd *GlobalData) InitVartypes() { usr("UNPRIVILEGED_GROUP", lkNone, CheckvarUserGroupName) pkglist("UNWRAP_FILES", lkShell, CheckvarPathmask) usr("UPDATE_TARGET", lkShell, CheckvarIdentifier) + pkg("USERGROUP_PHASE", lkNone, enum("configure build pre-install")) pkg("USE_BSD_MAKEFILE", lkNone, CheckvarYes) acl("USE_BUILTIN.*", lkNone, CheckvarYesNoIndirectly, "builtin.mk: set") pkg("USE_CMAKE", lkNone, CheckvarYes) @@ -709,12 +728,14 @@ func (gd *GlobalData) InitVartypes() { sys("WARNING_MSG", lkNone, CheckvarShellCommand) sys("WARNING_CAT", lkNone, CheckvarShellCommand) acl("WRAPPER_REORDER_CMDS", lkShell, CheckvarWrapperReorder, "Makefile, Makefile.common, buildlink3.mk: append") + pkg("WRAPPER_SHELL", lkNone, CheckvarShellCommand) acl("WRAPPER_TRANSFORM_CMDS", lkShell, CheckvarWrapperTransform, "Makefile, Makefile.common, buildlink3.mk: append") sys("WRKDIR", lkNone, CheckvarPathname) pkg("WRKSRC", lkNone, CheckvarWrkdirSubdirectory) sys("X11_PKGSRCDIR.*", lkNone, CheckvarPathname) usr("XAW_TYPE", lkNone, enum("3d neXtaw standard xpm")) acl("XMKMF_FLAGS", lkShell, CheckvarShellWord, "") + pkglist("_WRAP_EXTRA_ARGS.*", lkShell, CheckvarShellWord) } func enum(values string) *VarChecker { diff --git a/pkgtools/pkglint/files/vartypecheck.go b/pkgtools/pkglint/files/vartypecheck.go index 413169f9586..cde5676f6b0 100644 --- a/pkgtools/pkglint/files/vartypecheck.go +++ b/pkgtools/pkglint/files/vartypecheck.go @@ -970,7 +970,7 @@ func (cv *VartypeCheck) Version() { if !matches(cv.Value, `^[\d?\[][\w\-.*?\[\]]+$`) { cv.Line.Warn1("Invalid version number pattern %q.", cv.Value) } - } else if cv.Value == cv.ValueNoVar && !matches(cv.Value, `^\d[\w.]+$`) { + } else if cv.Value == cv.ValueNoVar && !matches(cv.Value, `^\d[\w.]*$`) { cv.Line.Warn1("Invalid version number %q.", cv.Value) } } diff --git a/pkgtools/pkglint/files/vartypecheck_test.go b/pkgtools/pkglint/files/vartypecheck_test.go index 74922a4c815..780eee026b3 100644 --- a/pkgtools/pkglint/files/vartypecheck_test.go +++ b/pkgtools/pkglint/files/vartypecheck_test.go @@ -386,6 +386,17 @@ func (s *Suite) Test_VartypeCheck_VariableName(c *check.C) { c.Check(s.Output(), equals, "WARN: fname:2: \"VarBase\" is not a valid variable name.\n") } +func (s *Suite) Test_VartypeCheck_Version(c *check.C) { + runVartypeChecks("PERL5_REQD", opAssignAppend, (*VartypeCheck).Version, + "0", + "1.2.3.4.5.6", + "4.1nb17", + "4.1-SNAPSHOT", + "4pre7") + + c.Check(s.Output(), equals, "WARN: fname:4: Invalid version number \"4.1-SNAPSHOT\".\n") +} + func (s *Suite) Test_VartypeCheck_Yes(c *check.C) { runVartypeChecks("APACHE_MODULE", opAssign, (*VartypeCheck).Yes, "yes", |