diff options
author | rillig <rillig@pkgsrc.org> | 2022-07-09 06:40:54 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2022-07-09 06:40:54 +0000 |
commit | f8291cd8edd297d1913ddc7a691bcc961cccdb4d (patch) | |
tree | 8a2c6f57f97dbba978cb27df418b27b023d06477 /pkgtools/pkglint | |
parent | 67ed0d6d87e008df302d804a59230f51557d644f (diff) | |
download | pkgsrc-f8291cd8edd297d1913ddc7a691bcc961cccdb4d.tar.gz |
pkgtools/pkglint: update to 22.2.2
Changes since 22.2.1:
Require the current checksum algorithms for pkgsrc-wip packages as well.
SHA1 and RMD160 are no longer allowed for distfiles.
Do not warn about 'Package should not' when checking .mk files in the
pkgsrc infrastructure.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/distinfo.go | 24 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkassignchecker.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkcondchecker.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkparser.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkparser_test.go | 24 |
6 files changed, 34 insertions, 28 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index b331a426c2b..5aa946467bb 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.720 2022/07/06 06:14:24 rillig Exp $ +# $NetBSD: Makefile,v 1.721 2022/07/09 06:40:54 rillig Exp $ -PKGNAME= pkglint-22.2.1 +PKGNAME= pkglint-22.2.2 CATEGORIES= pkgtools DISTNAME= tools MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} diff --git a/pkgtools/pkglint/files/distinfo.go b/pkgtools/pkglint/files/distinfo.go index 94ecc4e22a3..0b9d86de967 100644 --- a/pkgtools/pkglint/files/distinfo.go +++ b/pkgtools/pkglint/files/distinfo.go @@ -6,7 +6,6 @@ import ( "crypto/sha512" "encoding/hex" "golang.org/x/crypto/blake2s" - "golang.org/x/crypto/ripemd160" hashpkg "hash" "io" "strings" @@ -149,18 +148,6 @@ func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) { return 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, 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 } switch { @@ -277,8 +264,6 @@ func (ck *distinfoLinesChecker) checkAlgorithmsDistfile(info distinfoFileInfo) { switch alg { case "SHA1": return computeHash(sha1.New()) - case "RMD160": // TODO: remove after 2021Q4 - return computeHash(ripemd160.New()) case "BLAKE2s": blake, err := blake2s.New256(nil) assertNil(err, "blake2s") @@ -462,15 +447,6 @@ func (info *distinfoFileInfo) algorithms() string { func (info *distinfoFileInfo) hasDistfileAlgorithms() bool { h := info.hashes - // 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" && - h[3].algorithm == "Size" { - return true - } return len(h) == 3 && h[0].algorithm == "BLAKE2s" && h[1].algorithm == "SHA512" && diff --git a/pkgtools/pkglint/files/mkassignchecker.go b/pkgtools/pkglint/files/mkassignchecker.go index ea6d07c2900..3023f3a48b4 100644 --- a/pkgtools/pkglint/files/mkassignchecker.go +++ b/pkgtools/pkglint/files/mkassignchecker.go @@ -199,6 +199,10 @@ func (ck *MkAssignChecker) checkLeftUserSettable() bool { } switch { + case G.Infrastructure: + // No warnings, as the usage patterns between the packages + // and the pkgsrc infrastructure differ a lot. + case mkline.HasComment(): // Assume that the comment contains a rationale for disabling // this particular check. diff --git a/pkgtools/pkglint/files/mkcondchecker.go b/pkgtools/pkglint/files/mkcondchecker.go index b652df90ac8..2273816a796 100644 --- a/pkgtools/pkglint/files/mkcondchecker.go +++ b/pkgtools/pkglint/files/mkcondchecker.go @@ -246,10 +246,12 @@ func (ck *MkCondChecker) simplify(varuse *MkVarUse, fromEmpty bool, neg bool) { // Replace empty(VAR:M*.c) with !${VAR:M*.c}. if fromEmpty && positive && !exact && vartype != nil && isDefined() && // Restrict replacements to very simple patterns with only few - // special characters. + // special characters, for now. // Before generalizing this to arbitrary strings, there has to be // a proper code generator for these conditions that handles all // possible escaping. + // The same reasoning applies to the variable name, even though the + // variable name typically only uses a restricted character set. matches(varuse.Mod(), `^[*.:\w]+$`) { fixedPart := varname + modsExceptLast + ":M" + pattern diff --git a/pkgtools/pkglint/files/mkparser.go b/pkgtools/pkglint/files/mkparser.go index 9d5e5687349..8d965342bf0 100644 --- a/pkgtools/pkglint/files/mkparser.go +++ b/pkgtools/pkglint/files/mkparser.go @@ -437,8 +437,10 @@ func ToVarUse(str string) *MkVarUse { // // The representation is somewhere between syntactic and semantic. // Unnecessary parentheses are omitted in this representation, +// (TODO: double-check; the 'paren(paren(paren()))' tests contradict) // but !empty(VARNAME) is represented differently from ${VARNAME} != "". // For higher level analysis, a unified representation might be better. +// See MkParser.MkCond. type MkCond struct { Or []*MkCond And []*MkCond diff --git a/pkgtools/pkglint/files/mkparser_test.go b/pkgtools/pkglint/files/mkparser_test.go index 21fa06910a9..b9edf458bb6 100644 --- a/pkgtools/pkglint/files/mkparser_test.go +++ b/pkgtools/pkglint/files/mkparser_test.go @@ -1,6 +1,7 @@ package pkglint import ( + "encoding/json" "gopkg.in/check.v1" "strings" ) @@ -40,13 +41,22 @@ func (s *Suite) Test_MkParser_MkCond(c *check.C) { defined := func(varname string) *MkCond { return &MkCond{Defined: varname} } paren := func(cond *MkCond) *MkCond { return &MkCond{Paren: cond} } + toJSON := func(obj interface{}) string { + var sb strings.Builder + encoder := json.NewEncoder(&sb) + encoder.SetIndent("", " ") + err := encoder.Encode(obj) + t.AssertNil(err) + return sb.String() + } + testRest := func(input string, expectedTree *MkCond, expectedRest string) { // As of July 2019 p.MkCond does not emit warnings; // this is left to MkCondChecker.Check. line := t.NewLine("filename.mk", 1, ".if "+input) p := NewMkParser(line, input) actualTree := p.MkCond() - t.CheckDeepEquals(actualTree, expectedTree) + t.CheckDeepEquals(toJSON(actualTree), toJSON(expectedTree)) t.CheckEquals(p.Rest(), expectedRest) } test := func(input string, expectedTree *MkCond) { @@ -187,6 +197,18 @@ func (s *Suite) Test_MkParser_MkCond(c *check.C) { test("target(do-build)", call("target", "do-build")) + test("(!defined(VAR))", + paren(not(defined("VAR")))) + + test("(((((!defined(VAR))))))", + paren(paren(paren(paren(paren(not(defined("VAR")))))))) + + test("(${VAR} == \"value\")", + paren(cmp(cvar("VAR"), "==", cstr("value")))) + + test("(((((${VAR} == \"value\")))))", + paren(paren(paren(paren(paren(cmp(cvar("VAR"), "==", cstr("value")))))))) + // TODO: ok "${q}text${q} == ${VAR}" // TODO: fail "text${q} == ${VAR}" // TODO: ok "${VAR} == ${q}text${q}" |