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 19.4.12



details:   https://anonhg.NetBSD.org/pkgsrc/rev/336723eab3d3
branches:  trunk
changeset: 425045:336723eab3d3
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Mar 18 08:24:49 2020 +0000

description:
pkgtools/pkglint: update to 19.4.12

Changes since 19.4.11:

Redundant additions to BUILDLINK_API_DEPENDS and BUILDLINK_ABI_DEPENDS
get warnings since they may have been needed in the past but the
dependent package has increased its required version numbers over time.

diffstat:

 pkgtools/pkglint/Makefile                      |    4 +-
 pkgtools/pkglint/files/buildlink3.go           |   69 +++++++-
 pkgtools/pkglint/files/buildlink3_test.go      |   32 +++-
 pkgtools/pkglint/files/check_test.go           |    3 +-
 pkgtools/pkglint/files/mkassignchecker_test.go |    4 +-
 pkgtools/pkglint/files/mklines.go              |    8 +-
 pkgtools/pkglint/files/mkvarusechecker_test.go |   50 +++--
 pkgtools/pkglint/files/options.go              |    2 +-
 pkgtools/pkglint/files/package.go              |   28 ++-
 pkgtools/pkglint/files/package_test.go         |   27 +++
 pkgtools/pkglint/files/pkglint.go              |    6 +-
 pkgtools/pkglint/files/pkglint_test.go         |   35 ++++
 pkgtools/pkglint/files/pkgsrc.go               |   12 +-
 pkgtools/pkglint/files/pkgsrc_test.go          |   13 +
 pkgtools/pkglint/files/plist.go                |   59 ++++++-
 pkgtools/pkglint/files/plist_test.go           |  136 +++++++++++++++-
 pkgtools/pkglint/files/shell.go                |    2 -
 pkgtools/pkglint/files/shell_test.go           |    7 +-
 pkgtools/pkglint/files/util.go                 |   17 +-
 pkgtools/pkglint/files/util_test.go            |   90 ++++++++++
 pkgtools/pkglint/files/vardefs.go              |  212 ++++++++++++------------
 pkgtools/pkglint/files/vardefs_test.go         |    1 +
 pkgtools/pkglint/files/vartypecheck.go         |   54 ++++++
 pkgtools/pkglint/files/vartypecheck_test.go    |   30 +++-
 24 files changed, 719 insertions(+), 182 deletions(-)

diffs (truncated from 1540 to 300 lines):

diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/Makefile Wed Mar 18 08:24:49 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.634 2020/03/15 11:31:24 rillig Exp $
+# $NetBSD: Makefile,v 1.635 2020/03/18 08:24:49 rillig Exp $
 
-PKGNAME=       pkglint-19.4.11
+PKGNAME=       pkglint-19.4.12
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Wed Mar 18 08:24:49 2020 +0000
@@ -13,8 +13,8 @@
        abi, api         *DependencyPattern
 }
 
-func NewBuildlink3Checker(mklines *MkLines) *Buildlink3Checker {
-       return &Buildlink3Checker{mklines: mklines}
+func CheckLinesBuildlink3Mk(mklines *MkLines) {
+       (&Buildlink3Checker{mklines: mklines}).Check()
 }
 
 func (ck *Buildlink3Checker) Check() {
@@ -90,6 +90,9 @@
 
        mlex.SkipEmptyOrNote()
        ck.pkgbase = pkgbase
+       if pkg := ck.mklines.pkg; pkg != nil {
+               pkg.buildlinkID = ck.pkgbase
+       }
        ck.pkgbaseLine = pkgbaseLine
        return true
 }
@@ -309,3 +312,65 @@
                        "after the specific version has been decided.")
        }
 }
