pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint Updated pkglint to 5.4.25.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9eeefe72f9ef
branches:  trunk
changeset: 373594:9eeefe72f9ef
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jan 07 01:13:21 2018 +0000

description:
Updated pkglint to 5.4.25.

Changes since 5.4.24:

* More specific warning for "exitcode with pipe shell commands"
* Don't warn that the echo in "echo | sed" could fail
* Allow packages to define custom make targets
* Don't warn about a misplaced LICENSE when a package doesn't define it
* Skip .git directories
* Reduce number of hicolor-icon-theme error messages in PLIST files
* Remove MKCRYPTO, USE_CRYPTO, CRYPTO variable definitions

diffstat:

 pkgtools/pkglint/Makefile               |   4 +-
 pkgtools/pkglint/files/globaldata.go    |  14 ++++++++
 pkgtools/pkglint/files/mkline_test.go   |   6 +-
 pkgtools/pkglint/files/mklinechecker.go |  14 ++++++-
 pkgtools/pkglint/files/mklines_test.go  |  32 ++++++++++++++++++-
 pkgtools/pkglint/files/package.go       |  22 ++++++++-----
 pkgtools/pkglint/files/package_test.go  |  29 ++++++++++++++++++
 pkgtools/pkglint/files/pkglint.go       |   2 +-
 pkgtools/pkglint/files/plist.go         |  15 ++++----
 pkgtools/pkglint/files/plist_test.go    |   9 +++-
 pkgtools/pkglint/files/shell.go         |  53 ++++++++++++++++++++++++++++----
 pkgtools/pkglint/files/shell_test.go    |  37 +++++++++++++++++++++-
 pkgtools/pkglint/files/shtypes.go       |   8 ++++
 pkgtools/pkglint/files/util.go          |  29 ++++++++++++++++-
 14 files changed, 232 insertions(+), 42 deletions(-)

diffs (truncated from 521 to 300 lines):

diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jan 07 01:13:21 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.521 2018/01/02 08:13:15 maya Exp $
+# $NetBSD: Makefile,v 1.522 2018/01/07 01:13:21 rillig Exp $
 
-PKGNAME=       pkglint-5.4.24
+PKGNAME=       pkglint-5.4.25
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/globaldata.go
--- a/pkgtools/pkglint/files/globaldata.go      Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/globaldata.go      Sun Jan 07 01:13:21 2018 +0000
@@ -587,6 +587,20 @@
        }
 }
 
+func (tr *ToolRegistry) FindByCommand(cmd *ShToken) *Tool {
+       if tool := tr.byName[cmd.MkText]; tool != nil {
+               return tool
+       }
+       if len(cmd.Atoms) == 1 {
+               if varuse := cmd.Atoms[0].VarUse(); varuse != nil {
+                       if tool := tr.byVarname[varuse.varname]; tool != nil {
+                               return tool
+                       }
+               }
+       }
+       return nil
+}
+
 func (tr *ToolRegistry) Trace() {
        if trace.Tracing {
                defer trace.Call0()()
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sun Jan 07 01:13:21 2018 +0000
@@ -383,7 +383,7 @@
        MkLineChecker{G.Mk.mklines[1]}.Check()
 
        s.CheckOutputLines(
-               "WARN: Makefile:2: The exitcode of the left-hand-side command of the pipe operator is ignored.")
+               "WARN: Makefile:2: The exitcode of \"${FIND}\" at the left of the | operator is ignored.")
 }
 
 func (s *Suite) Test_MkLine_variableNeedsQuoting__word_as_part_of_word(c *check.C) {
@@ -420,8 +420,8 @@
        MkLineChecker{G.Mk.mklines[2]}.Check()
 
        s.CheckOutputLines(
-               "WARN: Makefile:2: The exitcode of the left-hand-side command of the pipe operator is ignored.",
-               "WARN: Makefile:3: The exitcode of the left-hand-side command of the pipe operator is ignored.")
+               "WARN: Makefile:2: The exitcode of the command at the left of the | operator is ignored.",
+               "WARN: Makefile:3: The exitcode of the command at the left of the | operator is ignored.")
 }
 
 // Based on mail/mailfront/Makefile.
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go   Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go   Sun Jan 07 01:13:21 2018 +0000
@@ -218,12 +218,20 @@
                } else if target == ".ORDER" {
                        // TODO: Check for spelling mistakes.
 
+               } else if hasPrefix(target, "${.CURDIR}/") {
+                       // OK, this is intentional
+
                } else if !allowedTargets[target] {
                        mkline.Warnf("Unusual target %q.", target)
                        Explain(
-                               "If you want to define your own targets, you can \"declare\"",
-                               "them by inserting a \".PHONY: my-target\" line before this line.  This",
-                               "will tell make(1) to not interpret this target's name as a filename.")
+                               "If you want to define your own target, declare it like this:",
+                               "",
+                               "\t.PHONY: my-target",
+                               "",
+                               "In the rare case that you actually want a file-based make(1)",
+                               "target, write it like this:",
+                               "",
+                               "\t${.CURDIR}/my-filename:")
                }
        }
 }
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/mklines_test.go
--- a/pkgtools/pkglint/files/mklines_test.go    Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/mklines_test.go    Sun Jan 07 01:13:21 2018 +0000
@@ -1,7 +1,7 @@
 package main
 
 import (
-       check "gopkg.in/check.v1"
+       "gopkg.in/check.v1"
 )
 
 const mkrcsid = "# $" + "NetBSD$"
