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 21.3.1



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a6fb17a37397
branches:  trunk
changeset: 459547:a6fb17a37397
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Oct 09 08:33:09 2021 +0000

description:
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.

diffstat:

 pkgtools/pkglint/Makefile                     |   5 +-
 pkgtools/pkglint/files/distinfo.go            |  22 +++++--
 pkgtools/pkglint/files/distinfo_test.go       |  81 +++++++++++---------------
 pkgtools/pkglint/files/package_test.go        |  10 ++-
 pkgtools/pkglint/files/pkglint.go             |   3 +
 pkgtools/pkglint/files/pkgsrc_test.go         |   8 +-
 pkgtools/pkglint/files/redundantscope_test.go |  23 +++++++
 pkgtools/pkglint/files/vardefs.go             |   1 +
 pkgtools/pkglint/files/vartypecheck.go        |   6 +-
 pkgtools/pkglint/files/vartypecheck_test.go   |  14 ++++
 10 files changed, 107 insertions(+), 66 deletions(-)

diffs (truncated from 473 to 300 lines):

diff -r 5338b35c4eff -r a6fb17a37397 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Oct 09 08:13:53 2021 +0000
+++ b/pkgtools/pkglint/Makefile Sat Oct 09 08:33:09 2021 +0000
@@ -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/}
diff -r 5338b35c4eff -r a6fb17a37397 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sat Oct 09 08:13:53 2021 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sat Oct 09 08:33:09 2021 +0000
@@ -146,9 +146,10 @@
        switch {
        case algorithms == "SHA1" && isPatch != no:
                return
-
+       case algorithms == "RMD160, SHA512, Size" && isPatch != yes:
+               return
        case algorithms == "SHA1, RMD160, SHA512, Size" && isPatch != yes:
-               return
+               return // TODO: remove as of 2021Q3
        }
 
        switch {
@@ -159,7 +160,7 @@
                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 @@
 // 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) 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 {
diff -r 5338b35c4eff -r a6fb17a37397 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Sat Oct 09 08:13:53 2021 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Sat Oct 09 08:33:09 2021 +0000
@@ -31,7 +31,7 @@
                "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 @@
        // 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 @@
        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 @@
                "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 @@
        // 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 @@
 
        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 @@
        // 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 @@
 
        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 @@
 
        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 @@
 
        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 @@
 
        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 @@
 
        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 @@
 
        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 @@
                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 @@
        // 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 @@
 
        // 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 @@
 
        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 @@
        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 "+



Home | Main Index | Thread Index | Old Index