Source-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 20.1.10



details:   https://anonhg.NetBSD.org/pkgsrc/rev/32e46e701af9
branches:  trunk
changeset: 432695:32e46e701af9
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun May 24 19:12:29 2020 +0000

description:
pkgtools/pkglint: update to 20.1.10

Changes since 20.1.8:

Recognize SUBST_NOOP_OK and SUBST_SHOW_DIFF.

Allow plain -Wl,-R and -Wl,-rpath in BUILDLINK_TRANSFORM, when they are
used to remove compiler options.

Recognize ggrep and other platform tools as valid tool names.  Seen in
lang/rust.

diffstat:

 pkgtools/pkglint/Makefile                    |   4 +-
 pkgtools/pkglint/files/distinfo.go           |   4 +-
 pkgtools/pkglint/files/distinfo_test.go      |  44 ++++++++++++++++++++++++++++
 pkgtools/pkglint/files/mklinechecker.go      |  10 +++++-
 pkgtools/pkglint/files/mklinechecker_test.go |  14 ++++++++
 pkgtools/pkglint/files/path_test.go          |   2 +
 pkgtools/pkglint/files/pkgsrc.go             |   6 +++
 pkgtools/pkglint/files/pkgsrc_test.go        |   3 +
 pkgtools/pkglint/files/substcontext.go       |  11 +++++-
 pkgtools/pkglint/files/substcontext_test.go  |  27 +++++++++++++++++
 pkgtools/pkglint/files/util_test.go          |   8 +++-
 pkgtools/pkglint/files/vardefs.go            |  13 +++++--
 12 files changed, 133 insertions(+), 13 deletions(-)

diffs (truncated from 312 to 300 lines):

diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sun May 24 19:12:29 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.648 2020/05/24 09:35:12 rillig Exp $
+# $NetBSD: Makefile,v 1.649 2020/05/24 19:12:29 rillig Exp $
 
-PKGNAME=       pkglint-20.1.8
+PKGNAME=       pkglint-20.1.10
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sun May 24 19:12:29 2020 +0000
@@ -6,7 +6,7 @@
        "crypto/sha512"
        "encoding/hex"
        "golang.org/x/crypto/ripemd160"
-       "hash"
+       hashpkg "hash"
        "io"
        "strings"
 )
@@ -243,7 +243,7 @@
                return
        }
 
-       computeHash := func(hasher hash.Hash) string {
+       computeHash := func(hasher hashpkg.Hash) string {
                f, err := distfile.Open()
                assertNil(err, "Opening distfile")
 
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Sun May 24 19:12:29 2020 +0000
@@ -849,3 +849,47 @@
        t.CheckOutputLines(
                "ERROR: ~/category/package/distinfo:5: Patch patch-nonexistent does not exist.")
 }
+
+// The check for versioned distfiles only makes sense if the file
+// has the usual hashes for distfiles.
+func (s *Suite) Test_distinfoFileInfo_hasDistfileAlgorithms__code_coverage(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("category/package")
+       t.CreateFileLines("category/package/distinfo",
+               CvsID,
+               "",
+               "other (dist-a.tar.gz) = 1234",
+               "RMD160 (dist-a.tar.gz) = 1234",
+               "SHA512 (dist-a.tar.gz) = 1234",
+               "Size (dist-a.tar.gz) = 1234",
+
+               "SHA1 (dist-b.tar.gz) = 1234",
+               "other (dist-b.tar.gz) = 1234",
+               "SHA512 (dist-b.tar.gz) = 1234",
+               "Size (dist-b.tar.gz) = 1234",
+
+               "SHA1 (dist-c.tar.gz) = 1234",
+               "RMD160 (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",
+               "SHA512 (dist-d.tar.gz) = 1234",
+               "other (dist-d.tar.gz) = 1234")
+       t.Chdir("category/package")
+       t.FinishSetUp()
+
+       G.Check(".")
+
+       t.CheckOutputLines(
+               "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for "+
+                       "\"dist-a.tar.gz\", got other, RMD160, SHA512, Size.",
+               "ERROR: distinfo:7: Expected SHA1, RMD160, SHA512, Size checksums for "+
+                       "\"dist-b.tar.gz\", got SHA1, other, SHA512, Size.",
+               "ERROR: distinfo:11: Expected SHA1, RMD160, SHA512, Size checksums for "+
+                       "\"dist-c.tar.gz\", got SHA1, RMD160, other, Size.",
+               "ERROR: distinfo:15: Expected SHA1, RMD160, SHA512, Size checksums for "+
+                       "\"dist-d.tar.gz\", got SHA1, RMD160, SHA512, other.")
+}
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go   Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go   Sun May 24 19:12:29 2020 +0000
@@ -110,8 +110,16 @@
 //
 // Note: A simple -R is not detected, as the rate of false positives is too high.
 func (ck MkLineChecker) checkTextRpath(text string) {
+       mkline := ck.MkLine
+
+       if mkline.IsVarassign() && mkline.Varname() == "BUILDLINK_TRANSFORM" &&
+               hasPrefix(mkline.Value(), "rm:") {
+
+               return
+       }
+
        if m, flag := match1(text, `(-Wl,--rpath,|-Wl,-rpath-link,|-Wl,-rpath,|-Wl,-R\b)`); m {
-               ck.MkLine.Warnf("Please use ${COMPILER_RPATH_FLAG} instead of %q.", flag)
+               mkline.Warnf("Please use ${COMPILER_RPATH_FLAG} instead of %q.", flag)
        }
 }
 
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/mklinechecker_test.go
--- a/pkgtools/pkglint/files/mklinechecker_test.go      Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/mklinechecker_test.go      Sun May 24 19:12:29 2020 +0000
@@ -172,6 +172,20 @@
                "WARN: ~/module.mk:3: WRKSRC is used but not defined.")
 }
 
