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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f612c2be402f
branches:  trunk
changeset: 373636:f612c2be402f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jan 07 17:08:15 2018 +0000

description:
Updated pkglint to 5.4.26.

Changes since 5.4.25:

* When autofixing a patch, fix the corresponding distinfo file as well.

* Properly parse ${VARNAME:[\#]};
  the # was interpreted as a comment before.

* Don't add unnecessary :Q to PKG_OPTIONS and related variables.

* Don't warn about missing manual pages. While Debian and other
  distributions do this work, pkgsrc keeps the packages as original as
  possible.

* Autofix redundant ".gz" for manual pages in PLISTs.

diffstat:

 pkgtools/pkglint/Makefile                 |   4 +-
 pkgtools/pkglint/files/buildlink3_test.go |  39 +++++++++++++++++++++++++++++++
 pkgtools/pkglint/files/distinfo.go        |  27 +++++++++++++++++---
 pkgtools/pkglint/files/mkline.go          |   9 +++---
 pkgtools/pkglint/files/mkline_test.go     |  23 ++++++++++++++++-
 pkgtools/pkglint/files/mklinechecker.go   |   3 +-
 pkgtools/pkglint/files/mklines.go         |   2 +-
 pkgtools/pkglint/files/mkparser.go        |   2 +-
 pkgtools/pkglint/files/mkparser_test.go   |   2 +
 pkgtools/pkglint/files/patches.go         |   8 +++++-
 pkgtools/pkglint/files/patches_test.go    |  28 +++++++++++++++++----
 pkgtools/pkglint/files/plist.go           |  31 +-----------------------
 pkgtools/pkglint/files/plist_test.go      |   2 -
 pkgtools/pkglint/files/vardefs.go         |  18 +++++++-------
 14 files changed, 133 insertions(+), 65 deletions(-)

diffs (truncated from 439 to 300 lines):

diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jan 07 17:08:15 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.522 2018/01/07 01:13:21 rillig Exp $
+# $NetBSD: Makefile,v 1.523 2018/01/07 17:08:15 rillig Exp $
 
-PKGNAME=       pkglint-5.4.25
+PKGNAME=       pkglint-5.4.26
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sun Jan 07 17:08:15 2018 +0000
@@ -295,3 +295,42 @@
                "WARN: buildlink3.mk:3: Please replace \"${LICENSE}\" with a simple string (also in other variables in this file).",
                "WARN: buildlink3.mk:13: This line should contain the following text: BUILDLINK_TREE+=\t-${LICENSE}-wxWidgets")
 }
+
+// Those .include lines that are not indented at all may stay as-is.
+// This special exception might have been for backwards-compatibility,
+// but ideally should be handled like everywhere else.
+// See MkLineChecker.checkInclude.
+func (s *Suite) Test_ChecklinesBuildlink3Mk_indentation(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("-Wall")
+       G.globalData.InitVartypes()
+       mklines := s.NewMkLines("buildlink3.mk",
+               mkrcsid,
+               "",
+               ".if ${VAAPI_AVAILABLE} == \"yes\"",
+               "",
+               "BUILDLINK_TREE+=       libva",
+               "",
+               ".  if !defined(LIBVA_BUILDLINK3_MK)",
+               "LIBVA_BUILDLINK3_MK:=",
+               "",
+               "BUILDLINK_API_DEPENDS.libva+=  libva>=1.0.6",
+               "BUILDLINK_PKGSRCDIR.libva?=    ../../multimedia/libva",
+               "",
+               ".include \"../../x11/libX11/buildlink3.mk\"",
+               "",
+               ".  endif       # LIBVA_BUILDLINK3_MK",
+               "",
+               "BUILDLINK_TREE+=       -libva",
+               "",
+               ".endif # VAAPI_AVAILABLE")
+
+       ChecklinesBuildlink3Mk(mklines)
+
+       // No warning about the indentation of the .include lines.
+       s.CheckOutputLines(
+               "ERROR: buildlink3.mk:11: \"/multimedia/libva\" does not exist.",
+               "ERROR: buildlink3.mk:11: There is no package in \"multimedia/libva\".",
+               "ERROR: buildlink3.mk:13: \"/x11/libX11/buildlink3.mk\" does not exist.",
+               "WARN: buildlink3.mk:3: Expected a BUILDLINK_TREE line.")
+}
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sun Jan 07 17:08:15 2018 +0000
@@ -106,11 +106,10 @@
        ck.algorithms = nil
 }
 
-func (ck *distinfoLinesChecker) checkPatchSha1(line Line, patchFname, distinfoSha1Hex string) {
-       patchBytes, err := ioutil.ReadFile(G.CurrentDir + "/" + patchFname)
+func computePatchSha1Hex(patchFilename string) (string, error) {
+       patchBytes, err := ioutil.ReadFile(patchFilename)
        if err != nil {
-               line.Errorf("%s does not exist.", patchFname)
-               return
+               return "", err
        }
 
        h := sha1.New()
@@ -120,7 +119,15 @@
                        h.Write(patchLine)
                }
        }
