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: Sat Aug 14 08:19:49 UTC 2021
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: mkline_test.go mklines.go
mklines_test.go package.go package_test.go pkglint_test.go
pkgsrc.go pkgsrc_test.go tools.go tools_test.go
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.694 -r1.695 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.82 -r1.83 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.73 -r1.74 pkgsrc/pkgtools/pkglint/files/mklines.go
cvs rdiff -u -r1.65 -r1.66 pkgsrc/pkgtools/pkglint/files/mklines_test.go
cvs rdiff -u -r1.101 -r1.102 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.84 -r1.85 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.69 -r1.70 pkgsrc/pkgtools/pkglint/files/pkglint_test.go
cvs rdiff -u -r1.62 -r1.63 pkgsrc/pkgtools/pkglint/files/pkgsrc.go
cvs rdiff -u -r1.52 -r1.53 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
cvs rdiff -u -r1.24 -r1.25 pkgsrc/pkgtools/pkglint/files/tools.go
cvs rdiff -u -r1.25 -r1.26 pkgsrc/pkgtools/pkglint/files/tools_test.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.694 pkgsrc/pkgtools/pkglint/Makefile:1.695
--- pkgsrc/pkgtools/pkglint/Makefile:1.694 Thu Aug 12 05:29:41 2021
+++ pkgsrc/pkgtools/pkglint/Makefile Sat Aug 14 08:19:49 2021
@@ -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/}
Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.82 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.83
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.82 Fri Jun 12 19:14:45 2020
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go Sat Aug 14 08:19:49 2021
@@ -703,7 +703,7 @@ func (s *Suite) Test_MkLine_VariableNeed
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(
Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.73 pkgsrc/pkgtools/pkglint/files/mklines.go:1.74
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.73 Sat Mar 20 23:32:43 2021
+++ pkgsrc/pkgtools/pkglint/files/mklines.go Sat Aug 14 08:19:49 2021
@@ -116,7 +116,7 @@ func (mklines *MkLines) Check() {
// 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 @@ func (mklines *MkLines) collectDocumente
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
Index: pkgsrc/pkgtools/pkglint/files/mklines_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.65 pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.66
--- pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.65 Fri Jul 31 22:39:36 2020
+++ pkgsrc/pkgtools/pkglint/files/mklines_test.go Sat Aug 14 08:19:49 2021
@@ -681,7 +681,7 @@ func (s *Suite) Test_MkLines_collectVari
"SUBST_VARS.id+=\tVAR3")
t.DisableTracing()
- mklines.collectVariables()
+ mklines.collectVariables(false, false)
t.CheckOutputEmpty()
}
@@ -807,9 +807,9 @@ func (s *Suite) Test_MkLines_checkAll__c
".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)
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.101 pkgsrc/pkgtools/pkglint/files/package.go:1.102
--- pkgsrc/pkgtools/pkglint/files/package.go:1.101 Thu Aug 12 05:29:41 2021
+++ pkgsrc/pkgtools/pkglint/files/package.go Sat Aug 14 08:19:49 2021
@@ -710,8 +710,8 @@ func (pkg *Package) checkfilePackageMake
// 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) checkMeson(mklines *
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(
Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.84 pkgsrc/pkgtools/pkglint/files/package_test.go:1.85
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.84 Thu Aug 12 05:29:42 2021
+++ pkgsrc/pkgtools/pkglint/files/package_test.go Sat Aug 14 08:19:49 2021
@@ -2619,14 +2619,6 @@ func (s *Suite) Test_Package_checkUseLan
}
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")
Index: pkgsrc/pkgtools/pkglint/files/pkglint_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.69 pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.70
--- pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.69 Fri Jun 25 14:15:01 2021
+++ pkgsrc/pkgtools/pkglint/files/pkglint_test.go Sat Aug 14 08:19:49 2021
@@ -719,7 +719,7 @@ func (s *Suite) Test_resolveVariableRefs
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 @@ func (s *Suite) Test_resolveVariableRefs
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)
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.62 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.63
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.62 Sun Aug 8 22:04:15 2021
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go Sat Aug 14 08:19:49 2021
@@ -842,7 +842,7 @@ func (src *Pkgsrc) loadUntypedVars() {
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 {
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.52 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.53
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.52 Sun Jun 6 07:41:34 2021
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go Sat Aug 14 08:19:49 2021
@@ -934,7 +934,7 @@ func (s *Suite) Test_Pkgsrc_loadUntypedV
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 @@ func (s *Suite) Test_Pkgsrc_loadUntypedV
"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)
Index: pkgsrc/pkgtools/pkglint/files/tools.go
diff -u pkgsrc/pkgtools/pkglint/files/tools.go:1.24 pkgsrc/pkgtools/pkglint/files/tools.go:1.25
--- pkgsrc/pkgtools/pkglint/files/tools.go:1.24 Mon Jun 1 20:49:54 2020
+++ pkgsrc/pkgtools/pkglint/files/tools.go Sat Aug 14 08:19:49 2021
@@ -245,7 +245,11 @@ func (tr *Tools) ParseToolLine(mklines *
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)
}
}
Index: pkgsrc/pkgtools/pkglint/files/tools_test.go
diff -u pkgsrc/pkgtools/pkglint/files/tools_test.go:1.25 pkgsrc/pkgtools/pkglint/files/tools_test.go:1.26
--- pkgsrc/pkgtools/pkglint/files/tools_test.go:1.25 Sat Mar 7 23:35:35 2020
+++ pkgsrc/pkgtools/pkglint/files/tools_test.go Sat Aug 14 08:19:49 2021
@@ -44,7 +44,7 @@ func (s *Suite) Test_Tool_UsableAtLoadTi
"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 @@ func (s *Suite) Test_Tools__aliases_in_f
"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 @@ func (s *Suite) Test_Tools_ParseToolLine
"_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