@@ -188,7 +188,7 @@
        s.CheckOutputLines(
                "WARN: audio/squeezeboxserver/Makefile:3: Variable names starting with an underscore (_list_) are reserved for internal pkgsrc use.",
                "WARN: audio/squeezeboxserver/Makefile:3: Variable names starting with an underscore (_dir_) are reserved for internal pkgsrc use.",
-               "WARN: audio/squeezeboxserver/Makefile:4: The exitcode of the left-hand-side command of the pipe operator is ignored.")
+               "WARN: audio/squeezeboxserver/Makefile:4: The exitcode of \"${FIND}\" at the left of the | operator is ignored.")
 }
 
 func (s *Suite) Test_MkLines__comparing_YesNo_variable_to_string(c *check.C) {
@@ -479,3 +479,31 @@
                "ERROR: options.mk:15: Unmatched .endif.\n"+
                "NOTE: options.mk:15: This directive should be indented by 0 spaces.\n")
 }
+
+// Demonstrates how to define your own make(1) targets.
+func (s *Suite) Test_MkLines_wip_category_Makefile(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("-Wall")
+       G.globalData.InitVartypes()
+       s.RegisterTool(&Tool{Name: "rm", Varname: "RM", Predefined: true})
+       mklines := s.NewMkLines("Makefile",
+               mkrcsid,
+               "",
+               "COMMENT=\tWIP pkgsrc packages",
+               "",
+               "SUBDIR+=\taaa",
+               "SUBDIR+=\tzzz",
+               "",
+               "${.CURDIR}/PKGDB:",
+               "\t${RM} -f ${.CURDIR}/PKGDB",
+               "",
+               "${.CURDIR}/INDEX:",
+               "\t${RM} -f ${.CURDIR}/INDEX",
+               "",
+               ".include \"../../mk/misc/category.mk\"")
+
+       mklines.Check()
+
+       c.Check(s.Output(), equals, ""+
+               "ERROR: Makefile:14: \"/mk/misc/category.mk\" does not exist.\n")
+}
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/package.go Sun Jan 07 01:13:21 2018 +0000
@@ -35,6 +35,7 @@
        loadTimeTools         map[string]bool   // true=ok, false=not ok, absent=not mentioned in USE_TOOLS.
        conditionalIncludes   map[string]MkLine
        unconditionalIncludes map[string]MkLine
+       once                  Once
 }
 
 func NewPackage(pkgpath string) *Package {
@@ -398,7 +399,7 @@
                perlLine.Warnf("REPLACE_PERL is ignored when NO_CONFIGURE is set (in %s)", noconfLine.ReferenceFrom(perlLine.Line))
        }
 
-       if vardef["LICENSE"] == nil && vardef["META_PACKAGE"] == nil {
+       if vardef["LICENSE"] == nil && vardef["META_PACKAGE"] == nil && pkg.once.FirstTime("LICENSE") {
                NewLineWhole(fname).Errorf("Each package must define its LICENSE.")
        }
 
@@ -756,16 +757,19 @@
 
                default:
                        for varindex < len(vars) {
+                               varname := vars[varindex].varname
                                if vars[varindex].count == once && !maySkipSection {
-                                       line.Warnf("The canonical position for the required variable %s is here.", vars[varindex].varname)
-                                       Explain(
-                                               "In simple package Makefiles, some common variables should be",
-                                               "arranged in a specific order.",
-                                               "",
-                                               "See doc/Makefile-example or the pkgsrc guide, section",
-                                               "\"Package components\", subsection \"Makefile\" for more information.")
+                                       if varname != "LICENSE" || pkg.once.FirstTime("LICENSE") {
+                                               line.Warnf("The canonical position for the required variable %s is here.", varname)
+                                               Explain(
+                                                       "In simple package Makefiles, some common variables should be",
+                                                       "arranged in a specific order.",
+                                                       "",
+                                                       "See doc/Makefile-example or the pkgsrc guide, section",
+                                                       "\"Package components\", subsection \"Makefile\" for more information.")
+                                       }
                                }
-                               below[vars[varindex].varname] = belowWhat
+                               below[varname] = belowWhat
                                varindex++
                        }
                        nextSection = true
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go    Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/package_test.go    Sun Jan 07 01:13:21 2018 +0000
@@ -48,6 +48,35 @@
                "WARN: Makefile:6: The canonical position for the required variable LICENSE is here.")
 }
 