-       fileSha1Hex := fmt.Sprintf("%x", h.Sum(nil))
+       return fmt.Sprintf("%x", h.Sum(nil)), nil
+}
+
+func (ck *distinfoLinesChecker) checkPatchSha1(line Line, patchFname, distinfoSha1Hex string) {
+       fileSha1Hex, err := computePatchSha1Hex(G.CurrentDir + "/" + patchFname)
+       if err != nil {
+               line.Errorf("%s does not exist.", patchFname)
+               return
+       }
        if distinfoSha1Hex != fileSha1Hex {
                if !line.AutofixReplace(distinfoSha1Hex, fileSha1Hex) {
                        line.Errorf("%s hash of %s differs (distinfo has %s, patch file has %s). Run \"%s makepatchsum\".", "SHA1", patchFname, distinfoSha1Hex, fileSha1Hex, confMake)
@@ -171,3 +178,13 @@
                ck.patches[patchName] = true
        }
 }
+
+func AutofixDistinfo(oldSha1, newSha1 string) {
+       distinfoFilename := G.CurrentDir + "/" + G.Pkg.DistinfoFile
+       if lines, err := readLines(distinfoFilename, false); err == nil {
+               for _, line := range lines {
+                       line.AutofixReplace(oldSha1, newSha1)
+               }
+               SaveAutofixChanges(lines)
+       }
+}
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Sun Jan 07 17:08:15 2018 +0000
@@ -102,12 +102,13 @@
                return
        }
 
-       if index := strings.IndexByte(text, '#'); index != -1 && strings.TrimSpace(text[:index]) == "" {
+       trimmedText := strings.TrimSpace(text)
+       if strings.HasPrefix(trimmedText, "#") {
                mkline.data = mkLineComment{}
                return
        }
 
-       if strings.TrimSpace(text) == "" {
+       if trimmedText == "" {
                mkline.data = mkLineEmpty{}
                return
        }
@@ -312,7 +313,7 @@
        }
 
        argsStart := i
-       for i < n && text[i] != '#' {
+       for i < n && (text[i] != '#' || text[i-1] == '\\') {
                i++
        }
        for i > argsStart && (text[i-1] == ' ' || text[i-1] == '\t') {
@@ -322,7 +323,7 @@
 
        m = true
        indent = text[indentStart:indentEnd]
-       args = text[argsStart:argsEnd]
+       args = strings.Replace(text[argsStart:argsEnd], "\\#", "#", -1)
        return
 }
 
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sun Jan 07 17:08:15 2018 +0000
@@ -133,7 +133,7 @@
                "\tshell command # shell comment",
                "# whole line comment",
                "",
-               ".  if !empty(PKGNAME:M*-*) # cond comment",
+               ".  if !empty(PKGNAME:M*-*) && ${RUBY_RAILS_SUPPORTED:[\\#]} == 1 # cond comment",
                ".    include \"../../mk/bsd.prefs.mk\" # include comment",
                ".    include <subdir.mk> # sysinclude comment",
                "target1 target2: source1 source2",
@@ -159,7 +159,7 @@
        c.Check(ln[4].IsCond(), equals, true)
        c.Check(ln[4].Indent(), equals, "  ")
        c.Check(ln[4].Directive(), equals, "if")
-       c.Check(ln[4].Args(), equals, "!empty(PKGNAME:M*-*)")
+       c.Check(ln[4].Args(), equals, "!empty(PKGNAME:M*-*) && ${RUBY_RAILS_SUPPORTED:[#]} == 1")
 
        c.Check(ln[5].IsInclude(), equals, true)
        c.Check(ln[5].Indent(), equals, "    ")
@@ -480,6 +480,25 @@
                "WARN: x11/mlterm/Makefile:2: Please move ${LDFLAGS:M*:Q} outside of any quoting characters.")
 }
 
+// No quoting is necessary here.
+// PKG_OPTIONS are declared as "lkShell" although they are processed
+// using make's .for loop, which splits them at whitespace and usually
+// requires the variable to be declared as "lkSpace".
+// In this case it doesn't matter though since each option is an identifier,
+// and these do not pose any quoting problems.
+func (s *Suite) Test_MkLine_variableNeedsQuoting__package_options(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("-Wall")
+       G.globalData.InitVartypes()
+       G.Mk = s.NewMkLines("Makefile",
+               mkrcsid,
+               "PKG_SUGGESTED_OPTIONS+=\t${PKG_DEFAULT_OPTIONS:Mcdecimal} ${PKG_OPTIONS.py-trytond:Mcdecimal}")
+
+       MkLineChecker{G.Mk.mklines[1]}.Check()
+
+       s.CheckOutputEmpty()
+}
+
 func (s *Suite) Test_MkLines_Check__MASTER_SITE_in_HOMEPAGE(c *check.C) {
        s.Init(c)
        s.UseCommandLine("-Wall")
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go   Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go   Sun Jan 07 17:08:15 2018 +0000
@@ -92,12 +92,11 @@
        }
 }
 
