pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkglint
Module Name: pkgsrc
Committed By: rillig
Date: Sat Apr 17 18:10:14 UTC 2021
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: mkline.go package.go package_test.go
patches.go path.go
Log Message:
pkgtools/pkglint: update to 21.1.1
Changes since 21.1.0:
Added check for packages that have been migrated to Meson but still
refer to their previous build system, most often involving GNU make and
GNU autotools. Suggested by nia.
To generate a diff of this commit:
cvs rdiff -u -r1.682 -r1.683 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.82 -r1.83 pkgsrc/pkgtools/pkglint/files/mkline.go \
pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.97 -r1.98 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.45 -r1.46 pkgsrc/pkgtools/pkglint/files/patches.go
cvs rdiff -u -r1.11 -r1.12 pkgsrc/pkgtools/pkglint/files/path.go
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.682 pkgsrc/pkgtools/pkglint/Makefile:1.683
--- pkgsrc/pkgtools/pkglint/Makefile:1.682 Thu Mar 25 21:55:05 2021
+++ pkgsrc/pkgtools/pkglint/Makefile Sat Apr 17 18:10:14 2021
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.682 2021/03/25 21:55:05 rillig Exp $
+# $NetBSD: Makefile,v 1.683 2021/04/17 18:10:14 rillig Exp $
-PKGNAME= pkglint-21.1.0
+PKGNAME= pkglint-21.1.1
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/mkline.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.82 pkgsrc/pkgtools/pkglint/files/mkline.go:1.83
--- pkgsrc/pkgtools/pkglint/files/mkline.go:1.82 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/mkline.go Sat Apr 17 18:10:14 2021
@@ -935,12 +935,13 @@ func (mkline *MkLine) checkFileGlobbing(
return
}
- if !mkline.once.FirstTimeSlice("unintended file globbing", string(ch)) {
+ chStr := string(rune(ch))
+ if !mkline.once.FirstTimeSlice("unintended file globbing", chStr) {
return
}
mkline.Warnf("The %q in the word %q may lead to unintended file globbing.",
- string(ch), str)
+ chStr, str)
mkline.Explain(
"To fix this, enclose the word in \"double\" or 'single' quotes.")
}
Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.82 pkgsrc/pkgtools/pkglint/files/package_test.go:1.83
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.82 Mon Mar 22 23:26:30 2021
+++ pkgsrc/pkgtools/pkglint/files/package_test.go Sat Apr 17 18:10:14 2021
@@ -2618,6 +2618,77 @@ func (s *Suite) Test_Package_checkUseLan
"Modifying USE_LANGUAGES after including ../../mk/compiler.mk has no effect.")
}
+func (s *Suite) Test_Package_checkMesonGnuMake(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("devel/meson/build.mk")
+ t.SetUpTool("gmake", "", AtRunTime)
+ t.SetUpPackage("category/package",
+ "USE_TOOLS+=\tgmake",
+ "",
+ ".include \"../../devel/meson/build.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ // XXX: Giving the line number would be nice.
+ t.CheckOutputLines(
+ "WARN: Meson packages usually don't need GNU make.")
+}
+
+func (s *Suite) Test_Package_checkMesonConfigureArgs(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("devel/meson/build.mk")
+ t.SetUpPackage("category/package",
+ "CONFIGURE_ARGS+=\t--enable-feature",
+ "",
+ ".include \"../../devel/meson/build.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: Makefile:20: Meson packages usually don't need CONFIGURE_ARGS.")
+}
+
+func (s *Suite) Test_Package_checkMesonPython(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("devel/meson/build.mk")
+ t.CreateFileLines("lang/python/application.mk")
+ t.SetUpPackage("category/package",
+ "PYTHON_FOR_BUILD_ONLY=\ttool",
+ "",
+ ".include \"../../lang/python/application.mk\"",
+ ".include \"../../devel/meson/build.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_Package_checkMesonPython__missing_PYTHON_FOR_BUILD_ONLY(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("devel/meson/build.mk")
+ t.CreateFileLines("lang/python/application.mk")
+ t.SetUpPackage("category/package",
+ ".include \"../../lang/python/application.mk\"",
+ ".include \"../../devel/meson/build.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: Meson packages usually need Python only at build time.")
+}
+
// PKGNAME is stronger than DISTNAME.
func (s *Suite) Test_Package_determineEffectivePkgVars__precedence(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.97 pkgsrc/pkgtools/pkglint/files/package.go:1.98
--- pkgsrc/pkgtools/pkglint/files/package.go:1.97 Sat Mar 20 23:32:43 2021
+++ pkgsrc/pkgtools/pkglint/files/package.go Sat Apr 17 18:10:14 2021
@@ -735,6 +735,8 @@ func (pkg *Package) checkfilePackageMake
pkg.CheckVarorder(mklines)
+ pkg.checkMeson(mklines)
+
SaveAutofixChanges(mklines.lines)
}
@@ -1178,6 +1180,65 @@ func (pkg *Package) checkUseLanguagesCom
})
}
+// checkMeson checks for typical leftover snippets from packages that used
+// GNU autotools or another build system, before being migrated to Meson.
+func (pkg *Package) checkMeson(mklines *MkLines) {
+
+ if pkg.Includes("../../devel/meson/build.mk") == nil {
+ return
+ }
+
+ pkg.checkMesonGnuMake(mklines)
+ pkg.checkMesonConfigureArgs()
+ pkg.checkMesonPython(mklines)
+}
+
+func (pkg *Package) checkMesonGnuMake(mklines *MkLines) {
+ gmake := mklines.Tools.ByName("gmake")
+ if gmake != nil && gmake.UsableAtRunTime() {
+ mkline := NewLineWhole(pkg.File("."))
+ mkline.Warnf("Meson packages usually don't need GNU make.")
+ mkline.Explain(
+ "After migrating a package from GNU make to Meson,",
+ "GNU make is typically not needed anymore.")
+ }
+}
+
+func (pkg *Package) checkMesonConfigureArgs() {
+ if mkline := pkg.vars.FirstDefinition("CONFIGURE_ARGS"); mkline != nil {
+ mkline.Warnf("Meson packages usually don't need CONFIGURE_ARGS.")
+ mkline.Explain(
+ "After migrating a package from GNU make to Meson,",
+ "CONFIGURE_ARGS are typically not needed anymore.")
+ }
+}
+
+func (pkg *Package) checkMesonPython(mklines *MkLines) {
+
+ if mklines.allVars.IsDefined("PYTHON_FOR_BUILD_ONLY") {
+ return
+ }
+
+ for path := range pkg.unconditionalIncludes {
+ if path.ContainsPath("lang/python") {
+ goto warn
+ }
+ }
+ return
+
+warn:
+ mkline := NewLineWhole(pkg.File("."))
+ mkline.Warnf("Meson packages usually need Python only at build time.")
+ mkline.Explain(
+ "The Meson build system is implemented in Python,",
+ "therefore packages that use Meson need Python",
+ "as a build-time dependency.",
+ "After building the package, it is typically independent from Python.",
+ "",
+ "To change the Python dependency to build-time,",
+ "set PYTHON_FOR_BUILD_ONLY=yes in the package Makefile.")
+}
+
func (pkg *Package) determineEffectivePkgVars() {
distnameLine := pkg.vars.FirstDefinition("DISTNAME")
pkgnameLine := pkg.vars.FirstDefinition("PKGNAME")
Index: pkgsrc/pkgtools/pkglint/files/patches.go
diff -u pkgsrc/pkgtools/pkglint/files/patches.go:1.45 pkgsrc/pkgtools/pkglint/files/patches.go:1.46
--- pkgsrc/pkgtools/pkglint/files/patches.go:1.45 Sun Aug 2 13:27:17 2020
+++ pkgsrc/pkgtools/pkglint/files/patches.go Sat Apr 17 18:10:14 2021
@@ -15,11 +15,7 @@ type PatchChecker struct {
previousLineEmpty bool
}
-const (
- rePatchUniFileDel = `^---[\t ]([^\t ]+)(?:[\t ]+(.*))?$`
- rePatchUniFileAdd = `^\+\+\+[\t ]([^\t ]+)(?:[\t ]+(.*))?$`
- rePatchUniHunk = `^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$`
-)
+const rePatchUniFileDel = `^---[\t ]([^\t ]+)(?:[\t ]+(.*))?$`
func (ck *PatchChecker) Check(pkg *Package) {
if ck.lines.CheckCvsID(0, ``, "") {
@@ -35,6 +31,9 @@ func (ck *PatchChecker) Check(pkg *Packa
var patchedFiles []Path
for !ck.llex.EOF() {
line := ck.llex.CurrentLine()
+
+ const rePatchUniFileAdd = `^\+\+\+[\t ]([^\t ]+)(?:[\t ]+(.*))?$`
+
if ck.llex.SkipRegexp(rePatchUniFileDel) {
if m := ck.llex.NextRegexp(rePatchUniFileAdd); m != nil {
patchedFile := NewPath(m[1])
@@ -104,7 +103,7 @@ func (ck *PatchChecker) checkUnifiedDiff
linesDiff := 0
hasHunks := false
for {
- m := ck.llex.NextRegexp(rePatchUniHunk)
+ m := ck.llex.NextRegexp(`^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$`)
if m == nil {
break
}
@@ -396,7 +395,7 @@ func (ck *PatchChecker) checktextCvsID(t
return
}
if m, tagname := match1(text, `\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State|NetBSD)(?::[^\$]*)?\$`); m {
- if matches(text, rePatchUniHunk) {
+ if matches(text, `^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$`) {
ck.llex.PreviousLine().Warnf("Found CVS tag \"$%s$\". Please remove it.", tagname)
} else {
ck.llex.PreviousLine().Warnf("Found CVS tag \"$%s$\". Please remove it by reducing the number of context lines using pkgdiff or \"diff -U[210]\".", tagname)
Index: pkgsrc/pkgtools/pkglint/files/path.go
diff -u pkgsrc/pkgtools/pkglint/files/path.go:1.11 pkgsrc/pkgtools/pkglint/files/path.go:1.12
--- pkgsrc/pkgtools/pkglint/files/path.go:1.11 Mon Jun 1 20:49:54 2020
+++ pkgsrc/pkgtools/pkglint/files/path.go Sat Apr 17 18:10:14 2021
@@ -25,7 +25,7 @@ func (p Path) GoString() string { return
// which is usually a sign of an uninitialized variable.
func (p Path) IsEmpty() bool { return p == "" }
-// Returns the directory of the path, with only minimal cleaning.
+// Dir returns the directory of the path, with only minimal cleaning.
// Only redundant dots and slashes are removed, and only at the end.
func (p Path) Dir() Path {
s := p.String()
@@ -188,7 +188,8 @@ func (p Path) CleanDot() Path {
return NewPath(strings.Join(parts, "/"))
}
-// Differs from path.Clean in that only "../../" is replaced, not "../".
+// CleanPath is similar to path.Clean.
+// The difference is that only "../../" is replaced, not "../".
// Also, the initial directory is always kept.
// This is to provide the package path as context in deeply nested .include chains.
func (p Path) CleanPath() Path {
Home |
Main Index |
Thread Index |
Old Index