+
+type Buildlink3Data struct {
+       id             Buildlink3ID
+       pkgsrcdir      PackagePath
+       apiDepends     *DependencyPattern
+       apiDependsLine *MkLine
+       abiDepends     *DependencyPattern
+       abiDependsLine *MkLine
+}
+
+// Buildlink3ID is the identifier that is used in the BUILDLINK_TREE
+// for referring to a dependent package.
+//
+// It almost uniquely identifies a package.
+// Packages that are alternatives to each other may use the same identifier.
+type Buildlink3ID string
+
+func LoadBuildlink3Data(mklines *MkLines) *Buildlink3Data {
+       assert(mklines.lines.BaseName == "buildlink3.mk")
+
+       var data Buildlink3Data
+       mklines.ForEach(func(mkline *MkLine) {
+               if mkline.IsVarassign() {
+                       varname := mkline.Varname()
+                       varbase := varnameBase(varname)
+                       varid := Buildlink3ID(varnameParam(varname))
+
+                       if varname == "BUILDLINK_TREE" {
+                               value := mkline.Value()
+                               if !hasPrefix(value, "-") {
+                                       data.id = Buildlink3ID(mkline.Value())
+                               }
+                       }
+
+                       if varbase == "BUILDLINK_API_DEPENDS" && varid == data.id {
+                               p := NewMkParser(nil, mkline.Value())
+                               dep := p.DependencyPattern()
+                               if dep != nil && p.EOF() {
+                                       data.apiDepends = dep
+                                       data.apiDependsLine = mkline
+                               }
+                       }
+
+                       if varbase == "BUILDLINK_ABI_DEPENDS" && varid == data.id {
+                               p := NewMkParser(nil, mkline.Value())
+                               dep := p.DependencyPattern()
+                               if dep != nil && p.EOF() {
+                                       data.abiDepends = dep
+                                       data.abiDependsLine = mkline
+                               }
+                       }
+
+                       if varbase == "BUILDLINK_PKGSRCDIR" && varid == data.id {
+                               data.pkgsrcdir = NewPackagePathString(mkline.Value())
+                       }
+               }
+       })
+       if data.id != "" && !data.pkgsrcdir.IsEmpty() && data.apiDepends != nil && data.abiDepends != nil {
+               return &data
+       }
+       return nil
+}
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Wed Mar 18 08:24:49 2020 +0000
@@ -2,10 +2,6 @@
 
 import "gopkg.in/check.v1"
 
-func CheckLinesBuildlink3Mk(mklines *MkLines) {
-       NewBuildlink3Checker(mklines).Check()
-}
-
 // This test ensures that CheckLinesBuildlink3Mk really checks for
 // buildlink3.mk files that are included by the buildlink3.mk file
 // but not by the package.
@@ -1066,3 +1062,31 @@
                "WARN: buildlink3.mk:3: Please replace \"${LICENSE}\" with a simple string "+
                        "(also in other variables in this file).")
 }
