pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Thu Jul 19 06:38:15 UTC 2018

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: check_test.go mklinechecker.go
            mklines.go mklines_test.go vardefs.go vartypecheck.go

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.541 -r1.542 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/pkglint/files/check_test.go
cvs rdiff -u -r1.13 -r1.14 pkgsrc/pkgtools/pkglint/files/mklinechecker.go
cvs rdiff -u -r1.25 -r1.26 pkgsrc/pkgtools/pkglint/files/mklines.go
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/pkglint/files/mklines_test.go
cvs rdiff -u -r1.42 -r1.43 pkgsrc/pkgtools/pkglint/files/vardefs.go
cvs rdiff -u -r1.33 -r1.34 pkgsrc/pkgtools/pkglint/files/vartypecheck.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.541 pkgsrc/pkgtools/pkglint/Makefile:1.542
--- pkgsrc/pkgtools/pkglint/Makefile:1.541      Thu Jul 12 16:23:36 2018
+++ pkgsrc/pkgtools/pkglint/Makefile    Thu Jul 19 06:38:15 2018
@@ -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
 

Index: pkgsrc/pkgtools/pkglint/files/check_test.go
diff -u pkgsrc/pkgtools/pkglint/files/check_test.go:1.19 pkgsrc/pkgtools/pkglint/files/check_test.go:1.20
--- pkgsrc/pkgtools/pkglint/files/check_test.go:1.19    Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/check_test.go Thu Jul 19 06:38:15 2018
@@ -124,6 +124,11 @@ func (t *Tester) SetupMasterSite(varname
        }
 }
 
+// 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) NewLinesAt(fileName str
 }
 
 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.

Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.13 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.14
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.13 Thu Jul 12 16:23:36 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go      Thu Jul 19 06:38:15 2018
@@ -26,6 +26,19 @@ func (ck MkLineChecker) Check() {
 
        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)
 

Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.25 pkgsrc/pkgtools/pkglint/files/mklines.go:1.26
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.25       Thu Jul 12 16:23:36 2018
+++ pkgsrc/pkgtools/pkglint/files/mklines.go    Thu Jul 19 06:38:15 2018
@@ -19,6 +19,7 @@ type MkLines struct {
        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 @@ func NewMkLines(lines []Line) *MkLines {
                tools,
                NewToolRegistry(),
                false,
-               Indentation{}}
+               Indentation{},
+               Once{}}
 }
 
 func (mklines *MkLines) UseVar(mkline MkLine, varname string) {

Index: pkgsrc/pkgtools/pkglint/files/mklines_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.20 pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.21
--- pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.20  Tue May  1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/mklines_test.go       Thu Jul 19 06:38:15 2018
@@ -493,3 +493,42 @@ func (s *Suite) Test_MkLines_ExtractDocu
                "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\".")
+}

Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.42 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.43
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.42       Mon May 21 08:12:23 2018
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go    Thu Jul 19 06:38:15 2018
@@ -121,6 +121,17 @@ func (src *Pkgsrc) InitVartypes() {
                        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 @@ func (src *Pkgsrc) InitVartypes() {
        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 @@ func (src *Pkgsrc) InitVartypes() {
        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 @@ func (src *Pkgsrc) InitVartypes() {
        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"))

Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.33 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.34
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.33  Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go       Thu Jul 19 06:38:15 2018
@@ -626,7 +626,7 @@ func (cv *VartypeCheck) Message() {
        }
 }
 
-// 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 @@ func (cv *VartypeCheck) Option() {
        }
 
        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