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: Sun Jun 6 07:41:34 UTC 2021
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: autofix.go autofix_test.go line.go
mkvarusechecker.go mkvarusechecker_test.go package.go pkgsrc.go
pkgsrc_test.go plist.go plist_test.go
Log Message:
pkgtools/pkglint: update to 21.1.3
Changes since 21.1.2:
The entries in doc/CHANGES are checked more strictly, they must always
consist of 4 words (for removed packages) or 6 words (for all other
changes).
Packages that include curses.buildlink3.mk may use all buildlink3
variables with the identifier "curses". The previous pkglint warnings
had been wrong.
Python packages that directly contain .egg-info in their PLIST files
should include egg.mk instead. Pkglint can now fix these packages
automatically.
To generate a diff of this commit:
cvs rdiff -u -r1.686 -r1.687 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.40 -r1.41 pkgsrc/pkgtools/pkglint/files/autofix.go
cvs rdiff -u -r1.41 -r1.42 pkgsrc/pkgtools/pkglint/files/autofix_test.go
cvs rdiff -u -r1.48 -r1.49 pkgsrc/pkgtools/pkglint/files/line.go
cvs rdiff -u -r1.13 -r1.14 pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go
cvs rdiff -u -r1.14 -r1.15 \
pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go
cvs rdiff -u -r1.98 -r1.99 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.59 -r1.60 pkgsrc/pkgtools/pkglint/files/pkgsrc.go
cvs rdiff -u -r1.51 -r1.52 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go \
pkgsrc/pkgtools/pkglint/files/plist_test.go
cvs rdiff -u -r1.60 -r1.61 pkgsrc/pkgtools/pkglint/files/plist.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.686 pkgsrc/pkgtools/pkglint/Makefile:1.687
--- pkgsrc/pkgtools/pkglint/Makefile:1.686 Tue May 25 21:48:46 2021
+++ pkgsrc/pkgtools/pkglint/Makefile Sun Jun 6 07:41:34 2021
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.686 2021/05/25 21:48:46 rillig Exp $
+# $NetBSD: Makefile,v 1.687 2021/06/06 07:41:34 rillig Exp $
-PKGNAME= pkglint-21.1.2
+PKGNAME= pkglint-21.1.3
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/autofix.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix.go:1.40 pkgsrc/pkgtools/pkglint/files/autofix.go:1.41
--- pkgsrc/pkgtools/pkglint/files/autofix.go:1.40 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/autofix.go Sun Jun 6 07:41:34 2021
@@ -84,6 +84,15 @@ func (fix *Autofix) Notef(format string,
fix.setDiag(Note, format, args)
}
+// Silent removes the need to specify the diagnostic that most fixes need.
+//
+// When a fix is part of a larger "transaction", the diagnostic may already be
+// printed by another fix, and no further diagnostic is needed to inform the
+// pkglint user about all changes that happen.
+func (fix *Autofix) Silent() {
+ fix.setDiag(Note, SilentAutofixFormat, nil)
+}
+
// Explain remembers the explanation for logging it later when Apply is called.
func (fix *Autofix) Explain(explanation ...string) {
// Since a silent fix doesn't have a diagnostic, its explanation would
Index: pkgsrc/pkgtools/pkglint/files/autofix_test.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.41 pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.42
--- pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.41 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/autofix_test.go Sun Jun 6 07:41:34 2021
@@ -401,6 +401,23 @@ func (s *Suite) Test_Autofix_Notef(c *ch
"NOTE: DESCR:1: Note.")
}
+func (s *Suite) Test_Autofix_Silent(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpCommandLine("--show-autofix")
+
+ line := t.NewLine("DESCR", 1, "Description of the package")
+
+ fix := line.Autofix()
+ fix.Silent()
+ fix.Replace("package", "replaced package")
+ fix.Apply()
+
+ t.CheckOutputLines(
+ "AUTOFIX: DESCR:1: Replacing \"package\" with \"replaced package\".")
+ t.CheckEquals(line.fix.texts[0], "Description of the replaced package\n")
+}
+
func (s *Suite) Test_Autofix_Explain__without_explain_option(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/line.go
diff -u pkgsrc/pkgtools/pkglint/files/line.go:1.48 pkgsrc/pkgtools/pkglint/files/line.go:1.49
--- pkgsrc/pkgtools/pkglint/files/line.go:1.48 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/line.go Sun Jun 6 07:41:34 2021
@@ -182,6 +182,7 @@ func (line *Line) String() string {
// fix.Errorf("Must not be ...")
// fix.Warnf("Should not be ...")
// fix.Notef("It is also possible ...")
+// fix.Silent()
//
// fix.Explain(
// "Explanation ...",
Index: pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.13 pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.14
--- pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.13 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go Sun Jun 6 07:41:34 2021
@@ -19,7 +19,7 @@ func NewMkVarUseChecker(use *MkVarUse, m
return &MkVarUseChecker{use, vartype, mklines, mkline}
}
-// CheckVaruse checks a single use of a variable in a specific context.
+// Check checks a single use of a variable in a specific context.
func (ck *MkVarUseChecker) Check(vuc *VarUseContext) {
if ck.use.IsExpression() {
return
@@ -242,6 +242,10 @@ func (ck *MkVarUseChecker) checkVarnameB
}
}
+ // TODO: Generalize the following paragraphs
+ if id == "curses" && pkg.Includes("../../mk/curses.buildlink3.mk") != nil {
+ return
+ }
if id == "mysql-client" && pkg.Includes("../../mk/mysql.buildlink3.mk") != nil {
return
}
Index: pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.14 pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.15
--- pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.14 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go Sun Jun 6 07:41:34 2021
@@ -524,6 +524,42 @@ func (s *Suite) Test_MkVarUseChecker_che
"WARN: module.mk:2: Buildlink identifier \"package\" is not known in this package.")
}
+func (s *Suite) Test_MkVarUseChecker_checkVarnameBuildlink__curses_ok(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package")
+ t.CreateFileLines("mk/curses.buildlink3.mk")
+ t.CreateFileLines("category/package/module.mk",
+ MkCvsID,
+ "CONFIGURE_ARGS+=\t--prefix=${BUILDLINK_PREFIX.curses}",
+ ".include \"../../mk/curses.buildlink3.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_MkVarUseChecker_checkVarnameBuildlink__curses_bad(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package")
+ t.CreateFileLines("mk/curses.buildlink3.mk")
+ t.CreateFileLines("category/package/module.mk",
+ MkCvsID,
+ "CONFIGURE_ARGS+=\t--prefix=${BUILDLINK_PREFIX.curses}",
+ // does not include mk/curses.buildlink3.mk
+ )
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: module.mk:2: Buildlink identifier \"curses\" is not known in this package.")
+}
+
func (s *Suite) Test_MkVarUseChecker_checkVarnameBuildlink__mysql_ok(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.98 pkgsrc/pkgtools/pkglint/files/package.go:1.99
--- pkgsrc/pkgtools/pkglint/files/package.go:1.98 Sat Apr 17 18:10:14 2021
+++ pkgsrc/pkgtools/pkglint/files/package.go Sun Jun 6 07:41:34 2021
@@ -20,6 +20,8 @@ type Package struct {
dir CurrPath // The directory of the package, for resolving files
Pkgpath PkgsrcPath // e.g. "category/pkgdir"
+ Makefile *MkLines
+
EffectivePkgname string // PKGNAME or DISTNAME from the package Makefile, including nb13, can be empty
EffectivePkgbase string // EffectivePkgname without the version
EffectivePkgversion string // The version part of the effective PKGNAME, excluding nb13
@@ -216,6 +218,7 @@ func (pkg *Package) loadPackageMakefile(
if mainLines == nil {
return nil, nil
}
+ pkg.Makefile = mainLines
G.checkRegCvsSubst(filename)
allLines := NewMkLines(NewLines("", nil), pkg, &pkg.vars)
@@ -1729,6 +1732,49 @@ func (pkg *Package) Includes(filename Pa
return mkline
}
+// CanFixAddInclude tests whether the package Makefile follows the standard
+// form and thus allows to add additional '.include' directives.
+func (pkg *Package) CanFixAddInclude() bool {
+ mklines := pkg.Makefile
+ lastLine := mklines.mklines[len(mklines.mklines)-1]
+ return lastLine.Text == ".include \"../../mk/bsd.pkg.mk\""
+}
+
+// FixAddInclude adds an '.include' directive at the end of the package
+// Makefile.
+func (pkg *Package) FixAddInclude(includedFile PackagePath) {
+ mklines := pkg.Makefile
+
+ alreadyThere := false
+ mklines.ForEach(func(mkline *MkLine) {
+ if mkline.IsInclude() && mkline.IncludedFile() == includedFile.AsRelPath() {
+ alreadyThere = true
+ }
+
+ // XXX: This low-level code should not be necessary.
+ // Instead, the added '.include' line should be a MkLine of its own.
+ if mkline.fix != nil {
+ expected := ".include \"" + includedFile.String() + "\"\n"
+ for _, rawLine := range mkline.fix.above {
+ if rawLine == expected {
+ alreadyThere = true
+ }
+ }
+ }
+ })
+ if alreadyThere {
+ return
+ }
+
+ lastLine := mklines.mklines[len(mklines.mklines)-1]
+ fix := lastLine.Autofix()
+ fix.Silent()
+ fix.InsertAbove(".include \"" + includedFile.String() + "\"")
+ fix.Apply()
+
+ mklines.SaveAutofixChanges()
+}
+
// PlistContent lists the directories and files that appear in the
// package's PLIST files. It serves two purposes:
//
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.59 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.60
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.59 Sat Mar 20 23:32:43 2021
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go Sun Jun 6 07:41:34 2021
@@ -399,11 +399,11 @@ func (*Pkgsrc) parseDocChange(line *Line
switch {
case
- action == Added && f[2] == "version",
- action == Updated && f[2] == "to",
- action == Downgraded && f[2] == "to",
- action == Removed && (f[2] == "successor" || f[2] == "version" || n == 4),
- (action == Renamed || action == Moved) && f[2] == "to":
+ action == Added && f[2] == "version" && n == 6,
+ action == Updated && f[2] == "to" && n == 6,
+ action == Downgraded && f[2] == "to" && n == 6,
+ action == Removed && ((f[2] == "successor" || f[2] == "version") && n == 6 || n == 4),
+ (action == Renamed || action == Moved) && f[2] == "to" && n == 6:
return &Change{
Location: line.Location,
Action: action,
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.51 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.52
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.51 Tue Oct 6 18:40:50 2020
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go Sun Jun 6 07:41:34 2021
@@ -514,6 +514,11 @@ func (s *Suite) Test_Pkgsrc_parseDocChan
test("\tAdded category/pkgpath version 1.0 [author-dash 2019-01-01]",
"WARN: doc/CHANGES-2019:123: Invalid doc/CHANGES line: "+
"\tAdded category/pkgpath version 1.0 [author-dash 2019-01-01]")
+
+ // The word 'version' must only appear with 'Added', not with 'Updated'.
+ test("\tUpdated category/pkgpath to version 1.0 [author 2019-01-01]",
+ "WARN: doc/CHANGES-2019:123: Invalid doc/CHANGES line: "+
+ "\tUpdated category/pkgpath to version 1.0 [author 2019-01-01]")
}
func (s *Suite) Test_Pkgsrc_checkRemovedAfterLastFreeze(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/plist_test.go
diff -u pkgsrc/pkgtools/pkglint/files/plist_test.go:1.51 pkgsrc/pkgtools/pkglint/files/plist_test.go:1.52
--- pkgsrc/pkgtools/pkglint/files/plist_test.go:1.51 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/plist_test.go Sun Jun 6 07:41:34 2021
@@ -624,6 +624,35 @@ func (s *Suite) Test_PlistChecker_checkP
"WARN: PLIST:2: Include \"../../lang/python/egg.mk\" instead of listing .egg-info files directly.")
}
+func (s *Suite) Test_PlistChecker_checkPathMisc__python_egg_autofix(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpCommandLine("--show-autofix")
+ t.SetUpPackage("category/package")
+ t.Chdir("category/package")
+ t.CreateFileLines("PLIST",
+ PlistCvsID,
+ "${PYSITELIB}/gdspy-${PKGVERSION}-py${PYVERSSUFFIX}.egg-info/PKG-INFO",
+ "${PYSITELIB}/gdspy-${PKGVERSION}-py${PYVERSSUFFIX}.egg-info/SOURCES.txt")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "WARN: PLIST:2: Include \"../../lang/python/egg.mk\" "+
+ "instead of listing .egg-info files directly.",
+ "AUTOFIX: PLIST:2: Replacing "+
+ "\"${PYSITELIB}/gdspy-${PKGVERSION}-py${PYVERSSUFFIX}.egg-info\" "+
+ "with \"${PYSITELIB}/${EGG_INFODIR}\".",
+ "AUTOFIX: Makefile:21: Inserting a line "+
+ "\".include \\\"../../lang/python/egg.mk\\\"\" above this line.",
+ "WARN: PLIST:3: Include \"../../lang/python/egg.mk\" "+
+ "instead of listing .egg-info files directly.",
+ "AUTOFIX: PLIST:3: Replacing "+
+ "\"${PYSITELIB}/gdspy-${PKGVERSION}-py${PYVERSSUFFIX}.egg-info\" "+
+ "with \"${PYSITELIB}/${EGG_INFODIR}\".")
+}
+
func (s *Suite) Test_PlistChecker_checkPathMisc__unwanted_entries(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/plist.go
diff -u pkgsrc/pkgtools/pkglint/files/plist.go:1.60 pkgsrc/pkgtools/pkglint/files/plist.go:1.61
--- pkgsrc/pkgtools/pkglint/files/plist.go:1.60 Wed Jul 1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/plist.go Sun Jun 6 07:41:34 2021
@@ -228,7 +228,17 @@ func (ck *PlistChecker) checkPathMisc(re
"since its contents depends on more than one package.")
}
if rel.ContainsText(".egg-info/") {
- pline.Warnf("Include \"../../lang/python/egg.mk\" instead of listing .egg-info files directly.")
+ canFix := ck.pkg != nil && ck.pkg.CanFixAddInclude()
+ fix := pline.Autofix()
+ fix.Warnf("Include \"../../lang/python/egg.mk\" " +
+ "instead of listing .egg-info files directly.")
+ if canFix {
+ fix.Replace(pline.Path().Dir().String(), "${PYSITELIB}/${EGG_INFODIR}")
+ }
+ fix.Apply()
+ if canFix {
+ ck.pkg.FixAddInclude("../../lang/python/egg.mk")
+ }
}
if rel.ContainsPath("..") {
pline.Errorf("Paths in PLIST files must not contain \"..\".")
@@ -534,6 +544,9 @@ type PlistLine struct {
text string // Line.Text without any conditions of the form ${PLIST.cond}
}
+// Autofix returns the autofix instance belonging to the line.
+//
+// See Line.Autofix for usage details.
func (pline *PlistLine) Autofix() *Autofix { return pline.Line.Autofix() }
func (pline *PlistLine) Errorf(format string, args ...interface{}) {
Home |
Main Index |
Thread Index |
Old Index