+
+func (s *Suite) Test_LoadBuildlink3Data(c *check.C) {
+       t := s.Init(c)
+
+       t.CreateFileBuildlink3("category/package/buildlink3.mk",
+               "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=0.1")
+       t.Chdir("category/package")
+       mklines := LoadMk("buildlink3.mk", nil, MustSucceed)
+
+       data := LoadBuildlink3Data(mklines)
+
+       t.CheckDeepEquals(data, &Buildlink3Data{
+               id:        "package",
+               pkgsrcdir: "../../category/package",
+               apiDepends: &DependencyPattern{
+                       Pkgbase: "package",
+                       LowerOp: ">=",
+                       Lower:   "0",
+               },
+               apiDependsLine: mklines.mklines[7],
+               abiDepends: &DependencyPattern{
+                       Pkgbase: "package",
+                       LowerOp: ">=",
+                       Lower:   "0.1",
+               },
+               abiDependsLine: mklines.mklines[11],
+       })
+}
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Wed Mar 18 08:24:49 2020 +0000
@@ -243,7 +243,7 @@
 
 func (t *Tester) SetUpMasterSite(varname string, urls ...string) {
        if !G.Pkgsrc.vartypes.IsDefinedExact(varname) {
-               G.Pkgsrc.vartypes.DefineParse(varname, BtFetchURL,
+               t.SetUpType(varname, BtFetchURL,
                        List|SystemProvided,
                        "buildlink3.mk: none",
                        "*: use")
@@ -613,6 +613,7 @@
                sprintf("%s_BUILDLINK3_MK:=", upperID),
                "",
                aligned("BUILDLINK_API_DEPENDS.%s+=", id)+sprintf("%s>=0", id),
+               // TODO: Add ABI_DEPENDS; see Test_LoadBuildlink3Data
                aligned("BUILDLINK_PKGSRCDIR.%s?=", id)+sprintf("../../%s", dir),
                aligned("BUILDLINK_DEPMETHOD.%s?=", id)+"build",
                "")
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/mkassignchecker_test.go
--- a/pkgtools/pkglint/files/mkassignchecker_test.go    Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker_test.go    Wed Mar 18 08:24:49 2020 +0000
@@ -427,9 +427,9 @@
 
        t.SetUpVartypes()
        t.SetUpTool("awk", "AWK", AtRunTime)
-       G.Pkgsrc.vartypes.DefineParse("SET_ONLY", BtUnknown, NoVartypeOptions,
+       t.SetUpType("SET_ONLY", BtUnknown, NoVartypeOptions,
                "options.mk: set")
-       G.Pkgsrc.vartypes.DefineParse("SET_ONLY_DEFAULT_ELSEWHERE", BtUnknown, NoVartypeOptions,
+       t.SetUpType("SET_ONLY_DEFAULT_ELSEWHERE", BtUnknown, NoVartypeOptions,
                "options.mk: set",
                "*.mk: default, set")
        mklines := t.NewMkLines("options.mk",
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/mklines.go Wed Mar 18 08:24:49 2020 +0000
@@ -248,13 +248,7 @@
 }
 
 func (mklines *MkLines) collectVariables() {
-       if trace.Tracing {
-               defer trace.Call0()()
-       }
-
-       mklines.ForEach(func(mkline *MkLine) {
-               mklines.collectVariable(mkline)
-       })
+       mklines.ForEach(mklines.collectVariable)
 }
 
 func (mklines *MkLines) collectVariable(mkline *MkLine) {
diff -r 4281da177917 -r 336723eab3d3 pkgtools/pkglint/files/mkvarusechecker_test.go
--- a/pkgtools/pkglint/files/mkvarusechecker_test.go    Wed Mar 18 07:43:15 2020 +0000
+++ b/pkgtools/pkglint/files/mkvarusechecker_test.go    Wed Mar 18 08:24:49 2020 +0000
@@ -455,9 +455,9 @@
        t := s.Init(c)
 
        t.SetUpPkgsrc()
-       G.Pkgsrc.vartypes.DefineParse("LOAD_TIME", BtPathPattern, List,
+       t.SetUpType("LOAD_TIME", BtPathPattern, List,
                "special:filename.mk: use-loadtime")
-       G.Pkgsrc.vartypes.DefineParse("RUN_TIME", BtPathPattern, List,
+       t.SetUpType("RUN_TIME", BtPathPattern, List,
                "special:filename.mk: use")
        t.Chdir(".")
        t.FinishSetUp()
@@ -479,9 +479,9 @@
        t := s.Init(c)
 
        t.SetUpPkgsrc()
-       G.Pkgsrc.vartypes.DefineParse("LOAD_TIME", BtPathPattern, List,
+       t.SetUpType("LOAD_TIME", BtPathPattern, List,
                "special:filename.mk: use-loadtime")
-       G.Pkgsrc.vartypes.DefineParse("RUN_TIME", BtPathPattern, List,
+       t.SetUpType("RUN_TIME", BtPathPattern, List,
                "special:filename.mk: use")
        t.Chdir(".")
        t.FinishSetUp()
@@ -532,16 +532,16 @@
        t := s.Init(c)
 
        t.SetUpPkgsrc()
-       G.Pkgsrc.vartypes.DefineParse("LOAD_TIME", BtUnknown, NoVartypeOptions,
+       t.SetUpType("LOAD_TIME", BtUnknown, NoVartypeOptions,
                "*.mk: use, use-loadtime")
-       G.Pkgsrc.vartypes.DefineParse("RUN_TIME", BtUnknown, NoVartypeOptions,
+       t.SetUpType("RUN_TIME", BtUnknown, NoVartypeOptions,
                "*.mk: use")
-       G.Pkgsrc.vartypes.DefineParse("WRITE_ONLY", BtUnknown, NoVartypeOptions,
+       t.SetUpType("WRITE_ONLY", BtUnknown, NoVartypeOptions,
                "*.mk: set")
-       G.Pkgsrc.vartypes.DefineParse("LOAD_TIME_ELSEWHERE", BtUnknown, NoVartypeOptions,
+       t.SetUpType("LOAD_TIME_ELSEWHERE", BtUnknown, NoVartypeOptions,
                "Makefile: use-loadtime",
                "*.mk: set")
-       G.Pkgsrc.vartypes.DefineParse("RUN_TIME_ELSEWHERE", BtUnknown, NoVartypeOptions,
+       t.SetUpType("RUN_TIME_ELSEWHERE", BtUnknown, NoVartypeOptions,
                "Makefile: use",
                "*.mk: set")
        t.Chdir(".")
@@ -637,7 +637,7 @@
 func (s *Suite) Test_MkVarUseChecker_checkPermissions__usable_only_at_loadtime_in_other_file(c *check.C) {
        t := s.Init(c)
 
-       G.Pkgsrc.vartypes.DefineParse("VAR", BtFilename, NoVartypeOptions,
+       t.SetUpType("VAR", BtFilename, NoVartypeOptions,
                "*: set, use-loadtime")
        mklines := t.NewMkLines("Makefile",
                MkCvsID,
@@ -656,9 +656,8 @@
 
        // This combination of BtUnknown and all permissions is typical for
        // otherwise unknown variables from the pkgsrc infrastructure.
-       G.Pkgsrc.vartypes.Define("INFRA", BtUnknown, NoVartypeOptions,
-               NewACLEntry("*", aclpAll))
-       G.Pkgsrc.vartypes.DefineParse("VAR", BtUnknown, NoVartypeOptions,
+       t.SetUpType("INFRA", BtUnknown, NoVartypeOptions)
+       t.SetUpType("VAR", BtUnknown, NoVartypeOptions,
                "buildlink3.mk: none",
                "*: use")
        mklines := t.NewMkLines("buildlink3.mk",
@@ -692,10 +691,10 @@
        // to use its value in LOAD_TIME, as the latter might be evaluated later
        // at load time, and at that point VAR would be evaluated as well.
 
-       G.Pkgsrc.vartypes.DefineParse("LOAD_TIME", BtMessage, NoVartypeOptions,
+       t.SetUpType("LOAD_TIME", BtMessage, NoVartypeOptions,
                "buildlink3.mk: set",
                "*.mk: use-loadtime")
-       G.Pkgsrc.vartypes.DefineParse("VAR", BtUnknown, NoVartypeOptions,
+       t.SetUpType("VAR", BtUnknown, NoVartypeOptions,
                "buildlink3.mk: none",
                "*.mk: use")
        mklines := t.NewMkLines("buildlink3.mk",
@@ -963,7 +962,8 @@
        t.SetUpVartypes()
        mklines := t.NewMkLines("filename.mk",
                "BUILTIN_FIND_FILES_VAR:=\tBIN_FILE",
-               "BUILTIN_FIND_FILES.BIN_FILE=\t${TOOLS_PLATFORM.file} /bin/file /usr/bin/file")
+               "BUILTIN_FIND_FILES.BIN_FILE=\t${TOOLS_PLATFORM.file} /bin/file /usr/bin/file",
+               "PKG_SHELL.user=\t${TOOLS_PLATFORM.false:Q}")
 
        mklines.ForEach(func(mkline *MkLine) {
                ck := NewMkAssignChecker(mkline, mklines)
@@ -971,8 +971,11 @@
        })
 
        t.CheckOutputLines(
-               "WARN: filename.mk:2: Incompatible types: " +
-                       "TOOLS_PLATFORM.file (type \"ShellCommand\") " +



Home | Main Index | Thread Index | Old Index