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:           Sat Oct  9 08:33:10 UTC 2021

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: distinfo.go distinfo_test.go
            package_test.go pkglint.go pkgsrc_test.go redundantscope_test.go
            vardefs.go vartypecheck.go vartypecheck_test.go

Log Message:
pkgtools/pkglint: update to 21.3.1

Changes since 21.3.0:

When checking a standalone makefile fragment, pkglint reports redundant
variable declarations.

In pathname patterns, spaces and other escaping is allowed. This is
needed for devel/meson. While here, register MESON_REQD.

Adjust to the removal of SHA1 for distfiles. Only RMD160, SHA512 and
Size remain now. Patches continue to use SHA1 since they don't come
via untrusted paths.


To generate a diff of this commit:
cvs rdiff -u -r1.699 -r1.700 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.46 -r1.47 pkgsrc/pkgtools/pkglint/files/distinfo.go
cvs rdiff -u -r1.44 -r1.45 pkgsrc/pkgtools/pkglint/files/distinfo_test.go
cvs rdiff -u -r1.86 -r1.87 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.82 -r1.83 pkgsrc/pkgtools/pkglint/files/pkglint.go
cvs rdiff -u -r1.53 -r1.54 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
cvs rdiff -u -r1.18 -r1.19 \
    pkgsrc/pkgtools/pkglint/files/redundantscope_test.go
cvs rdiff -u -r1.102 -r1.103 pkgsrc/pkgtools/pkglint/files/vardefs.go
cvs rdiff -u -r1.98 -r1.99 pkgsrc/pkgtools/pkglint/files/vartypecheck.go
cvs rdiff -u -r1.89 -r1.90 pkgsrc/pkgtools/pkglint/files/vartypecheck_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.699 pkgsrc/pkgtools/pkglint/Makefile:1.700
--- pkgsrc/pkgtools/pkglint/Makefile:1.699      Fri Oct  8 18:55:08 2021
+++ pkgsrc/pkgtools/pkglint/Makefile    Sat Oct  9 08:33:09 2021
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.699 2021/10/08 18:55:08 bsiegert Exp $
+# $NetBSD: Makefile,v 1.700 2021/10/09 08:33:09 rillig Exp $
 
-PKGNAME=       pkglint-21.3.0
-PKGREVISION=   1
+PKGNAME=       pkglint-21.3.1
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}

