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 to 20.1.1
details: https://anonhg.NetBSD.org/pkgsrc/rev/a2ac25c7e1d7
branches: trunk
changeset: 426092:a2ac25c7e1d7
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Mar 26 07:02:44 2020 +0000
description:
pkgtools/pkglint: update to 20.1.1
Changes since 20.1.0:
In UNLIMIT_RESOURCES, the recently added virtualsize is allowed.
Packages that have distfiles without any digit in their name should
define DIST_SUBDIR to avoid polluting the global namespace. The
top-level distfiles directory should only contain versioned filenames.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/distinfo.go | 29 +++++++
pkgtools/pkglint/files/distinfo_test.go | 42 ++++++++++-
pkgtools/pkglint/files/mkline.go | 6 +
pkgtools/pkglint/files/mklines.go | 12 +++
pkgtools/pkglint/files/package.go | 47 ++++++++++++
pkgtools/pkglint/files/package_test.go | 118 ++++++++++++++++++++++++++++++++
pkgtools/pkglint/files/pkglint.go | 2 +-
pkgtools/pkglint/files/shell.go | 2 +
pkgtools/pkglint/files/shell_test.go | 15 ++++
pkgtools/pkglint/files/util.go | 15 ++++
pkgtools/pkglint/files/vardefs.go | 5 +-
12 files changed, 289 insertions(+), 8 deletions(-)
diffs (truncated from 502 to 300 lines):
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/Makefile Thu Mar 26 07:02:44 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.638 2020/03/23 19:55:08 rillig Exp $
+# $NetBSD: Makefile,v 1.639 2020/03/26 07:02:44 rillig Exp $
-PKGNAME= pkglint-20.1.0
+PKGNAME= pkglint-20.1.1
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo.go Thu Mar 26 07:02:44 2020 +0000
@@ -34,6 +34,13 @@
CheckLinesTrailingEmptyLines(lines)
ck.checkUnrecordedPatches()
+ if pkg != nil {
+ pkg.distinfoDistfiles = make(map[string]bool)
+ for path := range ck.infos {
+ pkg.distinfoDistfiles[path.Base()] = true
+ }
+ }
+
SaveAutofixChanges(lines)
}
@@ -106,6 +113,7 @@
for _, filename := range ck.filenames {
info := ck.infos[filename]
+ ck.checkFilename(filename, info)
ck.checkAlgorithms(info)
for _, hash := range info.hashes {
ck.checkGlobalDistfileMismatch(hash)
@@ -116,6 +124,18 @@
}
}
+func (ck *distinfoLinesChecker) checkFilename(filename RelPath, info distinfoFileInfo) {
+ if info.isPatch != no || !info.hasDistfileAlgorithms() || matches(filename.String(), `\d`) {
+ return
+ }
+
+ line := info.line()
+ line.Warnf(
+ "Distfiles without version number should be placed in a versioned DIST_SUBDIR.")
+ line.Explain(
+ seeGuide("How to handle modified distfiles with the 'old' name", "modified-distfiles-same-name"))
+}
+
func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) {
filename := info.filename()
algorithms := info.algorithms()
@@ -419,6 +439,15 @@
return strings.Join(algs, ", ")
}
+func (info *distinfoFileInfo) hasDistfileAlgorithms() bool {
+ h := info.hashes
+ return len(h) == 4 &&
+ h[0].algorithm == "SHA1" &&
+ h[1].algorithm == "RMD160" &&
+ h[2].algorithm == "SHA512" &&
+ h[3].algorithm == "Size"
+}
+
type distinfoHash struct {
line *Line
filename RelPath
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go Thu Mar 26 07:02:44 2020 +0000
@@ -14,8 +14,8 @@
lines := t.SetUpFileLines("distinfo",
"should be the CVS ID",
"should be empty",
- "MD5 (distfile.tar.gz) = 12345678901234567890123456789012",
- "SHA1 (distfile.tar.gz) = 1234567890123456789012345678901234567890",
+ "MD5 (distfile-1.0.tar.gz) = 12345678901234567890123456789012",
+ "SHA1 (distfile-1.0.tar.gz) = 1234567890123456789012345678901234567890",
"SHA1 (patch-aa) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7",
"Size (patch-aa) = 104",
"SHA1 (patch-ab) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7",
@@ -31,7 +31,7 @@
"ERROR: distinfo:1: Invalid line: should be the CVS ID",
"ERROR: distinfo:2: Invalid line: should be empty",
"ERROR: distinfo:8: Invalid line: Another invalid line",
- "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile.tar.gz\", got MD5, SHA1.",
+ "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got MD5, SHA1.",
"ERROR: distinfo:5: Expected SHA1 hash for patch-aa, got SHA1, Size.",
"WARN: distinfo:9: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".")
}
@@ -204,6 +204,41 @@
t.CheckOutputEmpty()
}
+func (s *Suite) Test_distinfoLinesChecker_checkFilename(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package")
+ t.CreateFileLines("category/package/distinfo",
+ CvsID,
+ "",
+ "SHA1 (ok-1.0.tar.gz) = 1234",
+ "RMD160 (ok-1.0.tar.gz) = 1234",
+ "SHA512 (ok-1.0.tar.gz) = 1234",
+ "Size (ok-1.0.tar.gz) = 1234",
+ "SHA1 (not-ok.tar.gz) = 1234",
+ "RMD160 (not-ok.tar.gz) = 1234",
+ "SHA512 (not-ok.tar.gz) = 1234",
+ "Size (not-ok.tar.gz) = 1234",
+ "SHA1 (non-versioned/not-ok.tar.gz) = 1234",
+ "RMD160 (non-versioned/not-ok.tar.gz) = 1234",
+ "SHA512 (non-versioned/not-ok.tar.gz) = 1234",
+ "Size (non-versioned/not-ok.tar.gz) = 1234",
+ "SHA1 (versioned-1/ok.tar.gz) = 1234",
+ "RMD160 (versioned-1/ok.tar.gz) = 1234",
+ "SHA512 (versioned-1/ok.tar.gz) = 1234",
+ "Size (versioned-1/ok.tar.gz) = 1234")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: distinfo:7: Distfiles without version number "+
+ "should be placed in a versioned DIST_SUBDIR.",
+ "WARN: distinfo:11: Distfiles without version number "+
+ "should be placed in a versioned DIST_SUBDIR.")
+}
+
func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__nonexistent_distfile_called_patch(c *check.C) {
t := s.Init(c)
@@ -653,6 +688,7 @@
G.checkdirPackage(".")
t.CheckOutputLines(
+ "WARN: distinfo:3: Distfiles without version number should be placed in a versioned DIST_SUBDIR.",
"ERROR: distinfo: Patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".",
"ERROR: distinfo: Patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".")
}
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/mkline.go Thu Mar 26 07:02:44 2020 +0000
@@ -293,12 +293,18 @@
func (mkline *MkLine) Cond() *MkCond {
cond := mkline.data.(*mkLineDirective).cond
if cond == nil {
+ assert(mkline.HasCond())
cond = NewMkParser(mkline.Line, mkline.Args()).MkCond()
mkline.data.(*mkLineDirective).cond = cond
}
return cond
}
+func (mkline *MkLine) HasCond() bool {
+ directive := mkline.Directive()
+ return directive == "if" || directive == "elif"
+}
+
// DirectiveComment is the trailing end-of-line comment, typically at a deeply nested .endif or .endfor.
func (mkline *MkLine) DirectiveComment() string { return mkline.data.(*mkLineDirective).comment }
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/mklines.go Thu Mar 26 07:02:44 2020 +0000
@@ -653,6 +653,18 @@
return nil
}
+// IsUnreachable determines whether the given line is unreachable because a
+// condition on the way to that line is not satisfied.
+// If unsure, returns false.
+func (mklines *MkLines) IsUnreachable(mkline *MkLine) bool {
+ // To make this code as simple as possible, the code should operate
+ // on a high-level AST, where the nodes are If, For and BasicBlock.
+ //
+ // See lang/ghc*/bootstrap.mk for good examples how pkglint should
+ // treat variable assignments. It's getting complicated.
+ return false
+}
+
func (mklines *MkLines) SaveAutofixChanges() {
mklines.lines.SaveAutofixChanges()
}
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/package.go Thu Mar 26 07:02:44 2020 +0000
@@ -86,6 +86,10 @@
IgnoreMissingPatches bool // In distinfo, don't warn about patches that cannot be found.
Once Once
+
+ // Contains the basenames of the distfiles that are mentioned in distinfo,
+ // for example "package-1.0.tar.gz", even if that file is in a DIST_SUBDIR.
+ distinfoDistfiles map[string]bool
}
func NewPackage(dir CurrPath) *Package {
@@ -121,6 +125,7 @@
pkg.vars.Fallback("PATCHDIR", "patches")
pkg.vars.Fallback("KRB5_TYPE", "heimdal")
pkg.vars.Fallback("PGSQL_VERSION", "95")
+ pkg.vars.Fallback("EXTRACT_SUFX", ".tar.gz")
// In reality, this is an absolute pathname. Since this variable is
// typically used in the form ${.CURDIR}/../../somewhere, this doesn't
@@ -132,6 +137,9 @@
func (pkg *Package) Check() {
files, mklines, allLines := pkg.load()
+ if files == nil {
+ return
+ }
pkg.check(files, mklines, allLines)
}
@@ -588,6 +596,8 @@
pkg.checkDescr(filenames, mklines)
}
+
+ pkg.checkDistfilesInDistinfo(allLines)
}
func (pkg *Package) checkDescr(filenames []CurrPath, mklines *MkLines) {
@@ -605,6 +615,43 @@
mklines.Whole().Errorf("Each package must have a DESCR file.")
}
+func (pkg *Package) checkDistfilesInDistinfo(mklines *MkLines) {
+ // Needs more work; see MkLines.IsUnreachable.
+ if !G.Experimental {
+ return
+ }
+
+ if pkg.distinfoDistfiles == nil {
+ return
+ }
+
+ redundant := pkg.redundant
+ distfiles := redundant.get("DISTFILES")
+ if distfiles == nil {
+ return
+ }
+
+ for _, mkline := range distfiles.vari.WriteLocations() {
+ unreachable := newLazyBool(
+ func() bool { return mklines.IsUnreachable(mkline) })
+ resolved := resolveVariableRefs(mkline.Value(), nil, pkg)
+
+ for _, distfile := range mkline.ValueFields(resolved) {
+ if containsVarUse(distfile) {
+ continue
+ }
+ if pkg.distinfoDistfiles[NewPath(distfile).Base()] {
+ continue
+ }
+ if unreachable.get() {
+ continue
+ }
+ mkline.Warnf("Distfile %q is not mentioned in %s.",
+ distfile, mkline.Rel(pkg.File(pkg.DistinfoFile)))
+ }
+ }
+}
+
func (pkg *Package) checkfilePackageMakefile(filename CurrPath, mklines *MkLines, allLines *MkLines) {
if trace.Tracing {
defer trace.Call(filename)()
diff -r 58be9f64be1b -r a2ac25c7e1d7 pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go Thu Mar 26 06:34:00 2020 +0000
+++ b/pkgtools/pkglint/files/package_test.go Thu Mar 26 07:02:44 2020 +0000
@@ -1344,6 +1344,124 @@
t.CheckOutputEmpty()
}
+// All files that can possibly be added to DISTFILES need a corresponding
+// entry in the distinfo file.
+//
+// https://mail-index.netbsd.org/pkgsrc-changes/2020/02/05/msg206172.html
+// https://mail-index.netbsd.org/pkgsrc-changes/2020/03/25/msg209445.html
+func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_conditional_DISTFILES(c *check.C) {
+ G.Experimental = true
+
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package",
+ ".include \"../../mk/bsd.prefs.mk\"",
+ "",
+ "DISTFILES.i386=\t\tdistfile-i386.tar.gz",
+ "DISTFILES.other=\tdistfile-other.tar.gz",
+ "",
+ ".if ${MACHINE_ARCH} == i386",
+ "DISTFILES+=\t${DISTFILES.i386}",
+ ".else",
Home |
Main Index |
Thread Index |
Old Index