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.13
details: https://anonhg.NetBSD.org/pkgsrc/rev/fb8b8331a997
branches: trunk
changeset: 413814:fb8b8331a997
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Mar 22 17:43:15 2020 +0000
description:
pkgtools/pkglint: update to 19.4.13
Changes since 19.4.12:
Files that are mentioned redundantly in PLIST files generate an error.
Missing DESCR files generate an error.
Hard-coded /usr/pkg in patches generates an error.
diffstat:
pkgtools/pkglint/Makefile | 5 +-
pkgtools/pkglint/files/distinfo_test.go | 4 +
pkgtools/pkglint/files/package.go | 27 +++++++++-
pkgtools/pkglint/files/package_test.go | 25 ++++++++-
pkgtools/pkglint/files/patches.go | 13 ++++
pkgtools/pkglint/files/patches_test.go | 20 +++++++
pkgtools/pkglint/files/path.go | 21 +++++++-
pkgtools/pkglint/files/path_test.go | 6 +-
pkgtools/pkglint/files/pkglint_test.go | 13 +++-
pkgtools/pkglint/files/pkgsrc_test.go | 12 ++++
pkgtools/pkglint/files/plist.go | 89 ++++++++++++++++++++++++++------
pkgtools/pkglint/files/plist_test.go | 87 ++++++++++++++++++++++++++-----
pkgtools/pkglint/files/util_test.go | 62 +++++++++++-----------
13 files changed, 308 insertions(+), 76 deletions(-)
diffs (truncated from 707 to 300 lines):
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sun Mar 22 17:43:15 2020 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.636 2020/03/21 16:57:20 bsiegert Exp $
+# $NetBSD: Makefile,v 1.637 2020/03/22 17:43:15 rillig Exp $
-PKGNAME= pkglint-19.4.12
-PKGREVISION= 1
+PKGNAME= pkglint-19.4.13
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go Sun Mar 22 17:43:15 2020 +0000
@@ -185,6 +185,8 @@
"",
".include \"../../lang/php/ext.mk\"",
".include \"../../mk/bsd.pkg.mk\"")
+ t.CreateFileLines("archivers/php-bz2/DESCR",
+ "Description")
t.FinishSetUp()
G.Check(t.File("archivers/php-bz2"))
@@ -194,6 +196,8 @@
"",
".include \"../../lang/php/ext.mk\"",
".include \"../../mk/bsd.pkg.mk\"")
+ t.CreateFileLines("archivers/php-zlib/DESCR",
+ "Description")
G.Check(t.File("archivers/php-zlib"))
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/package.go Sun Mar 22 17:43:15 2020 +0000
@@ -31,6 +31,7 @@
Patchdir PackagePath // PATCHDIR from the package Makefile
DistinfoFile PackagePath // DISTINFO_FILE from the package Makefile
Plist PlistContent // Files and directories mentioned in the PLIST files
+ PlistLines *PlistLines
vars Scope
redundant *RedundantScope
@@ -104,6 +105,7 @@
Patchdir: "patches", // TODO: Redundant, see the vars.Fallback below.
DistinfoFile: "${PKGDIR}/distinfo", // TODO: Redundant, see the vars.Fallback below.
Plist: NewPlistContent(),
+ PlistLines: NewPlistLines(),
vars: NewScope(),
bl3: make(map[PackagePath]*MkLine),
bl3Data: make(map[Buildlink3ID]*Buildlink3Data),
@@ -520,7 +522,7 @@
"",
Once{},
false}
- ck.Load(lines)
+ plistLines := ck.Load(lines)
for filename, pline := range ck.allFiles {
pkg.Plist.Files[filename] = pline
@@ -528,6 +530,12 @@
for dirname, pline := range ck.allDirs {
pkg.Plist.Dirs[dirname] = pline
}
+ for _, plistLine := range plistLines {
+ if plistLine.HasPath() {
+ rank := NewPlistRank(plistLine.Basename)
+ pkg.PlistLines.Add(plistLine, rank)
+ }
+ }
}
func (pkg *Package) check(filenames []CurrPath, mklines, allLines *MkLines) {
@@ -577,9 +585,26 @@
"To generate a distinfo file for the existing patches, run",
sprintf("%q.", bmake("makepatchsum")))
}
+
+ pkg.checkDescr(filenames, mklines)
}
}
+func (pkg *Package) checkDescr(filenames []CurrPath, mklines *MkLines) {
+ if mklines == nil {
+ return
+ }
+ for _, filename := range filenames {
+ if filename.HasBase("DESCR") {
+ return
+ }
+ }
+ if pkg.vars.IsDefined("DESCR_SRC") {
+ return
+ }
+ mklines.Whole().Errorf("Each package must have a DESCR file.")
+}
+
func (pkg *Package) checkfilePackageMakefile(filename CurrPath, mklines *MkLines, allLines *MkLines) {
if trace.Tracing {
defer trace.Call(filename)()
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/package_test.go Sun Mar 22 17:43:15 2020 +0000
@@ -20,6 +20,8 @@
"TOOLS_CREATE+=nice",
"TOOLS_CREATE+=true",
"_TOOLS_VARNAME.nice=NICE")
+ t.CreateFileLines("category/pkgbase/DESCR",
+ "Description")
t.CreateFileLines("category/pkgbase/Makefile",
MkCvsID,
@@ -247,6 +249,8 @@
"",
".include \"../../math/R/Makefile.extension\"",
".include \"../../mk/bsd.pkg.mk\"")
+ t.CreateFileLines("math/R-date/DESCR",
+ "Description")
t.FinishSetUp()
// See Package.checkfilePackageMakefile
@@ -297,7 +301,9 @@
"WARN: x11/gst-x11/Makefile: This package should have a PLIST file.",
"ERROR: x11/gst-x11/Makefile: Each package must define its LICENSE.",
"WARN: x11/gst-x11/Makefile: Each package should define a COMMENT.",
- "WARN: x11/gst-x11/../../multimedia/gst-base/distinfo:3: Patch file \"patch-aa\" does not exist in directory \"../../x11/gst-x11/patches\".")
+ "WARN: x11/gst-x11/../../multimedia/gst-base/distinfo:3: "+
+ "Patch file \"patch-aa\" does not exist in directory \"../../x11/gst-x11/patches\".",
+ "ERROR: x11/gst-x11/Makefile: Each package must have a DESCR file.")
}
func (s *Suite) Test_Package__case_insensitive(c *check.C) {
@@ -549,6 +555,8 @@
t.SetUpCommandLine("--dumpmakefile")
t.SetUpPkgsrc()
t.CreateFileLines("category/Makefile")
+ t.CreateFileLines("category/package/DESCR",
+ "Description")
t.CreateFileLines("category/package/PLIST",
PlistCvsID,
"bin/program")
@@ -1322,6 +1330,20 @@
"1 warning found.")
}
+func (s *Suite) Test_Package_checkDescr__DESCR_SRC(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("other/package")
+ t.SetUpPackage("category/package",
+ "DESCR_SRC=\t../../other/package/DESCR")
+ t.Remove("category/package/DESCR")
+ t.FinishSetUp()
+
+ G.Check(t.File("category/package"))
+
+ t.CheckOutputEmpty()
+}
+
func (s *Suite) Test_Package_checkfilePackageMakefile__GNU_CONFIGURE(c *check.C) {
t := s.Init(c)
@@ -1923,6 +1945,7 @@
t.CreateFileLines("mk/bsd.pkg.mk", "# dummy")
t.CreateFileLines("x11/Makefile", MkCvsID)
+ t.CreateFileLines("x11/9term/DESCR", "Terminal")
t.CreateFileLines("x11/9term/PLIST", PlistCvsID, "bin/9term")
t.CreateFileLines("x11/9term/Makefile",
MkCvsID,
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/patches.go
--- a/pkgtools/pkglint/files/patches.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/patches.go Sun Mar 22 17:43:15 2020 +0000
@@ -136,6 +136,7 @@
linesToAdd--
ck.checktextCvsID(text)
ck.checkConfigure(text[1:], isConfigure)
+ ck.checkAddedLine(text[1:])
case hasPrefix(text, "\\"):
// \ No newline at end of file (or a translation of that message)
@@ -222,6 +223,18 @@
"mk/configure/gnu-configure.mk.")
}
+func (ck *PatchChecker) checkAddedLine(addedText string) {
+ if !matches(addedText, `/usr/pkg\b`) {
+ return
+ }
+
+ line := ck.llex.PreviousLine()
+ line.Errorf("Patches must not hard-code the pkgsrc PREFIX.")
+ line.Explain(
+ "Instead of hard-coding /usr/pkg, packages should use the PREFIX variable.",
+ "The usual way of doing this is to use the SUBST framework in mk/subst.mk.")
+}
+
func (ck *PatchChecker) checktextUniHunkCr() {
line := ck.llex.PreviousLine()
if !hasSuffix(line.Text, "\r") {
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/patches_test.go
--- a/pkgtools/pkglint/files/patches_test.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/patches_test.go Sun Mar 22 17:43:15 2020 +0000
@@ -596,6 +596,26 @@
t.CheckOutputEmpty()
}
+func (s *Suite) Test_PatchChecker_Check__add_hardcoded_usr_pkg(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.SetUpFileLines("patch-aa",
+ CvsID,
+ "",
+ "This patch wrongly contains the hard-coded PREFIX.",
+ "",
+ "--- Makefile",
+ "+++ Makefile",
+ "@@ -1,1 +1,1 @@",
+ "- prefix := @prefix@",
+ "+ prefix := /usr/pkg")
+
+ CheckLinesPatch(lines, nil)
+
+ t.CheckOutputLines(
+ "ERROR: ~/patch-aa:9: Patches must not hard-code the pkgsrc PREFIX.")
+}
+
func (s *Suite) Test_PatchChecker_checkUnifiedDiff__lines_at_end(c *check.C) {
t := s.Init(c)
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/path.go
--- a/pkgtools/pkglint/files/path.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/path.go Sun Mar 22 17:43:15 2020 +0000
@@ -94,6 +94,25 @@
return !p.IsAbs()
}
+ si := 0
+ pi := 0
+ for {
+ for si < len(p) && (p[si] == '.' || p[si] == '/') {
+ si++
+ }
+ for pi < len(prefix) && (prefix[pi] == '.' || prefix[pi] == '/') {
+ pi++
+ }
+ if si >= len(p) || pi >= len(prefix) {
+ break
+ }
+ if p[si] != prefix[pi] {
+ return false
+ }
+ si++
+ pi++
+ }
+
parts := p.Parts()
prefixParts := prefix.Parts()
if len(prefixParts) > len(parts) {
@@ -192,7 +211,7 @@
}
func (p Path) IsAbs() bool {
- return p.HasPrefixText("/") || filepath.IsAbs(filepath.FromSlash(string(p)))
+ return len(p) > 0 && (p[0] == '/' || len(p) > 2 && p[1] == ':' && p[2] == '/')
}
// Rel returns the relative path from this path to the other.
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/path_test.go
--- a/pkgtools/pkglint/files/path_test.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/path_test.go Sun Mar 22 17:43:15 2020 +0000
@@ -487,8 +487,8 @@
test(".", false)
test("a/b", false)
test("/a", true)
- test("C:/", runtime.GOOS == "windows")
- test("c:/", runtime.GOOS == "windows")
+ test("C:/", true)
+ test("c:/", true)
}
func (s *Suite) Test_Path_Rel(c *check.C) {
@@ -651,7 +651,7 @@
test("/", true)
test("./", false)
- test("C:/", runtime.GOOS == "windows")
+ test("C:/", true)
}
func (s *Suite) Test_CurrPath_HasPrefixPath(c *check.C) {
diff -r 93f11a23e6b8 -r fb8b8331a997 pkgtools/pkglint/files/pkglint_test.go
--- a/pkgtools/pkglint/files/pkglint_test.go Sun Mar 22 17:01:49 2020 +0000
+++ b/pkgtools/pkglint/files/pkglint_test.go Sun Mar 22 17:43:15 2020 +0000
@@ -186,6 +186,9 @@
"",
".include \"../../mk/bsd.pkg.mk\"")
Home |
Main Index |
Thread Index |
Old Index