pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: updated to 5.5.14



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4b01c619e484
branches:  trunk
changeset: 382960:4b01c619e484
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jul 19 06:38:15 2018 +0000

description:
pkgtools/pkglint: updated to 5.5.14

Changes since 5.5.13:

* Suppress duplicate warnings for unknown options in the same file

* Grab acceptable package versions directly from the infrastructure files

* Note about too deeply indented shell programs

diffstat:

 pkgtools/pkglint/Makefile               |   4 +-
 pkgtools/pkglint/files/check_test.go    |  11 ++++++++-
 pkgtools/pkglint/files/mklinechecker.go |  13 +++++++++++
 pkgtools/pkglint/files/mklines.go       |   4 ++-
 pkgtools/pkglint/files/mklines_test.go  |  39 +++++++++++++++++++++++++++++++++
 pkgtools/pkglint/files/vardefs.go       |  17 +++++++++++--
 pkgtools/pkglint/files/vartypecheck.go  |   8 +++++-
 7 files changed, 87 insertions(+), 9 deletions(-)

diffs (204 lines):

diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/Makefile Thu Jul 19 06:38:15 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.541 2018/07/12 16:23:36 rillig Exp $
+# $NetBSD: Makefile,v 1.542 2018/07/19 06:38:15 rillig Exp $
 
-PKGNAME=       pkglint-5.5.13
+PKGNAME=       pkglint-5.5.14
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Thu Jul 19 06:38:15 2018 +0000
@@ -124,6 +124,11 @@
        }
 }
 
+// SetupOption pretends that the package option is defined in mk/defaults/options.description.
+func (t *Tester) SetupOption(name, description string) {
+       G.Pkgsrc.PkgOptions[name] = description
+}
+
 func (t *Tester) SetupTool(tool *Tool) {
        reg := G.Pkgsrc.Tools
 
@@ -254,7 +259,11 @@
 }
 
 func (t *Tester) NewMkLines(fileName string, lines ...string) *MkLines {
-       return NewMkLines(t.NewLines(fileName, lines...))
+       rawText := ""
+       for _, line := range lines {
+               rawText += line + "\n"
+       }
+       return NewMkLines(convertToLogicalLines(fileName, rawText, true))
 }
 
 // Returns and consumes the output from both stdout and stderr.
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go   Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go   Thu Jul 19 06:38:15 2018 +0000
@@ -26,6 +26,19 @@
 
        case mkline.IsShellCommand():
                shellCommand := mkline.ShellCommand()
+
+               if G.opts.WarnSpace && hasPrefix(mkline.Text, "\t\t") {
+                       fix := mkline.Autofix()
+                       fix.Notef("Shell programs should be indented with a single tab.")
+                       fix.Explain(
+                               "The first tab in the line marks the line as a shell command.  Since",
+                               "every line of shell commands starts with a completely new shell",
+                               "environment, there is no need to indent some of the commands, or to",
+                               "use more horizontal space than necessary.")
+                       fix.ReplaceRegex(`^\t\t+`, "\t", 1)
+                       fix.Apply()
+               }
+
                ck.checkText(shellCommand)
                NewShellLine(mkline).CheckShellCommandLine(shellCommand)
 
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/mklines.go Thu Jul 19 06:38:15 2018 +0000
@@ -19,6 +19,7 @@
        toolRegistry   ToolRegistry    // Tools defined in file scope.
        SeenBsdPrefsMk bool
        indentation    Indentation // Indentation depth of preprocessing directives
+       Once
        // XXX: Why both tools and toolRegistry?
 }
 
@@ -45,7 +46,8 @@
                tools,
                NewToolRegistry(),
                false,
-               Indentation{}}
+               Indentation{},
+               Once{}}
 }
 
 func (mklines *MkLines) UseVar(mkline MkLine, varname string) {
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/mklines_test.go
--- a/pkgtools/pkglint/files/mklines_test.go    Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/mklines_test.go    Thu Jul 19 06:38:15 2018 +0000
@@ -493,3 +493,42 @@
                "VARBASE3.* (line 19)"}
        c.Check(varnames, deepEquals, expected)
 }
+
+func (s *Suite) Test_MkLines__shell_command_indentation(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupCommandLine("-Wall")
+       t.SetupVartypes()
+       mklines := t.NewMkLines("Makefile",
+               MkRcsID,
+               "#",
+               "pre-configure:",
+               "\tcd 'indented correctly'",
+               "\t\tcd 'indented needlessly'",
+               "\tcd 'indented correctly' \\",
+               "\t\t&& cd 'with indented continuation'")
+
+       mklines.Check()
+
+       t.CheckOutputLines(
+               "NOTE: Makefile:5: Shell programs should be indented with a single tab.")
+}
+
+func (s *Suite) Test_MkLines__unknown_options(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupCommandLine("-Wall")
+       t.SetupVartypes()
+       t.SetupOption("known", "")
+       mklines := t.NewMkLines("options.mk",
+               MkRcsID,
+               "#",
+               "PKG_OPTIONS_VAR=\tPKG_OPTIONS.pkgbase",
+               "PKG_SUPPORTED_OPTIONS=\tknown unknown",
+               "PKG_SUGGESTED_OPTIONS=\tknown unknown")
+
+       mklines.Check()
+
+       t.CheckOutputLines(
+               "WARN: options.mk:4: Unknown option \"unknown\".")
+}
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Thu Jul 19 06:38:15 2018 +0000
@@ -121,6 +121,17 @@
                        return joined
                }())
 