-func (ck MkLineChecker) checkCond(forVars map[string]bool) {
+func (ck MkLineChecker) checkCond(forVars map[string]bool, indentation *Indentation) {
        mkline := ck.MkLine
 
        directive := mkline.Directive()
        args := mkline.Args()
-       indentation := &G.Mk.indentation
 
        switch directive {
        case "endif", "endfor":
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mklines.go Sun Jan 07 17:08:15 2018 +0000
@@ -130,7 +130,7 @@
                        }
 
                case mkline.IsCond():
-                       ck.checkCond(mklines.forVars)
+                       ck.checkCond(mklines.forVars, indentation)
 
                case mkline.IsDependency():
                        ck.checkDependencyRule(allowedTargets)
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mkparser.go
--- a/pkgtools/pkglint/files/mkparser.go        Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mkparser.go        Sun Jan 07 17:08:15 2018 +0000
@@ -171,7 +171,7 @@
                        }
 
                case '[':
-                       if repl.AdvanceRegexp(`^\[[-.\d]+\]`) {
+                       if repl.AdvanceRegexp(`^\[(?:[-.\d]+|#)\]`) {
                                modifiers = append(modifiers, repl.Since(modifierMark))
                                continue
                        }
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/mkparser_test.go
--- a/pkgtools/pkglint/files/mkparser_test.go   Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/mkparser_test.go   Sun Jan 07 17:08:15 2018 +0000
@@ -13,6 +13,7 @@
                for i, expectedToken := range expectedTokens {
                        if i < len(actualTokens) {
                                c.Check(*actualTokens[i], deepEquals, *expectedToken)
+                               c.Check(actualTokens[i].Varuse, deepEquals, expectedToken.Varuse)
                        }
                }
                c.Check(p.Rest(), equals, expectedRest)
@@ -80,6 +81,7 @@
        check("${ALT_GCC_RTS:S%${LOCALBASE}%%:S%/%%}", varuse("ALT_GCC_RTS", "S%${LOCALBASE}%%", "S%/%%"))
        check("${PREFIX:C;///*;/;g:C;/$;;}", varuse("PREFIX", "C;///*;/;g", "C;/$;;"))
        check("${GZIP_CMD:[1]:Q}", varuse("GZIP_CMD", "[1]", "Q"))
+       check("${RUBY_RAILS_SUPPORTED:[#]}", varuse("RUBY_RAILS_SUPPORTED", "[#]"))
        check("${DISTNAME:C/-[0-9]+$$//:C/_/-/}", varuse("DISTNAME", "C/-[0-9]+$$//", "C/_/-/"))
        check("${DISTNAME:slang%=slang2%}", varuse("DISTNAME", "slang%=slang2%"))
        check("${OSMAP_SUBSTVARS:@v@-e 's,\\@${v}\\@,${${v}},g' @}", varuse("OSMAP_SUBSTVARS", "@v@-e 's,\\@${v}\\@,${${v}},g' @"))
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/patches.go
--- a/pkgtools/pkglint/files/patches.go Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/patches.go Sun Jan 07 17:08:15 2018 +0000
@@ -90,7 +90,13 @@
        }
 
        ChecklinesTrailingEmptyLines(ck.lines)
-       SaveAutofixChanges(ck.lines)
+       sha1Before, err := computePatchSha1Hex(ck.lines[0].Filename)
+       if SaveAutofixChanges(ck.lines) && G.Pkg != nil && err == nil {
+               sha1After, err := computePatchSha1Hex(ck.lines[0].Filename)
+               if err == nil {
+                       AutofixDistinfo(sha1Before, sha1After)
+               }
+       }
 }
 
 // See http://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
diff -r cf0fe5f5c715 -r f612c2be402f pkgtools/pkglint/files/patches_test.go
--- a/pkgtools/pkglint/files/patches_test.go    Sun Jan 07 17:04:38 2018 +0000
+++ b/pkgtools/pkglint/files/patches_test.go    Sun Jan 07 17:08:15 2018 +0000
@@ -27,11 +27,9 @@
        s.CheckOutputEmpty()
 }
 
-func (s *Suite) Test_ChecklinesPatch__without_empty_line(c *check.C) {
+func (s *Suite) Test_ChecklinesPatch__without_empty_line__autofix(c *check.C) {
        s.Init(c)
-       fname := s.CreateTmpFile("patch-WithoutEmptyLines", "dummy")
-       s.UseCommandLine("-Wall", "--autofix")
-       lines := s.NewLines(fname,
+       patchFilename := s.CreateTmpFileLines("patch-WithoutEmptyLines",
                "$"+"NetBSD$",
                "Text",
                "--- file.orig",
@@ -41,15 +39,27 @@
                "-old line",
                "+old line",
                " context after")
+       distinfoFilename := s.CreateTmpFileLines("distinfo",
+               "$"+"NetBSD$",
+               "",
+               "SHA1 (some patch) = 87ffcaaa0b0677ec679fff612b44df1af05f04df") // Taken from breakpoint at AutofixDistinfo
+
+       s.UseCommandLine("-Wall", "--autofix")
+       lines := LoadExistingLines(patchFilename, false)
+       G.CurrentDir = s.TmpDir()
+       G.Pkg = &Package{DistinfoFile: "distinfo"}
 



Home | Main Index | Thread Index | Old Index