summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2021-10-28 20:15:25 +0000
committerrillig <rillig@pkgsrc.org>2021-10-28 20:15:25 +0000
commitdb2b8c88e7edb2bbb91623efbf16ed07d7c07332 (patch)
tree2811a95c30489599228de307d3096d051fad111d /pkgtools/pkglint
parentf67861bd2e5fbb18dd414894f5a660cd3b0f2816 (diff)
downloadpkgsrc-db2b8c88e7edb2bbb91623efbf16ed07d7c07332.tar.gz
pkglint: update to 21.3.2
Changes since 21.3.1: Replace RMD160 with BLAKE2s for distfiles in main pkgsrc, keep the previous RMD160 for pkgsrc-wip, at least until 2021Q4.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r--pkgtools/pkglint/Makefile4
-rw-r--r--pkgtools/pkglint/files/check_test.go3
-rw-r--r--pkgtools/pkglint/files/distinfo.go31
-rw-r--r--pkgtools/pkglint/files/distinfo_test.go158
-rw-r--r--pkgtools/pkglint/files/homepage.go16
-rw-r--r--pkgtools/pkglint/files/package_test.go40
-rw-r--r--pkgtools/pkglint/files/pkglint_test.go5
7 files changed, 113 insertions, 144 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index d5c16f2dbba..24d00109b1b 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.700 2021/10/09 08:33:09 rillig Exp $
+# $NetBSD: Makefile,v 1.701 2021/10/28 20:15:25 rillig Exp $
-PKGNAME= pkglint-21.3.1
+PKGNAME= pkglint-21.3.2
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff --git a/pkgtools/pkglint/files/check_test.go b/pkgtools/pkglint/files/check_test.go
index d0e9deb5539..a56aee0fb6d 100644
--- a/pkgtools/pkglint/files/check_test.go
+++ b/pkgtools/pkglint/files/check_test.go
@@ -479,8 +479,7 @@ func (t *Tester) SetUpPackage(pkgpath RelPath, makefileLines ...string) CurrPath
t.CreateFileLines(pkgpath.JoinNoClean("distinfo"),
CvsID,
"",
- "SHA1 (distfile-1.0.tar.gz) = 12341234",
- "RMD160 (distfile-1.0.tar.gz) = 12341234",
+ "BLAKE2s (distfile-1.0.tar.gz) = 12341234",
"SHA512 (distfile-1.0.tar.gz) = 12341234",
"Size (distfile-1.0.tar.gz) = 12341234")
diff --git a/pkgtools/pkglint/files/distinfo.go b/pkgtools/pkglint/files/distinfo.go
index 90bb58c7c54..d20655c51a1 100644
--- a/pkgtools/pkglint/files/distinfo.go
+++ b/pkgtools/pkglint/files/distinfo.go
@@ -5,6 +5,7 @@ import (
"crypto/sha1"
"crypto/sha512"
"encoding/hex"
+ "golang.org/x/crypto/blake2s"
"golang.org/x/crypto/ripemd160"
hashpkg "hash"
"io"
@@ -146,10 +147,16 @@ func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) {
switch {
case algorithms == "SHA1" && isPatch != no:
return
- case algorithms == "RMD160, SHA512, Size" && isPatch != yes:
+ case algorithms == "BLAKE2s, SHA512, Size" && isPatch != yes:
+ return
+ case G.Wip && algorithms == "RMD160, SHA512, Size" && isPatch != yes:
+ // TODO: remove after 2021Q4. Until then, allow pkgsrc-wip to
+ // be used with the stable 2021Q3.
+ return
+ case G.Wip && algorithms == "SHA1, BLAKE2s, SHA512, Size" && isPatch != yes:
+ // TODO: remove after 2021Q4. Until then, allow pkgsrc-wip to
+ // be used with the stable 2021Q3.
return
- case algorithms == "SHA1, RMD160, SHA512, Size" && isPatch != yes:
- return // TODO: remove as of 2021Q3
}
switch {
@@ -160,7 +167,7 @@ func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) {
line.Errorf("Wrong checksum algorithms %s for %s.", algorithms, filename)
line.Explain(
"Distfiles that are downloaded from external sources must have the",
- "checksum algorithms RMD160, SHA512, Size.",
+ "checksum algorithms BLAKE2s, SHA512, Size.",
"",
"Patch files from pkgsrc must have only the SHA1 hash.")
@@ -191,10 +198,10 @@ func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) {
// added to the distinfo file via an autofix.
func (ck *distinfoLinesChecker) checkAlgorithmsDistfile(info distinfoFileInfo) {
line := info.line()
- line.Errorf("Expected RMD160, SHA512, Size checksums for %q, got %s.",
+ line.Errorf("Expected BLAKE2s, SHA512, Size checksums for %q, got %s.",
info.filename(), info.algorithms())
- algorithms := [...]string{"RMD160", "SHA512", "Size"}
+ algorithms := [...]string{"BLAKE2s", "SHA512", "Size"}
missing := map[string]bool{}
for _, alg := range algorithms {
@@ -266,8 +273,12 @@ func (ck *distinfoLinesChecker) checkAlgorithmsDistfile(info distinfoFileInfo) {
switch alg {
case "SHA1":
return computeHash(sha1.New())
- case "RMD160":
+ case "RMD160": // TODO: remove after 2021Q4
return computeHash(ripemd160.New())
+ case "BLAKE2s":
+ blake, err := blake2s.New256(nil)
+ assertNil(err, "blake2s")
+ return computeHash(blake)
case "SHA512":
return computeHash(sha512.New())
default:
@@ -447,7 +458,9 @@ func (info *distinfoFileInfo) algorithms() string {
func (info *distinfoFileInfo) hasDistfileAlgorithms() bool {
h := info.hashes
- if len(h) == 4 && // TODO: remove as of 2021Q3
+ // TODO: remove after 2021Q4. Until then, allow pkgsrc-wip to
+ // be used with the stable 2021Q3.
+ if G.Wip && len(h) == 4 &&
h[0].algorithm == "SHA1" &&
h[1].algorithm == "RMD160" &&
h[2].algorithm == "SHA512" &&
@@ -455,7 +468,7 @@ func (info *distinfoFileInfo) hasDistfileAlgorithms() bool {
return true
}
return len(h) == 3 &&
- h[0].algorithm == "RMD160" &&
+ h[0].algorithm == "BLAKE2s" &&
h[1].algorithm == "SHA512" &&
h[2].algorithm == "Size"
}
diff --git a/pkgtools/pkglint/files/distinfo_test.go b/pkgtools/pkglint/files/distinfo_test.go
index a8a835715d9..acf3fff82ce 100644
--- a/pkgtools/pkglint/files/distinfo_test.go
+++ b/pkgtools/pkglint/files/distinfo_test.go
@@ -31,7 +31,7 @@ func (s *Suite) Test_CheckLinesDistinfo__parse_errors(c *check.C) {
"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 RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got MD5, SHA1.",
+ "ERROR: distinfo:3: Expected BLAKE2s, 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\".")
}
@@ -238,20 +238,16 @@ func (s *Suite) Test_distinfoLinesChecker_checkFilename(c *check.C) {
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (ok-1.0.tar.gz) = 1234",
- "RMD160 (ok-1.0.tar.gz) = 1234",
+ "BLAKE2s (ok-1.0.tar.gz) = 1234",
"SHA512 (ok-1.0.tar.gz) = 1234",
"Size (ok-1.0.tar.gz) = 1234",
- "SHA1 (not-ok.tar.gz) = 1234",
- "RMD160 (not-ok.tar.gz) = 1234",
+ "BLAKE2s (not-ok.tar.gz) = 1234",
"SHA512 (not-ok.tar.gz) = 1234",
"Size (not-ok.tar.gz) = 1234",
- "SHA1 (non-versioned/not-ok.tar.gz) = 1234",
- "RMD160 (non-versioned/not-ok.tar.gz) = 1234",
+ "BLAKE2s (non-versioned/not-ok.tar.gz) = 1234",
"SHA512 (non-versioned/not-ok.tar.gz) = 1234",
"Size (non-versioned/not-ok.tar.gz) = 1234",
- "SHA1 (versioned-1/ok.tar.gz) = 1234",
- "RMD160 (versioned-1/ok.tar.gz) = 1234",
+ "BLAKE2s (versioned-1/ok.tar.gz) = 1234",
"SHA512 (versioned-1/ok.tar.gz) = 1234",
"Size (versioned-1/ok.tar.gz) = 1234")
t.Chdir("category/package")
@@ -260,9 +256,9 @@ func (s *Suite) Test_distinfoLinesChecker_checkFilename(c *check.C) {
G.Check(".")
t.CheckOutputLines(
- "WARN: distinfo:7: Distfiles without version number "+
+ "WARN: distinfo:6: Distfiles without version number "+
"should be placed in a versioned DIST_SUBDIR.",
- "WARN: distinfo:11: Distfiles without version number "+
+ "WARN: distinfo:9: Distfiles without version number "+
"should be placed in a versioned DIST_SUBDIR.")
}
@@ -283,7 +279,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__nonexistent_distfile_
// a patch, it is a normal distfile because it has other hash algorithms
// than exactly SHA1.
t.CheckOutputLines(
- "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums " +
+ "ERROR: distinfo:3: Expected BLAKE2s, SHA512, Size checksums " +
"for \"patch-5.3.tar.gz\", got MD5, SHA1.")
}
@@ -300,7 +296,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__wrong_distfile_algori
CheckLinesDistinfo(nil, lines)
t.CheckOutputLines(
- "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums " +
+ "ERROR: distinfo:3: Expected BLAKE2s, SHA512, Size checksums " +
"for \"distfile.tar.gz\", got MD5, SHA1.")
}
@@ -326,7 +322,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__ambiguous_distfile(c
"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 RMD160, SHA512, Size.",
+ "\tchecksum algorithms BLAKE2s, SHA512, Size.",
"",
"\tPatch files from pkgsrc must have only the SHA1 hash.",
"")
@@ -360,8 +356,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__missing_patch_with_di
lines := t.SetUpFileLines("distinfo",
CvsID,
"",
- "SHA1 (patch-aa) = ...",
- "RMD160 (patch-aa) = ...",
+ "BLAKE2s (patch-aa) = ...",
"SHA512 (patch-aa) = ...",
"Size (patch-aa) = ... bytes")
@@ -369,7 +364,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__missing_patch_with_di
// The file name certainly looks like a pkgsrc patch, but there
// is no corresponding file in the file system, and there is no
- // current package to correctly determine the PATCHDIR. Therefore
+ // current package to correctly determine the PATCHDIR. Therefore,
// pkglint doesn't know whether this is a distfile or a missing
// patch file and doesn't warn at all.
t.CheckOutputEmpty()
@@ -382,8 +377,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__existing_patch_with_d
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (patch-aa) = ...",
- "RMD160 (patch-aa) = ...",
+ "BLAKE2s (patch-aa) = ...",
"SHA512 (patch-aa) = ...",
"Size (patch-aa) = ... bytes")
t.CreateFileDummyPatch("category/package/patches/patch-aa")
@@ -398,11 +392,8 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__existing_patch_with_d
// that the distinfo lines clearly refer to that patch file and not
// to a distfile.
t.CheckOutputLines(
- "ERROR: ~/category/package/distinfo:3: "+
- "Expected SHA1 hash for patch-aa, got SHA1, RMD160, SHA512, Size.",
- "ERROR: ~/category/package/distinfo:3: "+
- "SHA1 hash of patches/patch-aa differs (distinfo has ..., "+
- "patch file has 9a93207561abfef7e7550598c5a08f2c3226995b).")
+ "ERROR: ~/category/package/distinfo:3: " +
+ "Expected SHA1 hash for patch-aa, got BLAKE2s, SHA512, Size.")
}
func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__missing_patch_with_wrong_algorithms(c *check.C) {
@@ -412,7 +403,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__missing_patch_with_wr
t.SetUpFileLines("category/package/distinfo",
CvsID,
"",
- "RMD160 (patch-aa) = ...")
+ "BLAKE2s (patch-aa) = ...")
t.FinishSetUp()
G.Check(t.File("category/package"))
@@ -422,7 +413,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__missing_patch_with_wr
// therefore it requires the usual distfile checksum algorithms here.
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: " +
- "Expected RMD160, SHA512, Size checksums for \"patch-aa\", got RMD160.")
+ "Expected BLAKE2s, SHA512, Size checksums for \"patch-aa\", got BLAKE2s.")
}
// When there is at least one correct hash for a distfile and the distfile
@@ -436,21 +427,21 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__add_missing_h
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
+ "BLAKE2s (package-1.0.txt) = ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59",
"Size (package-1.0.txt) = 13 bytes",
"CRC32 (package-1.0.txt) = asdf")
t.CreateFileLines("distfiles/package-1.0.txt",
"hello, world")
t.FinishSetUp()
- // This run is only used to verify that the RMD160 hash is correct, and if
+ // This run is only used to verify that the BLAKE2s hash is correct, and if
// it should ever differ, the correct hash will appear in an error message.
G.Check(t.File("category/package"))
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
- "got RMD160, Size, CRC32.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", "+
+ "got BLAKE2s, Size, CRC32.",
"ERROR: ~/category/package/distinfo:3: Missing SHA512 hash for package-1.0.txt.")
t.SetUpCommandLine("-Wall", "--autofix", "--show-autofix", "--source")
@@ -466,7 +457,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__add_missing_h
"Inserting a line \"SHA512 (package-1.0.txt) "+
"= f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f"+
"268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c\" below this line.",
- ">\tRMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
+ ">\tBLAKE2s (package-1.0.txt) = ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59",
"+\tSHA512 (package-1.0.txt) = f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f"+
"268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c")
@@ -476,8 +467,8 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__add_missing_h
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: " +
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
- "got RMD160, SHA512, Size, CRC32.")
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", " +
+ "got BLAKE2s, SHA512, Size, CRC32.")
}
// When some of the hashes for a distfile are missing, pkglint can calculate
@@ -494,7 +485,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__add_missing_h
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
+ "BLAKE2s (package-1.0.txt) = ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59",
"Size (package-1.0.txt) = 13 bytes",
"CRC32 (package-1.0.txt) = asdf")
t.FinishSetUp()
@@ -503,8 +494,8 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__add_missing_h
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
- "got RMD160, Size, CRC32.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", "+
+ "got BLAKE2s, Size, CRC32.",
"",
"\tTo add the missing lines to the distinfo file, run",
"\t\t"+confMake+" distinfo",
@@ -538,7 +529,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__wrong_distfil
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "RMD160 (package-1.0.txt) = 1234wrongHash1234")
+ "BLAKE2s (package-1.0.txt) = 1234wrongHash1234")
t.CreateFileLines("distfiles/package-1.0.txt",
"hello, world")
t.FinishSetUp()
@@ -547,11 +538,11 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__wrong_distfil
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
- "got RMD160.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", "+
+ "got BLAKE2s.",
"ERROR: ~/category/package/distinfo:3: "+
- "The RMD160 checksum for \"package-1.0.txt\" is 1234wrongHash1234 in distinfo, "+
- "1a88147a0344137404c63f3b695366eab869a98a in ../../distfiles/package-1.0.txt.")
+ "The BLAKE2s checksum for \"package-1.0.txt\" is 1234wrongHash1234 in distinfo, "+
+ "ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59 in ../../distfiles/package-1.0.txt.")
}
func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__no_usual_algorithm(c *check.C) {
@@ -570,11 +561,11 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__no_usual_algo
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: " +
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", " +
"got MD5.")
}
-func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__top_algorithms_missing(c *check.C) {
+func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__top_algorithm_missing(c *check.C) {
t := s.Init(c)
t.SetUpPackage("category/package")
@@ -592,9 +583,9 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__top_algorithm
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", "+
"got SHA512, Size.",
- "ERROR: ~/category/package/distinfo:3: Missing RMD160 hash for package-1.0.txt.")
+ "ERROR: ~/category/package/distinfo:3: Missing BLAKE2s hash for package-1.0.txt.")
}
func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__bottom_algorithms_missing(c *check.C) {
@@ -604,8 +595,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__bottom_algori
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (package-1.0.txt) = cd50d19784897085a8d0e3e413f8612b097c03f1",
- "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a")
+ "BLAKE2s (package-1.0.txt) = ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59")
t.CreateFileLines("distfiles/package-1.0.txt",
"hello, world")
t.FinishSetUp()
@@ -614,8 +604,8 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__bottom_algori
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", "+
- "got SHA1, RMD160.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", "+
+ "got BLAKE2s.",
"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.")
@@ -627,9 +617,9 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__bottom_algori
"AUTOFIX: ~/category/package/distinfo:3: "+
"Inserting a line \"SHA512 (package-1.0.txt) = f65f341b35981fda842b"+
"09b2c8af9bcdb7602a4c2e6fa1f7d41f0974d3e3122f268fc79d5a4af66358f513"+
- "3885cd1c165c916f80ab25e5d8d95db46f803c782c\" above this line.",
+ "3885cd1c165c916f80ab25e5d8d95db46f803c782c\" below this line.",
"AUTOFIX: ~/category/package/distinfo:3: "+
- "Inserting a line \"Size (package-1.0.txt) = 13 bytes\" above this line.")
+ "Inserting a line \"Size (package-1.0.txt) = 13 bytes\" below this line.")
}
func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__algorithms_in_wrong_order(c *check.C) {
@@ -639,32 +629,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__algorithms_in
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
- "Size (package-1.0.txt) = 13 bytes",
- "SHA512 (package-1.0.txt) = f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7"+
- "d41f0974d3e3122f268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c")
-
- t.CreateFileLines("distfiles/package-1.0.txt",
- "hello, world")
- t.FinishSetUp()
-
- G.Check(t.File("category/package"))
-
- // This case doesn't happen in practice, therefore there's no autofix for it.
- t.CheckOutputLines(
- "ERROR: ~/category/package/distinfo:3: " +
- "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) {
- t := s.Init(c)
-
- t.SetUpPackage("category/package")
- t.CreateFileLines("category/package/distinfo",
- CvsID,
- "",
- "RMD160 (package-1.0.txt) = 1a88147a0344137404c63f3b695366eab869a98a",
+ "BLAKE2s (package-1.0.txt) = ee494623e60caeda840ed7de4fb70db4a36bc92b445b09f12b9ed46094e9bd59",
"Size (package-1.0.txt) = 13 bytes",
"SHA512 (package-1.0.txt) = f65f341b35981fda842b09b2c8af9bcdb7602a4c2e6fa1f7"+
"d41f0974d3e3122f268fc79d5a4af66358f5133885cd1c165c916f80ab25e5d8d95db46f803c782c")
@@ -678,8 +643,8 @@ func (s *Suite) Test_distinfoLinesChecker_checkAlgorithmsDistfile__some_algorith
// This case doesn't happen in practice, therefore there's no autofix for it.
t.CheckOutputLines(
"ERROR: ~/category/package/distinfo:3: " +
- "Expected RMD160, SHA512, Size checksums for \"package-1.0.txt\", " +
- "got RMD160, Size, SHA512.")
+ "Expected BLAKE2s, SHA512, Size checksums for \"package-1.0.txt\", " +
+ "got BLAKE2s, Size, SHA512.")
}
func (s *Suite) Test_distinfoLinesChecker_checkUnrecordedPatches(c *check.C) {
@@ -693,8 +658,7 @@ func (s *Suite) Test_distinfoLinesChecker_checkUnrecordedPatches(c *check.C) {
t.SetUpFileLines("distinfo",
CvsID,
"",
- "SHA1 (distfile.tar.gz) = ...",
- "RMD160 (distfile.tar.gz) = ...",
+ "BLAKE2s (distfile.tar.gz) = ...",
"SHA512 (distfile.tar.gz) = ...",
"Size (distfile.tar.gz) = 1024 bytes")
t.FinishSetUp()
@@ -751,21 +715,21 @@ func (s *Suite) Test_distinfoLinesChecker_checkGlobalDistfileMismatch(c *check.C
t.CheckOutputLines(
"ERROR: ~/category/package1/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
"ERROR: ~/category/package1/distinfo:4: "+
- "Expected RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
"ERROR: ~/category/package1/distinfo:5: "+
- "Expected RMD160, SHA512, Size checksums for \"patch-4.2.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"patch-4.2.tar.gz\", got SHA512.",
"ERROR: ~/category/package2/distinfo:3: "+
- "Expected RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, 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 RMD160, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, SHA512, Size checksums for \"distfile-1.1.tar.gz\", got SHA512.",
"ERROR: ~/category/package2/distinfo:5: "+
- "Expected RMD160, SHA512, Size checksums for \"encoding-error.tar.gz\", got SHA512.",
+ "Expected BLAKE2s, 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.",
@@ -931,7 +895,7 @@ func (s *Suite) Test_distinfoFileInfo_hasDistfileAlgorithms__code_coverage(c *ch
CvsID,
"",
"other (dist-a.tar.gz) = 1234",
- "RMD160 (dist-a.tar.gz) = 1234",
+ "BLAKE2s (dist-a.tar.gz) = 1234",
"SHA512 (dist-a.tar.gz) = 1234",
"Size (dist-a.tar.gz) = 1234",
@@ -941,12 +905,12 @@ func (s *Suite) Test_distinfoFileInfo_hasDistfileAlgorithms__code_coverage(c *ch
"Size (dist-b.tar.gz) = 1234",
"SHA1 (dist-c.tar.gz) = 1234",
- "RMD160 (dist-c.tar.gz) = 1234",
+ "BLAKE2s (dist-c.tar.gz) = 1234",
"other (dist-c.tar.gz) = 1234",
"Size (dist-c.tar.gz) = 1234",
"SHA1 (dist-d.tar.gz) = 1234",
- "RMD160 (dist-d.tar.gz) = 1234",
+ "BLAKE2s (dist-d.tar.gz) = 1234",
"SHA512 (dist-d.tar.gz) = 1234",
"other (dist-d.tar.gz) = 1234")
t.Chdir("category/package")
@@ -955,14 +919,14 @@ func (s *Suite) Test_distinfoFileInfo_hasDistfileAlgorithms__code_coverage(c *ch
G.Check(".")
t.CheckOutputLines(
- "ERROR: distinfo:3: Expected RMD160, SHA512, Size checksums for "+
- "\"dist-a.tar.gz\", got other, RMD160, SHA512, Size.",
- "ERROR: distinfo:7: Expected RMD160, SHA512, Size checksums for "+
+ "ERROR: distinfo:3: Expected BLAKE2s, SHA512, Size checksums for "+
+ "\"dist-a.tar.gz\", got other, BLAKE2s, SHA512, Size.",
+ "ERROR: distinfo:7: Expected BLAKE2s, SHA512, Size checksums for "+
"\"dist-b.tar.gz\", got SHA1, other, SHA512, Size.",
- "ERROR: distinfo:11: Expected RMD160, SHA512, Size checksums for "+
- "\"dist-c.tar.gz\", got SHA1, RMD160, other, Size.",
- "ERROR: distinfo:15: Expected RMD160, SHA512, Size checksums for "+
- "\"dist-d.tar.gz\", got SHA1, RMD160, SHA512, other.")
+ "ERROR: distinfo:11: Expected BLAKE2s, SHA512, Size checksums for "+
+ "\"dist-c.tar.gz\", got SHA1, BLAKE2s, other, Size.",
+ "ERROR: distinfo:15: Expected BLAKE2s, SHA512, Size checksums for "+
+ "\"dist-d.tar.gz\", got SHA1, BLAKE2s, SHA512, other.")
}
func (s *Suite) Test_computePatchSha1Hex(c *check.C) {
diff --git a/pkgtools/pkglint/files/homepage.go b/pkgtools/pkglint/files/homepage.go
index a9385b3a963..c92bf713a07 100644
--- a/pkgtools/pkglint/files/homepage.go
+++ b/pkgtools/pkglint/files/homepage.go
@@ -338,19 +338,13 @@ func (*HomepageChecker) hasAnySuffix(s string, suffixes ...string) bool {
func (*HomepageChecker) classifyNetworkError(err error) string {
cause := err
- for {
- // Unwrap was added in Go 1.13.
- // See https://github.com/golang/go/issues/36781
- if unwrap, ok := cause.(interface{ Unwrap() error }); ok {
- cause = unwrap.Unwrap()
- continue
- }
- break
+again:
+ if wrapper, ok := cause.(interface{ Unwrap() error }); ok {
+ cause = wrapper.Unwrap()
+ goto again
}
- // DNSError.IsNotFound was added in Go 1.13.
- // See https://github.com/golang/go/issues/28635
- if cause, ok := cause.(*net.DNSError); ok && cause.Err == "no such host" {
+ if cause, ok := cause.(*net.DNSError); ok && cause.IsNotFound {
return "name not found"
}
diff --git a/pkgtools/pkglint/files/package_test.go b/pkgtools/pkglint/files/package_test.go
index 9bf058483da..b8fdb2dce13 100644
--- a/pkgtools/pkglint/files/package_test.go
+++ b/pkgtools/pkglint/files/package_test.go
@@ -567,8 +567,7 @@ func (s *Suite) Test_Package_loadPackageMakefile__dump(c *check.C) {
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (distfile-1.0.tar.gz) = 12341234...",
- "RMD160 (distfile-1.0.tar.gz) = 12341234...",
+ "BLAKE2s (distfile-1.0.tar.gz) = 12341234...",
"SHA512 (distfile-1.0.tar.gz) = 12341234...",
"Size (distfile-1.0.tar.gz) = 12341234...")
t.CreateFileLines("category/package/Makefile",
@@ -1397,12 +1396,10 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_conditional_DIST
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (ok-3.tar.gz) = 1234",
- "RMD160 (ok-3.tar.gz) = 1234",
+ "BLAKE2s (ok-3.tar.gz) = 1234",
"SHA512 (ok-3.tar.gz) = 1234",
"Size (ok-3.tar.gz) = 1234",
- "SHA1 (package-1.0.tar.gz) = 1234",
- "RMD160 (package-1.0.tar.gz) = 1234",
+ "BLAKE2s (package-1.0.tar.gz) = 1234",
"SHA512 (package-1.0.tar.gz) = 1234",
"Size (package-1.0.tar.gz) = 1234")
t.Chdir("category/package")
@@ -1425,19 +1422,17 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__unresolvable(c *check.C)
".include \"../../mk/bsd.prefs.mk\"",
"",
".if ${MACHINE_ARCH} == i386",
- "DISTFILES+=\t${UNKNOWN}",
+ "DISTFILES+=\t${UNKNOWN} missing-i386-1.0.tar.gz",
".endif",
"",
- "DISTFILES+=\tok-3.tar.gz")
+ "DISTFILES+=\tok-3.tar.gz missing-all-1.0.tar.gz")
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (ok-3.tar.gz) = 1234",
- "RMD160 (ok-3.tar.gz) = 1234",
+ "BLAKE2s (ok-3.tar.gz) = 1234",
"SHA512 (ok-3.tar.gz) = 1234",
"Size (ok-3.tar.gz) = 1234",
- "SHA1 (package-1.0.tar.gz) = 1234",
- "RMD160 (package-1.0.tar.gz) = 1234",
+ "BLAKE2s (package-1.0.tar.gz) = 1234",
"SHA512 (package-1.0.tar.gz) = 1234",
"Size (package-1.0.tar.gz) = 1234")
t.Chdir("category/package")
@@ -1445,8 +1440,15 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__unresolvable(c *check.C)
G.Check(".")
+ // DISTFILES refers to the missing variable UNKNOWN. Therefore, pkglint
+ // skips that part of the variable. It still checks all other files that
+ // are listed somewhere in DISTFILES.
t.CheckOutputLines(
- "WARN: Makefile:23: UNKNOWN is used but not defined.")
+ "WARN: Makefile:23: UNKNOWN is used but not defined.",
+ "WARN: Makefile:23: Distfile \"missing-i386-1.0.tar.gz\" "+
+ "is not mentioned in distinfo.",
+ "WARN: Makefile:26: Distfile \"missing-all-1.0.tar.gz\" "+
+ "is not mentioned in distinfo.")
}
func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_DIST_SUBDIR(c *check.C) {
@@ -1467,11 +1469,11 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_DIST_SUBDIR(c *c
CvsID,
"",
"SHA1 (package-1.0/distfile-other.tar.gz) = 1234",
- "RMD160 (package-1.0/distfile-other.tar.gz) = 1234",
+ "BLAKE2s (package-1.0/distfile-other.tar.gz) = 1234",
"SHA512 (package-1.0/distfile-other.tar.gz) = 1234",
"Size (package-1.0/distfile-other.tar.gz) = 1234",
"SHA1 (package-1.0/package-1.0.tar.gz) = 1234",
- "RMD160 (package-1.0/package-1.0.tar.gz) = 1234",
+ "BLAKE2s (package-1.0/package-1.0.tar.gz) = 1234",
"SHA512 (package-1.0/package-1.0.tar.gz) = 1234",
"Size (package-1.0/package-1.0.tar.gz) = 1234")
t.Chdir("category/package")
@@ -1499,8 +1501,7 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__depending_on_package_sett
t.CreateFileLines("print/tex-varisize/distinfo",
CvsID,
"",
- "SHA1 (tex-varisize-15878/varisize.tar.xz) = 1234",
- "RMD160 (tex-varisize-15878/varisize.tar.xz) = 1234",
+ "BLAKE2s (tex-varisize-15878/varisize.tar.xz) = 1234",
"SHA512 (tex-varisize-15878/varisize.tar.xz) = 1234",
"Size (tex-varisize-15878/varisize.tar.xz) = 3176 bytes")
t.CreateFileLines("print/texlive/package.mk",
@@ -1554,8 +1555,7 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__no_distfiles(c *check.C)
t.CreateFileLines("category/package/distinfo",
CvsID,
"",
- "SHA1 (distfile-1.0.tar.gz) = 1234",
- "RMD160 (distfile-1.0.tar.gz) = 1234",
+ "BLAKE2s (distfile-1.0.tar.gz) = 1234",
"SHA512 (distfile-1.0.tar.gz) = 1234",
"Size (distfile-1.0.tar.gz) = 1234 bytes")
t.Chdir("category/package")
@@ -1563,7 +1563,7 @@ func (s *Suite) Test_Package_checkDistfilesInDistinfo__no_distfiles(c *check.C)
G.Check(".")
- // For completely empty distinfo files, the check is skipped.
+ // For completely empty DISTFILES, the check is skipped.
t.CheckOutputLines(
"WARN: distinfo: This file should not exist.")
}
diff --git a/pkgtools/pkglint/files/pkglint_test.go b/pkgtools/pkglint/files/pkglint_test.go
index 52d373c6763..4930d20affb 100644
--- a/pkgtools/pkglint/files/pkglint_test.go
+++ b/pkgtools/pkglint/files/pkglint_test.go
@@ -224,8 +224,7 @@ func (s *Suite) Test_Pkglint_Main__complete_package(c *check.C) {
t.CreateFileLines("sysutils/checkperms/distinfo",
CvsID,
"",
- "SHA1 (checkperms-1.12.tar.gz) = 34c084b4d06bcd7a8bba922ff57677e651eeced5",
- "RMD160 (checkperms-1.12.tar.gz) = cd95029aa930b6201e9580b3ab7e36dd30b8f925",
+ "BLAKE2s (checkperms-1.12.tar.gz) = cd95029aa930b6201e9580b3ab7e36dd30b8f925",
"SHA512 (checkperms-1.12.tar.gz) = "+
"43e37b5963c63fdf716acdb470928d7e21a7bdfddd6c85cf626a11acc7f45fa5"+
"2a53d4bcd83d543150328fe8cec5587987d2d9a7c5f0aaeb02ac1127ab41f8ae",
@@ -242,7 +241,7 @@ func (s *Suite) Test_Pkglint_Main__complete_package(c *check.C) {
"This package should be updated to 1.13 (supports more file formats; see ../../doc/TODO:5).",
"ERROR: ~/sysutils/checkperms/Makefile:4: Invalid category \"tools\".",
"ERROR: ~/sysutils/checkperms/TODO: Packages in main pkgsrc must not have a TODO file.",
- "ERROR: ~/sysutils/checkperms/distinfo:7: SHA1 hash of patches/patch-checkperms.c differs "+
+ "ERROR: ~/sysutils/checkperms/distinfo:6: SHA1 hash of patches/patch-checkperms.c differs "+
"(distinfo has asdfasdf, patch file has bcfb79696cb6bf4d2222a6d78a530e11bf1c0cea).",
"WARN: ~/sysutils/checkperms/patches/patch-checkperms.c:12: Premature end of patch hunk "+
"(expected 1 lines to be deleted and 0 lines to be added).",