+       enumFrom := func(fileName, varname, defval string) *BasicType {
+               lines, _ := readLines(src.File(fileName), true)
+               mklines := NewMkLines(lines)
+               for _, mkline := range mklines.mklines {
+                       if mkline.IsVarassign() && mkline.Varname() == varname {
+                               return enum(mkline.Value())
+                       }
+               }
+               return enum(defval)
+       }
+
        // Last synced with mk/defaults/mk.conf revision 1.269
        usr("USE_CWRAPPERS", lkNone, enum("yes no auto"))
        usr("ALLOW_VULNERABLE_PACKAGES", lkNone, BtYes)
@@ -588,7 +599,7 @@
        sys("EMACS_PKGNAME_PREFIX", lkNone, BtIdentifier) // Or the empty string.
        sys("EMACS_TYPE", lkNone, enum("emacs xemacs"))
        acl("EMACS_USE_LEIM", lkNone, BtYes, "")
-       acl("EMACS_VERSIONS_ACCEPTED", lkShell, enum("emacs25 emacs21 emacs21nox emacs20 xemacs215 xemacs215nox xemacs214 xemacs214nox"), "Makefile: set")
+       acl("EMACS_VERSIONS_ACCEPTED", lkShell, enumFrom("editors/emacs/modules.mk", "_EMACS_VERSIONS_ALL", "emacs25 emacs21 emacs21nox emacs20 xemacs215 xemacs215nox xemacs214 xemacs214nox"), 
"Makefile: set")
        sys("EMACS_VERSION_MAJOR", lkNone, BtInteger)
        sys("EMACS_VERSION_MINOR", lkNone, BtInteger)
        acl("EMACS_VERSION_REQD", lkShell, enum("emacs25 emacs25nox emacs21 emacs21nox emacs20 xemacs215 xemacs214"), "Makefile: set, append")
@@ -785,7 +796,7 @@
        acl("MESSAGE_SUBST", lkShell, BtShellWord, "Makefile, Makefile.common, options.mk: append")
        pkg("META_PACKAGE", lkNone, BtYes)
        sys("MISSING_FEATURES", lkShell, BtIdentifier)
-       acl("MYSQL_VERSIONS_ACCEPTED", lkShell, enum("51 55 56"), "Makefile: set")
+       acl("MYSQL_VERSIONS_ACCEPTED", lkShell, enumFrom("mk/mysql.buildlink3.mk", "MYSQL_VERSIONS_ACCEPTED", "57 56 55 51 MARIADB55"), "Makefile: set")
        usr("MYSQL_VERSION_DEFAULT", lkNone, BtVersion)
        sys("NM", lkNone, BtShellCommand)
        sys("NONBINMODE", lkNone, BtFileMode)
@@ -833,7 +844,7 @@
        pkg("PERL5_REQD", lkShell, BtVersion)
        pkg("PERL5_USE_PACKLIST", lkNone, BtYesNo)
        sys("PGSQL_PREFIX", lkNone, BtPathname)
-       acl("PGSQL_VERSIONS_ACCEPTED", lkShell, enum("10 93 94 95 96"), "")
+       acl("PGSQL_VERSIONS_ACCEPTED", lkShell, enumFrom("mk/pgsql.buildlink3.mk", "PGSQL_VERSIONS_ACCEPTED", "10 96 95 94 93"), "")
        usr("PGSQL_VERSION_DEFAULT", lkNone, BtVersion)
        sys("PG_LIB_EXT", lkNone, enum("dylib so"))
        sys("PGSQL_TYPE", lkNone, enum("postgresql81-client postgresql80-client"))
diff -r 0222fdc3cb5a -r 4b01c619e484 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go    Thu Jul 19 04:47:13 2018 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go    Thu Jul 19 06:38:15 2018 +0000
@@ -626,7 +626,7 @@
        }
 }
 
-// A package option from options.mk
+// Option checks whether a single package option from options.mk conforms to the naming conventions.
 func (cv *VartypeCheck) Option() {
        line, value, valueNovar := cv.Line, cv.Value, cv.ValueNoVar
 
@@ -638,8 +638,12 @@
        }
 
        if m, optname := match1(value, `^-?([a-z][-0-9a-z+]*)$`); m {
+               if G.Mk != nil && !G.Mk.FirstTime("option:"+optname) {
+                       return
+               }
+
                if _, found := G.Pkgsrc.PkgOptions[optname]; !found { // There's a difference between empty and absent here.
-                       line.Warnf("Unknown option \"%s\".", optname)
+                       line.Warnf("Unknown option %q.", optname)
                        Explain(
                                "This option is not documented in the mk/defaults/options.description",
                                "file.  Please think of a brief but precise description and either",



Home | Main Index | Thread Index | Old Index