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 19.4.3



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0308692091a7
branches:  trunk
changeset: 421138:0308692091a7
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jan 11 15:47:58 2020 +0000

description:
pkgtools/pkglint: update to 19.4.3

Changes since 19.4.2:

PLIST_VARS identifiers must not contain characters that are interpreted
specially in regular expressions.

All pkgsrc text files except for doc/pkgsrc.{html,txt} must use the
default CVS keyword substitution.

diffstat:

 pkgtools/pkglint/Makefile                   |   5 +-
 pkgtools/pkglint/files/category_test.go     |   2 +-
 pkgtools/pkglint/files/package.go           |   1 +
 pkgtools/pkglint/files/pkglint.go           |  23 ++++++++++++++
 pkgtools/pkglint/files/pkglint_test.go      |  47 +++++++++++++++++++++++++++++
 pkgtools/pkglint/files/util.go              |  13 ++++++-
 pkgtools/pkglint/files/vardefs.go           |   2 +-
 pkgtools/pkglint/files/vartype.go           |   2 +
 pkgtools/pkglint/files/vartypecheck.go      |  32 +++++++++++++++++++
 pkgtools/pkglint/files/vartypecheck_test.go |  46 +++++++++++++++++++++++++---
 10 files changed, 161 insertions(+), 12 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sat Jan 11 15:47:58 2020 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.624 2020/01/10 13:32:19 bsiegert Exp $
+# $NetBSD: Makefile,v 1.625 2020/01/11 15:48:28 rillig Exp $
 
-PKGNAME=       pkglint-19.4.2
-PKGREVISION=   1
+PKGNAME=       pkglint-19.4.3
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go   Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/category_test.go   Sat Jan 11 15:47:58 2020 +0000
@@ -56,7 +56,7 @@
        CheckdirCategory(t.File("archivers"))
 
        t.CheckOutputLines(
-               "WARN: ~/archivers/Makefile:3: COMMENT contains invalid characters (U+005C U+0024 U+0024 U+0024 U+0024 U+0022).")
+               "WARN: ~/archivers/Makefile:3: COMMENT contains invalid characters (\\ $ $ $ $ \").")
 }
 
 // The pkgsrc-wip Makefile has a large section with special code below
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/package.go Sat Jan 11 15:47:58 2020 +0000
@@ -181,6 +181,7 @@
                return nil, nil
        }
 
+       G.checkRegCvsSubst(filename)
        allLines := NewMkLines(NewLines("", nil), pkg, &pkg.vars)
        if !pkg.parse(mainLines, allLines, "", true) {
                return nil, nil
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/pkglint.go
--- a/pkgtools/pkglint/files/pkglint.go Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/pkglint.go Sat Jan 11 15:47:58 2020 +0000
@@ -569,6 +569,8 @@
                return
        }
 
+       pkglint.checkRegCvsSubst(filename)
+
        switch {
        case basename == "ALTERNATIVES":
                CheckFileAlternatives(filename, pkg)
@@ -646,6 +648,27 @@
        }
 }
 
+func (pkglint *Pkglint) checkRegCvsSubst(filename CurrPath) {
+       entries := G.loadCvsEntries(filename)
+       entry, found := entries[filename.Base()]
+       if !found || entry.Options == "" {
+               return
+       }
+
+       diag := NewLineWhole(filename)
+       diag.Errorf("The CVS keyword substitution must be the default one.")
+       diag.Explain(
+               "The CVS keyword \\$NetBSD\\$ is used throughout pkgsrc to record",
+               "changes to each file.",
+               "Based on this information, the bulk builds decide when a package",
+               "has to be rebuilt.",
+               "",
+               "For more information, see",
+               "https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Substitution-modes.html.";,
+               "",
+               sprintf("To fix this, run \"cvs admin -kkv %s\"", shquote(filename.Base())))
+}
+
 func (pkglint *Pkglint) checkExecutable(filename CurrPath, mode os.FileMode) {
        if mode.Perm()&0111 == 0 {
                // Not executable at all.
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/pkglint_test.go
--- a/pkgtools/pkglint/files/pkglint_test.go    Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/pkglint_test.go    Sat Jan 11 15:47:58 2020 +0000
@@ -1105,6 +1105,53 @@
                "WARN: ~/category/package/spec: Only packages in regress/ may have spec files.")
 }
 
