summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-05-17 07:07:18 +0000
committerrillig <rillig@pkgsrc.org>2020-05-17 07:07:18 +0000
commitd0a7a7cdc05b4b8f23a07457f8a06ca1f1f7b3d6 (patch)
tree241cf2063ea6dfa03115d8d987d27efa1737c196 /pkgtools
parent3956774c2b599ae262446497c838a1a6f8d8f79b (diff)
downloadpkgsrc-d0a7a7cdc05b4b8f23a07457f8a06ca1f1f7b3d6.tar.gz
pkgtools/pkglint: update to 20.1.6
Changes since 20.1.5: Category Makefiles must only list subdirectories in SUBDIR that actually contain a package. There is no need to mention the other directories. This is the same as in the top-level Makefile, where mk/ and regress/ are not listed. Packages from pkgsrc-wip may have a COMMIT_MSG file with a suggested commit message for importing the package into main pkgsrc.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/Makefile4
-rw-r--r--pkgtools/pkglint/files/category.go12
-rw-r--r--pkgtools/pkglint/files/category_test.go63
-rw-r--r--pkgtools/pkglint/files/pkglint.go3
-rw-r--r--pkgtools/pkglint/files/pkglint_test.go27
5 files changed, 83 insertions, 26 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index 59cbc21ffd2..cdfe8c7c8b1 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.644 2020/05/09 19:26:11 rillig Exp $
+# $NetBSD: Makefile,v 1.645 2020/05/17 07:07:18 rillig Exp $
-PKGNAME= pkglint-20.1.5
+PKGNAME= pkglint-20.1.6
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff --git a/pkgtools/pkglint/files/category.go b/pkgtools/pkglint/files/category.go
index 127abdaeb4e..14a40f17f6d 100644
--- a/pkgtools/pkglint/files/category.go
+++ b/pkgtools/pkglint/files/category.go
@@ -43,9 +43,15 @@ func CheckdirCategory(dir CurrPath) {
// the (hopefully) sorted list of SUBDIRs. The first step is to
// collect the SUBDIRs in the Makefile and in the file system.
- fSubdirs := getSubdirs(dir)
+ var fSubdirs []RelPath
var mSubdirs []subdir
+ for _, subdir := range getSubdirs(dir) {
+ if dir.JoinNoClean(subdir).JoinNoClean("Makefile").IsFile() {
+ fSubdirs = append(fSubdirs, subdir)
+ }
+ }
+
seen := make(map[RelPath]*MkLine)
for !mlex.EOF() {
mkline := mlex.CurrentMkLine()
@@ -114,7 +120,7 @@ func CheckdirCategory(dir CurrPath) {
}
fix := line.Autofix()
- fix.Errorf("%q exists in the file system but not in the Makefile.", fCurrent)
+ fix.Errorf("Package %q must be listed here.", fCurrent)
fix.InsertAbove("SUBDIR+=\t" + fCurrent.String())
fix.Apply()
}
@@ -123,7 +129,7 @@ func CheckdirCategory(dir CurrPath) {
} else if len(fRest) == 0 || mRest[0].name < fRest[0] {
if !fCheck[mRest[0].name] {
fix := mRest[0].line.Autofix()
- fix.Errorf("%q exists in the Makefile but not in the file system.", mRest[0].name)
+ fix.Errorf("%q does not contain a package.", mRest[0].name)
fix.Delete()
fix.Apply()
}
diff --git a/pkgtools/pkglint/files/category_test.go b/pkgtools/pkglint/files/category_test.go
index 2b02d0cf30c..d2f274ec53c 100644
--- a/pkgtools/pkglint/files/category_test.go
+++ b/pkgtools/pkglint/files/category_test.go
@@ -29,8 +29,8 @@ func (s *Suite) Test_CheckdirCategory__totally_broken(c *check.C) {
"NOTE: ~/archivers/Makefile:2: Empty line expected above this line.",
"WARN: ~/archivers/Makefile:3: \"aaaaa\" should come before \"pkg1\".",
"ERROR: ~/archivers/Makefile:4: SUBDIR+= line or empty line expected.",
- "ERROR: ~/archivers/Makefile:2: \"pkg1\" exists in the Makefile but not in the file system.",
- "ERROR: ~/archivers/Makefile:3: \"aaaaa\" exists in the Makefile but not in the file system.",
+ "ERROR: ~/archivers/Makefile:2: \"pkg1\" does not contain a package.",
+ "ERROR: ~/archivers/Makefile:3: \"aaaaa\" does not contain a package.",
"NOTE: ~/archivers/Makefile:4: Empty line expected above this line.",
"WARN: ~/archivers/Makefile:4: This line should contain the following text: .include \"../mk/misc/category.mk\"",
"ERROR: ~/archivers/Makefile:4: The file must end here.")
@@ -125,9 +125,9 @@ func (s *Suite) Test_CheckdirCategory__subdirs(c *check.C) {
"WARN: ~/category/Makefile:7: \"duplicate\" should come before \"in-wrong-order\".",
"WARN: ~/category/Makefile:10: \"commented-mk-and-fs\" should come before \"mk-only\".",
"WARN: ~/category/Makefile:12: \"commented-without-reason\" commented out without giving a reason.",
- "ERROR: ~/category/Makefile:6: \"fs-only\" exists in the file system but not in the Makefile.",
- "ERROR: ~/category/Makefile:9: \"mk-only\" exists in the Makefile but not in the file system.",
- "ERROR: ~/category/Makefile:11: \"commented-mk-only\" exists in the Makefile but not in the file system.")
+ "ERROR: ~/category/Makefile:6: Package \"fs-only\" must be listed here.",
+ "ERROR: ~/category/Makefile:9: \"mk-only\" does not contain a package.",
+ "ERROR: ~/category/Makefile:11: \"commented-mk-only\" does not contain a package.")
}
func (s *Suite) Test_CheckdirCategory__only_in_Makefile(c *check.C) {
@@ -151,10 +151,10 @@ func (s *Suite) Test_CheckdirCategory__only_in_Makefile(c *check.C) {
CheckdirCategory(t.File("category"))
t.CheckOutputLines(
- "ERROR: ~/category/Makefile:5: \"above-only-in-makefile\" exists in the Makefile "+
- "but not in the file system.",
- "ERROR: ~/category/Makefile:7: \"only-in-makefile\" exists in the Makefile "+
- "but not in the file system.")
+ "ERROR: ~/category/Makefile:5: "+
+ "\"above-only-in-makefile\" does not contain a package.",
+ "ERROR: ~/category/Makefile:7: "+
+ "\"only-in-makefile\" does not contain a package.")
}
func (s *Suite) Test_CheckdirCategory__only_in_file_system(c *check.C) {
@@ -178,10 +178,8 @@ func (s *Suite) Test_CheckdirCategory__only_in_file_system(c *check.C) {
CheckdirCategory(t.File("category"))
t.CheckOutputLines(
- "ERROR: ~/category/Makefile:5: \"above-only-in-fs\" exists in the file system "+
- "but not in the Makefile.",
- "ERROR: ~/category/Makefile:6: \"only-in-fs\" exists in the file system "+
- "but not in the Makefile.")
+ "ERROR: ~/category/Makefile:5: Package \"above-only-in-fs\" must be listed here.",
+ "ERROR: ~/category/Makefile:6: Package \"only-in-fs\" must be listed here.")
}
func (s *Suite) Test_CheckdirCategory__recursive(c *check.C) {
@@ -245,7 +243,7 @@ func (s *Suite) Test_CheckdirCategory__subdirs_file_system_at_the_bottom(c *chec
CheckdirCategory(t.File("category"))
t.CheckOutputLines(
- "ERROR: ~/category/Makefile:6: \"zzz-fs-only\" exists in the file system but not in the Makefile.",
+ "ERROR: ~/category/Makefile:6: Package \"zzz-fs-only\" must be listed here.",
"AUTOFIX: ~/category/Makefile:6: Inserting a line \"SUBDIR+=\\tzzz-fs-only\" above this line.")
}
@@ -303,7 +301,7 @@ func (s *Suite) Test_CheckdirCategory__comment_at_the_top(c *check.C) {
"ERROR: ~/category/Makefile:3: COMMENT= line expected.",
"NOTE: ~/category/Makefile:3: Empty line expected above this line.",
"ERROR: ~/category/Makefile:3: SUBDIR+= line or empty line expected.",
- "ERROR: ~/category/Makefile:3: \"package\" exists in the file system but not in the Makefile.",
+ "ERROR: ~/category/Makefile:3: Package \"package\" must be listed here.",
"NOTE: ~/category/Makefile:3: Empty line expected above this line.",
"WARN: ~/category/Makefile:3: This line should contain the following text: .include \"../mk/misc/category.mk\"",
"ERROR: ~/category/Makefile:3: The file must end here.")
@@ -364,10 +362,10 @@ func (s *Suite) Test_CheckdirCategory__case_mismatch(c *check.C) {
G.Check(t.File("category"))
t.CheckOutputLines(
- "ERROR: ~/category/Makefile:5: \"p5-Net-DNS\" "+
- "exists in the file system but not in the Makefile.",
- "ERROR: ~/category/Makefile:5: \"p5-net-dns\" "+
- "exists in the Makefile but not in the file system.")
+ "ERROR: ~/category/Makefile:5: "+
+ "Package \"p5-Net-DNS\" must be listed here.",
+ "ERROR: ~/category/Makefile:5: "+
+ "\"p5-net-dns\" does not contain a package.")
}
func (s *Suite) Test_CheckdirCategory__dot(c *check.C) {
@@ -389,8 +387,7 @@ func (s *Suite) Test_CheckdirCategory__dot(c *check.C) {
G.Check(".")
t.CheckOutputLines(
- "ERROR: Makefile:5: \"package\" exists in the Makefile " +
- "but not in the file system.")
+ "ERROR: Makefile:5: \"package\" does not contain a package.")
}
func (s *Suite) Test_CheckdirCategory__absolute(c *check.C) {
@@ -416,3 +413,27 @@ func (s *Suite) Test_CheckdirCategory__absolute(c *check.C) {
"contains the invalid character \"/\".",
"ERROR: Makefile:5: \"/other\" must be a relative path.")
}
+
+func (s *Suite) Test_CheckdirCategory__subdir_that_is_not_a_package(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPkgsrc()
+ t.CreateFileLines("mk/misc/category.mk")
+ t.CreateFileLines("category/Makefile",
+ MkCvsID,
+ "",
+ "COMMENT=\tCategory comment",
+ "",
+ "SUBDIR+=\tsub2",
+ "",
+ ".include \"../mk/misc/category.mk\"")
+ t.CreateFileLines("category/sub1/module.mk")
+ t.CreateFileLines("category/sub2/module.mk")
+ t.Chdir("category")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "ERROR: Makefile:5: \"sub2\" does not contain a package.")
+}
diff --git a/pkgtools/pkglint/files/pkglint.go b/pkgtools/pkglint/files/pkglint.go
index 0d38983a4cd..41a964b10a3 100644
--- a/pkgtools/pkglint/files/pkglint.go
+++ b/pkgtools/pkglint/files/pkglint.go
@@ -581,6 +581,9 @@ func (p *Pkglint) checkReg(filename CurrPath, basename string, depth int, pkg *P
CheckLinesBuildlink3Mk(mklines)
}
+ case p.Wip && basename == "COMMIT_MSG":
+ // https://mail-index.netbsd.org/pkgsrc-users/2020/05/10/msg031174.html
+
case hasPrefix(basename, "DESCR"):
if lines := Load(filename, NotEmpty|LogErrors); lines != nil {
CheckLinesDescr(lines)
diff --git a/pkgtools/pkglint/files/pkglint_test.go b/pkgtools/pkglint/files/pkglint_test.go
index 9e6d588c42d..c7f1b684210 100644
--- a/pkgtools/pkglint/files/pkglint_test.go
+++ b/pkgtools/pkglint/files/pkglint_test.go
@@ -1171,6 +1171,33 @@ func (s *Suite) Test_Pkglint_checkReg__options_mk(c *check.C) {
t.CheckOutputEmpty()
}
+func (s *Suite) Test_Pkglint_checkReg__main_commit_message(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package")
+ t.Chdir("category/package")
+ t.CreateFileLines("COMMIT_MSG")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: COMMIT_MSG: Unexpected file found.")
+}
+
+func (s *Suite) Test_Pkglint_checkReg__wip_commit_message(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("wip/package")
+ t.Chdir("wip/package")
+ t.CreateFileLines("COMMIT_MSG")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputEmpty()
+}
+
func (s *Suite) Test_Pkglint_checkRegCvsSubst(c *check.C) {
t := s.Init(c)