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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/047c34ad847f
branches:  trunk
changeset: 369952:047c34ad847f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Oct 08 22:31:13 2017 +0000

description:
Updated pkglint to 5.4.21

Changes since 5.4.20:

* Removed obsolete kde3 check
* Removed obsolete WindowMaker variables
* Removed postgresql91
* Removed teTeX
* Removed old Emacs versions 22, 23, 24
* Allow db6
* Allow c++11 in USE_LANGUAGES
* New check for GNOME icon themes
* Added CHECK_RELRO variables
* Refactoring: new package linechecks
* Refactoring: regex.Pattern

diffstat:

 pkgtools/pkglint/Makefile                             |    5 +-
 pkgtools/pkglint/files/distinfo.go                    |    3 +-
 pkgtools/pkglint/files/getopt/getopt.go               |    4 +-
 pkgtools/pkglint/files/globaldata.go                  |    2 +-
 pkgtools/pkglint/files/line.go                        |    4 +-
 pkgtools/pkglint/files/line/line.go                   |    2 +-
 pkgtools/pkglint/files/linechecks/linechecker.go      |  109 ++++++++++++++++++
 pkgtools/pkglint/files/linechecks/linechecker_test.go |   76 ++++++++++++
 pkgtools/pkglint/files/mkline_test.go                 |    1 -
 pkgtools/pkglint/files/mklinechecker.go               |   15 +-
 pkgtools/pkglint/files/mklines.go                     |    3 +-
 pkgtools/pkglint/files/mkparser.go                    |   12 +-
 pkgtools/pkglint/files/mkshtypes.go                   |    4 +-
 pkgtools/pkglint/files/package.go                     |    2 +-
 pkgtools/pkglint/files/patches.go                     |   35 +-----
 pkgtools/pkglint/files/pkglint.go                     |   15 +-
 pkgtools/pkglint/files/plist.go                       |   43 ++++--
 pkgtools/pkglint/files/plist_test.go                  |    3 +-
 pkgtools/pkglint/files/regex/regex.go                 |   30 ++--
 pkgtools/pkglint/files/shell.go                       |    3 +-
 pkgtools/pkglint/files/textproc/expecter.go           |    2 +-
 pkgtools/pkglint/files/textproc/prefixreplacer.go     |    4 +-
 pkgtools/pkglint/files/util.go                        |   16 +-
 pkgtools/pkglint/files/vardefs.go                     |    1 +
 pkgtools/pkglint/files/vartypecheck.go                |    5 +-
 25 files changed, 287 insertions(+), 112 deletions(-)

diffs (truncated from 931 to 300 lines):

diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/Makefile Sun Oct 08 22:31:13 2017 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.517 2017/07/27 11:21:25 wiz Exp $
+# $NetBSD: Makefile,v 1.518 2017/10/08 22:31:13 rillig Exp $
 
-PKGNAME=       pkglint-5.4.20
-PKGREVISION=   3
+PKGNAME=       pkglint-5.4.21
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sun Oct 08 22:31:13 2017 +0000
@@ -6,6 +6,7 @@
        "fmt"
        "io/ioutil"
        "netbsd.org/pkglint/line"
+       "netbsd.org/pkglint/linechecks"
        "netbsd.org/pkglint/trace"
        "strings"
 )
