pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update...
details: https://anonhg.NetBSD.org/pkgsrc/rev/74d12935cf16
branches: trunk
changeset: 308268:74d12935cf16
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat May 19 12:58:24 2018 +0000
description:
pkgtools/pkglint: update to 5.5.12
Changes since 5.5.11:
* Improve support for TEST_DEPENDS and USE_TOOLS+= *:test (thanks @leot)
* Add checks for ALTERNATIVES files
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/alternatives.go | 42 +++++++++++++++++++++++++++++
pkgtools/pkglint/files/alternatives_test.go | 27 ++++++++++++++++++
pkgtools/pkglint/files/distinfo.go | 7 ++--
pkgtools/pkglint/files/distinfo_test.go | 2 +-
pkgtools/pkglint/files/licenses.go | 9 +++--
pkgtools/pkglint/files/line.go | 4 +-
pkgtools/pkglint/files/package.go | 11 +++++++
pkgtools/pkglint/files/pkglint.go | 3 --
pkgtools/pkglint/files/pkgsrc.go | 7 ++++-
pkgtools/pkglint/files/plist.go | 4 +-
pkgtools/pkglint/files/toplevel.go | 4 +-
pkgtools/pkglint/files/vartypecheck.go | 4 +-
pkgtools/pkglint/files/vartypecheck_test.go | 4 +-
14 files changed, 108 insertions(+), 24 deletions(-)
diffs (truncated from 322 to 300 lines):
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sat May 19 12:58:24 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.538 2018/05/14 20:25:48 rillig Exp $
+# $NetBSD: Makefile,v 1.539 2018/05/19 12:58:24 rillig Exp $
-PKGNAME= pkglint-5.5.11
+PKGNAME= pkglint-5.5.12
DISTFILES= # none
CATEGORIES= pkgtools
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/alternatives.go
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/alternatives.go Sat May 19 12:58:24 2018 +0000
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "netbsd.org/pkglint/regex"
+ "strings"
+)
+
+func CheckfileAlternatives(filename string, plistFiles map[string]bool) {
+ lines, err := readLines(filename, false)
+ if err != nil {
+ return
+ }
+
+ for _, line := range lines {
+ if m, wrapper, space, implementation := match3(line.Text, `^(\S+)([ \t]+)(\S+)`); m {
+ if plistFiles[wrapper] {
+ line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
+ }
+
+ relImplementation := strings.Replace(implementation, "@PREFIX@/", "", 1)
+ plistName := regex.Compile(`@(\w+)@`).ReplaceAllString(relImplementation, "${$1}")
+ if !plistFiles[plistName] && !G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
+ if plistName != implementation {
+ line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", implementation, plistName)
+ } else {
+ line.Errorf("Alternative implementation %q must appear in the PLIST.", implementation)
+ }
+ }
+
+ fix := line.Autofix()
+ fix.Notef("@PREFIX@/ can be omitted from the file name.")
+ fix.Explain(
+ "The alternative implementation is always interpreted relative to ${PREFIX}.")
+ fix.ReplaceAfter(space, "@PREFIX@/", "")
+ fix.Apply()
+ } else {
+ line.Errorf("Invalid ALTERNATIVES line %q.", line.Text)
+ Explain(
+ "Run \"" + confMake + " help topic=alternatives\" for more information.")
+ }
+ }
+}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/alternatives_test.go
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/alternatives_test.go Sat May 19 12:58:24 2018 +0000
@@ -0,0 +1,27 @@
+package main
+
+import "gopkg.in/check.v1"
+
+func (s *Suite) Test_Alternatives_PLIST(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupFileLines("ALTERNATIVES",
+ "sbin/sendmail @PREFIX@/sbin/sendmail.postfix@POSTFIXVER@",
+ "sbin/sendmail @PREFIX@/sbin/sendmail.exim@EXIMVER@",
+ "bin/echo bin/gnu-echo",
+ "bin/editor bin/vim -e")
+
+ G.Pkg = NewPackage("")
+ G.Pkg.PlistFiles["bin/echo"] = true
+ G.Pkg.PlistFiles["bin/vim"] = true
+ G.Pkg.PlistFiles["sbin/sendmail.exim${EXIMVER}"] = true
+
+ CheckfileAlternatives(t.TempFilename("ALTERNATIVES"), G.Pkg.PlistFiles)
+
+ t.CheckOutputLines(
+ "ERROR: ~/ALTERNATIVES:1: Alternative implementation \"@PREFIX@/sbin/sendmail.postfix@POSTFIXVER@\" must appear in the PLIST as \"sbin/sendmail.postfix${POSTFIXVER}\".",
+ "NOTE: ~/ALTERNATIVES:1: @PREFIX@/ can be omitted from the file name.",
+ "NOTE: ~/ALTERNATIVES:2: @PREFIX@/ can be omitted from the file name.",
+ "ERROR: ~/ALTERNATIVES:3: Alternative wrapper \"bin/echo\" must not appear in the PLIST.",
+ "ERROR: ~/ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must appear in the PLIST.")
+}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/distinfo.go Sat May 19 12:58:24 2018 +0000
@@ -157,16 +157,17 @@
// Inter-package check for differing distfile checksums.
func (ck *distinfoLinesChecker) checkGlobalMismatch(line Line, fname, alg, hash string) {
- if G.Hash != nil && !hasPrefix(fname, "patch-") { // Intentionally checking the filename instead of ck.isPatch
+ hashes := G.Pkgsrc.Hashes
+ if hashes != nil && !hasPrefix(fname, "patch-") { // Intentionally checking the filename instead of ck.isPatch
key := alg + ":" + fname
- otherHash := G.Hash[key]
+ otherHash := hashes[key]
if otherHash != nil {
if otherHash.hash != hash {
line.Errorf("The hash %s for %s is %s, which differs from %s in %s.",
alg, fname, hash, otherHash.hash, otherHash.line.ReferenceFrom(line))
}
} else {
- G.Hash[key] = &Hash{hash, line}
+ hashes[key] = &Hash{hash, line}
}
}
}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go Sat May 19 12:58:24 2018 +0000
@@ -32,7 +32,7 @@
t := s.Init(c)
otherLine := t.NewLine("other/distinfo", 7, "dummy")
- G.Hash = map[string]*Hash{"SHA512:pkgname-1.0.tar.gz": {"Some-512-bit-hash", otherLine}}
+ G.Pkgsrc.Hashes = map[string]*Hash{"SHA512:pkgname-1.0.tar.gz": {"Some-512-bit-hash", otherLine}}
lines := t.NewLines("distinfo",
RcsID,
"",
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/licenses.go
--- a/pkgtools/pkglint/files/licenses.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/licenses.go Sat May 19 12:58:24 2018 +0000
@@ -6,7 +6,8 @@
)
func checkToplevelUnusedLicenses() {
- if G.UsedLicenses == nil {
+ usedLicenses := G.Pkgsrc.UsedLicenses
+ if usedLicenses == nil {
return
}
@@ -16,7 +17,7 @@
licensename := licensefile.Name()
licensepath := licensedir + "/" + licensename
if fileExists(licensepath) {
- if !G.UsedLicenses[licensename] {
+ if !usedLicenses[licensename] {
NewLineWhole(licensepath).Warnf("This license seems to be unused.")
}
}
@@ -52,8 +53,8 @@
}
if licenseFile == "" {
licenseFile = G.Pkgsrc.File("licenses/" + license)
- if G.UsedLicenses != nil {
- G.UsedLicenses[license] = true
+ if G.Pkgsrc.UsedLicenses != nil {
+ G.Pkgsrc.UsedLicenses[license] = true
}
}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/line.go
--- a/pkgtools/pkglint/files/line.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/line.go Sat May 19 12:58:24 2018 +0000
@@ -162,7 +162,7 @@
// Usage:
//
-// fix := mkline.Line.Autofix()
+// fix := line.Autofix()
//
// fix.Errorf("Must not be ...")
// fix.Warnf("Should not be ...")
@@ -174,7 +174,7 @@
//
// fix.Replace("from", "to")
// fix.ReplaceAfter("prefix", "from", "to")
-// fix.ReplaceRegex(`\s+`, "space", "from", "to")
+// fix.ReplaceRegex(`\s+`, "space", -1)
// fix.InsertBefore("new line")
// fix.InsertAfter("new line")
// fix.Delete()
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/package.go Sat May 19 12:58:24 2018 +0000
@@ -26,6 +26,7 @@
EffectivePkgnameLine MkLine // The origin of the three effective_* values
SeenBsdPrefsMk bool // Has bsd.prefs.mk already been included?
PlistDirs map[string]bool // Directories mentioned in the PLIST files
+ PlistFiles map[string]bool // Regular files mentioned in the PLIST files
vars Scope
bl3 map[string]Line // buildlink3.mk name => line; contains only buildlink3.mk files that are directly included.
@@ -42,6 +43,7 @@
pkg := &Package{
Pkgpath: pkgpath,
PlistDirs: make(map[string]bool),
+ PlistFiles: make(map[string]bool),
vars: NewScope(),
bl3: make(map[string]Line),
plistSubstCond: make(map[string]bool),
@@ -216,6 +218,14 @@
}
}
+ if G.opts.CheckAlternatives {
+ for _, fname := range files {
+ if path.Base(fname) == "ALTERNATIVES" {
+ CheckfileAlternatives(fname, pkg.PlistFiles)
+ }
+ }
+ }
+
if !isEmptyDir(G.CurrentDir + "/scripts") {
NewLineWhole(G.CurrentDir + "/scripts").Warnf("This directory and its contents are deprecated! Please call the script(s) explicitly from the corresponding target(s) in the pkg's
Makefile.")
}
@@ -934,6 +944,7 @@
for _, line := range lines {
text := line.Text
+ pkg.PlistFiles[text] = true // XXX: ignores PLIST conditionals for now
// Keep in sync with PlistChecker.collectFilesAndDirs
if !contains(text, "$") && !contains(text, "@") {
for dir := path.Dir(text); dir != "."; dir = path.Dir(dir) {
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/pkglint.go
--- a/pkgtools/pkglint/files/pkglint.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/pkglint.go Sat May 19 12:58:24 2018 +0000
@@ -41,9 +41,6 @@
CvsEntriesDir string // Cached to avoid I/O
CvsEntriesLines []Line
- Hash map[string]*Hash // Maps "alg:fname" => hash (inter-package check).
- UsedLicenses map[string]bool // Maps "license name" => true (inter-package check).
-
errors int
warnings int
explainNext bool
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go Sat May 19 12:58:24 2018 +0000
@@ -35,6 +35,9 @@
UserDefinedVars map[string]MkLine // varname => line; used for checking BUILD_DEFS
Deprecated map[string]string //
vartypes map[string]*Vartype // varcanon => type
+
+ Hashes map[string]*Hash // Maps "alg:fname" => hash (inter-package check).
+ UsedLicenses map[string]bool // Maps "license name" => true (inter-package check).
}
func NewPkgsrc(dir string) *Pkgsrc {
@@ -51,7 +54,9 @@
make(map[string]string),
make(map[string]MkLine),
make(map[string]string),
- make(map[string]*Vartype)}
+ make(map[string]*Vartype),
+ nil, // Only initialized when pkglint is run for a whole pkgsrc installation
+ nil}
// Some user-defined variables do not influence the binary
// package at all and therefore do not have to be added to
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/plist.go
--- a/pkgtools/pkglint/files/plist.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/plist.go Sat May 19 12:58:24 2018 +0000
@@ -402,8 +402,8 @@
line := pline.line
if cmd == "unexec" {
- if m, arg := match1(arg, `^(?:rmdir|\$\{RMDIR\} \%D/)(.*)`); m {
- if !contains(arg, "true") && !contains(arg, "${TRUE}") {
+ if m, dir := match1(arg, `^(?:rmdir|\$\{RMDIR\} \%D/)(.*)`); m {
+ if !contains(dir, "true") && !contains(dir, "${TRUE}") {
pline.line.Warnf("Please remove this line. It is no longer necessary.")
}
}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/toplevel.go
--- a/pkgtools/pkglint/files/toplevel.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/toplevel.go Sat May 19 12:58:24 2018 +0000
@@ -32,8 +32,8 @@
if G.opts.Recursive {
if G.opts.CheckGlobal {
- G.UsedLicenses = make(map[string]bool)
- G.Hash = make(map[string]*Hash)
+ G.Pkgsrc.UsedLicenses = make(map[string]bool)
+ G.Pkgsrc.Hashes = make(map[string]*Hash)
}
G.Todo = append(append([]string(nil), ctx.subdirs...), G.Todo...)
}
diff -r afb6f6824aa4 -r 74d12935cf16 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go Sat May 19 12:38:28 2018 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go Sat May 19 12:58:24 2018 +0000
@@ -950,9 +950,9 @@
cv.Line.Errorf("Unknown tool %q.", toolname)
}
switch tooldep {
- case "", "bootstrap", "build", "pkgsrc", "run":
+ case "", "bootstrap", "build", "pkgsrc", "run", "test":
default:
- cv.Line.Errorf("Unknown tool dependency %q. Use one of \"bootstrap\", \"build\", \"pkgsrc\" or \"run\".", tooldep)
+ cv.Line.Errorf("Unknown tool dependency %q. Use one of \"bootstrap\", \"build\", \"pkgsrc\" or \"run\" or \"test\".", tooldep)
}
} else if cv.Op != opUseMatch {
Home |
Main Index |
Thread Index |
Old Index