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: update to 21.2.4



details:   https://anonhg.NetBSD.org/pkgsrc/rev/115c13e22c4d
branches:  trunk
changeset: 457022:115c13e22c4d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Aug 14 08:19:49 2021 +0000

description:
pkgtools/pkglint: update to 21.2.4

Changes since 21.2.3:

Fixed loading of the tool definitions.  This adds 76 warnings for
packages that use tools without adding them to USE_TOOLS.  It also fixes
the warning about gmake and Meson.

diffstat:

 pkgtools/pkglint/Makefile              |   4 +-
 pkgtools/pkglint/files/mkline_test.go  |   2 +-
 pkgtools/pkglint/files/mklines.go      |  12 ++++++----
 pkgtools/pkglint/files/mklines_test.go |   6 ++--
 pkgtools/pkglint/files/package.go      |   6 ++--
 pkgtools/pkglint/files/package_test.go |   8 -------
 pkgtools/pkglint/files/pkglint_test.go |   4 +-
 pkgtools/pkglint/files/pkgsrc.go       |   2 +-
 pkgtools/pkglint/files/pkgsrc_test.go  |  37 +++++++++++++++++++++++++++++++++-
 pkgtools/pkglint/files/tools.go        |   6 ++++-
 pkgtools/pkglint/files/tools_test.go   |   6 ++--
 11 files changed, 63 insertions(+), 30 deletions(-)

diffs (253 lines):

diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/Makefile Sat Aug 14 08:19:49 2021 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.694 2021/08/12 05:29:41 rillig Exp $
+# $NetBSD: Makefile,v 1.695 2021/08/14 08:19:49 rillig Exp $
 
-PKGNAME=       pkglint-21.2.3
+PKGNAME=       pkglint-21.2.4
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sat Aug 14 08:19:49 2021 +0000
@@ -703,7 +703,7 @@
                MkCvsID,
                "GENERATE_PLIST= cd ${DESTDIR}${PREFIX}; ${FIND} * \\( -type f -or -type l \\) | ${SORT};")
 
