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.3.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2845f4faceef
branches:  trunk
changeset: 349415:2845f4faceef
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jul 07 12:09:26 2016 +0000

description:
Updated pkglint to 5.4.3.

Changes since 5.4.2:

* Variables like ${VAR_${OTHER_VAR}} are no longer checked for
  use/define mismatch
* The check for plural variable names has been removed
* The type of variables called *DESTDIR is no longer guessed to be a
  directory name
* The check for unknown shell commands is disabled in Makefile
  sections that depend on OPSYS
* The experimental hand-written shell parser has been replaced with
  a Yacc-generated one
* Meta packages don't need a LICENSE
* When PKGNAME is defined in terms of ${DISTNAME:S/from/to/:tl}, more
  modifiers (like :tl) are handled properly
* When the MAINTAINER or OWNER of a package is not the current user,
  a warning is printed for modified files
* The check for share/applications/*.desktop has been disabled, since
  pkglint would need to inspect the file's actual contents to see
  whether desktopdb.mk must be included or not
* SUBST_CLASSES may also be SUBST_CLASSES.NetBSD
* Loosened the usage restrictions for several variables, e.g. many
  variables that may be appended in a Makefile may also be set
  unconditionally
* PKG_OPTIONS_VAR must be of the form PKG_OPTIONS.*

diffstat:

 pkgtools/pkglint/Makefile                   |    9 +-
 pkgtools/pkglint/files/check_test.go        |    8 +-
 pkgtools/pkglint/files/globaldata.go        |    3 +
 pkgtools/pkglint/files/licenses.go          |    5 +
 pkgtools/pkglint/files/mkline.go            |   71 +--
 pkgtools/pkglint/files/mkline_test.go       |   52 +-
 pkgtools/pkglint/files/mklines_test.go      |   53 +
 pkgtools/pkglint/files/mkparser.go          |    7 +-
 pkgtools/pkglint/files/mkparser_test.go     |    2 +-
 pkgtools/pkglint/files/mkshparser.go        |  817 ++++++---------------------
 pkgtools/pkglint/files/mkshparser_test.go   |  767 +++++++++++++++++--------
 pkgtools/pkglint/files/mkshtypes.go         |  162 +---
 pkgtools/pkglint/files/mkshwalker.go        |  153 +++++
 pkgtools/pkglint/files/mkshwalker_test.go   |   32 +
 pkgtools/pkglint/files/mktypes_test.go      |    6 +
 pkgtools/pkglint/files/package.go           |   96 ++-
 pkgtools/pkglint/files/package_test.go      |   16 +
 pkgtools/pkglint/files/pkglint.go           |    5 +-
 pkgtools/pkglint/files/plist.go             |    3 +-
 pkgtools/pkglint/files/plist_test.go        |    3 +
 pkgtools/pkglint/files/shell.go             |  583 ++++++++-----------
 pkgtools/pkglint/files/shell.y              |  422 ++++++++++++++
 pkgtools/pkglint/files/shell_test.go        |  100 ++-
 pkgtools/pkglint/files/shtokenizer.go       |   62 ++-
 pkgtools/pkglint/files/shtokenizer_test.go  |   25 +-
 pkgtools/pkglint/files/shtypes.go           |   16 +-
 pkgtools/pkglint/files/substcontext.go      |    4 +-
 pkgtools/pkglint/files/substcontext_test.go |   17 +
 pkgtools/pkglint/files/util.go              |   38 +-
 pkgtools/pkglint/files/util_test.go         |   26 +-
 pkgtools/pkglint/files/vardefs.go           |   73 +-
 pkgtools/pkglint/files/vartypecheck.go      |    5 +
 pkgtools/pkglint/files/vartypecheck_test.go |    6 +-
 pkgtools/pkglint/files/vercmp_test.go       |   51 +-
 34 files changed, 2177 insertions(+), 1521 deletions(-)

diffs (truncated from 4865 to 300 lines):

diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/Makefile Thu Jul 07 12:09:26 2016 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.487 2016/06/19 18:03:29 wiz Exp $
+# $NetBSD: Makefile,v 1.488 2016/07/07 12:09:26 rillig Exp $
 
-PKGNAME=       pkglint-5.4.2
+PKGNAME=       pkglint-5.4.3
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
@@ -25,7 +25,10 @@
 
 do-extract:
        ${RUN} mkdir -p ${WRKDIR}/pkglint/plist-clash
-       ${RUN} cd ${FILESDIR} && ${PAX} -rw *.go */*.go pkglint.[01] ${WRKDIR}/pkglint
+       ${RUN} cd ${FILESDIR} && ${PAX} -rw *.go *.y */*.go pkglint.[01] ${WRKDIR}/pkglint
+
+pre-build:
+       ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg go generate ${GO_BUILD_PATTERN}
 
 do-install: do-install-man
 
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Thu Jul 07 12:09:26 2016 +0000
@@ -75,12 +75,18 @@
        return NewMkLines(s.NewLines(fname, lines...))
 }
 
-func (s *Suite) DebugToStdout() {
+func (s *Suite) BeginDebugToStdout() {
        G.debugOut = os.Stdout
        G.logOut = os.Stdout
        G.opts.Debug = true
 }
 
+func (s *Suite) EndDebugToStdout() {
+       G.debugOut = &s.stdout
+       G.logOut = &s.stdout
+       G.opts.Debug = false
+}
+
 func (s *Suite) UseCommandLine(c *check.C, args ...string) {
        exitcode := new(Pkglint).ParseCommandLine(append([]string{"pkglint"}, args...))
        if exitcode != nil && *exitcode != 0 {
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/globaldata.go
--- a/pkgtools/pkglint/files/globaldata.go      Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/globaldata.go      Thu Jul 07 12:09:26 2016 +0000
@@ -516,6 +516,9 @@
 
                // January 2016
                "SUBST_POSTCMD.*": "Has been removed, as it seemed unused.",
+
+               // June 2016
+               "USE_CROSSBASE": "Has been removed.",
        }
 }
 
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/licenses.go
--- a/pkgtools/pkglint/files/licenses.go        Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/licenses.go        Thu Jul 07 12:09:26 2016 +0000
@@ -56,6 +56,11 @@
                        "no-redistribution",
                        "shareware":
                        line.Warn1("License %q is deprecated.", license)
+                       Explain(
+                               "Instead of using these deprecated licenses, extract the actual",
+                               "license from the package into the pkgsrc/licenses/ directory",
+                               "and define LICENSE to that file name.  See the pkgsrc guide,",
+                               "keyword LICENSE, for more information.")
                }
        }
 }
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Thu Jul 07 12:09:26 2016 +0000
@@ -430,7 +430,7 @@
                (vartype == nil || vartype.guessed) &&
                !varIsUsed(varname) &&
                !(G.Mk != nil && G.Mk.forVars[varname]) &&
-               !hasPrefix(varname, "${") {
+               !containsVarRef(varname) {
                mkline.Warn1("%s is used but not defined. Spelling mistake?", varname)
        }
 
@@ -999,61 +999,6 @@
        }
 }
 
-const reVarnamePlural = `^(?:` +
-       `.*[Ss]` +
-       `|.*LIST` +
-       `|.*_AWK` +
-       `|.*_ENV` +
-       `|.*_OVERRIDE` +
-       `|.*_PREREQ` +
-       `|.*_REQD` +
-       `|.*_SED` +
-       `|.*_SKIP` +
-       `|.*_SRC` +
-       `|.*_SUBST` +
-       `|.*_TARGET` +
-       `|.*_TMPL` +
-       `|BROKEN_EXCEPT_ON_PLATFORM` +
-       `|BROKEN_ON_PLATFORM` +
-       `|BUILDLINK_DEPMETHOD` +
-       `|BUILDLINK_LDADD` +
-       `|BUILDLINK_TRANSFORM` +
-       `|COMMENT` +
-       `|CRYPTO` +
-       `|DEINSTALL_TEMPLATE` +
-       `|EVAL_PREFIX` +
-       `|EXTRACT_ONLY` +
-       `|FETCH_MESSAGE` +
-       `|FIX_RPATH` +
-       `|GENERATE_PLIST` +
-       `|INSTALL_TEMPLATE` +
-       `|INTERACTIVE_STAGE` +
-       `|LICENSE` +
-       `|MASTER_SITE_.*` +
-       `|MASTER_SORT_REGEX` +
-       `|NOT_FOR_COMPILER` +
-       `|NOT_FOR_PLATFORM` +
-       `|ONLY_FOR_COMPILER` +
-       `|ONLY_FOR_PLATFORM` +
-       `|PERL5_PACKLIST` +
-       `|PLIST_CAT` +
-       `|PLIST_PRE` +
-       `|PKG_FAIL_REASON` +
-       `|PKG_SKIP_REASON` +
-       `|PREPEND_PATH` +
-       `|PYTHON_VERSIONS_INCOMPATIBLE` +
-       `|REPLACE_INTERPRETER` +
-       `|REPLACE_PERL` +
-       `|REPLACE_RUBY` +
-       `|RESTRICTED` +
-       `|SITES_.+` +
-       `|TOOLS_ALIASES\..+` +
-       `|TOOLS_BROKEN` +
-       `|TOOLS_CREATE` +
-       `|TOOLS_GNU_MISSING` +
-       `|TOOLS_NOOP` +
-       `)$`
-
 func (mkline *MkLine) CheckVartype(varname string, op MkOperator, value, comment string) {
        if G.opts.Debug {
                defer tracecall(varname, op, value, comment)()
@@ -1063,22 +1008,16 @@
                return
        }
 
-       varbase := varnameBase(varname)
        vartype := mkline.getVariableType(varname)
 
        if op == opAssignAppend {
-               if vartype != nil {
-                       if !vartype.MayBeAppendedTo() {
-                               mkline.Warn0("The \"+=\" operator should only be used with lists.")
-                       }
-               } else if !hasPrefix(varbase, "_") && !matches(varbase, reVarnamePlural) {
-                       mkline.Warn1("As %s is modified using \"+=\", its name should indicate plural.", varname)
+               if vartype != nil && !vartype.MayBeAppendedTo() {
+                       mkline.Warn0("The \"+=\" operator should only be used with lists.")
                }
        }
 
        switch {
        case vartype == nil:
-               // Cannot check anything if the type is not known.
                if G.opts.Debug {
                        traceStep1("Unchecked variable assignment for %s.", varname)
                }
@@ -1380,7 +1319,7 @@
 )
 
 func (nq NeedsQuoting) String() string {
-       return [...]string{"no", "yes", "doesn't matter", "don't known"}[nq]
+       return [...]string{"no", "yes", "doesn't matter", "don't know"}[nq]
 }
 
 func (mkline *MkLine) variableNeedsQuoting(varname string, vartype *Vartype, vuc *VarUseContext) (needsQuoting NeedsQuoting) {
@@ -1530,7 +1469,7 @@
        switch {
        case hasSuffix(varbase, "DIRS"):
                gtype = &Vartype{lkShell, CheckvarPathmask, allowRuntime, true}
-       case hasSuffix(varbase, "DIR"), hasSuffix(varname, "_HOME"):
+       case hasSuffix(varbase, "DIR") && !hasSuffix(varbase, "DESTDIR"), hasSuffix(varname, "_HOME"):
                gtype = &Vartype{lkNone, CheckvarPathname, allowRuntime, true}
        case hasSuffix(varbase, "FILES"):
                gtype = &Vartype{lkShell, CheckvarPathmask, allowRuntime, true}
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Thu Jul 07 12:09:26 2016 +0000
@@ -292,16 +292,11 @@
 
        G.Mk = s.NewMkLines("Makefile",
                "# $"+"NetBSD$",
-               "ac_cv_libpari_libs+=\t-L${BUILDLINK_PREFIX.pari}/lib", // From math/clisp-pari/Makefile, rev. 1.8
-               "var+=value")
+               "ac_cv_libpari_libs+=\t-L${BUILDLINK_PREFIX.pari}/lib") // From math/clisp-pari/Makefile, rev. 1.8
 
        G.Mk.mklines[1].checkVarassign()
-       G.Mk.mklines[2].checkVarassign()
 
-       c.Check(s.Output(), equals, ""+
-               "WARN: Makefile:2: ac_cv_libpari_libs is defined but not used. Spelling mistake?\n"+
-               "WARN: Makefile:3: As var is modified using \"+=\", its name should indicate plural.\n"+
-               "WARN: Makefile:3: var is defined but not used. Spelling mistake?\n")
+       c.Check(s.Output(), equals, "WARN: Makefile:2: ac_cv_libpari_libs is defined but not used. Spelling mistake?\n")
 }
 
 // In variable assignments, a plain '#' introduces a line comment, unless
@@ -679,6 +674,24 @@
        c.Check(s.Output(), equals, "") // Donâ??t warn about missing :Q operators.
 }
 
+func (s *Suite) Test_MkLine_variableNeedsQuoting_tool_in_CONFIGURE_ENV(c *check.C) {
+       s.UseCommandLine(c, "-Wall")
+       G.globalData.InitVartypes()
+       G.globalData.Tools = NewToolRegistry()
+       G.globalData.Tools.RegisterVarname("tar", "TAR")
+
+       mklines := s.NewMkLines("Makefile",
+               "# $"+"NetBSD$",
+               "",
+               "CONFIGURE_ENV+=\tSYS_TAR_COMMAND_PATH=${TOOLS_TAR:Q}")
+
+       mklines.mklines[2].checkVarassignVaruse()
+
+       // The TOOLS_* variables only contain the path to the tool,
+       // without any additional arguments that might be necessary.
+       c.Check(s.Output(), equals, "NOTE: Makefile:3: The :Q operator isn't necessary for ${TOOLS_TAR} here.\n")
+}
+
 func (s *Suite) Test_MkLine_Varuse_Modifier_L(c *check.C) {
        s.UseCommandLine(c, "-Wall")
        G.globalData.InitVartypes()
@@ -771,3 +784,28 @@
 
        c.Check(s.Output(), equals, "WARN: x11/motif/Makefile:3: Unknown shell command \"${GREP}\".\n") // No parse errors.
 }
+
+// See PR 46570, Ctrl+F "3. In lang/perl5".
+func (s *Suite) Test_MkLine_getVariableType(c *check.C) {
+       mkline := NewMkLine(dummyLine)
+
+       c.Check(mkline.getVariableType("_PERL5_PACKLIST_AWK_STRIP_DESTDIR"), check.IsNil)
+       c.Check(mkline.getVariableType("SOME_DIR").guessed, equals, true)
+       c.Check(mkline.getVariableType("SOMEDIR").guessed, equals, true)
+}
+
+// See PR 46570, Ctrl+F "4. Shell quoting".
+// Pkglint is correct, since this definition for CPPFLAGS should be
+// seen by the shell as three words, not one word.
+func (s *Suite) Test_MkLine_Cflags(c *check.C) {
+       G.globalData.InitVartypes()
+       mklines := s.NewMkLines("Makefile",
+               "# $"+"NetBSD$",
+               "CPPFLAGS.SunOS+=\t-DPIPECOMMAND=\\\"/usr/sbin/sendmail -bs %s\\\"")
+
+       mklines.Check()
+
+       c.Check(s.Output(), equals, ""+
+               "WARN: Makefile:2: Unknown compiler flag \"-bs\".\n"+
+               "WARN: Makefile:2: Compiler flag \"%s\\\\\\\"\" should start with a hyphen.\n")
+}
diff -r 611a00a01b63 -r 2845f4faceef pkgtools/pkglint/files/mklines_test.go
--- a/pkgtools/pkglint/files/mklines_test.go    Thu Jul 07 12:01:22 2016 +0000
+++ b/pkgtools/pkglint/files/mklines_test.go    Thu Jul 07 12:09:26 2016 +0000
@@ -4,6 +4,8 @@
        check "gopkg.in/check.v1"
 )
 
+const mkrcsid = "# $" + "NetBSD$"
+
 func (s *Suite) TestMkLines_AutofixConditionalIndentation(c *check.C) {
        s.UseCommandLine(c, "--autofix", "-Wspace")
        tmpfile := s.CreateTmpFile(c, "fname.mk", "")
@@ -258,3 +260,54 @@
 
        c.Check(s.Output(), equals, "NOTE: Makefile:4: Consider defining NOT_FOR_PLATFORM instead of setting PKG_SKIP_REASON depending on ${OPSYS}.\n")
 }
+
+// PR 46570, item "15. net/uucp/Makefile has a make loop"
+func (s *Suite) Test_MkLines_indirect_variables(c *check.C) {
+       s.UseCommandLine(c, "-Wall")
+       mklines := s.NewMkLines("net/uucp/Makefile",
+               "# $"+"NetBSD$",
+               "",
+               "post-configure:",
+               ".for var in MAIL_PROGRAM CMDPATH",
+               "\t"+`${RUN} ${ECHO} "#define ${var} \""${UUCP_${var}}"\"`,
+               ".endfor")
+
+       mklines.Check()
+
+       // No warning about UUCP_${var} being used but not defined.
+       c.Check(s.Output(), equals, ""+



Home | Main Index | Thread Index | Old Index