Index: pkgsrc/pkgtools/pkglint/files/distinfo.go
diff -u pkgsrc/pkgtools/pkglint/files/distinfo.go:1.46 pkgsrc/pkgtools/pkglint/files/distinfo.go:1.47
--- pkgsrc/pkgtools/pkglint/files/distinfo.go:1.46      Sat Jun  6 20:42:56 2020
+++ pkgsrc/pkgtools/pkglint/files/distinfo.go   Sat Oct  9 08:33:09 2021
@@ -146,9 +146,10 @@ func (ck *distinfoLinesChecker) checkAlg
        switch {
        case algorithms == "SHA1" && isPatch != no:
                return
-
-       case algorithms == "SHA1, RMD160, SHA512, Size" && isPatch != yes:
+       case algorithms == "RMD160, SHA512, Size" && isPatch != yes:
                return
+       case algorithms == "SHA1, RMD160, SHA512, Size" && isPatch != yes:
+               return // TODO: remove as of 2021Q3
        }
 
        switch {
@@ -159,7 +160,7 @@ func (ck *distinfoLinesChecker) checkAlg
                line.Errorf("Wrong checksum algorithms %s for %s.", algorithms, filename)
                line.Explain(
                        "Distfiles that are downloaded from external sources must have the",
-                       "checksum algorithms SHA1, RMD160, SHA512, Size.",
+                       "checksum algorithms RMD160, SHA512, Size.",
                        "",
                        "Patch files from pkgsrc must have only the SHA1 hash.")
 
@@ -190,9 +191,10 @@ func (ck *distinfoLinesChecker) checkAlg
 // added to the distinfo file via an autofix.
 func (ck *distinfoLinesChecker) checkAlgorithmsDistfile(info distinfoFileInfo) {
        line := info.line()
-       line.Errorf("Expected SHA1, RMD160, SHA512, Size checksums for %q, got %s.", info.filename(), info.algorithms())
+       line.Errorf("Expected RMD160, SHA512, Size checksums for %q, got %s.",
+               info.filename(), info.algorithms())
 
-       algorithms := [...]string{"SHA1", "RMD160", "SHA512", "Size"}
+       algorithms := [...]string{"RMD160", "SHA512", "Size"}
 
        missing := map[string]bool{}
        for _, alg := range algorithms {
@@ -445,11 +447,17 @@ func (info *distinfoFileInfo) algorithms
 
 func (info *distinfoFileInfo) hasDistfileAlgorithms() bool {
        h := info.hashes
-       return len(h) == 4 &&
+       if len(h) == 4 && // TODO: remove as of 2021Q3
                h[0].algorithm == "SHA1" &&
                h[1].algorithm == "RMD160" &&
                h[2].algorithm == "SHA512" &&
-               h[3].algorithm == "Size"
+               h[3].algorithm == "Size" {
+               return true
+       }
+       return len(h) == 3 &&
+               h[0].algorithm == "RMD160" &&
+               h[1].algorithm == "SHA512" &&
+               h[2].algorithm == "Size"
 }
 
 type distinfoHash struct {

Index: pkgsrc/pkgtools/pkglint/files/distinfo_test.go
diff -u pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.44 pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.45
--- pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.44 Fri Jun 25 14:15:01 2021
+++ pkgsrc/pkgtools/pkglint/files/distinfo_test.go      Sat Oct  9 08:33:09 2021
@@ -31,7 +31,7 @@ func (s *Suite) Test_CheckLinesDistinfo_
                "ERROR: distinfo:1: Invalid line: should be the CVS ID",
                "ERROR: distinfo:2: Invalid line: should be empty",
                "ERROR: distinfo:8: Invalid line: Another invalid line",
-               "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got MD5, SHA1.",
+               "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got MD5, SHA1.",
                "ERROR: distinfo:5: Expected SHA1 hash for patch-aa, got SHA1, Size.",
                "WARN: distinfo:9: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".")
 }
@@ -283,7 +283,7 @@ func (s *Suite) Test_distinfoLinesChecke
        // a patch, it is a normal distfile because it has other hash algorithms
        // than exactly SHA1.
        t.CheckOutputLines(
-               "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums " +
+               "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums " +
                        "for \"patch-5.3.tar.gz\", got MD5, SHA1.")
 }
 
@@ -300,7 +300,7 @@ func (s *Suite) Test_distinfoLinesChecke
        CheckLinesDistinfo(nil, lines)
 
        t.CheckOutputLines(
-               "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums " +
+               "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums " +
                        "for \"distfile.tar.gz\", got MD5, SHA1.")
 }
 
@@ -326,7 +326,7 @@ func (s *Suite) Test_distinfoLinesChecke
                "ERROR: distinfo:3: Wrong checksum algorithms MD5 for patch-4.2.tar.gz.",
                "",
                "\tDistfiles that are downloaded from external sources must have the",
-               "\tchecksum algorithms SHA1, RMD160, SHA512, Size.",
+               "\tchecksum algorithms RMD160, SHA512, Size.",
                "",
                "\tPatch files from pkgsrc must have only the SHA1 hash.",
                "")
@@ -422,7 +422,7 @@ func (s *Suite) Test_distinfoLinesChecke
        // therefore it requires the usual distfile checksum algorithms here.
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: " +
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"patch-aa\", got RMD160.")
+                       "Expected RMD160, SHA512, Size checksums for \"patch-aa\", got RMD160.")
 }
 
 // When there is at least one correct hash for a distfile and the distfile
@@ -449,9 +449,8 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
                        "got RMD160, Size, CRC32.",
-               "ERROR: ~/category/package/distinfo:3: Missing SHA1 hash for package-1.0.txt.",
                "ERROR: ~/category/package/distinfo:3: Missing SHA512 hash for package-1.0.txt.")
 
        t.SetUpCommandLine("-Wall", "--autofix", "--show-autofix", "--source")
