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 5.6.5
details: https://anonhg.NetBSD.org/pkgsrc/rev/94129eff6768
branches: trunk
changeset: 386165:94129eff6768
user: rillig <rillig%pkgsrc.org@localhost>
date: Tue Oct 09 23:17:17 2018 +0000
description:
pkgtools/pkglint: update to 5.6.5
Changes since 5.6.4:
* GCC_REQD should only contain the major version. For GCC versions up to
4.x, this consists of the first two numbers, such as 4.8, while starting
with the 5.x series, the major version is only the first number, such as
7.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/mklinechecker.go | 48 +++++++++++++++++++++------
pkgtools/pkglint/files/mklinechecker_test.go | 18 ++++++++++
pkgtools/pkglint/files/util_test.go | 2 +-
pkgtools/pkglint/files/vardefs.go | 2 +-
pkgtools/pkglint/files/vartype.go | 1 +
pkgtools/pkglint/files/vartypecheck.go | 18 ++++++++++
pkgtools/pkglint/files/vartypecheck_test.go | 18 ++++++++++
8 files changed, 96 insertions(+), 15 deletions(-)
diffs (196 lines):
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/Makefile Tue Oct 09 23:17:17 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.550 2018/10/09 19:12:13 rillig Exp $
+# $NetBSD: Makefile,v 1.551 2018/10/09 23:17:17 rillig Exp $
-PKGNAME= pkglint-5.6.4
+PKGNAME= pkglint-5.6.5
DISTFILES= # none
CATEGORIES= pkgtools
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go Tue Oct 09 23:17:17 2018 +0000
@@ -362,17 +362,7 @@
mkline.Warnf("%s is used but not defined.", varname)
}
- if hasPrefix(varuse.Mod(), ":=") && vartype != nil && !vartype.IsConsideredList() {
- mkline.Warnf("The :from=to modifier should only be used with lists, not with %s.", varuse.varname)
- Explain(
- "Instead of:",
- "\tMASTER_SITES=\t${HOMEPAGE:=repository/}",
- "",
- "Write:",
- "\tMASTER_SITES=\t${HOMEPAGE}repository/",
- "",
- "This is a much clearer expression of the same thought.")
- }
+ ck.checkVaruseMod(varuse, vartype)
if varuse.varname == "@" {
ck.MkLine.Warnf("Please use %q instead of %q.", "${.TARGET}", "$@")
@@ -404,6 +394,42 @@
}
}
+func (ck MkLineChecker) checkVaruseMod(varuse *MkVarUse, vartype *Vartype) {
+ mods := varuse.modifiers
+ if len(mods) == 0 {
+ return
+ }
+
+ if hasPrefix(mods[0], "=") && vartype != nil && !vartype.IsConsideredList() {
+ ck.MkLine.Warnf("The :from=to modifier should only be used with lists, not with %s.", varuse.varname)
+ Explain(
+ "Instead of:",
+ "\tMASTER_SITES=\t${HOMEPAGE:=repository/}",
+ "",
+ "Write:",
+ "\tMASTER_SITES=\t${HOMEPAGE}repository/",
+ "",
+ "This is a much clearer expression of the same thought.")
+ }
+
+ if len(mods) == 3 {
+ if m, magic := match1(mods[0], `^[CS]/\^/(\w+)/1$`); m {
+ if mods[1] == "M"+magic+"*" {
+ if matches(mods[2], regex.Pattern(`^[CS]/\^`+magic+`//$`)) {
+ fix := ck.MkLine.Autofix()
+ fix.Notef("The modifier %q can be written as %q.", varuse.Mod(), ":[1]")
+ fix.Explain(
+ "The range modifier is much easier to understand than the",
+ "complicated regular expressions, which were needed before",
+ "the year 2006.")
+ fix.Replace(varuse.Mod(), ":[1]")
+ fix.Apply()
+ }
+ }
+ }
+ }
+}
+
// checkVarusePermissions checks the permissions for the right-hand side
// of a variable assignment line.
//
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/mklinechecker_test.go
--- a/pkgtools/pkglint/files/mklinechecker_test.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/mklinechecker_test.go Tue Oct 09 23:17:17 2018 +0000
@@ -689,6 +689,24 @@
"WARN: ~/options.mk:2: The user-defined variable VARBASE is used but not added to BUILD_DEFS.")
}
+func (s *Suite) Test_MkLineChecker_CheckVaruse__complicated_range(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupCommandLine("--show-autofix", "--source")
+ t.SetupVartypes()
+ mkline := t.NewMkLine("mk/compiler/gcc.mk", 150,
+ "CC:=\t${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}")
+
+ MkLineChecker{mkline}.Check()
+
+ // FIXME: The check is called two times, even though it only produces a single NOTE.
+ t.CheckOutputLines(
+ "NOTE: mk/compiler/gcc.mk:150: The modifier \":C/^/_asdf_/1:M_asdf_*:S/^_asdf_//\" can be written as \":[1]\".",
+ "AUTOFIX: mk/compiler/gcc.mk:150: Replacing \":C/^/_asdf_/1:M_asdf_*:S/^_asdf_//\" with \":[1]\".",
+ "-\tCC:=\t${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}",
+ "+\tCC:=\t${CC:[1]}")
+}
+
func (s *Suite) Test_MkLineChecker_checkVarassignSpecific(c *check.C) {
t := s.Init(c)
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/util_test.go
--- a/pkgtools/pkglint/files/util_test.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/util_test.go Tue Oct 09 23:17:17 2018 +0000
@@ -84,7 +84,7 @@
c.Check(cleanpath("dir/"), equals, "dir")
}
-func (s *Suite) Test_relpath(c *check.C) {
+func (s *Suite) Test_relpath__failure(c *check.C) {
t := s.Init(c)
if runtime.GOOS == "windows" {
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Tue Oct 09 23:17:17 2018 +0000
@@ -719,7 +719,7 @@
sys("GAMEDIR_PERMS", lkShell, BtPerms)
sys("GAMEMODE", lkNone, BtFileMode)
sys("GAMES_USER", lkNone, BtUserGroupName)
- pkglist("GCC_REQD", lkShell, BtVersion)
+ pkglist("GCC_REQD", lkShell, BtGccReqd)
pkglist("GENERATE_PLIST", lkNone, BtShellCommands)
pkg("GITHUB_PROJECT", lkNone, BtIdentifier)
pkg("GITHUB_TAG", lkNone, BtIdentifier)
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/vartype.go
--- a/pkgtools/pkglint/files/vartype.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/vartype.go Tue Oct 09 23:17:17 2018 +0000
@@ -216,6 +216,7 @@
BtFilename = &BasicType{"Filename", (*VartypeCheck).Filename}
BtFilemask = &BasicType{"Filemask", (*VartypeCheck).Filemask}
BtFileMode = &BasicType{"FileMode", (*VartypeCheck).FileMode}
+ BtGccReqd = &BasicType{"GccReqd", (*VartypeCheck).GccReqd}
BtHomepage = &BasicType{"Homepage", (*VartypeCheck).Homepage}
BtIdentifier = &BasicType{"Identifier", (*VartypeCheck).Identifier}
BtInteger = &BasicType{"Integer", (*VartypeCheck).Integer}
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go Tue Oct 09 23:17:17 2018 +0000
@@ -456,6 +456,24 @@
}
}
+func (cv *VartypeCheck) GccReqd() {
+ cv.Version()
+
+ if m, major := match1(cv.Value, `^([5-9])\.\d+$`); m {
+ fix := cv.Line.Autofix()
+
+ fix.Warnf("GCC version numbers should only contain the major version (%s).", major)
+ fix.Explain(
+ "For GCC up to 4.x, the major version consists of the first and",
+ "second number, such as 4.8.",
+ "",
+ "Starting with GCC >= 5, the major version is only the first number",
+ "such as 5 or 7.")
+ fix.Replace(cv.Value, major)
+ fix.Apply()
+ }
+}
+
func (cv *VartypeCheck) Homepage() {
MkLineChecker{cv.MkLine}.CheckVartypePrimitive(cv.Varname, BtURL, cv.Op, cv.Value, cv.MkComment, cv.Guessed)
diff -r 478d97775d22 -r 94129eff6768 pkgtools/pkglint/files/vartypecheck_test.go
--- a/pkgtools/pkglint/files/vartypecheck_test.go Tue Oct 09 22:55:48 2018 +0000
+++ b/pkgtools/pkglint/files/vartypecheck_test.go Tue Oct 09 23:17:17 2018 +0000
@@ -413,6 +413,24 @@
"WARN: fname:11: Invalid file mode \"u+rwx\".")
}
+func (s *Suite) Test_VartypeCheck_GccReqd(c *check.C) {
+ vt := NewVartypeCheckTester(s.Init(c), (*VartypeCheck).GccReqd)
+
+ vt.Varname("GCC_REQD")
+ vt.Op(opAssignAppend)
+ vt.Values(
+ "2.95",
+ "3.1.5",
+ "4.7",
+ "4.8",
+ "5.1",
+ "6",
+ "7.3")
+ vt.Output(
+ "WARN: fname:5: GCC version numbers should only contain the major version (5).",
+ "WARN: fname:7: GCC version numbers should only contain the major version (7).")
+}
+
func (s *Suite) Test_VartypeCheck_Homepage(c *check.C) {
t := s.Init(c)
vt := NewVartypeCheckTester(t, (*VartypeCheck).Homepage)
Home |
Main Index |
Thread Index |
Old Index