+// In general, -Wl,-R should not appear in package Makefiles.
+// BUILDLINK_TRANSFORM is an exception to this since this command line option
+// is removed here from the compiler invocations.
+func (s *Suite) Test_MkLineChecker_checkTextRpath(c *check.C) {
+       t := s.Init(c)
+
+       t.NewMkLines("filename.mk",
+               MkCvsID,
+               "BUILDLINK_TRANSFORM+=\trm:-Wl,-R/usr/lib",
+               "BUILDLINK_TRANSFORM+=\trm:-Wl,-rpath,/usr/lib")
+
+       t.CheckOutputEmpty()
+}
+
 func (s *Suite) Test_MkLineChecker_checkVartype__simple_type(c *check.C) {
        t := s.Init(c)
 
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/path_test.go
--- a/pkgtools/pkglint/files/path_test.go       Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/path_test.go       Sun May 24 19:12:29 2020 +0000
@@ -489,6 +489,8 @@
        test("/a", true)
        test("C:/", true)
        test("c:/", true)
+       test("c::", false)
+       test("c:relative", false)
 }
 
 func (s *Suite) Test_Path_Rel(c *check.C) {
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go  Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go  Sun May 24 19:12:29 2020 +0000
@@ -544,6 +544,12 @@
                scope.IsRelevant = func(*MkLine) bool { return false }
                scope.Check(mklines)
                scopes[opsys] = scope
+
+               mklines.ForEach(func(mkline *MkLine) {
+                       if mkline.IsVarassign() && hasPrefix(mkline.Varname(), "TOOLS_PLATFORM.") {
+                               src.Tools.Define(mkline.Varparam(), "", mkline)
+                       }
+               })
        }
 
        // 0 = undefined, 1 = conditional, 2 = definitely assigned
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/pkgsrc_test.go
--- a/pkgtools/pkglint/files/pkgsrc_test.go     Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/pkgsrc_test.go     Sun May 24 19:12:29 2020 +0000
@@ -705,6 +705,8 @@
                "USE_TOOLS+=\tm4:pkgsrc")
        t.CreateFileLines("mk/bsd.pkg.mk",
                "USE_TOOLS+=\tmv")
+       t.CreateFileLines("mk/tools/tools.NetBSD.mk",
+               "TOOLS_PLATFORM.ggrep=\t/usr/bin/grep")
 
        G.Pkgsrc.loadTools()
 
@@ -721,6 +723,7 @@
                "TRACE: 1   tool echo -n:ECHO_N:var:AfterPrefsMk",
                "TRACE: 1   tool false:FALSE:var:AtRunTime",
                "TRACE: 1   tool gawk:AWK::Nowhere",