@@ -54,7 +55,7 @@
 }
 
 func (ck *distinfoLinesChecker) checkLines(lines []line.Line) {
-       LineChecker{lines[0]}.CheckRcsid(``, "")
+       linechecks.CheckRcsid(lines[0], ``, "")
        if 1 < len(lines) && lines[1].Text() != "" {
                lines[1].Notef("Empty line expected.")
        }
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/getopt/getopt.go
--- a/pkgtools/pkglint/files/getopt/getopt.go   Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/getopt/getopt.go   Sun Oct 08 22:31:13 2017 +0000
@@ -1,7 +1,7 @@
+// Package getopt provides a parser for command line options,
+// supporting multi-value options such as -Wall,no-extra.
 package getopt
 
-// Self-written getopt to support multi-argument options.
-
 import (
        "fmt"
        "io"
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/globaldata.go
--- a/pkgtools/pkglint/files/globaldata.go      Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/globaldata.go      Sun Oct 08 22:31:13 2017 +0000
@@ -67,7 +67,7 @@
        gd.loadDeprecatedVars()
 }
 
-func (gd *GlobalData) Latest(category string, re regex.RegexPattern, repl string) string {
+func (gd *GlobalData) Latest(category string, re regex.Pattern, repl string) string {
        key := category + "/" + string(re) + " => " + repl
        if latest, found := gd.latest[key]; found {
                return latest
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/line.go
--- a/pkgtools/pkglint/files/line.go    Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/line.go    Sun Oct 08 22:31:13 2017 +0000
@@ -17,6 +17,7 @@
        "fmt"
        "io"
        "netbsd.org/pkglint/line"
+       "netbsd.org/pkglint/linechecks"
        "netbsd.org/pkglint/regex"
        "path"
        "strconv"
@@ -205,7 +206,7 @@
        return false
 }
 
-func (line *LineImpl) AutofixReplaceRegexp(from regex.RegexPattern, to string) bool {
+func (line *LineImpl) AutofixReplaceRegexp(from regex.Pattern, to string) bool {
        for _, rawLine := range line.raw {
                if rawLine.Lineno != 0 {
                        if replaced := regex.Compile(from).ReplaceAllString(rawLine.textnl, to); replaced != rawLine.textnl {
@@ -242,4 +243,5 @@
 
 func init() {
        line.NewLineEOF = NewLineEOF
+       linechecks.Explain = Explain
 }
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/line/line.go
--- a/pkgtools/pkglint/files/line/line.go       Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/line/line.go       Sun Oct 08 22:31:13 2017 +0000
@@ -21,7 +21,7 @@
        ReferenceFrom(Line) string
 
        AutofixReplace(from, to string) bool
-       AutofixReplaceRegexp(from regex.RegexPattern, to string) bool
+       AutofixReplaceRegexp(from regex.Pattern, to string) bool
        AutofixInsertBefore(text string) bool
        AutofixDelete() bool
        AutofixMark(reason string)
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/linechecks/linechecker.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/linechecks/linechecker.go  Sun Oct 08 22:31:13 2017 +0000
@@ -0,0 +1,109 @@
+package linechecks
+
+import (
+       "fmt"
+       "netbsd.org/pkglint/line"
+       "netbsd.org/pkglint/regex"
+       "netbsd.org/pkglint/trace"
+       "strings"
+)
+
+var Explain func(...string)
+
+func CheckAbsolutePathname(line line.Line, text string) {
+       if trace.Tracing {
+               defer trace.Call1(text)()
+       }
+
+       // In the GNU coding standards, DESTDIR is defined as a (usually
+       // empty) prefix that can be used to install files to a different
+       // location from what they have been built for. Therefore
+       // everything following it is considered an absolute pathname.
+       //
+       // Another context where absolute pathnames usually appear is in
+       // assignments like "bindir=/bin".
+       if m, path := regex.Match1(text, `(?:^|\$[{(]DESTDIR[)}]|[\w_]+\s*=\s*)(/(?:[^"'\s]|"[^"*]"|'[^']*')*)`); m {
+               if regex.Matches(path, `^/\w`) {
+                       CheckwordAbsolutePathname(line, path)
+               }
+       }
+}
+
+func CheckLength(line line.Line, maxlength int) {
+       if len(line.Text()) > maxlength {
+               line.Warnf("Line too long (should be no more than %d characters).", maxlength)
+               Explain(
+                       "Back in the old time, terminals with 80x25 characters were common.",
+                       "And this is still the default size of many terminal emulators.",
+                       "Moderately short lines also make reading easier.")
+       }
+}
+
+func CheckValidCharacters(line line.Line, reChar regex.Pattern) {
+       rest := regex.Compile(reChar).ReplaceAllString(line.Text(), "")
+       if rest != "" {
+               uni := ""
+               for _, c := range rest {
+                       uni += fmt.Sprintf(" %U", c)
+               }
+               line.Warnf("Line contains invalid characters (%s).", uni[1:])
+       }
+}
+
+func CheckTrailingWhitespace(line line.Line) {
+       if strings.HasSuffix(line.Text(), " ") || strings.HasSuffix(line.Text(), "\t") {
+               if !line.AutofixReplaceRegexp(`\s+\n$`, "\n") {
+                       line.Notef("Trailing white-space.")
+                       Explain(
+                               "When a line ends with some white-space, that space is in most cases",
+                               "irrelevant and can be removed.")
+               }
+       }
+}
+
+func CheckRcsid(line line.Line, prefixRe regex.Pattern, suggestedPrefix string) bool {
+       if trace.Tracing {
+               defer trace.Call(prefixRe, suggestedPrefix)()
+       }
+
+       if regex.Matches(line.Text(), `^`+prefixRe+`\$`+`NetBSD(?::[^\$]+)?\$$`) {
+               return true
+       }
+
+       if !line.AutofixInsertBefore(suggestedPrefix + "$" + "NetBSD$") {
+               line.Errorf("Expected %q.", suggestedPrefix+"$"+"NetBSD$")
+               Explain(
+                       "Several files in pkgsrc must contain the CVS Id, so that their",
+                       "current version can be traced back later from a binary package.",
+                       "This is to ensure reproducible builds, for example for finding bugs.")
+       }
+       return false
+}
+
+func CheckwordAbsolutePathname(line line.Line, word string) {
+       if trace.Tracing {
+               defer trace.Call1(word)()
+       }
+
+       switch {
+       case regex.Matches(word, `^/dev/(?:null|tty|zero)$`):
+       // These are defined by POSIX.
+       case word == "/bin/sh":
+       // This is usually correct, although on Solaris, it's pretty feature-crippled.
+       case regex.Matches(word, `^/s\W`):
+       // Probably a sed(1) command
+       case regex.Matches(word, `^/(?:[a-z]|\$[({])`):
+               // Absolute paths probably start with a lowercase letter.
+               line.Warnf("Found absolute pathname: %s", word)
+               Explain(
+                       "Absolute pathnames are often an indicator for unportable code.  As",
+                       "pkgsrc aims to be a portable system, absolute pathnames should be",
+                       "avoided whenever possible.",
+                       "",
+                       "A special variable in this context is ${DESTDIR}, which is used in",
+                       "GNU projects to specify a different directory for installation than",
+                       "what the programs see later when they are executed.  Usually it is",
+                       "empty, so if anything after that variable starts with a slash, it is",
+                       "considered an absolute pathname.")
+       }
+}
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/linechecks/linechecker_test.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/linechecks/linechecker_test.go     Sun Oct 08 22:31:13 2017 +0000
@@ -0,0 +1,76 @@
+package linechecks
+
+// Note: These tests are currently not run, since the dependencies
+// between the Go packages are not yet resolved properly.
+
+import (
+       "gopkg.in/check.v1"
+       "netbsd.org/pkglint/line"
+)
+
+type Suite struct {
+       c *check.C
+}
+
+func (s *Suite) SetUpTest(c *check.C) {
+       Explain = func(...string) {}
+}
+
+func (s *Suite) TearDownTest(c *check.C) {
+       Explain = nil
+}
+
+func (s *Suite) Init(c *check.C) {
+       s.c = c
+}
+
+func (s *Suite) CheckOutputLines(lines ...string) {
+       panic("Not yet implemented")
+}
+
+func (s *Suite) NewLines(...string) []line.Line {
+       panic("Not yet implemented")
+}
+
+func NewLine(string, int, string, []string) line.Line {
+       panic("Not yet implemented")
+}
+
+func (s *Suite) Test_LineChecker_CheckAbsolutePathname(c *check.C) {
+       line := NewLine("Makefile", 1, "# dummy", nil)
+
+       CheckAbsolutePathname(line, "bindir=/bin")
+       CheckAbsolutePathname(line, "bindir=/../lib")
+
+       s.CheckOutputLines(
+               "WARN: Makefile:1: Found absolute pathname: /bin")
+}
+
+func (s *Suite) Test_LineChecker_CheckTrailingWhitespace(c *check.C) {
+       s.Init(c)
+       line := NewLine("Makefile", 32, "The line must go on   ", nil)
+
+       CheckTrailingWhitespace(line)
+
+       s.CheckOutputLines(
+               "NOTE: Makefile:32: Trailing white-space.")
+}
+
+func (s *Suite) Test_LineChecker_CheckRcsid(c *check.C) {
+       s.Init(c)
+       lines := s.NewLines("fname",
+               "$"+"NetBSD: dummy $",
+               "$"+"NetBSD$",
+               "$"+"Id: dummy $",
+               "$"+"Id$",
+               "$"+"FreeBSD$")
+
+       for _, line := range lines {
+               CheckRcsid(line, ``, "")
+       }
+
+       s.CheckOutputLines(
+               "ERROR: fname:3: Expected \"$"+"NetBSD$\".",
+               "ERROR: fname:4: Expected \"$"+"NetBSD$\".",
+               "ERROR: fname:5: Expected \"$"+"NetBSD$\".")
+}
diff -r d1cb86caee44 -r 047c34ad847f pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sun Oct 08 22:17:06 2017 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sun Oct 08 22:31:13 2017 +0000
@@ -297,7 +297,6 @@
 
        s.CheckOutputLines(
                "WARN: options.mk:3: The values for PYTHON_VERSIONS_ACCEPTED should be in decreasing order.",
-               "NOTE: options.mk:4: Please .include \"../../meta-pkgs/kde3/kde3.mk\" instead of this line.",
                "NOTE: options.mk:5: Please use \"# empty\", \"# none\" or \"yes\" instead of \"# defined\".",
                "WARN: options.mk:7: Please include \"../../mk/bsd.prefs.mk\" before using \"?=\".",
                "WARN: options.mk:10: Building the package should take place entirely inside ${WRKSRC}, not \"${WRKSRC}/..\".",



Home | Main Index | Thread Index | Old Index