-       mklines.collectVariables()
+       mklines.collectVariables(false, true)
        MkLineChecker{mklines, mklines.mklines[1]}.Check()
 
        t.CheckOutputLines(
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/mklines.go Sat Aug 14 08:19:49 2021 +0000
@@ -116,7 +116,7 @@
        // are collected to make the order of the definitions irrelevant.
        mklines.collectRationale()
        mklines.collectUsedVariables()
-       mklines.collectVariables()
+       mklines.collectVariables(false, true)
        mklines.collectPlistVars()
        if mklines.pkg != nil {
                mklines.pkg.collectConditionalIncludes(mklines)
@@ -249,12 +249,14 @@
        finish()
 }
 
-func (mklines *MkLines) collectVariables() {
-       mklines.ForEach(mklines.collectVariable)
+func (mklines *MkLines) collectVariables(infrastructure bool, addToUseTools bool) {
+       mklines.ForEach(func(mkline *MkLine) {
+               mklines.collectVariable(mkline, infrastructure, addToUseTools)
+       })
 }
 
-func (mklines *MkLines) collectVariable(mkline *MkLine) {
-       mklines.Tools.ParseToolLine(mklines, mkline, false, true)
+func (mklines *MkLines) collectVariable(mkline *MkLine, infrastructure bool, addToUseTools bool) {
+       mklines.Tools.ParseToolLine(mklines, mkline, infrastructure, addToUseTools)
 
        if !mkline.IsVarassignMaybeCommented() {
                return
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/mklines_test.go
--- a/pkgtools/pkglint/files/mklines_test.go    Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/mklines_test.go    Sat Aug 14 08:19:49 2021 +0000
@@ -681,7 +681,7 @@
                "SUBST_VARS.id+=\tVAR3")
        t.DisableTracing()
 
-       mklines.collectVariables()
+       mklines.collectVariables(false, false)
 
        t.CheckOutputEmpty()
 }
@@ -807,9 +807,9 @@
                ".elif 0",
                ".endif")
 
-       // As a side-effect of MkLines.ForEach,
+       // As a side effect of MkLines.ForEach,
        // the HasElseBranch in the lines is updated.
-       mklines.collectVariables()
+       mklines.collectVariables(false, false)
 
        t.CheckEquals(mklines.mklines[2].HasElseBranch(), false)
        t.CheckEquals(mklines.mklines[5].HasElseBranch(), true)
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/package.go Sat Aug 14 08:19:49 2021 +0000
@@ -710,8 +710,8 @@
        //  though.
        // pkg.collectConditionalIncludes(allLines)
 
-       allLines.collectVariables()    // To get the tool definitions
-       mklines.Tools = allLines.Tools // TODO: also copy the other collected data
+       allLines.collectVariables(false, true) // To get the tool definitions
+       mklines.Tools = allLines.Tools         // TODO: also copy the other collected data
 
        // TODO: Checking only mklines instead of allLines ignores the
        //  .include lines. For example, including "options.mk" does not
@@ -1194,7 +1194,7 @@
 
 func (pkg *Package) checkMesonGnuMake(mklines *MkLines) {
        gmake := mklines.Tools.ByName("gmake")
-       if G.Experimental && gmake != nil && gmake.UsableAtRunTime() {
+       if gmake != nil && gmake.UsableAtRunTime() {
                mkline := NewLineWhole(pkg.File("."))
                mkline.Warnf("Meson packages usually don't need GNU make.")
                mkline.Explain(
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go    Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/package_test.go    Sat Aug 14 08:19:49 2021 +0000
@@ -2619,14 +2619,6 @@
 }
 
 func (s *Suite) Test_Package_checkMesonGnuMake(c *check.C) {
-
-       // False positive in x11/libxkbcommon, 2021-08-12.
-       //
-       // It seems that the Tools registry is not initialized properly since
-       // x11/libxkbcommon does not mention gmake at all, and 'bmake show-all'
-       // also does not contain 'gmake'.
-       G.Experimental = true
-
        t := s.Init(c)
 
        t.CreateFileLines("devel/meson/build.mk")
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/pkglint_test.go
--- a/pkgtools/pkglint/files/pkglint_test.go    Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/pkglint_test.go    Sat Aug 14 08:19:49 2021 +0000
@@ -719,7 +719,7 @@
        mklines := t.NewMkLines("filename.mk",
                MkCvsID,
                "ORIGIN=\tfilename.mk")
-       mklines.collectVariables()
+       mklines.collectVariables(false, false)
        pkg := NewPackage(t.File("category/package"))
        pkg.vars.Define("ORIGIN", t.NewMkLine("other.mk", 123, "ORIGIN=\tpackage"))
 
@@ -750,7 +750,7 @@
        pkg.vars.Define("PKGVAR", t.NewMkLine("filename.mk", 123, "PKGVAR!=\tcommand"))
        mklines := t.NewMkLinesPkg("filename.mk", pkg,
                "VAR!=\tcommand")
-       mklines.collectVariables()
+       mklines.collectVariables(false, false)
 
        resolved := resolveVariableRefs("${VAR} ${PKGVAR}", mklines, nil)
 
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go  Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go  Sat Aug 14 08:19:49 2021 +0000
@@ -842,7 +842,7 @@
 
        handleMkFile := func(path CurrPath) {
                mklines := LoadMk(path, nil, MustSucceed)
-               mklines.collectVariables()
+               mklines.collectVariables(false, true) // FIXME
                mklines.collectUsedVariables()
                mklines.allVars.forEach(func(varname string, data *scopeVar) {
                        if data.firstDef != nil {
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/pkgsrc_test.go
--- a/pkgtools/pkglint/files/pkgsrc_test.go     Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/pkgsrc_test.go     Sat Aug 14 08:19:49 2021 +0000
@@ -934,7 +934,7 @@
        t.CheckOutputEmpty()
 }
 
-func (s *Suite) Test_Pkgsrc_loadUntypedVars__loop_variable(c *check.C) {
+func (s *Suite) Test_Pkgsrc_loadUntypedVars__local_varnames(c *check.C) {
        t := s.Init(c)
 
        t.CreateFileLines("mk/check/check-files.mk",
@@ -969,6 +969,41 @@
                        "Invalid part \"/\" after variable name \"\".")
 }
 
+// An optional tool is not available by default.
+// A package can choose to include a tool by adding it to USE_TOOLS.
+func (s *Suite) Test_Pkgsrc_loadUntypedVars__tools(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("category/package",
+               "do-configure:",
+               "\tlinux-tool",
+               "\toptional-tool")
+       t.CreateFileLines("mk/tools/default.mk",
+               MkCvsID,
+               "",
+               // This tool is available by default.
+               ".if ${OPSYS} == Linux",
+               "TOOLS_CREATE+=\tlinux-tool",
+               ".endif",
+               "",
+               // This tool is only available if it is listed in USE_TOOLS.
+               ".if ${_USE_TOOLS:Moptional-tool}",
+               "TOOLS_CREATE+=\toptional-tool",
+               ".endif")
+       t.FinishSetUp()
+
+       G.Check(t.File("category/package"))
+
+       // FIXME: The command names must be recognized.
+       // TODO: linux-tool must be available to the package.
+       // TODO: optional-tool must not be available to the package.
+       t.CheckOutputLines(
+               "WARN: ~/category/package/Makefile:21: "+
+                       "Unknown shell command \"linux-tool\".",
+               "WARN: ~/category/package/Makefile:22: "+
+                       "Unknown shell command \"optional-tool\".")
+}
+
 func (s *Suite) Test_Pkgsrc_Latest__multiple_candidates(c *check.C) {
        t := s.Init(c)
 
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/tools.go
--- a/pkgtools/pkglint/files/tools.go   Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/tools.go   Sat Aug 14 08:19:49 2021 +0000
@@ -245,7 +245,11 @@
                case "TOOLS_CREATE":
                        for _, name := range mkline.ValueFields(value) {
                                if tr.IsValidToolName(name) {
-                                       tr.def(name, "", false, AtRunTime, nil)
+                                       validity := AtRunTime
+                                       if mklines.indentation.DependsOn("_USE_TOOLS") {
+                                               validity = Nowhere // see mk/tools/replace.mk
+                                       }
+                                       tr.def(name, "", false, validity, nil)
                                }
                        }
 
diff -r 3ab61f1e5c2a -r 115c13e22c4d pkgtools/pkglint/files/tools_test.go
--- a/pkgtools/pkglint/files/tools_test.go      Sat Aug 14 08:19:25 2021 +0000
+++ b/pkgtools/pkglint/files/tools_test.go      Sat Aug 14 08:19:49 2021 +0000
@@ -44,7 +44,7 @@
                        "To use the tool ${TOOL1} at load time, " +
                        "bsd.prefs.mk has to be included before.")
        // Maybe an explanation might help here.
-       // There is surprisingly few feedback on any of the explanations
+       // There is surprisingly little feedback on any of the explanations
        // though (about 0 in 10 years), therefore I don't even know
        // whether anyone reads them.
 }
@@ -447,7 +447,7 @@
                "TOOLS_ALIASES.ggrep+=\t${t}",
                ".endfor")
 
-       mklines.collectVariables() // calls ParseToolLine internally
+       mklines.collectVariables(false, true) // calls ParseToolLine internally
 
        t.CheckDeepEquals(
                mklines.Tools.ByName("ggrep").Aliases,
@@ -592,7 +592,7 @@
                "_TOOLS.${t}=\t${t}",
                ".endfor")
 
-       mklines.collectVariables()
+       mklines.collectVariables(false, true)
        t.Check(mklines.Tools.byName, check.HasLen, 1)
        t.CheckEquals(mklines.Tools.ByName("tool").String(), "tool:::Nowhere:abc")
 



Home | Main Index | Thread Index | Old Index