Source-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 20.1.16
details: https://anonhg.NetBSD.org/pkgsrc/rev/77b660b10717
branches: trunk
changeset: 434209:77b660b10717
user: rillig <rillig%pkgsrc.org@localhost>
date: Fri Jun 12 19:14:45 2020 +0000
description:
pkgtools/pkglint: update to 20.1.16
Changes since 20.1.15:
When a package adds an additional version requirement for another
package, it must do so using BUILDLINK_API_DEPENDS instead of
BUILDLINK_ABI_DEPENDS. Most packages already do this.
When a values is appended to an undefined variable using the += operator,
bmake does not add a space before, and pkglint caught up to do the same.
This change has no practical consequences though.
As always, a bit of refactoring. The method names of MkAssignChecker
contained the redundant word "varassign".
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/buildlink3_test.go | 1 +
pkgtools/pkglint/files/homepage_test.go | 12 +-
pkgtools/pkglint/files/mkassignchecker.go | 117 ++++++++++++++++--------
pkgtools/pkglint/files/mkassignchecker_test.go | 117 ++++++++++++++----------
pkgtools/pkglint/files/mkline_test.go | 16 +-
pkgtools/pkglint/files/mklinechecker.go | 4 +-
pkgtools/pkglint/files/mklines_test.go | 24 ++++-
pkgtools/pkglint/files/mkvarusechecker.go | 2 +-
pkgtools/pkglint/files/mkvarusechecker_test.go | 4 +-
pkgtools/pkglint/files/package.go | 4 +-
pkgtools/pkglint/files/redundantscope_test.go | 1 +
pkgtools/pkglint/files/shell_test.go | 2 +-
pkgtools/pkglint/files/util.go | 92 +++++++++++++------
pkgtools/pkglint/files/util_test.go | 4 +-
pkgtools/pkglint/files/var.go | 7 +-
pkgtools/pkglint/files/var_test.go | 4 +-
pkgtools/pkglint/files/vartypecheck_test.go | 22 +++-
18 files changed, 282 insertions(+), 155 deletions(-)
diffs (truncated from 1318 to 300 lines):
diff -r 1e28fb7f9801 -r 77b660b10717 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Fri Jun 12 19:10:49 2020 +0000
+++ b/pkgtools/pkglint/Makefile Fri Jun 12 19:14:45 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.654 2020/06/07 15:49:23 rillig Exp $
+# $NetBSD: Makefile,v 1.655 2020/06/12 19:14:45 rillig Exp $
-PKGNAME= pkglint-20.1.15
+PKGNAME= pkglint-20.1.16
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 1e28fb7f9801 -r 77b660b10717 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Fri Jun 12 19:10:49 2020 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Fri Jun 12 19:14:45 2020 +0000
@@ -305,6 +305,7 @@
CheckLinesBuildlink3Mk(mklines)
t.CheckOutputLines(
+ "ERROR: buildlink3.mk:10: Packages must only require API versions, not ABI versions of dependencies.",
"WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" and API \"hs-X11\" (from line 8).",
"WARN: buildlink3.mk:10: Only buildlink variables for \"hs-X11\", not \"hs-X12\" may be set in this file.")
}
diff -r 1e28fb7f9801 -r 77b660b10717 pkgtools/pkglint/files/homepage_test.go
--- a/pkgtools/pkglint/files/homepage_test.go Fri Jun 12 19:10:49 2020 +0000
+++ b/pkgtools/pkglint/files/homepage_test.go Fri Jun 12 19:14:45 2020 +0000
@@ -64,8 +64,8 @@
vt.Output(
"WARN: filename.mk:11: HOMEPAGE should not be defined in terms of MASTER_SITEs.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\thttps://cdn.NetBSD.org/pub/pkgsrc/distfiles/"))
@@ -76,8 +76,8 @@
"WARN: filename.mk:21: HOMEPAGE should not be defined in terms of MASTER_SITEs. " +
"Use https://cdn.NetBSD.org/pub/pkgsrc/distfiles/ directly.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\t${MASTER_SITE_GITHUB}"))
@@ -89,8 +89,8 @@
vt.Output(
"WARN: filename.mk:31: HOMEPAGE should not be defined in terms of MASTER_SITEs.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\t# none"))
diff -r 1e28fb7f9801 -r 77b660b10717 pkgtools/pkglint/files/mkassignchecker.go
--- a/pkgtools/pkglint/files/mkassignchecker.go Fri Jun 12 19:10:49 2020 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker.go Fri Jun 12 19:14:45 2020 +0000
@@ -15,26 +15,27 @@
return &MkAssignChecker{MkLine: mkLine, MkLines: mkLines}
}
-func (ck *MkAssignChecker) checkVarassign() {
- ck.checkVarassignLeft()
- ck.checkVarassignOp()
- ck.checkVarassignRight()
+func (ck *MkAssignChecker) check() {
+ ck.checkLeft()
+ ck.checkOp()
+ ck.checkRight()
}
-// checkVarassignLeft checks everything to the left of the assignment operator.
-func (ck *MkAssignChecker) checkVarassignLeft() {
+// 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 {
ck.MkLine.Warnf("Variable names starting with an underscore (%s) are reserved for internal pkgsrc use.", varname)
}
- ck.checkVarassignLeftNotUsed()
- ck.checkVarassignLeftDeprecated()
- ck.checkVarassignLeftBsdPrefs()
- if !ck.checkVarassignLeftUserSettable() {
- ck.checkVarassignLeftPermissions()
+ ck.checkLeftNotUsed()
+ ck.checkLeftDeprecated()
+ ck.checkLeftBsdPrefs()
+ if !ck.checkLeftUserSettable() {
+ ck.checkLeftPermissions()
+ ck.checkLeftAbiDepends()
}
- ck.checkVarassignLeftRationale()
+ ck.checkLeftRationale()
NewMkLineChecker(ck.MkLines, ck.MkLine).checkTextVarUse(
ck.MkLine.Varname(),
@@ -42,10 +43,10 @@
VucLoadTime)
}
-// checkVarassignLeftNotUsed checks whether the left-hand side of a variable
+// checkLeftNotUsed checks whether the left-hand side of a variable
// assignment is not used. If it is unused and also doesn't have a predefined
// data type, it may be a spelling mistake.
-func (ck *MkAssignChecker) checkVarassignLeftNotUsed() {
+func (ck *MkAssignChecker) checkLeftNotUsed() {
varname := ck.MkLine.Varname()
varcanon := varnameCanon(varname)
@@ -90,7 +91,7 @@
"see mk/subst.mk for an example of such a documentation comment.")
}
-func (ck *MkAssignChecker) checkVarassignLeftDeprecated() {
+func (ck *MkAssignChecker) checkLeftDeprecated() {
varname := ck.MkLine.Varname()
if fix := G.Pkgsrc.Deprecated[varname]; fix != "" {
ck.MkLine.Warnf("Definition of %s is deprecated. %s", varname, fix)
@@ -99,7 +100,7 @@
}
}
-func (ck *MkAssignChecker) checkVarassignLeftBsdPrefs() {
+func (ck *MkAssignChecker) checkLeftBsdPrefs() {
mkline := ck.MkLine
switch mkline.Varcanon() {
@@ -147,10 +148,10 @@
"bsd.prefs.mk file, which will take care of everything.")
}
-// checkVarassignLeftUserSettable checks whether a package defines a
+// checkLeftUserSettable checks whether a package defines a
// variable that is marked as user-settable since it is defined in
// mk/defaults/mk.conf.
-func (ck *MkAssignChecker) checkVarassignLeftUserSettable() bool {
+func (ck *MkAssignChecker) checkLeftUserSettable() bool {
mkline := ck.MkLine
varname := mkline.Varname()
@@ -198,11 +199,11 @@
return true
}
-// checkVarassignLeftPermissions checks the permissions for the left-hand side
+// checkLeftPermissions checks the permissions for the left-hand side
// of a variable assignment line.
//
// See checkPermissions.
-func (ck *MkAssignChecker) checkVarassignLeftPermissions() {
+func (ck *MkAssignChecker) checkLeftPermissions() {
if !G.WarnPerm {
return
}
@@ -273,7 +274,43 @@
}
}
-func (ck *MkAssignChecker) checkVarassignLeftRationale() {
+func (ck *MkAssignChecker) checkLeftAbiDepends() {
+ mkline := ck.MkLine
+
+ varname := mkline.Varname()
+ if !hasPrefix(varname, "BUILDLINK_ABI_DEPENDS.") {
+ return
+ }
+
+ basename := mkline.Basename
+ if basename == "buildlink3.mk" {
+ varparam := varnameParam(varname)
+ bl3id := ""
+ for _, bl3line := range ck.MkLines.mklines {
+ if bl3line.IsVarassign() && bl3line.Varname() == "BUILDLINK_TREE" {
+ bl3id = bl3line.Value()
+ break
+ }
+ }
+ if varparam == bl3id {
+ return
+ }
+ }
+
+ fix := mkline.Autofix()
+ fix.Errorf("Packages must only require API versions, not ABI versions of dependencies.")
+ fix.Explain(
+ "When building a package from the sources,",
+ "the version of the installed package does not matter.",
+ "That version is specified by BUILDLINK_ABI_VERSION.",
+ "",
+ "The only version that matters is the API of the dependency,",
+ "which is selected by specifying BUILDLINK_API_DEPENDS.")
+ fix.Replace("BUILDLINK_ABI_DEPENDS", "BUILDLINK_API_DEPENDS")
+ fix.Apply()
+}
+
+func (ck *MkAssignChecker) checkLeftRationale() {
if !G.WarnExtra {
return
}
@@ -305,11 +342,11 @@
"* has it been reported upstream?")
}
-func (ck *MkAssignChecker) checkVarassignOp() {
- ck.checkVarassignOpShell()
+func (ck *MkAssignChecker) checkOp() {
+ ck.checkOpShell()
}
-func (ck *MkAssignChecker) checkVarassignOpShell() {
+func (ck *MkAssignChecker) checkOpShell() {
mkline := ck.MkLine
switch {
@@ -356,8 +393,8 @@
"or .for directive.")
}
-// checkVarassignLeft checks everything to the right of the assignment operator.
-func (ck *MkAssignChecker) checkVarassignRight() {
+// checkLeft checks everything to the right of the assignment operator.
+func (ck *MkAssignChecker) checkRight() {
mkline := ck.MkLine
varname := mkline.Varname()
op := mkline.Op()
@@ -372,12 +409,12 @@
mkLineChecker.checkText(value)
mkLineChecker.checkVartype(varname, op, value, comment)
- ck.checkVarassignMisc()
+ ck.checkMisc()
- ck.checkVarassignRightVaruse()
+ ck.checkRightVaruse()
}
-func (ck *MkAssignChecker) checkVarassignRightCategory() {
+func (ck *MkAssignChecker) checkRightCategory() {
mkline := ck.MkLine
if mkline.Op() != opAssign && mkline.Op() != opAssignDefault {
return
@@ -403,7 +440,7 @@
fix.Apply()
}
-func (ck *MkAssignChecker) checkVarassignMisc() {
+func (ck *MkAssignChecker) checkMisc() {
mkline := ck.MkLine
varname := mkline.Varname()
value := mkline.Value()
@@ -413,7 +450,7 @@
}
if varname == "PYTHON_VERSIONS_ACCEPTED" {
- ck.checkVarassignDecreasingVersions()
+ ck.checkDecreasingVersions()
}
if mkline.Comment() == " defined" && !hasSuffix(varname, "_MK") && !hasSuffix(varname, "_COMMON") {
@@ -444,14 +481,16 @@
if varname == "PKG_SKIP_REASON" && ck.MkLines.indentation.DependsOn("OPSYS") {
// TODO: Provide autofix for simple cases, like ".if ${OPSYS} == SunOS".
+ // This needs support for high-level refactoring tools though.
+ // As of June 2020, refactoring is limited to text replacements in single lines.
mkline.Notef("Consider setting NOT_FOR_PLATFORM instead of " +
"PKG_SKIP_REASON depending on ${OPSYS}.")
}
- ck.checkVarassignMiscRedundantInstallationDirs()
+ ck.checkMiscRedundantInstallationDirs()
}
-func (ck *MkAssignChecker) checkVarassignDecreasingVersions() {
+func (ck *MkAssignChecker) checkDecreasingVersions() {
mkline := ck.MkLine
strVersions := mkline.Fields()
intVersions := make([]int, len(strVersions))
@@ -475,7 +514,7 @@
}
}
-func (ck *MkAssignChecker) checkVarassignMiscRedundantInstallationDirs() {
+func (ck *MkAssignChecker) checkMiscRedundantInstallationDirs() {
mkline := ck.MkLine
varname := mkline.Varname()
pkg := ck.MkLines.pkg
@@ -502,10 +541,10 @@
}
}
-// checkVarassignRightVaruse checks that in a variable assignment,
+// checkRightVaruse checks that in a variable assignment,
// each variable used on the right-hand side of the assignment operator
Home |
Main Index |
Thread Index |
Old Index