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 22.2.2



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ba9143837327
branches:  trunk
changeset: 381549:ba9143837327
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 09 06:40:54 2022 +0000

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

 pkgtools/pkglint/Makefile                 |   4 ++--
 pkgtools/pkglint/files/distinfo.go        |  24 ------------------------
 pkgtools/pkglint/files/mkassignchecker.go |   4 ++++
 pkgtools/pkglint/files/mkcondchecker.go   |   4 +++-
 pkgtools/pkglint/files/mkparser.go        |   2 ++
 pkgtools/pkglint/files/mkparser_test.go   |  24 +++++++++++++++++++++++-
 6 files changed, 34 insertions(+), 28 deletions(-)

diffs (166 lines):

diff -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/Makefile Sat Jul 09 06:40:54 2022 +0000
@@ -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 -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sat Jul 09 06:40:54 2022 +0000
@@ -6,7 +6,6 @@
        "crypto/sha512"
        "encoding/hex"
        "golang.org/x/crypto/blake2s"
-       "golang.org/x/crypto/ripemd160"
        hashpkg "hash"
        "io"
        "strings"
@@ -149,18 +148,6 @@
                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 @@
                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) 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 -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/files/mkassignchecker.go
--- a/pkgtools/pkglint/files/mkassignchecker.go Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker.go Sat Jul 09 06:40:54 2022 +0000
@@ -199,6 +199,10 @@
        }
 
        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 -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/files/mkcondchecker.go
--- a/pkgtools/pkglint/files/mkcondchecker.go   Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/files/mkcondchecker.go   Sat Jul 09 06:40:54 2022 +0000
@@ -246,10 +246,12 @@
        // 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 -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/files/mkparser.go
--- a/pkgtools/pkglint/files/mkparser.go        Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/files/mkparser.go        Sat Jul 09 06:40:54 2022 +0000
@@ -437,8 +437,10 @@
 //
 // 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 -r 211d7e3e23f4 -r ba9143837327 pkgtools/pkglint/files/mkparser_test.go
--- a/pkgtools/pkglint/files/mkparser_test.go   Sat Jul 09 06:33:09 2022 +0000
+++ b/pkgtools/pkglint/files/mkparser_test.go   Sat Jul 09 06:40:54 2022 +0000
@@ -1,6 +1,7 @@
 package pkglint
 
 import (
+       "encoding/json"
        "gopkg.in/check.v1"
        "strings"
 )
@@ -40,13 +41,22 @@
        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 @@
        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}"



Home | Main Index | Thread Index | Old Index