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 22.2.6
details: https://anonhg.NetBSD.org/pkgsrc/rev/dcbe66e0ce78
branches: trunk
changeset: 383506:dcbe66e0ce78
user: rillig <rillig%pkgsrc.org@localhost>
date: Fri Aug 19 17:35:43 2022 +0000
description:
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.
diffstat:
pkgtools/pkglint/Makefile | 4 ++--
pkgtools/pkglint/files/mkassignchecker.go | 26 +++++++++++++++++++++++++-
pkgtools/pkglint/files/mkassignchecker_test.go | 22 ++++++++++++++++++++++
pkgtools/pkglint/files/vartypecheck.go | 3 +++
pkgtools/pkglint/files/vartypecheck_test.go | 11 ++++++++---
5 files changed, 60 insertions(+), 6 deletions(-)
diffs (126 lines):
diff -r 5adb51a740e4 -r dcbe66e0ce78 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Fri Aug 19 16:45:26 2022 +0000
+++ b/pkgtools/pkglint/Makefile Fri Aug 19 17:35:43 2022 +0000
@@ -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/}
diff -r 5adb51a740e4 -r dcbe66e0ce78 pkgtools/pkglint/files/mkassignchecker.go
--- a/pkgtools/pkglint/files/mkassignchecker.go Fri Aug 19 16:45:26 2022 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker.go Fri Aug 19 17:35:43 2022 +0000
@@ -25,7 +25,7 @@
// 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) 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
+}
diff -r 5adb51a740e4 -r dcbe66e0ce78 pkgtools/pkglint/files/mkassignchecker_test.go
--- a/pkgtools/pkglint/files/mkassignchecker_test.go Fri Aug 19 16:45:26 2022 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker_test.go Fri Aug 19 17:35:43 2022 +0000
@@ -1188,3 +1188,25 @@
"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.")
+}
diff -r 5adb51a740e4 -r dcbe66e0ce78 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go Fri Aug 19 16:45:26 2022 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go Fri Aug 19 17:35:43 2022 +0000
@@ -397,6 +397,9 @@
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.",
diff -r 5adb51a740e4 -r dcbe66e0ce78 pkgtools/pkglint/files/vartypecheck_test.go
--- a/pkgtools/pkglint/files/vartypecheck_test.go Fri Aug 19 16:45:26 2022 +0000
+++ b/pkgtools/pkglint/files/vartypecheck_test.go Fri Aug 19 17:35:43 2022 +0000
@@ -489,8 +489,13 @@
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 @@
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