@@ -462,20 +461,11 @@ func (s *Suite) Test_distinfoLinesChecke
        // hash right away. It also adds the missing hashes since this file is
        // not a patch file.
        t.CheckOutputLines(
-               "ERROR: ~/category/package/distinfo:3: Missing SHA1 hash for package-1.0.txt.",
-               "AUTOFIX: ~/category/package/distinfo:3: "+
-                       "Inserting a line \"SHA1 (package-1.0.txt) "+
-                       "= cd50d19784897085a8d0e3e413f8612b097c03f1\" "+
-                       "above this line.",
-               "+\tSHA1 (package-1.0.txt) = cd50d19784897085a8d0e3e413f8612b097c03f1",
-               ">\tRMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
-               "",
                "ERROR: ~/category/package/distinfo:3: Missing SHA512 hash for package-1.0.txt.",
                "AUTOFIX: ~/category/package/distinfo:3: "+
                        "Inserting a line \"SHA512 (package-1.0.txt) "+
                        "= f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f"+
                        "268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c\" below this line.",
-               "+\tSHA1 (package-1.0.txt) = cd50d19784897085a8d0e3e413f8612b097c03f1",
                ">\tRMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
                "+\tSHA512 (package-1.0.txt) = f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f"+
                        "268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c")
@@ -486,8 +476,8 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: " +
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
-                       "got SHA1, RMD160, SHA512, Size, CRC32.")
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
+                       "got RMD160, SHA512, Size, CRC32.")
 }
 
 // When some of the hashes for a distfile are missing, pkglint can calculate
@@ -513,7 +503,7 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
                        "got RMD160, Size, CRC32.",
                "",
                "\tTo add the missing lines to the distinfo file, run",
@@ -557,7 +547,7 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
                        "got RMD160.",
                "ERROR: ~/category/package/distinfo:3: "+
                        "The RMD160 checksum for \"package-1.0.txt\" is 1234wrongHash1234 in distinfo, "+
@@ -580,7 +570,7 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: " +
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
                        "got MD5.")
 }
 
@@ -602,9 +592,8 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
                        "got SHA512, Size.",
-               "ERROR: ~/category/package/distinfo:3: Missing SHA1 hash for package-1.0.txt.",
                "ERROR: ~/category/package/distinfo:3: Missing RMD160 hash for package-1.0.txt.")
 }
 
@@ -625,22 +614,22 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
                        "got SHA1, RMD160.",
-               "ERROR: ~/category/package/distinfo:4: Missing SHA512 hash for package-1.0.txt.",
-               "ERROR: ~/category/package/distinfo:4: Missing Size hash for package-1.0.txt.")
+               "ERROR: ~/category/package/distinfo:3: Missing SHA512 hash for package-1.0.txt.",
+               "ERROR: ~/category/package/distinfo:3: Missing Size hash for package-1.0.txt.")
 
        t.SetUpCommandLine("-Wall", "--autofix")
 
        G.Check(t.File("category/package"))
 
        t.CheckOutputLines(
-               "AUTOFIX: ~/category/package/distinfo:4: "+
+               "AUTOFIX: ~/category/package/distinfo:3: "+
                        "Inserting a line \"SHA512 (package-1.0.txt) = f65f341b35981fda842b"+
                        "09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f268fc79d5a4af66358f513"+
-                       "3885cd1c165c916f80ab25e5d8d95db46f803c782c\" below this line.",
-               "AUTOFIX: ~/category/package/distinfo:4: "+
-                       "Inserting a line \"Size (package-1.0.txt) = 13 bytes\" below this line.")
+                       "3885cd1c165c916f80ab25e5d8d95db46f803c782c\" above this line.",
+               "AUTOFIX: ~/category/package/distinfo:3: "+
+                       "Inserting a line \"Size (package-1.0.txt) = 13 bytes\" above this line.")
 }
 
 func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__algorithms_in_wrong_order(c *check.C) {
@@ -651,7 +640,6 @@ func (s *Suite) Test_distinfoLinesChecke
                CvsID,
                "",
                "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
-               "SHA1 (package-1.0.txt) = cd50d19784897085a8d0e3e413f8612b097c03f1",
                "Size (package-1.0.txt) = 13 bytes",
                "SHA512 (package-1.0.txt) = f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7"+
                        "d41f0974d3e3122f268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c")