+func (s *Suite) Test_Pkglint_checkRegCvsSubst(c *check.C) {
+       t := s.Init(c)
+
+       t.Chdir(".")
+       t.CreateFileLines("ok")
+       t.CreateFileLines("binary")
+       t.CreateFileLines("other")
+       t.CreateFileLines("CVS/Entries",
+               "/ok/1.1/mod//",
+               "/binary/1.1/mod/-kb/",
+               "/other/1.1/mod/-ko/")
+
+       G.checkRegCvsSubst("ok")
+       G.checkRegCvsSubst("binary")
+       G.checkRegCvsSubst("other")
+
+       t.CheckOutputLines(
+               "ERROR: binary: The CVS keyword substitution must be the default one.",
+               "ERROR: other: The CVS keyword substitution must be the default one.")
+}
+
+// The package Makefile is loaded via a different path
+// than direct command line arguments. Same for the patches.
+// Therefore these code paths must be tested separately.
+func (s *Suite) Test_Pkglint_checkRegCvsSubst__full_package(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("category/package")
+       t.Chdir("category/package")
+       t.CreateFileDummyPatch("patches/patch-any")
+       t.CreateFileLines("distinfo",
+               CvsID,
+               "",
+               "SHA1 (patch-any) = ebbf34b0641bcb508f17d5a27f2bf2a536d810ac")
+       t.CreateFileLines("CVS/Entries",
+               "/Makefile/1.1/modified/-ko/")
+       t.CreateFileLines("patches/CVS/Entries",
+               "/patch-any/1.1/modified/-ko/")
+       t.FinishSetUp()
+
+       G.Check(".")
+
+       t.CheckOutputLines(
+               "ERROR: Makefile: The CVS keyword substitution must be the default one.",
+               "ERROR: patches/patch-any: The CVS keyword substitution must be the default one.")
+}
+
 func (s *Suite) Test_Pkglint_checkExecutable(c *check.C) {
        t := s.Init(c)
 
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/util.go
--- a/pkgtools/pkglint/files/util.go    Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/util.go    Sat Jan 11 15:47:58 2020 +0000
@@ -107,10 +107,19 @@
        var unis strings.Builder
 
        for _, r := range s {
-               if r == rune(byte(r)) && valid.Contains(byte(r)) {
+               switch {
+               case r == rune(byte(r)) && valid.Contains(byte(r)):
                        continue
+               case '!' <= r && r <= '~':
+                       unis.WriteByte(' ')
+                       unis.WriteByte(byte(r))
+               case r == ' ':
+                       unis.WriteString(" space")
+               case r == '\t':
+                       unis.WriteString(" tab")
+               default:
+                       _, _ = fmt.Fprintf(&unis, " %U", r)
                }
-               _, _ = fmt.Fprintf(&unis, " %U", r)
        }
 
        if unis.Len() == 0 {
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Sat Jan 11 15:47:58 2020 +0000
@@ -1542,7 +1542,7 @@
        reg.pkglist("PKG_USERS_VARS", BtVariableName)
        reg.pkg("PKG_USE_KERBEROS", BtYes)
        reg.pkgload("PLIST.*", BtYes)
-       reg.pkgloadlist("PLIST_VARS", BtIdentifierIndirect)
+       reg.pkgloadlist("PLIST_VARS", BtPlistIdentifier)
        reg.pkglist("PLIST_SRC", BtRelativePkgPath)
        reg.pkglist("PLIST_SUBST", BtShellWord)
        reg.pkg("PLIST_TYPE", enum("dynamic static"))
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/vartype.go
--- a/pkgtools/pkglint/files/vartype.go Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/vartype.go Sat Jan 11 15:47:58 2020 +0000
@@ -363,6 +363,7 @@
                BtPkgOptionsVar,
                BtPkgpath,
                BtPkgrevision,
+               BtPlistIdentifier,
                BtPrefixPathname,
                BtPythonDependency,
                BtRPkgName,
@@ -440,6 +441,7 @@
        BtPkgpath                = &BasicType{"Pkgpath", (*VartypeCheck).Pkgpath}
        BtPkgOptionsVar          = &BasicType{"PkgOptionsVar", (*VartypeCheck).PkgOptionsVar}
        BtPkgrevision            = &BasicType{"Pkgrevision", (*VartypeCheck).Pkgrevision}
+       BtPlistIdentifier        = &BasicType{"PlistIdentifier", (*VartypeCheck).PlistIdentifier}
        BtPrefixPathname         = &BasicType{"PrefixPathname", (*VartypeCheck).PrefixPathname}
        BtPythonDependency       = &BasicType{"PythonDependency", (*VartypeCheck).PythonDependency}
        BtRPkgName               = &BasicType{"RPkgName", (*VartypeCheck).RPkgName}
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go    Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go    Sat Jan 11 15:47:58 2020 +0000
@@ -1059,6 +1059,38 @@
        }
 }
 
+// PlistIdentifier checks for valid identifiers in PLIST_VARS.
+// These identifiers are interpreted as regular expressions by
+// mk/plist/plist-subst.mk, therefore they are limited to very
+// few characters.
+func (cv *VartypeCheck) PlistIdentifier() {
+       if cv.Value != cv.ValueNoVar {
+               return
+       }
+
+       if cv.Op == opUseMatch {
+               invalidPatternChars := textproc.NewByteSet("A-Za-z0-9---_*?[]")
+               invalid := invalidCharacters(cv.Value, invalidPatternChars)
+               if invalid != "" {
+                       cv.Warnf("PLIST identifier pattern %q contains invalid characters (%s).",
+                               cv.Value, invalid)
+                       cv.Explain(
+                               "PLIST identifiers must consist of [A-Za-z0-9-_] only.",
+                               "In patterns, the characters *?[] are allowed additionally.")
+               }
+               return
+       }
+
+       invalidChars := textproc.NewByteSet("A-Za-z0-9---_")
+       invalid := invalidCharacters(cv.Value, invalidChars)
+       if invalid != "" {
+               cv.Errorf("PLIST identifier %q contains invalid characters (%s).",
+                       cv.Value, invalid)
+               cv.Explain(
+                       "PLIST identifiers must consist of [A-Za-z0-9-_] only.")
+       }
+}
+
 // PrefixPathname checks for a pathname relative to ${PREFIX}.
 func (cv *VartypeCheck) PrefixPathname() {
        if NewPath(cv.Value).IsAbs() {
diff -r 41d5f2554cee -r 0308692091a7 pkgtools/pkglint/files/vartypecheck_test.go
--- a/pkgtools/pkglint/files/vartypecheck_test.go       Sat Jan 11 15:18:58 2020 +0000
+++ b/pkgtools/pkglint/files/vartypecheck_test.go       Sat Jan 11 15:47:58 2020 +0000
@@ -1499,6 +1499,39 @@
        vt.OutputEmpty()
 }
 
+func (s *Suite) Test_VartypeCheck_PlistIdentifier(c *check.C) {
+       vt := NewVartypeCheckTester(s.Init(c), BtPlistIdentifier)
+
+       vt.Varname("PLIST_VARS")
+       vt.Values(
+               "gtk",
+               "gtk+",
+               "gcc-cxx",
+               "gcc-c__",
+               "package1.5")
+
+       vt.Output(
+               "ERROR: filename.mk:2: "+
+                       "PLIST identifier \"gtk+\" contains invalid characters (+).",
+               "ERROR: filename.mk:5: "+
+                       "PLIST identifier \"package1.5\" contains invalid characters (.).")
+
+       vt.Op(opUseMatch)
+       vt.Values(
+               "*",
+               "/",
+               "-",
+               "[A-Z]",
+               "gtk",
+               "***+")
+
+       vt.Output(
+               "WARN: filename.mk:12: PLIST identifier pattern \"/\" "+
+                       "contains invalid characters (/).",
+               "WARN: filename.mk:16: PLIST identifier pattern \"***+\" "+
+                       "contains invalid characters (+).")
+}
+
 func (s *Suite) Test_VartypeCheck_PrefixPathname(c *check.C) {
        vt := NewVartypeCheckTester(s.Init(c), BtPrefixPathname)
 
@@ -1915,6 +1948,7 @@
        vt.Varname("APACHE_USER")
        vt.Values(
                "user with spaces",
+               "user\twith\ttabs",
                "typical_username",
                "user123",
                "domain\\user",
@@ -1925,12 +1959,14 @@
 
        vt.Output(
                "WARN: filename.mk:1: User or group name \"user with spaces\" "+
-                       "contains invalid characters: U+0020 U+0020",
-               "WARN: filename.mk:4: User or group name \"domain\\\\user\" "+
-                       "contains invalid characters: U+005C",
-               "ERROR: filename.mk:7: User or group name \"-rf\" "+
+                       "contains invalid characters: space space",
+               "WARN: filename.mk:2: User or group name \"user\\twith\\ttabs\" "+
+                       "contains invalid characters: tab tab",
+               "WARN: filename.mk:5: User or group name \"domain\\\\user\" "+
+                       "contains invalid characters: \\",
+               "ERROR: filename.mk:8: User or group name \"-rf\" "+
                        "must not start with a hyphen.",
-               "ERROR: filename.mk:8: User or group name \"rf-\" "+
+               "ERROR: filename.mk:9: User or group name \"rf-\" "+
                        "must not end with a hyphen.")



Home | Main Index | Thread Index | Old Index