+               "TRACE: 1   tool ggrep:::Nowhere",
                "TRACE: 1   tool m4:::AfterPrefsMk",
                "TRACE: 1   tool msgfmt:::AtRunTime",
                "TRACE: 1   tool mv:MV::AtRunTime",
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/substcontext.go
--- a/pkgtools/pkglint/files/substcontext.go    Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/substcontext.go    Sun May 24 19:12:29 2020 +0000
@@ -218,6 +218,8 @@
 }
 
 func (*SubstContext) isForeign(varcanon string) bool {
+       // keep in sync with substBlock.varassign
+
        switch varcanon {
        case
                "SUBST_STAGE.*",
@@ -225,7 +227,10 @@
                "SUBST_FILES.*",
                "SUBST_SED.*",
                "SUBST_VARS.*",
-               "SUBST_FILTER_CMD.*":
+               "SUBST_FILTER_CMD.*",
+               "SUBST_SKIP_TEXT_CHECK.*", // TODO: remove this from subst.mk (unneeded)
+               "SUBST_SHOW_DIFF.*",       // TODO: remove this from subst.mk (unneeded)
+               "SUBST_NOOP_OK.*":
                return false
        }
        return true
@@ -399,6 +404,8 @@
 }
 
 func (b *substBlock) varassign(mkline *MkLine, pkg *Package) {
+       // keep in sync with SubstBlock.isForeign
+
        switch mkline.Varcanon() {
        case "SUBST_STAGE.*":
                b.varassignStage(mkline, pkg)
@@ -410,7 +417,7 @@
                b.varassignSed(mkline)
        case "SUBST_VARS.*":
                b.varassignVars(mkline)
-       default:
+       case "SUBST_FILTER_CMD.*":
                b.varassignFilterCmd(mkline)
        }
 }
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/substcontext_test.go
--- a/pkgtools/pkglint/files/substcontext_test.go       Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/substcontext_test.go       Sun May 24 19:12:29 2020 +0000
@@ -254,6 +254,33 @@
                        "Please add only one class at a time to SUBST_CLASSES.")
 }
 
+func (s *Suite) Test_SubstContext_varassign__noop_ok(c *check.C) {
+       t := s.Init(c)
+
+       t.RunSubst(
+               "SUBST_CLASSES+=         id",
+               "SUBST_STAGE.id=         post-configure",
+               "SUBST_FILES.id=         setup.py",
+               "SUBST_VARS.id=          VAR",
+               "SUBST_NOOP_OK.id=       yes")
+
+       t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_SubstContext_varassign__other_variables(c *check.C) {
+       t := s.Init(c)
+
+       t.RunSubst(
+               "SUBST_CLASSES+=         id",
+               "SUBST_STAGE.id=         post-configure",
+               "SUBST_FILES.id=         setup.py",
+               "SUBST_VARS.id=          VAR",
+               "SUBST_SKIP_TEXT_CHECK.id= yes",
+               "SUBST_SHOW_DIFF.id=     yes")
+
+       t.CheckOutputEmpty()
+}
+
 func (s *Suite) Test_SubstContext_varassignClasses__OPSYSVARS(c *check.C) {
        t := s.Init(c)
 
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/util_test.go
--- a/pkgtools/pkglint/files/util_test.go       Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/util_test.go       Sun May 24 19:12:29 2020 +0000
@@ -715,11 +715,15 @@
                ".include \"Makefile.common\"",
                "PLIST_VARS+=\ttwo",
                "PLIST.two=\tyes")
-       t.CreateFileLines("category/package/Makefile.common",
+       t.Chdir("category/package")
+       t.CreateFileLines("PLIST",
+               PlistCvsID,
+               "${PLIST.one}${PLIST.two}bin/program")
+       t.CreateFileLines("Makefile.common",
                MkCvsID,
                "PLIST_VARS=\tone",
                "PLIST.one=\tyes")
-       pkg := NewPackage(t.File("category/package"))
+       pkg := NewPackage(".")
        t.FinishSetUp()
 
        pkg.Check()
diff -r 83f23aa3c664 -r 32e46e701af9 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Sun May 24 16:58:43 2020 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Sun May 24 19:12:29 2020 +0000
@@ -1334,7 +1334,7 @@
        reg.syslist("MISSING_FEATURES", BtIdentifierDirect)
        reg.pkglist("MYSQL_VERSIONS_ACCEPTED", mysqlVersions)
        reg.usr("MYSQL_VERSION_DEFAULT", BtVersion)
-       reg.sys("NATIVE_CC", BtShellCommand) // See mk/platform/tools.NetBSD.mk (and some others).
+       reg.sys("NATIVE_CC", BtShellCommand) // See mk/tools/tools.NetBSD.mk (and some others).
        reg.sys("NM", BtShellCommand)
        reg.sys("NONBINMODE", BtFileMode)
        reg.pkglistrat("NOT_FOR_COMPILER", compilers)
@@ -1660,14 +1660,19 @@
                PackageSettable,
                "Makefile: append")
 
+       reg.usr("SUBST_NOOP_OK", BtYesNo)
+       reg.usr("SUBST_SHOW_DIFF", BtYesNo)
        reg.pkglistbl3("SUBST_CLASSES", BtIdentifierDirect)
        reg.pkglistbl3("SUBST_CLASSES.*", BtIdentifierDirect) // OPSYS-specific
-       reg.pkglistbl3("SUBST_FILES.*", BtWrksrcPathPattern)
-       reg.pkgbl3("SUBST_FILTER_CMD.*", BtShellCommand)
+       reg.pkgbl3("SUBST_STAGE.*", BtStage)



Home | Main Index | Thread Index | Old Index