pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint Update pkglint to 5.5.9



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ffb46b748dd1
branches:  trunk
changeset: 306881:ffb46b748dd1
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Apr 28 23:32:52 2018 +0000
description:
Update pkglint to 5.5.9

Changes since 5.5.8:
* Improved support for the "strip" tool, which has a special definition
  and is not directly connected to the STRIP variable.
* Miscellaneous code cleanup and new tests.

diffstat:

 pkgtools/pkglint/Makefile                   |   5 +-
 pkgtools/pkglint/files/autofix.go           |   2 +
 pkgtools/pkglint/files/licenses_test.go     |  49 ++++++++++++++++++++++++++++-
 pkgtools/pkglint/files/mkline_test.go       |   4 +-
 pkgtools/pkglint/files/mklines.go           |   3 +-
 pkgtools/pkglint/files/mktypes.go           |   7 +++-
 pkgtools/pkglint/files/pkglint.go           |   6 +-
 pkgtools/pkglint/files/pkgsrc.go            |  28 +++++++--------
 pkgtools/pkglint/files/pkgsrc_test.go       |  25 ++++++++++++--
 pkgtools/pkglint/files/shell_test.go        |  26 +++++++++++++++
 pkgtools/pkglint/files/shtypes.go           |  21 +++++------
 pkgtools/pkglint/files/shtypes_test.go      |  15 ++++++++-
 pkgtools/pkglint/files/tools.go             |  44 ++++++++++++++++++-------
 pkgtools/pkglint/files/tools_test.go        |  20 +++++++++++
 pkgtools/pkglint/files/util.go              |   2 +-
 pkgtools/pkglint/files/util_test.go         |   7 ++++
 pkgtools/pkglint/files/vardefs.go           |   1 +
 pkgtools/pkglint/files/vartype.go           |   1 +
 pkgtools/pkglint/files/vartypecheck.go      |   5 +-
 pkgtools/pkglint/files/vartypecheck_test.go |  24 ++++++++++++++
 20 files changed, 237 insertions(+), 58 deletions(-)

diffs (truncated from 646 to 300 lines):

diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sat Apr 28 23:32:52 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.535 2018/04/06 21:04:22 rillig Exp $
+# $NetBSD: Makefile,v 1.536 2018/04/28 23:32:52 rillig Exp $
 
-PKGNAME=       pkglint-5.5.8
+PKGNAME=       pkglint-5.5.9
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
@@ -11,7 +11,6 @@
 CONFLICTS+=    pkglint4-[0-9]*
 
 NO_CHECKSUM=   yes
-USE_LANGUAGES= c
 USE_TOOLS+=    pax
 AUTO_MKDIRS=   yes
 GO_SRCPATH=    netbsd.org/pkglint
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sat Apr 28 23:32:52 2018 +0000
@@ -42,8 +42,10 @@
 // because of the --only option.
 //
 // The fixer function must always call Describef.
+//
 // If printAutofix or autofix is true, the fix should be done in
 // memory as far as possible (e.g. changes to the text of the line).
