pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkglint/files
Module Name: pkgsrc
Committed By: rillig
Date: Sat Jan 11 15:47:58 UTC 2020
Modified Files:
pkgsrc/pkgtools/pkglint/files: category_test.go package.go pkglint.go
pkglint_test.go util.go vardefs.go vartype.go vartypecheck.go
vartypecheck_test.go
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 pkgsrc/pkgtools/pkglint/files/category_test.go
cvs rdiff -u -r1.77 -r1.78 pkgsrc/pkgtools/pkglint/files/package.go \
pkgsrc/pkgtools/pkglint/files/vartypecheck.go
cvs rdiff -u -r1.71 -r1.72 pkgsrc/pkgtools/pkglint/files/pkglint.go \
pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
cvs rdiff -u -r1.57 -r1.58 pkgsrc/pkgtools/pkglint/files/pkglint_test.go
cvs rdiff -u -r1.70 -r1.71 pkgsrc/pkgtools/pkglint/files/util.go
cvs rdiff -u -r1.86 -r1.87 pkgsrc/pkgtools/pkglint/files/vardefs.go
cvs rdiff -u -r1.44 -r1.45 pkgsrc/pkgtools/pkglint/files/vartype.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/files/category_test.go
diff -u pkgsrc/pkgtools/pkglint/files/category_test.go:1.30 pkgsrc/pkgtools/pkglint/files/category_test.go:1.31
--- pkgsrc/pkgtools/pkglint/files/category_test.go:1.30 Sat Jan 4 19:53:14 2020
+++ pkgsrc/pkgtools/pkglint/files/category_test.go Sat Jan 11 15:47:58 2020
@@ -56,7 +56,7 @@ func (s *Suite) Test_CheckdirCategory__i
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
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.77 pkgsrc/pkgtools/pkglint/files/package.go:1.78
--- pkgsrc/pkgtools/pkglint/files/package.go:1.77 Mon Jan 6 20:38:42 2020
+++ pkgsrc/pkgtools/pkglint/files/package.go Sat Jan 11 15:47:58 2020
@@ -181,6 +181,7 @@ func (pkg *Package) loadPackageMakefile(
return nil, nil
}
+ G.checkRegCvsSubst(filename)
allLines := NewMkLines(NewLines("", nil), pkg, &pkg.vars)
if !pkg.parse(mainLines, allLines, "", true) {
return nil, nil
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.77 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.78
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.77 Sat Jan 4 19:53:14 2020
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go Sat Jan 11 15:47:58 2020
@@ -1059,6 +1059,38 @@ func (cv *VartypeCheck) Pkgrevision() {
}
}
+// 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() {
Index: pkgsrc/pkgtools/pkglint/files/pkglint.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint.go:1.71 pkgsrc/pkgtools/pkglint/files/pkglint.go:1.72
--- pkgsrc/pkgtools/pkglint/files/pkglint.go:1.71 Sat Jan 4 19:53:14 2020
+++ pkgsrc/pkgtools/pkglint/files/pkglint.go Sat Jan 11 15:47:58 2020
@@ -569,6 +569,8 @@ func (pkglint *Pkglint) checkReg(filenam
return
}
+ pkglint.checkRegCvsSubst(filename)
+
switch {
case basename == "ALTERNATIVES":
CheckFileAlternatives(filename, pkg)
@@ -646,6 +648,27 @@ func (pkglint *Pkglint) checkReg(filenam
}
}
+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.
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.71 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.72
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.71 Mon Jan 6 20:38:42 2020
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go Sat Jan 11 15:47:58 2020
@@ -1499,6 +1499,39 @@ func (s *Suite) Test_VartypeCheck_Pkgrev
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 @@ func (s *Suite) Test_VartypeCheck_UserGr
vt.Varname("APACHE_USER")
vt.Values(
"user with spaces",
+ "user\twith\ttabs",
"typical_username",
"user123",
"domain\\user",
@@ -1925,12 +1959,14 @@ func (s *Suite) Test_VartypeCheck_UserGr
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.")
}
Index: pkgsrc/pkgtools/pkglint/files/pkglint_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.57 pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.58
--- pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.57 Sat Jan 4 19:53:14 2020
+++ pkgsrc/pkgtools/pkglint/files/pkglint_test.go Sat Jan 11 15:47:58 2020
@@ -1105,6 +1105,53 @@ func (s *Suite) Test_Pkglint_checkReg__s
"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)
Index: pkgsrc/pkgtools/pkglint/files/util.go
diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.70 pkgsrc/pkgtools/pkglint/files/util.go:1.71
--- pkgsrc/pkgtools/pkglint/files/util.go:1.70 Mon Jan 6 20:38:42 2020
+++ pkgsrc/pkgtools/pkglint/files/util.go Sat Jan 11 15:47:58 2020
@@ -107,10 +107,19 @@ func invalidCharacters(s string, valid *
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 {
Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.86 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.87
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.86 Sat Jan 4 19:53:14 2020
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go Sat Jan 11 15:47:58 2020
@@ -1542,7 +1542,7 @@ func (reg *VarTypeRegistry) Init(src *Pk
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"))
Index: pkgsrc/pkgtools/pkglint/files/vartype.go
diff -u pkgsrc/pkgtools/pkglint/files/vartype.go:1.44 pkgsrc/pkgtools/pkglint/files/vartype.go:1.45
--- pkgsrc/pkgtools/pkglint/files/vartype.go:1.44 Sat Dec 14 18:04:16 2019
+++ pkgsrc/pkgtools/pkglint/files/vartype.go Sat Jan 11 15:47:58 2020
@@ -363,6 +363,7 @@ func (bt *BasicType) NeedsQ() bool {
BtPkgOptionsVar,
BtPkgpath,
BtPkgrevision,
+ BtPlistIdentifier,
BtPrefixPathname,
BtPythonDependency,
BtRPkgName,
@@ -440,6 +441,7 @@ var (
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}
Home |
Main Index |
Thread Index |
Old Index