+func (s *Suite) Test_Package_varorder_license(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("-Worder")
+
+       s.CreateTmpFileLines("mk/bsd.pkg.mk", "# dummy")
+       s.CreateTmpFileLines("x11/Makefile", mkrcsid)
+       s.CreateTmpFileLines("x11/9term/PLIST", "@comment $"+"NetBSD$", "bin/9term")
+       s.CreateTmpFileLines("x11/9term/distinfo", "$"+"NetBSD$")
+       s.CreateTmpFileLines("x11/9term/Makefile",
+               mkrcsid,
+               "",
+               "DISTNAME=9term-1.0",
+               "CATEGORIES=x11",
+               "",
+               "COMMENT=Terminal",
+               "",
+               ".include \"../../mk/bsd.pkg.mk\"")
+
+       G.globalData.InitVartypes()
+       G.globalData.Pkgsrcdir = s.TmpDir()
+       G.CurrentDir = s.TmpDir()
+
+       (&Pkglint{}).CheckDirent(s.TmpDir() + "/x11/9term")
+
+       // Since the error is grave enough, the warning about the correct position is suppressed.
+       s.CheckOutputLines(
+               "ERROR: ~/x11/9term/Makefile: Each package must define its LICENSE.")
+}
+
 // https://mail-index.netbsd.org/tech-pkg/2017/01/18/msg017698.html
 func (s *Suite) Test_Package_ChecklinesPackageMakefileVarorder__MASTER_SITES(c *check.C) {
        s.Init(c)
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/pkglint.go
--- a/pkgtools/pkglint/files/pkglint.go Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/pkglint.go Sun Jan 07 01:13:21 2018 +0000
@@ -384,7 +384,7 @@
        switch {
        case st.Mode().IsDir():
                switch {
-               case basename == "files" || basename == "patches" || basename == "CVS":
+               case basename == "files" || basename == "patches" || isIgnoredFilename(basename):
                        // Ok
                case matches(fname, `(?:^|/)files/[^/]*$`):
                        // Ok
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/plist.go
--- a/pkgtools/pkglint/files/plist.go   Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/plist.go   Sun Jan 07 01:13:21 2018 +0000
@@ -33,15 +33,15 @@
                make(map[string]*PlistLine),
                make(map[string]*PlistLine),
                "",
-               false}
+               Once{}}
        ck.Check(lines)
 }
 
 type PlistChecker struct {
-       allFiles              map[string]*PlistLine
-       allDirs               map[string]*PlistLine
-       lastFname             string
-       warnedAboutIconThemes bool
+       allFiles  map[string]*PlistLine
+       allDirs   map[string]*PlistLine
+       lastFname string
+       once      Once
 }
 
 type PlistLine struct {
@@ -365,7 +365,7 @@
        case hasPrefix(text, "share/icons/") && G.Pkg != nil:
                if hasPrefix(text, "share/icons/hicolor/") && G.Pkg.Pkgpath != "graphics/hicolor-icon-theme" {
                        f := "../../graphics/hicolor-icon-theme/buildlink3.mk"
-                       if G.Pkg.included[f] == nil {
+                       if G.Pkg.included[f] == nil && ck.once.FirstTime("hicolor-icon-theme") {
                                line.Errorf("Packages that install hicolor icons must include %q in the Makefile.", f)
                        }
                }
@@ -380,9 +380,8 @@
                        }
                }
 
-               if !ck.warnedAboutIconThemes && contains(text[12:], "/") && G.Pkg.vardef["ICON_THEMES"] == nil {
+               if contains(text[12:], "/") && G.Pkg.vardef["ICON_THEMES"] == nil && ck.once.FirstTime("ICON_THEMES") {
                        line.Warnf("Packages that install icon theme files should set ICON_THEMES.")
-                       ck.warnedAboutIconThemes = true
                }
 
        case hasPrefix(text, "share/doc/html/"):
diff -r 0819811f085b -r 9eeefe72f9ef pkgtools/pkglint/files/plist_test.go
--- a/pkgtools/pkglint/files/plist_test.go      Sat Jan 06 21:41:08 2018 +0000
+++ b/pkgtools/pkglint/files/plist_test.go      Sun Jan 07 01:13:21 2018 +0000
@@ -23,6 +23,8 @@
                "${PLIST.obsolete}@unexec rmdir /tmp",
                "sbin/clockctl",
                "share/icons/gnome/delete-icon",
+               "share/icons/hicolor/icon1.png",
+               "share/icons/hicolor/icon2.png", // No additional warning
                "share/tzinfo",
                "share/tzinfo")
 
@@ -45,7 +47,8 @@
                "WARN: PLIST:13: Manual page missing for sbin/clockctl.",
                "ERROR: PLIST:14: The package Makefile must include \"../../graphics/gnome-icon-theme/buildlink3.mk\".",
                "WARN: PLIST:14: Packages that install icon theme files should set ICON_THEMES.",
-               "ERROR: PLIST:16: Duplicate filename \"share/tzinfo\", already appeared in line 15.")
+               "ERROR: PLIST:15: Packages that install hicolor icons must include \"../../graphics/hicolor-icon-theme/buildlink3.mk\" in the Makefile.",



Home | Main Index | Thread Index | Old Index