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: Fri Aug 19 17:35:43 UTC 2022
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: mkassignchecker.go
mkassignchecker_test.go vartypecheck.go vartypecheck_test.go
Log Message:
pkgtools/pkglint: update to 22.2.6
Changes since 22.2.5:
A makefile that adds a _VARGROUPS section is partly considered part of
the infrastructure. It may define and use variables from its own
namespace. For example, devel/cmake/build.mk adds _VARGROUPS+=cmake,
thereby reserving the namespace '_CMAKE_*' for itself.
Dependencies in BUILDLINK_API_DEPENDS and BUILDLINK_ABI_DEPENDS that
contain unresolved variable expressions are no longer marked as
redundant. They were marked as redundant before because '$', when
interpreted as a package version, was smaller than 0.0.
To generate a diff of this commit:
cvs rdiff -u -r1.726 -r1.727 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.15 -r1.16 pkgsrc/pkgtools/pkglint/files/mkassignchecker.go
cvs rdiff -u -r1.12 -r1.13 \
pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go
cvs rdiff -u -r1.101 -r1.102 pkgsrc/pkgtools/pkglint/files/vartypecheck.go
cvs rdiff -u -r1.93 -r1.94 pkgsrc/pkgtools/pkglint/files/vartypecheck_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.726 pkgsrc/pkgtools/pkglint/Makefile:1.727
--- pkgsrc/pkgtools/pkglint/Makefile:1.726 Wed Aug 17 20:41:51 2022
+++ pkgsrc/pkgtools/pkglint/Makefile Fri Aug 19 17:35:43 2022
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.726 2022/08/17 20:41:51 rillig Exp $
+# $NetBSD: Makefile,v 1.727 2022/08/19 17:35:43 rillig Exp $
-PKGNAME= pkglint-22.2.5
+PKGNAME= pkglint-22.2.6
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/mkassignchecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.15 pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.16
--- pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.15 Sun Jul 24 20:07:20 2022
+++ pkgsrc/pkgtools/pkglint/files/mkassignchecker.go Fri Aug 19 17:35:43 2022
@@ -25,7 +25,7 @@ func (ck *MkAssignChecker) check() {
// checkLeft checks everything to the left of the assignment operator.
func (ck *MkAssignChecker) checkLeft() {
varname := ck.MkLine.Varname()
- if hasPrefix(varname, "_") && !G.Infrastructure && G.Pkgsrc.vartypes.Canon(varname) == nil {
+ if !ck.mayBeDefined(varname) {
ck.MkLine.Warnf("Variable names starting with an underscore (%s) are reserved for internal pkgsrc use.", varname)
}
@@ -691,3 +691,27 @@ func (ck *MkAssignChecker) checkVaruseSh
}
}
}
+
+func (ck *MkAssignChecker) mayBeDefined(varname string) bool {
+ if !hasPrefix(varname, "_") {
+ return true
+ }
+ if G.Infrastructure {
+ return true
+ }
+ if G.Pkgsrc.vartypes.Canon(varname) != nil {
+ return true
+ }
+
+ // Defining the group 'cmake' allows the variable names '_CMAKE_*',
+ // it's kind of a namespace declaration.
+ vargroups := ck.MkLines.allVars.FirstDefinition("_VARGROUPS")
+ if vargroups != nil {
+ prefix := "_" + strings.ToUpper(vargroups.Value()) + "_"
+ if hasPrefix(varname, prefix) {
+ return true
+ }
+ }
+
+ return false
+}
Index: pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.12 pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.13
--- pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.12 Wed Aug 17 20:41:51 2022
+++ pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go Fri Aug 19 17:35:43 2022
@@ -1188,3 +1188,25 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: filename.mk:1: Unknown shell command \"grep\".",
"WARN: filename.mk:1: EXAMPLE_FILES is used but not defined.")
}
+
+func (s *Suite) Test_MkAssignChecker_mayBeDefined(c *check.C) {
+ t := s.Init(c)
+ t.SetUpVartypes()
+
+ mklines := t.NewMkLines("filename.mk",
+ MkCvsID,
+ "",
+ "_GOOD_PREFIX=\t\tvalue",
+ "_BAD_PREFIX=\t\tvalue",
+ "",
+ "_VARGROUPS+=\t\tgood",
+ "_IGN_VARS.good+=\t_GOOD_PREFIX")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: filename.mk:3: _GOOD_PREFIX is defined but not used.",
+ "WARN: filename.mk:4: Variable names starting with an underscore (_BAD_PREFIX) are reserved for internal pkgsrc use.",
+ "WARN: filename.mk:4: _BAD_PREFIX is defined but not used.",
+ "WARN: filename.mk:4: Variable _BAD_PREFIX is defined but not mentioned in the _VARGROUPS section.")
+}
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.101 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.102
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.101 Sun Jul 24 20:07:20 2022
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go Fri Aug 19 17:35:43 2022
@@ -397,6 +397,9 @@ func (cv *VartypeCheck) DependencyPatter
if defpat == nil || defpat.LowerOp == "" {
return
}
+ if containsVarUse(defpat.LowerOp) || containsVarUse(deppat.Lower) {
+ return
+ }
limit := condInt(defpat.LowerOp == ">=" && deppat.LowerOp == ">", 1, 0)
if pkgver.Compare(deppat.Lower, defpat.Lower) < limit {
cv.Notef("The requirement %s%s is already guaranteed by the %s%s from %s.",
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.93 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.94
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.93 Sun Jul 24 20:07:20 2022
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go Fri Aug 19 17:35:43 2022
@@ -489,8 +489,13 @@ func (s *Suite) Test_VartypeCheck_Depend
t := s.Init(c)
t.SetUpPackage("category/package",
+ "LIB_VERSION_SMALL=\t1.0",
+ "LIB_VERSION_LARGE=\t10.0",
+ "",
".include \"../../category/lib/buildlink3.mk\"",
"BUILDLINK_API_DEPENDS.lib+=\tlib>=1.0pkg",
+ "BUILDLINK_API_DEPENDS.lib+=\tlib>=${LIB_VERSION_SMALL}",
+ "BUILDLINK_API_DEPENDS.lib+=\tlib>=${LIB_VERSION_LARGE}",
"BUILDLINK_ABI_DEPENDS.lib+=\tlib>=1.1pkg")
t.SetUpPackage("category/lib")
t.CreateFileBuildlink3("category/lib/buildlink3.mk",
@@ -502,11 +507,11 @@ func (s *Suite) Test_VartypeCheck_Depend
G.checkdirPackage(".")
t.CheckOutputLines(
- "NOTE: Makefile:21: The requirement >=1.0pkg is already guaranteed "+
+ "NOTE: Makefile:24: The requirement >=1.0pkg is already guaranteed "+
"by the >=1.3api from ../../category/lib/buildlink3.mk:12.",
- "ERROR: Makefile:22: Packages must only require API versions, "+
+ "ERROR: Makefile:27: Packages must only require API versions, "+
"not ABI versions of dependencies.",
- "NOTE: Makefile:22: The requirement >=1.1pkg is already guaranteed "+
+ "NOTE: Makefile:27: The requirement >=1.1pkg is already guaranteed "+
"by the >=1.4abi from ../../category/lib/buildlink3.mk:13.")
}
Home |
Main Index |
Thread Index |
Old Index