+//
 // If autofix is true, the fix should be done permanently
 // (e.g. direct changes to the file system).
 func (fix *Autofix) Custom(fixer func(printAutofix, autofix bool)) {
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/licenses_test.go
--- a/pkgtools/pkglint/files/licenses_test.go   Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/licenses_test.go   Sat Apr 28 23:32:52 2018 +0000
@@ -1,7 +1,7 @@
 package main
 
 import (
-       check "gopkg.in/check.v1"
+       "gopkg.in/check.v1"
 )
 
 func (s *Suite) Test_checklineLicense(c *check.C) {
@@ -44,3 +44,50 @@
 
        t.CheckOutputEmpty()
 }
+
+func (s *Suite) Test_checkToplevelUnusedLicenses(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupFileLines("mk/bsd.pkg.mk", "# dummy")
+       t.SetupFileLines("mk/fetch/sites.mk", "# dummy")
+       t.SetupFileLines("mk/defaults/options.description", "option\tdescription")
+       t.SetupFileLines("doc/TODO")
+       t.SetupFileLines("mk/defaults/mk.conf")
+       t.SetupFileLines("mk/tools/bsd.tools.mk",
+               ".include \"actual-tools.mk\"")
+       t.SetupFileLines("mk/tools/actual-tools.mk")
+       t.SetupFileLines("mk/tools/defaults.mk")
+       t.SetupFileLines("mk/bsd.prefs.mk")
+       t.SetupFileLines("mk/misc/category.mk")
+       t.SetupFileLines("licenses/2-clause-bsd")
+       t.SetupFileLines("licenses/gnu-gpl-v3")
+
+       t.SetupFileLines("Makefile",
+               MkRcsID,
+               "SUBDIR+=\tcategory")
+
+       t.SetupFileLines("category/Makefile",
+               MkRcsID,
+               "COMMENT=\tExample category",
+               "",
+               "SUBDIR+=\tpackage",
+               "",
+               ".include \"../mk/misc/category.mk\"")
+
+       t.SetupFileLines("category/package/Makefile",
+               MkRcsID,
+               "CATEGORIES=\tcategory",
+               "",
+               "COMMENT=Example package",
+               "LICENSE=\t2-clause-bsd",
+               "NO_CHECKSUM=\tyes")
+       t.SetupFileLines("category/package/PLIST",
+               PlistRcsID,
+               "bin/program")
+
+       G.Main("pkglint", "-r", "-Cglobal", t.TmpDir())
+
+       t.CheckOutputLines(
+               "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.",
+               "0 errors and 1 warning found.")
+}
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sat Apr 28 23:32:52 2018 +0000
@@ -627,7 +627,7 @@
 
        t.SetupCommandLine("-Wall")
        t.SetupVartypes()
-       G.Pkgsrc.Tools.RegisterVarname("tar", "TAR")
+       G.Pkgsrc.Tools.RegisterVarname("tar", "TAR", dummyLine)
        mklines := t.NewMkLines("Makefile",
                MkRcsID,
                "",
@@ -648,7 +648,7 @@
 
        t.SetupCommandLine("-Wall")
        t.SetupVartypes()
-       G.Pkgsrc.Tools.RegisterVarname("cat", "CAT")
+       G.Pkgsrc.Tools.RegisterVarname("cat", "CAT", dummyLine)
        mklines := t.NewMkLines("Makefile",
                MkRcsID,
                "",
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/mklines.go Sat Apr 28 23:32:52 2018 +0000
@@ -19,6 +19,7 @@
        toolRegistry   ToolRegistry    // Tools defined in file scope.
        SeenBsdPrefsMk bool
        indentation    Indentation // Indentation depth of preprocessing directives
+       // XXX: Why both tools and toolRegistry?
 }
 
 func NewMkLines(lines []Line) *MkLines {
@@ -289,7 +290,7 @@
 type varalignBlockInfo struct {
        mkline         MkLine
        varnameOp      string // Variable name + assignment operator
-       varnameOpWidth int    // Screen width of varnameOp + space
+       varnameOpWidth int    // Screen width of varnameOp
        space          string // Whitespace between varnameOp and the variable value
        totalWidth     int    // Screen width of varnameOp + space
        continuation   bool   // A continuation line with no value in the first line.
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/mktypes.go
--- a/pkgtools/pkglint/files/mktypes.go Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/mktypes.go Sat Apr 28 23:32:52 2018 +0000
@@ -11,10 +11,15 @@
 
 // MkVarUse represents a reference to a Make variable, with optional modifiers.
 //
+// For nested variable expressions, the variable name can contain references
+// to other variables. For example, ${TOOLS.${t}} is a MkVarUse with varname
+// "TOOLS.${t}" and no modifiers.
+//
 // Example: ${PKGNAME}
+//
 // Example: ${PKGNAME:S/from/to/}
 type MkVarUse struct {
-       varname   string
+       varname   string   // E.g. "PKGNAME", or "${BUILD_DEFS}"
        modifiers []string // E.g. "Q", "S/from/to/"
 }
 
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/pkglint.go
--- a/pkgtools/pkglint/files/pkglint.go Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/pkglint.go Sat Apr 28 23:32:52 2018 +0000
@@ -119,8 +119,8 @@
 }
 
 // Main runs the main program with the given arguments.
-// args[0] is the program name.
-func (pkglint *Pkglint) Main(args ...string) (exitcode int) {
+// argv[0] is the program name.
+func (pkglint *Pkglint) Main(argv ...string) (exitcode int) {
        defer func() {
                if r := recover(); r != nil {
                        if _, ok := r.(pkglintFatal); ok {
@@ -131,7 +131,7 @@
                }
        }()
 
-       if exitcode := pkglint.ParseCommandLine(args); exitcode != nil {
+       if exitcode := pkglint.ParseCommandLine(argv); exitcode != nil {
                return *exitcode
        }
 
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go  Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go  Sat Apr 28 23:32:52 2018 +0000
@@ -14,7 +14,6 @@
 type Pkgsrc = *PkgsrcImpl
 
 type PkgsrcImpl struct {
-
        // The top directory (PKGSRCDIR), either absolute or relative to
        // the current working directory.
        topdir string
@@ -145,7 +144,8 @@
 func (src *PkgsrcImpl) loadTools() {
        toolFiles := []string{"defaults.mk"}
        {
-               lines := G.Pkgsrc.LoadExistingLines("mk/tools/bsd.tools.mk", true)
+               toc := G.Pkgsrc.File("mk/tools/bsd.tools.mk")
+               lines := LoadExistingLines(toc, true)
                for _, line := range lines {
                        if m, _, _, includefile := MatchMkInclude(line.Text); m {
                                if !contains(includefile, "/") {
@@ -154,16 +154,16 @@
                        }
                }
                if len(toolFiles) <= 1 {
-                       lines[0].Fatalf("Too few tool files.")
+                       NewLine(toc, 0, "", nil).Fatalf("Too few tool files.")
                }
        }
 
        reg := src.Tools
-       reg.RegisterTool(&Tool{"echo", "ECHO", true, true, true})
-       reg.RegisterTool(&Tool{"echo -n", "ECHO_N", true, true, true})
-       reg.RegisterTool(&Tool{"false", "FALSE", true /*why?*/, true, false})
-       reg.RegisterTool(&Tool{"test", "TEST", true, true, true})
-       reg.RegisterTool(&Tool{"true", "TRUE", true /*why?*/, true, true})
+       reg.RegisterTool(&Tool{"echo", "ECHO", true, true, true}, dummyLine)
+       reg.RegisterTool(&Tool{"echo -n", "ECHO_N", true, true, true}, dummyLine)
+       reg.RegisterTool(&Tool{"false", "FALSE", true /*why?*/, true, false}, dummyLine)
+       reg.RegisterTool(&Tool{"test", "TEST", true, true, true}, dummyLine)
+       reg.RegisterTool(&Tool{"true", "TRUE", true /*why?*/, true, true}, dummyLine)
 
        for _, basename := range toolFiles {
                lines := G.Pkgsrc.LoadExistingLines("mk/tools/"+basename, true)
@@ -190,11 +190,10 @@
                                        if condDepth == 0 || condDepth == 1 && relativeName == "mk/bsd.prefs.mk" {
                                                for _, toolname := range splitOnSpace(value) {
                                                        if !containsVarRef(toolname) {
-                                                               for _, tool := range [...]*Tool{reg.Register(toolname), reg.Register("TOOLS_" + toolname)} {
-                                                                       tool.Predefined = true
-                                                                       if relativeName == "mk/bsd.prefs.mk" {
-                                                                               tool.UsableAtLoadtime = true
-                                                                       }
+                                                               tool := reg.Register(toolname, line)
+                                                               tool.Predefined = true
+                                                               if relativeName == "mk/bsd.prefs.mk" {
+                                                                       tool.UsableAtLoadtime = true
                                                                }
                                                        }
                                                }
@@ -357,7 +356,6 @@
 
 func (src *PkgsrcImpl) initDeprecatedVars() {
        src.Deprecated = map[string]string{
-
                // December 2003
                "FIX_RPATH": "It has been removed from pkgsrc in 2003.",
 
@@ -519,7 +517,7 @@
 
 // LoadExistingLines loads the file relative to the pkgsrc top directory.
 func (src *PkgsrcImpl) LoadExistingLines(fileName string, joinBackslashLines bool) []Line {
-       return LoadExistingLines(src.topdir+"/"+fileName, joinBackslashLines)
+       return LoadExistingLines(src.File(fileName), joinBackslashLines)
 }
 
 // File resolves a file name relative to the pkgsrc top directory.
diff -r a6f0514d4add -r ffb46b748dd1 pkgtools/pkglint/files/pkgsrc_test.go
--- a/pkgtools/pkglint/files/pkgsrc_test.go     Sat Apr 28 20:19:09 2018 +0000
+++ b/pkgtools/pkglint/files/pkgsrc_test.go     Sat Apr 28 23:32:52 2018 +0000
@@ -66,7 +66,9 @@
 
        t.SetupFileLines("mk/tools/bsd.tools.mk",
                ".include \"flex.mk\"",
-               ".include \"gettext.mk\"")
+               ".include \"gettext.mk\"",
+               ".include \"strip.mk\"",
+               ".include \"replace.mk\"")
        t.SetupFileLines("mk/tools/defaults.mk",
                "_TOOLS_VARNAME.chown=CHOWN",
                "_TOOLS_VARNAME.gawk=AWK",
@@ -77,8 +79,21 @@
        t.SetupFileLines("mk/tools/gettext.mk",
                "USE_TOOLS+=msgfmt",
                "TOOLS_CREATE+=msgfmt")
+       t.SetupFileLines("mk/tools/strip.mk",
+               ".if defined(_INSTALL_UNSTRIPPED) || !defined(TOOLS_PLATFORM.strip)",
+               "TOOLS_NOOP+=            strip",
+               ".else",
+               "TOOLS_CREATE+=          strip",
+               "TOOLS_PATH.strip=       ${TOOLS_PLATFORM.strip}",
+               ".endif",
+               "STRIP?=         strip")
+       t.SetupFileLines("mk/tools/replace.mk",
+               "_TOOLS.bzip2=\tbzip2 bzcat",
+               "#TOOLS_CREATE+=commented out",
+               "_UNRELATED_VAR=\t# empty")
        t.SetupFileLines("mk/bsd.prefs.mk",
-               "USE_TOOLS+=\tpwd")
+               "USE_TOOLS+=\tpwd",
+               "USE_TOOLS+=\tm4:pkgsrc")
        t.SetupFileLines("mk/bsd.pkg.mk",
                "USE_TOOLS+=\tmv")
        G.CurrentDir = t.TmpDir()
@@ -91,16 +106,18 @@
 
        t.CheckOutputLines(
                "TRACE: + (*ToolRegistry).Trace()",
-               "TRACE: 1   tool &{Name:TOOLS_mv Varname: MustUseVarForm:false Predefined:true UsableAtLoadtime:false}",



Home | Main Index | Thread Index | Old Index