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: Mon Nov 28 23:33:29 UTC 2022
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: mkcondchecker.go mkcondchecker_test.go
mkshparser.go
pkgsrc/pkgtools/pkglint/files/pkgver: vercmp.go vercmp_test.go
Log Message:
pkgtools/pkglint: update to 22.3.2
Changes since 22.3.1:
Complain about conditions of the form '_PYTHON_VERSION < 38', as they
lead to 'Malformed conditional' when _PYTHON_VERSION is 'none' instead
of a number.
To generate a diff of this commit:
cvs rdiff -u -r1.734 -r1.735 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.14 -r1.15 pkgsrc/pkgtools/pkglint/files/mkcondchecker.go
cvs rdiff -u -r1.13 -r1.14 \
pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go
cvs rdiff -u -r1.21 -r1.22 pkgsrc/pkgtools/pkglint/files/mkshparser.go
cvs rdiff -u -r1.7 -r1.8 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go
cvs rdiff -u -r1.11 -r1.12 \
pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_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.734 pkgsrc/pkgtools/pkglint/Makefile:1.735
--- pkgsrc/pkgtools/pkglint/Makefile:1.734 Sat Nov 19 10:51:07 2022
+++ pkgsrc/pkgtools/pkglint/Makefile Mon Nov 28 23:33:28 2022
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.734 2022/11/19 10:51:07 rillig Exp $
+# $NetBSD: Makefile,v 1.735 2022/11/28 23:33:28 rillig Exp $
-PKGNAME= pkglint-22.3.1
+PKGNAME= pkglint-22.3.2
CATEGORIES= pkgtools
MAINTAINER= rillig%NetBSD.org@localhost
Index: pkgsrc/pkgtools/pkglint/files/mkcondchecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mkcondchecker.go:1.14 pkgsrc/pkgtools/pkglint/files/mkcondchecker.go:1.15
--- pkgsrc/pkgtools/pkglint/files/mkcondchecker.go:1.14 Sun Jul 24 20:07:20 2022
+++ pkgsrc/pkgtools/pkglint/files/mkcondchecker.go Mon Nov 28 23:33:28 2022
@@ -165,7 +165,7 @@ var mkCondModifierPatternLiteral = textp
func (ck *MkCondChecker) checkCompare(left *MkCondTerm, op string, right *MkCondTerm) {
switch {
case right.Num != "":
- ck.checkCompareVarNum(op, right.Num)
+ ck.checkCompareVarNum(left, op, right.Num)
case left.Var != nil && right.Var == nil:
ck.checkCompareVarStr(left.Var, op, right.Str)
}
@@ -209,7 +209,12 @@ func (ck *MkCondChecker) checkCompareVar
}
}
-func (ck *MkCondChecker) checkCompareVarNum(op string, num string) {
+func (ck *MkCondChecker) checkCompareVarNum(left *MkCondTerm, op string, num string) {
+ ck.checkCompareVarNumVersion(op, num)
+ ck.checkCompareVarNumPython(left, op, num)
+}
+
+func (ck *MkCondChecker) checkCompareVarNumVersion(op string, num string) {
if !contains(num, ".") {
return
}
@@ -231,6 +236,25 @@ func (ck *MkCondChecker) checkCompareVar
"the version number 1.11 would also match, which is not intended.")
}
+func (ck *MkCondChecker) checkCompareVarNumPython(left *MkCondTerm, op string, num string) {
+ if left.Var != nil && left.Var.varname == "_PYTHON_VERSION" &&
+ op != "==" && op != "!=" &&
+ matches(num, `^\d+$`) {
+
+ ck.MkLine.Errorf("The Python version must not be compared numerically.")
+ ck.MkLine.Explain(
+ "The variable _PYTHON_VERSION must not be compared",
+ "against an integer number, as these comparisons are",
+ "not meaningful.",
+ "For example, 27 < 39 < 40 < 41 < 310, which means that",
+ "Python 3.10 would be considered newer than a",
+ "possible future Python 4.0.",
+ "",
+ "In addition, _PYTHON_VERSION can be \"none\",",
+ "which is not a number.")
+ }
+}
+
func (ck *MkCondChecker) checkCompareVarStrCompiler(op string, value string) {
if !matches(value, `^\w+$`) {
return
Index: pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go:1.13 pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go:1.14
--- pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go:1.13 Sat Nov 19 10:51:07 2022
+++ pkgsrc/pkgtools/pkglint/files/mkcondchecker_test.go Mon Nov 28 23:33:28 2022
@@ -605,6 +605,24 @@ func (s *Suite) Test_MkCondChecker_check
mklines := t.NewMkLines("filename.mk",
MkCvsID,
"",
+ "OS_VERSION=\t6.0",
+ ".if ${OS_VERSION} > 6.5 || ${_PYTHON_VERSION} < 38",
+ ".endif")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: filename.mk:4: Numeric comparison > 6.5.",
+ "ERROR: filename.mk:4: The Python version must not be compared numerically.",
+ "WARN: filename.mk:4: _PYTHON_VERSION is used but not defined.")
+}
+
+func (s *Suite) Test_MkCondChecker_checkCompareVarNumVersion(c *check.C) {
+ t := s.Init(c)
+
+ mklines := t.NewMkLines("filename.mk",
+ MkCvsID,
+ "",
"OS_VERSION=\t9.0",
"",
".if ${OS_VERSION} > 6.5",
@@ -620,6 +638,33 @@ func (s *Suite) Test_MkCondChecker_check
"WARN: filename.mk:8: Numeric comparison == 6.5.")
}
+func (s *Suite) Test_MkCondChecker_checkCompareVarNumPython(c *check.C) {
+ t := s.Init(c)
+
+ mklines := t.NewMkLines("filename.mk",
+ MkCvsID,
+ "",
+ "_PYTHON_VERSION=\tnone",
+ "",
+ ".if ${_PYTHON_VERSION} < 38",
+ ".endif",
+ "",
+ ".if ${_PYTHON_VERSION} < 310",
+ ".endif")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: filename.mk:3: "+
+ "Variable names starting with an underscore "+
+ "(_PYTHON_VERSION) are reserved "+
+ "for internal pkgsrc use.",
+ "ERROR: filename.mk:5: "+
+ "The Python version must not be compared numerically.",
+ "ERROR: filename.mk:8: "+
+ "The Python version must not be compared numerically.")
+}
+
func (s *Suite) Test_MkCondChecker_checkCompareVarStrCompiler(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/mkshparser.go
diff -u pkgsrc/pkgtools/pkglint/files/mkshparser.go:1.21 pkgsrc/pkgtools/pkglint/files/mkshparser.go:1.22
--- pkgsrc/pkgtools/pkglint/files/mkshparser.go:1.21 Fri Jun 24 07:16:23 2022
+++ pkgsrc/pkgtools/pkglint/files/mkshparser.go Mon Nov 28 23:33:28 2022
@@ -250,7 +250,7 @@ func (lex *ShellLexer) Lex(lval *shyySym
lval.Word = p.ShToken()
lex.atCommandStart = false
- // Inside of a case statement, ${PATTERNS:@p@ (${p}) continue ;; @} expands to
+ // Inside a case statement, ${PATTERNS:@p@ (${p}) continue ;; @} expands to
// a list of case-items, and after this list a new command starts.
// This is necessary to return a following "esac" as tkESAC instead of a
// simple word.
Index: pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.7 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.8
--- pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.7 Wed Aug 17 20:41:51 2022
+++ pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go Mon Nov 28 23:33:28 2022
@@ -44,10 +44,9 @@ type version struct {
}
func newVersion(vstr string) *version {
- v := new(version)
+ var v version
lex := textproc.NewLexer(strings.ToLower(vstr))
for !lex.EOF() {
-
switch {
case lex.TestByteSet(textproc.Digit):
num := lex.NextBytesSet(textproc.Digit)
@@ -76,7 +75,7 @@ func newVersion(vstr string) *version {
lex.Skip(1)
}
}
- return v
+ return &v
}
//go:noinline
Index: pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.11 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.12
--- pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.11 Wed Aug 17 20:41:51 2022
+++ pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go Mon Nov 28 23:33:28 2022
@@ -115,6 +115,7 @@ func Test_newVersion(t *testing.T) {
func (s *Suite) Test_newVersion(c *check.C) {
// See Test_newVersion.
+ _ = c
}
func (s *Suite) Test__qa(c *check.C) {
Home |
Main Index |
Thread Index |
Old Index