@@ -665,8 +653,8 @@ func (s *Suite) Test_distinfoLinesChecke
        // This case doesn't happen in practice, therefore there's no autofix for it.
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:3: " +
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
-                       "got RMD160, SHA1, Size, SHA512.")
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
+                       "got RMD160, Size, SHA512.")
 }
 
 func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__some_algorithms_in_wrong_order(c *check.C) {
@@ -689,10 +677,9 @@ func (s *Suite) Test_distinfoLinesChecke
 
        // This case doesn't happen in practice, therefore there's no autofix for it.
        t.CheckOutputLines(
-               "ERROR: ~/category/package/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
-                       "got RMD160, Size, SHA512.",
-               "ERROR: ~/category/package/distinfo:3: Missing SHA1 hash for package-1.0.txt.")
+               "ERROR: ~/category/package/distinfo:3: " +
+                       "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
+                       "got RMD160, Size, SHA512.")
 }
 
 func (s *Suite) Test_distinfoLinesChecker_checkUnrecordedPatches(c *check.C) {
@@ -764,21 +751,21 @@ func (s *Suite) Test_distinfoLinesChecke
 
        t.CheckOutputLines(
                "ERROR: ~/category/package1/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
                "ERROR: ~/category/package1/distinfo:4: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
                "ERROR: ~/category/package1/distinfo:5: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"patch-4.2.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"patch-4.2.tar.gz\", got SHA512.",
 
                "ERROR: ~/category/package2/distinfo:3: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
                "ERROR: ~/category/package2/distinfo:3: "+
                        "The SHA512 hash for distfile-1.0.tar.gz is 1234567822222222, "+
                        "which conflicts with 1234567811111111 in ../../category/package1/distinfo:3.",
                "ERROR: ~/category/package2/distinfo:4: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
                "ERROR: ~/category/package2/distinfo:5: "+
-                       "Expected SHA1, RMD160, SHA512, Size checksums for \"encoding-error.tar.gz\", got SHA512.",
+                       "Expected RMD160, SHA512, Size checksums for \"encoding-error.tar.gz\", got SHA512.",
                "ERROR: ~/category/package2/distinfo:5: "+
                        "The SHA512 hash for encoding-error.tar.gz contains a non-hex character.",
 
@@ -968,13 +955,13 @@ func (s *Suite) Test_distinfoFileInfo_ha
        G.Check(".")
 
        t.CheckOutputLines(
-               "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for "+
+               "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums for "+
                        "\"dist-a.tar.gz\", got other, RMD160, SHA512, Size.",
-               "ERROR: distinfo:7: Expected SHA1, RMD160, SHA512, Size checksums for "+
+               "ERROR: distinfo:7: Expected RMD160, SHA512, Size checksums for "+
                        "\"dist-b.tar.gz\", got SHA1, other, SHA512, Size.",
-               "ERROR: distinfo:11: Expected SHA1, RMD160, SHA512, Size checksums for "+
+               "ERROR: distinfo:11: Expected RMD160, SHA512, Size checksums for "+
                        "\"dist-c.tar.gz\", got SHA1, RMD160, other, Size.",
-               "ERROR: distinfo:15: Expected SHA1, RMD160, SHA512, Size checksums for "+
+               "ERROR: distinfo:15: Expected RMD160, SHA512, Size checksums for "+
                        "\"dist-d.tar.gz\", got SHA1, RMD160, SHA512, other.")
 }
 

Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.86 pkgsrc/pkgtools/pkglint/files/package_test.go:1.87
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.86  Sat Aug 14 09:46:11 2021
+++ pkgsrc/pkgtools/pkglint/files/package_test.go       Sat Oct  9 08:33:09 2021
@@ -498,6 +498,7 @@ func (s *Suite) Test_Package_load__extra
                "ERROR: gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
                "ERROR: gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: gnu-style.mk:2: IS_GCC is defined but not used.",
+               "WARN: gnu-style.mk:2: Variable IS_GCC is overwritten in line 4.",
 
                // There is no warning about files/gnu-style.mk since pkglint
                // doesn't even attempt at guessing the file type. Files placed
@@ -519,6 +520,7 @@ func (s *Suite) Test_Package_load__extra
                "ERROR: ../../category/other/gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
                "ERROR: ../../category/other/gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: ../../category/other/gnu-style.mk:2: IS_GCC is defined but not used.",
+               "WARN: ../../category/other/gnu-style.mk:2: Variable IS_GCC is overwritten in line 4.",
 
                "ERROR: patches/patch-Makefile.mk: Contains no patch.",
                "WARN: patches/readme.mk: Patch files should be named \"patch-\", followed by letters, '-', '_', '.', and digits only.")
