diff options
author | rillig <rillig@pkgsrc.org> | 2021-03-22 23:26:30 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2021-03-22 23:26:30 +0000 |
commit | 22c4feeea5d8bf5aa479c358aab71d57f39bbf81 (patch) | |
tree | 18a0c11417eeb0f8089c342abd3a7cee80c1e74f /pkgtools | |
parent | 35410a721506c989373e62f863ed1442f9e214dd (diff) | |
download | pkgsrc-22c4feeea5d8bf5aa479c358aab71d57f39bbf81.tar.gz |
pkgtools/pkglint: update to 20.4.2
Changes since 20.4.1:
Error out on package directories that differ only in case. This ensures
that pkgsrc can be used on case-insensitive file systems as well, such
as on macOS or Windows.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/category.go | 21 | ||||
-rw-r--r-- | pkgtools/pkglint/files/category_test.go | 29 | ||||
-rw-r--r-- | pkgtools/pkglint/files/logging.go | 3 | ||||
-rw-r--r-- | pkgtools/pkglint/files/package_test.go | 3 |
5 files changed, 53 insertions, 7 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index ed7627fc476..f134b110494 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.680 2021/03/20 23:32:43 rillig Exp $ +# $NetBSD: Makefile,v 1.681 2021/03/22 23:26:30 rillig Exp $ -PKGNAME= pkglint-20.4.1 +PKGNAME= pkglint-20.4.2 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 2ae66912699..5c6b21e99d8 100644 --- a/pkgtools/pkglint/files/category.go +++ b/pkgtools/pkglint/files/category.go @@ -1,6 +1,9 @@ package pkglint -import "netbsd.org/pkglint/textproc" +import ( + "netbsd.org/pkglint/textproc" + "strings" +) func CheckdirCategory(dir CurrPath) { if trace.Tracing { @@ -53,6 +56,7 @@ func CheckdirCategory(dir CurrPath) { } seen := make(map[RelPath]*MkLine) + seenLower := make(map[string]subdir) for !mlex.EOF() { mkline := mlex.CurrentMkLine() @@ -76,6 +80,15 @@ func CheckdirCategory(dir CurrPath) { } seen[sub] = mkline + lowerSub := strings.ToLower(sub.String()) + if lower := seenLower[lowerSub]; lower.line != nil && lower.name != sub { + mkline.Errorf("On case-insensitive file systems, "+ + "%q is the same as %q from %s.", + sub, lower.name, mkline.RelMkLine(lower.line)) + } else { + seenLower[lowerSub] = subdir{sub, mkline} + } + if len(mSubdirs) > 0 { if prev := mSubdirs[len(mSubdirs)-1].name; sub < prev { mkline.Warnf("%q should come before %q.", sub, prev) @@ -127,9 +140,11 @@ func CheckdirCategory(dir CurrPath) { fRest = fRest[1:] } else if len(fRest) == 0 || mRest[0].name < fRest[0] { - if !fCheck[mRest[0].name] { + mName := mRest[0].name + if !fCheck[mName] && + seenLower[strings.ToLower(mName.String())].name == mName { fix := mRest[0].line.Autofix() - fix.Errorf("%q does not contain a package.", mRest[0].name) + fix.Errorf("%q does not contain a package.", mName) fix.Delete() fix.Apply() } diff --git a/pkgtools/pkglint/files/category_test.go b/pkgtools/pkglint/files/category_test.go index 6310743bb12..58e4437b6e8 100644 --- a/pkgtools/pkglint/files/category_test.go +++ b/pkgtools/pkglint/files/category_test.go @@ -437,3 +437,32 @@ func (s *Suite) Test_CheckdirCategory__subdir_that_is_not_a_package(c *check.C) t.CheckOutputLines( "ERROR: Makefile:5: \"sub2\" does not contain a package.") } + +func (s *Suite) Test_CheckdirCategory__case_insensitive_file_system(c *check.C) { + t := s.Init(c) + + t.SetUpPackage("category/PACKAGE") + t.SetUpPackage("category/Package") // may overwrite PACKAGE + t.SetUpPackage("category/package") // may overwrite PACKAGE + t.CreateFileLines("mk/misc/category.mk") + t.CreateFileLines("category/Makefile", + MkCvsID, + "", + "COMMENT=\tCategory comment", + "", + "SUBDIR+=\tPACKAGE", + "SUBDIR+=\tPackage", + "SUBDIR+=\tpackage", + "", + ".include \"../mk/misc/category.mk\"") + t.Chdir("category") + t.FinishSetUp() + + G.Check(".") + + t.CheckOutputLines( + "ERROR: Makefile:6: On case-insensitive file systems, "+ + "\"Package\" is the same as \"PACKAGE\" from line 5.", + "ERROR: Makefile:7: On case-insensitive file systems, "+ + "\"package\" is the same as \"PACKAGE\" from line 5.") +} diff --git a/pkgtools/pkglint/files/logging.go b/pkgtools/pkglint/files/logging.go index e0f3db1b792..dbb6f4239ed 100644 --- a/pkgtools/pkglint/files/logging.go +++ b/pkgtools/pkglint/files/logging.go @@ -295,6 +295,9 @@ func (l *Logger) Logf(level *LogLevel, filename CurrPath, lineno, format, msg st if !filename.IsEmpty() { filename = filename.CleanPath() } + if filename == "." { + filename = NewCurrPath("") + } if G.Profiling && format != autofixFormat { l.histo.Add(format, 1) } diff --git a/pkgtools/pkglint/files/package_test.go b/pkgtools/pkglint/files/package_test.go index e3683a9508f..ae4609a5cdb 100644 --- a/pkgtools/pkglint/files/package_test.go +++ b/pkgtools/pkglint/files/package_test.go @@ -3210,9 +3210,8 @@ func (s *Suite) Test_Package_checkOwnerMaintainer__maintainer_unequal_several_fi G.Check(".") - // TODO: Remove the ".:", it is more confusing than helpful. t.CheckOutputLines( - "NOTE: .: Please only commit changes " + + "NOTE: Please only commit changes " + "that maintainer@example.org would approve.") } |