pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Mon Mar 22 23:26:30 UTC 2021

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: category.go category_test.go logging.go
            package_test.go

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.680 -r1.681 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.34 -r1.35 pkgsrc/pkgtools/pkglint/files/category.go \
    pkgsrc/pkgtools/pkglint/files/category_test.go
cvs rdiff -u -r1.42 -r1.43 pkgsrc/pkgtools/pkglint/files/logging.go
cvs rdiff -u -r1.81 -r1.82 pkgsrc/pkgtools/pkglint/files/package_test.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/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.680 pkgsrc/pkgtools/pkglint/Makefile:1.681
--- pkgsrc/pkgtools/pkglint/Makefile:1.680      Sat Mar 20 23:32:43 2021
+++ pkgsrc/pkgtools/pkglint/Makefile    Mon Mar 22 23:26:30 2021
@@ -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/}

Index: pkgsrc/pkgtools/pkglint/files/category.go
diff -u pkgsrc/pkgtools/pkglint/files/category.go:1.34 pkgsrc/pkgtools/pkglint/files/category.go:1.35
--- pkgsrc/pkgtools/pkglint/files/category.go:1.34      Sun Jun  7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/category.go   Mon Mar 22 23:26:30 2021
@@ -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()
                        }
Index: pkgsrc/pkgtools/pkglint/files/category_test.go
diff -u pkgsrc/pkgtools/pkglint/files/category_test.go:1.34 pkgsrc/pkgtools/pkglint/files/category_test.go:1.35
--- pkgsrc/pkgtools/pkglint/files/category_test.go:1.34 Sun Jun  7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/category_test.go      Mon Mar 22 23:26:30 2021
@@ -437,3 +437,32 @@ func (s *Suite) Test_CheckdirCategory__s
        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.")
+}

Index: pkgsrc/pkgtools/pkglint/files/logging.go
diff -u pkgsrc/pkgtools/pkglint/files/logging.go:1.42 pkgsrc/pkgtools/pkglint/files/logging.go:1.43
--- pkgsrc/pkgtools/pkglint/files/logging.go:1.42       Sat Mar  7 23:35:35 2020
+++ pkgsrc/pkgtools/pkglint/files/logging.go    Mon Mar 22 23:26:30 2021
@@ -295,6 +295,9 @@ func (l *Logger) Logf(level *LogLevel, f
        if !filename.IsEmpty() {
                filename = filename.CleanPath()
        }
+       if filename == "." {
+               filename = NewCurrPath("")
+       }
        if G.Profiling && format != autofixFormat {
                l.histo.Add(format, 1)
        }

Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.81 pkgsrc/pkgtools/pkglint/files/package_test.go:1.82
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.81  Sat Mar 20 23:32:43 2021
+++ pkgsrc/pkgtools/pkglint/files/package_test.go       Mon Mar 22 23:26:30 2021
@@ -3210,9 +3210,8 @@ func (s *Suite) Test_Package_checkOwnerM
 
        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@localhost would approve.")
 }
 



Home | Main Index | Thread Index | Old Index