@@ -1869,9 +1871,11 @@ func (s *Suite) Test_Package_checkfilePa
 
        G.Check("mk/redundant.mk")
 
-       // The redundancy check is only performed when a whole package
-       // is checked. Therefore nothing is reported here.
-       t.CheckOutputEmpty()
+       // The redundancy check applies both to package Makefiles and to
+       // makefile fragments that are given in the command line.
+       t.CheckOutputLines(
+               "NOTE: mk/redundant.mk:3: " +
+                       "Definition of INFRA_REDUNDANT is redundant because of line 2.")
 
        // If the global checks are enabled, redundancy warnings from the
        // pkgsrc infrastructure are reported as well.

Index: pkgsrc/pkgtools/pkglint/files/pkglint.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint.go:1.82 pkgsrc/pkgtools/pkglint/files/pkglint.go:1.83
--- pkgsrc/pkgtools/pkglint/files/pkglint.go:1.82       Mon Jun  1 20:49:54 2020
+++ pkgsrc/pkgtools/pkglint/files/pkglint.go    Sat Oct  9 08:33:09 2021
@@ -542,6 +542,9 @@ func CheckFileMk(filename CurrPath, pkg 
        }
 
        mklines.Check()
+       if pkg == nil || pkg.Includes(pkg.Rel(filename)) == nil {
+               NewRedundantScope().Check(mklines)
+       }
        mklines.SaveAutofixChanges()
 }
 

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.53 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.54
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.53   Sat Aug 14 08:19:49 2021
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go        Sat Oct  9 08:33:09 2021
@@ -1301,7 +1301,7 @@ func (s *Suite) Test_Pkgsrc_guessVariabl
 
        mklines := t.NewMkLines("filename.mk",
                MkCvsID,
-               "MY_CHECK_SKIP=\t*.c \"bad*pathname\"",
+               "MY_CHECK_SKIP=\t*.c \"quoted*pathname\"",
                "MY_CHECK_SKIP+=\t*.cpp",
                ".if ${MY_CHECK_SKIP}",
                ".endif")
@@ -1313,16 +1313,14 @@ func (s *Suite) Test_Pkgsrc_guessVariabl
        t.CheckEquals(vartype.EffectivePermissions("filename.mk"), aclpAllRuntime)
 
        // The permissions for MY_CHECK_SKIP say aclpAllRuntime, which excludes
-       // aclpUseLoadtime. Therefore there should be a warning about the VarUse in
+       // aclpUseLoadtime. Therefore, there should be a warning about the VarUse in
        // the .if line. As of March 2019, pkglint skips the permissions check for
        // guessed variables since that variable might have an entirely different
        // meaning; see MkVarUseChecker.checkPermissions.
        //
        // There is no warning for the += operator in line 3 since the variable type
        // (although guessed) is a list of things, and lists may be appended to.
-       t.CheckOutputLines(
-               "WARN: filename.mk:2: The pathname pattern \"\\\"bad*pathname\\\"\" " +
-                       "contains the invalid characters \"\\\"\\\"\".")
+       t.CheckOutputEmpty()
 }
 
 func (s *Suite) Test_Pkgsrc_checkToplevelUnusedLicenses(c *check.C) {

Index: pkgsrc/pkgtools/pkglint/files/redundantscope_test.go
diff -u pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.18 pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.19
--- pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.18   Wed Jul 22 19:26:30 2020
+++ pkgsrc/pkgtools/pkglint/files/redundantscope_test.go        Sat Oct  9 08:33:09 2021
@@ -1470,6 +1470,29 @@ func (s *Suite) Test_RedundantScope__is_
                        "Variable PKG_OPTIONS is overwritten in line 3.")
 }
 
+// All makefile fragments that are not directly or indirectly included by the
+// package Makefile need to be checked separately for redundant variable
+// assignments since these would otherwise go unnoticed.
+//
+// See CheckFileMk and Package.checkfilePackageMakefile.
+func (s *Suite) Test_RedundantScope__standalone(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("category/package")
+       t.CreateFileLines("category/package/build.mk",
+               MkCvsID,
+               "",
+               "_PKG_VARS.package=\tPACKAGE_REQD",
+               "_PKG_VARS.package=\tCONFIGURE_DIRS")
+       t.FinishSetUp()
+
+       G.Check(t.File("category/package"))
+
+       t.CheckOutputLines(
+               "WARN: ~/category/package/build.mk:3: " +
+                       "Variable _PKG_VARS.package is overwritten in line 4.")
+}
+
 // Branch coverage for info.vari.IsConstant(). The other tests typically
 // make a variable non-constant by adding conditional assignments between
 // .if/.endif. But there are other ways. The output of shell commands is

Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.102 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.103
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.102      Sun Jun  6 11:46:43 2021
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go    Sat Oct  9 08:33:09 2021
@@ -1381,6 +1381,7 @@ func (reg *VarTypeRegistry) Init(src *Pk
 
        reg.pkglist("MESSAGE_SRC", BtPathname)
        reg.pkglist("MESSAGE_SUBST", BtShellWord)
+       reg.pkgloadlist("MESON_REQD", BtVersion)
        reg.pkg("META_PACKAGE", BtYes)
        reg.syslist("MISSING_FEATURES", BtIdentifierDirect)
        reg.pkglist("MYSQL_VERSIONS_ACCEPTED", mysqlVersions)

Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.98 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.99
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.98  Sat Aug 14 15:11:30 2021
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go       Sat Oct  9 08:33:09 2021
@@ -980,9 +980,13 @@ func (cv *VartypeCheck) Pathlist() {
 
 // PathPattern is a shell pattern for pathnames, possibly including slashes.
 //
+// Spaces, backslashes and quotes are rarely needed but still allowed.
+// Without these characters, the patterns would need to use '?', which does
+// not represent the intended patterns exactly.
+//
 // See FilePattern.
 func (cv *VartypeCheck) PathPattern() {
-       invalid := replaceAll(cv.ValueNoVar, `[!%*+,\-./0-9?@A-Z\[\]_a-z~]`, "")
+       invalid := replaceAll(cv.ValueNoVar, `[ "%'*+,\-./0-9?@A-Z\[\\\]_a-z~]`, "")
        if invalid == "" {
                return
        }

Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.89 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.90
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.89     Sat Aug 14 15:11:30 2021
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go  Sat Oct  9 08:33:09 2021
@@ -2442,6 +2442,20 @@ func (s *Suite) Test_VartypeCheck_Wrksrc
 
        vt.Output(
                "AUTOFIX: filename.mk:12: Replacing \"${WRKSRC}/\" with \"\".")
+
+       t.SetUpCommandLine("-Wall")
+
+       // Seen in devel/meson/Makefile.
+       vt.Varname("REPLACE_PYTHON")
+       vt.Op(opAssign)
+       vt.Values(
+               "test\\ cases/*/*/*.py",
+               "test\" \"cases/*/*/*.py",
+               "test' 'cases/*/*/*.py",
+               // This matches the single file literally named '*.py'.
+               "'test cases/*/*/*.py'")
+
+       vt.OutputEmpty()
 }
 
 func (s *Suite) Test_VartypeCheck_WrksrcSubdirectory(c *check.C) {



Home | Main Index | Thread Index | Old Index