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: Thu Jul 12 16:23:36 UTC 2018
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: alternatives.go autofix.go
autofix_test.go buildlink3.go buildlink3_test.go category_test.go
codewalk.md line.go logging.go mkline.go mkline_test.go
mklinechecker.go mklinechecker_test.go mklines.go package.go
package_test.go patches.go pkglint_test.go plist.go shell_test.go
shtokenizer.go substcontext.go substcontext_test.go toplevel.go
toplevel_test.go vartypecheck_test.go
pkgsrc/pkgtools/pkglint/files/pkgver: vercmp.go vercmp_test.go
Log Message:
pkgtools/pkglint: Update to 5.5.13
Changes since 5.5.12:
* Allow underscore in package version.
* Warn about SUBST in post-patch and pre-patch phases.
* Allow multiple SUBST blocks per paragraph.
* Code cleanup.
To generate a diff of this commit:
cvs rdiff -u -r1.540 -r1.541 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/pkglint/files/alternatives.go \
pkgsrc/pkgtools/pkglint/files/codewalk.md
cvs rdiff -u -r1.7 -r1.8 pkgsrc/pkgtools/pkglint/files/autofix.go
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/pkglint/files/autofix_test.go
cvs rdiff -u -r1.11 -r1.12 pkgsrc/pkgtools/pkglint/files/buildlink3.go \
pkgsrc/pkgtools/pkglint/files/logging.go \
pkgsrc/pkgtools/pkglint/files/substcontext_test.go
cvs rdiff -u -r1.13 -r1.14 pkgsrc/pkgtools/pkglint/files/buildlink3_test.go
cvs rdiff -u -r1.9 -r1.10 pkgsrc/pkgtools/pkglint/files/category_test.go \
pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
cvs rdiff -u -r1.23 -r1.24 pkgsrc/pkgtools/pkglint/files/line.go
cvs rdiff -u -r1.31 -r1.32 pkgsrc/pkgtools/pkglint/files/mkline.go
cvs rdiff -u -r1.34 -r1.35 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.12 -r1.13 pkgsrc/pkgtools/pkglint/files/mklinechecker.go
cvs rdiff -u -r1.24 -r1.25 pkgsrc/pkgtools/pkglint/files/mklines.go \
pkgsrc/pkgtools/pkglint/files/shell_test.go
cvs rdiff -u -r1.30 -r1.31 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.22 -r1.23 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/pkglint/files/patches.go
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/pkglint/files/pkglint_test.go
cvs rdiff -u -r1.25 -r1.26 pkgsrc/pkgtools/pkglint/files/plist.go \
pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
cvs rdiff -u -r1.8 -r1.9 pkgsrc/pkgtools/pkglint/files/shtokenizer.go
cvs rdiff -u -r1.10 -r1.11 pkgsrc/pkgtools/pkglint/files/substcontext.go \
pkgsrc/pkgtools/pkglint/files/toplevel.go \
pkgsrc/pkgtools/pkglint/files/toplevel_test.go
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.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.540 pkgsrc/pkgtools/pkglint/Makefile:1.541
--- pkgsrc/pkgtools/pkglint/Makefile:1.540 Tue Jun 12 17:50:26 2018
+++ pkgsrc/pkgtools/pkglint/Makefile Thu Jul 12 16:23:36 2018
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.540 2018/06/12 17:50:26 bsiegert Exp $
+# $NetBSD: Makefile,v 1.541 2018/07/12 16:23:36 rillig Exp $
-PKGNAME= pkglint-5.5.12
-PKGREVISION= 1
+PKGNAME= pkglint-5.5.13
DISTFILES= # none
CATEGORIES= pkgtools
Index: pkgsrc/pkgtools/pkglint/files/alternatives.go
diff -u pkgsrc/pkgtools/pkglint/files/alternatives.go:1.1 pkgsrc/pkgtools/pkglint/files/alternatives.go:1.2
--- pkgsrc/pkgtools/pkglint/files/alternatives.go:1.1 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/alternatives.go Thu Jul 12 16:23:36 2018
@@ -30,7 +30,8 @@ func CheckfileAlternatives(filename stri
fix := line.Autofix()
fix.Notef("@PREFIX@/ can be omitted from the file name.")
fix.Explain(
- "The alternative implementation is always interpreted relative to ${PREFIX}.")
+ "The alternative implementation is always interpreted relative to",
+ "${PREFIX}.")
fix.ReplaceAfter(space, "@PREFIX@/", "")
fix.Apply()
} else {
Index: pkgsrc/pkgtools/pkglint/files/codewalk.md
diff -u pkgsrc/pkgtools/pkglint/files/codewalk.md:1.1 pkgsrc/pkgtools/pkglint/files/codewalk.md:1.2
--- pkgsrc/pkgtools/pkglint/files/codewalk.md:1.1 Sun Mar 4 20:34:33 2018
+++ pkgsrc/pkgtools/pkglint/files/codewalk.md Thu Jul 12 16:23:36 2018
@@ -24,7 +24,7 @@ When running pkglint, the `G` variable i
It contains the whole global state of pkglint.
(Except for some of the subpackages, which have to be initialized separately.)
All the interesting code is in the `Pkglint` type.
-This code structure makes it easy to test the code.
+Having only a single global variable makes it easy to reset the global state during testing.
### Testing pkglint
@@ -80,8 +80,9 @@ The path of the pkgsrc directory is dete
line argument, which in this file is `DESCR`. From there, the pkgsrc
root is usually reachable via `../../`, and this is what pkglint tries.
-After the initialization of everything,
-all items from the TODO list are worked off and handed over to `CheckDirent`.
+After initializing the pkgsrc metadata,
+all items from the TODO list are worked off and handed over to `CheckDirent`,
+one after another.
```codewalk
file pkglint.go
@@ -121,7 +122,10 @@ end ^\}
Now we are where the actual action takes place.
The code looks straight-forward here.
First, each line is checked on its own,
-and the final check is for too long files.
+and the final check is for too long files.
+Pkglint takes great care to output all diagnostics in a logical order,
+that is file by file, and top to bottom within each file.
+Therefore the checks for individual lines happen before the other check.
The call to `SaveAutofixChanges` at the end looks a bit strange
since none of the visible checks fixes anything.
@@ -135,7 +139,8 @@ end ^\}
```
This code is a typical example for using the autofix feature.
-Some more details are described at the `Autofix` type itself:
+Some more details are described at the `Autofix` type itself
+and at its typical call site `Line.Autofix()`:
```codewalk
file linechecker.go
@@ -143,6 +148,12 @@ start /^type Autofix/ upwhile /^\/\//
end /^type Autofix/
```
+```codewalk
+file line.go
+start /^func .* Autofix/ upwhile /^\/\//
+end /^func .* Autofix/
+```
+
The journey ends here, and it hasn't been that difficult.
If that was too easy, have a look at the complex cases here:
@@ -184,6 +195,11 @@ end ^\}
### MkLine
+Most of the pkgsrc infrastructure is written in Makefiles.
+In these, there may be line continuations (the ones ending in backslash).
+Plus, they may contain Make variables of the form `${VARNAME}` or `${VARNAME:Modifiers}`,
+and these are handled specially.
+
```codewalk
file mkline.go
start ^type MkLine =
@@ -195,14 +211,10 @@ start ^type MkLineImpl struct
end ^\}
```
-Most of the pkgsrc infrastructure is written in Makefiles.
-In these, there may be line continuations (the ones ending in backslash).
-Plus, they may contain Make variables of the form `${VARNAME}` or `${VARNAME:Modifiers}`,
-and these are handled specially.
-
### ShellLine
-The instructions for building and installing packages are written in Shell.
+The instructions for building and installing packages are written in shell commands,
+which are embedded in Makefile fragments.
The `ShellLine` type provides methods for checking shell commands and their individual parts.
```codewalk
Index: pkgsrc/pkgtools/pkglint/files/autofix.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix.go:1.7 pkgsrc/pkgtools/pkglint/files/autofix.go:1.8
--- pkgsrc/pkgtools/pkglint/files/autofix.go:1.7 Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/autofix.go Thu Jul 12 16:23:36 2018
@@ -211,23 +211,17 @@ func (fix *Autofix) Describef(lineno int
// Notef remembers the note for logging it later when Apply is called.
func (fix *Autofix) Notef(format string, args ...interface{}) {
- fix.level = llNote
- fix.diagFormat = format
- fix.diagArgs = args
+ fix.setDiag(llNote, format, args)
}
// Warnf remembers the warning for logging it later when Apply is called.
func (fix *Autofix) Warnf(format string, args ...interface{}) {
- fix.level = llWarn
- fix.diagFormat = format
- fix.diagArgs = args
+ fix.setDiag(llWarn, format, args)
}
// Errorf remembers the error for logging it later when Apply is called.
func (fix *Autofix) Errorf(format string, args ...interface{}) {
- fix.level = llError
- fix.diagFormat = format
- fix.diagArgs = args
+ fix.setDiag(llError, format, args)
}
// Explain remembers the explanation for logging it later when Apply is called.
@@ -263,13 +257,13 @@ func (fix *Autofix) Apply() {
if action.lineno != 0 {
lineno = strconv.Itoa(action.lineno)
}
- logs(llAutofix, line.Filename, lineno, "", action.description)
+ logs(llAutofix, line.Filename, lineno, "Magic-Autofix-Format", action.description)
}
}
if logDiagnostic || logRepair {
line.printSource(G.logOut)
- if G.opts.Explain && logDiagnostic && len(fix.explanation) != 0 {
+ if logDiagnostic && len(fix.explanation) != 0 {
Explain(fix.explanation...)
} else if G.opts.PrintSource {
G.logOut.Separate()
@@ -286,6 +280,16 @@ func (fix *Autofix) Apply() {
fix.explanation = nil
}
+func (fix *Autofix) setDiag(level *LogLevel, format string, args []interface{}) {
+ if G.Testing && format != "Silent-Magic-Diagnostic" && !hasSuffix(format, ".") {
+ panic(fmt.Sprintf("Autofix: format %q must end with a period.", format))
+ }
+
+ fix.level = level
+ fix.diagFormat = format
+ fix.diagArgs = args
+}
+
func (fix *Autofix) skip() bool {
// This check is necessary for the --only command line option.
if fix.diagFormat == "" {
Index: pkgsrc/pkgtools/pkglint/files/autofix_test.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.5 pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.6
--- pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.5 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/autofix_test.go Thu Jul 12 16:23:36 2018
@@ -287,12 +287,12 @@ func (s *Suite) Test_Autofix_InsertBefor
line := t.NewLine("Makefile", 30, "original")
fix := line.Autofix()
- fix.Warnf("Dummy")
+ fix.Warnf("Dummy.")
fix.InsertBefore("inserted")
fix.Apply()
t.CheckOutputLines(
- "WARN: Makefile:30: Dummy",
+ "WARN: Makefile:30: Dummy.",
"AUTOFIX: Makefile:30: Inserting a line \"inserted\" before this line.",
"+\tinserted",
">\toriginal")
@@ -305,12 +305,12 @@ func (s *Suite) Test_Autofix_Delete(c *c
line := t.NewLine("Makefile", 30, "to be deleted")
fix := line.Autofix()
- fix.Warnf("Dummy")
+ fix.Warnf("Dummy.")
fix.Delete()
fix.Apply()
t.CheckOutputLines(
- "WARN: Makefile:30: Dummy",
+ "WARN: Makefile:30: Dummy.",
"AUTOFIX: Makefile:30: Deleting this line.",
"-\tto be deleted")
}
@@ -401,7 +401,7 @@ func (s *Suite) Test_Autofix_CustomFix(c
doFix := func(line Line) {
fix := line.Autofix()
- fix.Warnf("Please write in ALL-UPPERCASE")
+ fix.Warnf("Please write in ALL-UPPERCASE.")
fix.Custom(func(printAutofix, autofix bool) {
fix.Describef(int(line.firstLine), "Converting to uppercase")
if printAutofix || autofix {
@@ -414,14 +414,14 @@ func (s *Suite) Test_Autofix_CustomFix(c
doFix(lines[0])
t.CheckOutputLines(
- "WARN: Makefile:1: Please write in ALL-UPPERCASE")
+ "WARN: Makefile:1: Please write in ALL-UPPERCASE.")
t.SetupCommandLine("--show-autofix")
doFix(lines[1])
t.CheckOutputLines(
- "WARN: Makefile:2: Please write in ALL-UPPERCASE",
+ "WARN: Makefile:2: Please write in ALL-UPPERCASE.",
"AUTOFIX: Makefile:2: Converting to uppercase")
c.Check(lines[1].Text, equals, "LINE2")
@@ -433,3 +433,19 @@ func (s *Suite) Test_Autofix_CustomFix(c
"AUTOFIX: Makefile:3: Converting to uppercase")
c.Check(lines[2].Text, equals, "LINE3")
}
+
+func (s *Suite) Test_Autofix_Explain(c *check.C) {
+ t := s.Init(c)
+
+ line := t.NewLine("Makefile", 74, "line1")
+
+ fix := line.Autofix()
+ fix.Warnf("Please write row instead of line.")
+ fix.Replace("line", "row")
+ fix.Explain("Explanation")
+ fix.Apply()
+
+ t.CheckOutputLines(
+ "WARN: Makefile:74: Please write row instead of line.")
+ c.Check(G.explanationsAvailable, equals, true)
+}
Index: pkgsrc/pkgtools/pkglint/files/buildlink3.go
diff -u pkgsrc/pkgtools/pkglint/files/buildlink3.go:1.11 pkgsrc/pkgtools/pkglint/files/buildlink3.go:1.12
--- pkgsrc/pkgtools/pkglint/files/buildlink3.go:1.11 Mon Jan 1 18:04:15 2018
+++ pkgsrc/pkgtools/pkglint/files/buildlink3.go Thu Jul 12 16:23:36 2018
@@ -101,7 +101,7 @@ func ChecklinesBuildlink3Mk(mklines *MkL
indentLevel := 1 // The first .if is from the second paragraph.
for {
if exp.EOF() {
- exp.CurrentLine().Warnf("Expected .endif")
+ exp.CurrentLine().Warnf("Expected \".endif\".")
return
}
@@ -113,11 +113,6 @@ func ChecklinesBuildlink3Mk(mklines *MkL
varname, value := mkline.Varname(), mkline.Value()
doCheck := false
- const (
- reDependencyCmp = `^((?:\$\{[\w_]+\}|[\w_\.+]|-[^\d])+)[<>]=?(\d[^-*?\[\]]*)$`
- reDependencyWildcard = `^(-(?:\[0-9\]\*|\d[^-]*)$`
- )
-
if varname == "BUILDLINK_ABI_DEPENDS."+pkgbase {
abiLine = line
parser := NewParser(line, value, false)
Index: pkgsrc/pkgtools/pkglint/files/logging.go
diff -u pkgsrc/pkgtools/pkglint/files/logging.go:1.11 pkgsrc/pkgtools/pkglint/files/logging.go:1.12
--- pkgsrc/pkgtools/pkglint/files/logging.go:1.11 Sun Mar 4 20:34:33 2018
+++ pkgsrc/pkgtools/pkglint/files/logging.go Thu Jul 12 16:23:36 2018
@@ -56,6 +56,9 @@ func logs(level *LogLevel, fname, lineno
if fname != "" {
fname = cleanpath(fname)
}
+ if G.Testing && format != "Magic-Autofix-Format" && !hasSuffix(format, ".") && !hasSuffix(format, ": %s") && !hasSuffix(format, ". %s") {
+ panic(fmt.Sprintf("Format %q must end in a period.", format))
+ }
if !G.opts.LogVerbose && loggedAlready(fname, lineno, msg) {
return false
@@ -77,7 +80,7 @@ func logs(level *LogLevel, fname, lineno
text += sep + level.GccName + ":"
sep = " "
}
- if G.opts.Profiling && format != "" {
+ if G.opts.Profiling && format != "Magic-Autofix-Format" {
G.loghisto.Add(format, 1)
}
text += sep + msg + "\n"
@@ -100,6 +103,9 @@ func logs(level *LogLevel, fname, lineno
return true
}
+// Explain outputs an explanation for the preceding diagnostic
+// if the --explain option is given. Otherwise it just records
+// that an explanation is available.
func Explain(explanation ...string) {
if G.Testing {
for _, s := range explanation {
Index: pkgsrc/pkgtools/pkglint/files/substcontext_test.go
diff -u pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.11 pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.12
--- pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.11 Sat Jan 27 18:50:36 2018
+++ pkgsrc/pkgtools/pkglint/files/substcontext_test.go Thu Jul 12 16:23:36 2018
@@ -173,6 +173,75 @@ func (s *Suite) Test_SubstContext__neste
"WARN: Makefile:25: Incomplete SUBST block: SUBST_FILES.os missing.")
}
+func (s *Suite) Test_SubstContext__post_patch(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupCommandLine("-Wextra,no-space", "--show-autofix")
+ t.SetupVartypes()
+
+ mklines := t.NewMkLines("os.mk",
+ MkRcsID,
+ "",
+ "SUBST_CLASSES+= os",
+ "SUBST_STAGE.os= post-patch",
+ "SUBST_FILES.os= guess-os.h",
+ "SUBST_SED.os= -e s,@OPSYS@,Darwin,")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: os.mk:4: Substitutions should not happen in the patch phase.",
+ "AUTOFIX: os.mk:4: Replacing \"post-patch\" with \"pre-configure\".")
+}
+
+func (s *Suite) Test_SubstContext__adjacent(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupCommandLine("-Wextra")
+ t.SetupVartypes()
+
+ mklines := t.NewMkLines("os.mk",
+ MkRcsID,
+ "",
+ "SUBST_CLASSES+= 1",
+ "SUBST_STAGE.1= pre-configure",
+ "SUBST_FILES.1= file1",
+ "SUBST_SED.1= -e s,subst1,repl1,",
+ "SUBST_CLASSES+= 2",
+ "SUBST_SED.1+= -e s,subst1b,repl1b,", // Misplaced
+ "SUBST_STAGE.2= pre-configure",
+ "SUBST_FILES.2= file2",
+ "SUBST_SED.2= -e s,subst2,repl2,")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: os.mk:8: Variable \"SUBST_SED.1\" does not match SUBST class \"2\".")
+}
+
+func (s *Suite) Test_SubstContext__do_patch(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupCommandLine("-Wextra,no-space")
+ t.SetupVartypes()
+
+ mklines := t.NewMkLines("os.mk",
+ MkRcsID,
+ "",
+ "SUBST_CLASSES+= os",
+ "SUBST_STAGE.os= do-patch",
+ "SUBST_FILES.os= guess-os.h",
+ "SUBST_SED.os= -e s,@OPSYS@,Darwin,")
+
+ mklines.Check()
+
+ // No warning, since there is nothing to fix automatically.
+ // This case also doesn't occur in practice.
+ t.CheckOutputEmpty()
+}
+
+// simulateSubstLines only tests some of the inner workings of SubstContext.
+// It is not realistic for all cases. If in doubt, use MkLines.Check.
func simulateSubstLines(t *Tester, texts ...string) {
ctx := NewSubstContext()
for _, lineText := range texts {
Index: pkgsrc/pkgtools/pkglint/files/buildlink3_test.go
diff -u pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.13 pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.14
--- pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.13 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/buildlink3_test.go Thu Jul 12 16:23:36 2018
@@ -206,7 +206,7 @@ func (s *Suite) Test_ChecklinesBuildlink
ChecklinesBuildlink3Mk(mklines)
t.CheckOutputLines(
- "WARN: buildlink3.mk:6: UNRELATED_BUILDLINK3_MK is defined but not used. Spelling mistake?",
+ "WARN: buildlink3.mk:6: UNRELATED_BUILDLINK3_MK is defined but not used.",
"WARN: buildlink3.mk:6: This line should contain the following text: HS_X11_BUILDLINK3_MK:=")
}
@@ -225,7 +225,7 @@ func (s *Suite) Test_ChecklinesBuildlink
ChecklinesBuildlink3Mk(mklines)
t.CheckOutputLines(
- "WARN: buildlink3.mk:EOF: Expected .endif")
+ "WARN: buildlink3.mk:EOF: Expected \".endif\".")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_unknown_dependency_patterns(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/category_test.go
diff -u pkgsrc/pkgtools/pkglint/files/category_test.go:1.9 pkgsrc/pkgtools/pkglint/files/category_test.go:1.10
--- pkgsrc/pkgtools/pkglint/files/category_test.go:1.9 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/category_test.go Thu Jul 12 16:23:36 2018
@@ -20,7 +20,7 @@ func (s *Suite) Test_CheckdirCategory_to
t.CheckOutputLines(
"ERROR: ~/archivers/Makefile:1: Expected \"# $"+"NetBSD$\".",
"WARN: ~/archivers/Makefile:4: Line contains invalid characters (U+2019).",
- "WARN: ~/archivers/Makefile:4: SUBDIR- is defined but not used. Spelling mistake?",
+ "WARN: ~/archivers/Makefile:4: SUBDIR- is defined but not used.",
"ERROR: ~/archivers/Makefile:6: \"../mk/category.mk\" does not exist.",
"ERROR: ~/archivers/Makefile:2: COMMENT= line expected.",
"WARN: ~/archivers/Makefile:2: Indentation should be a single tab character.",
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.9 pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.10
--- pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.9 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go Thu Jul 12 16:23:36 2018
@@ -142,7 +142,7 @@ func (s *Suite) Test_MkLineChecker_check
MkLineChecker{G.Mk.mklines[1]}.checkVarassign()
t.CheckOutputLines(
- "WARN: Makefile:2: ac_cv_libpari_libs is defined but not used. Spelling mistake?")
+ "WARN: Makefile:2: ac_cv_libpari_libs is defined but not used.")
}
func (s *Suite) Test_MkLineChecker_checkVarassignDefPermissions(c *check.C) {
@@ -231,8 +231,8 @@ func (s *Suite) Test_MkLineChecker__uncl
mklines.Check()
t.CheckOutputLines(
- "WARN: Makefile:2: Unclosed Make variable starting at \"${EGDIR/apparmor.d $...\"",
- "WARN: Makefile:2: EGDIRS is defined but not used. Spelling mistake?",
+ "WARN: Makefile:2: Unclosed Make variable starting at \"${EGDIR/apparmor.d $...\".",
+ "WARN: Makefile:2: EGDIRS is defined but not used.",
"WARN: Makefile:2: Pkglint parse error in MkLine.Tokenize at "+
"\"${EGDIR/apparmor.d ${EGDIR/dbus-1/system.d ${EGDIR/pam.d\".")
}
Index: pkgsrc/pkgtools/pkglint/files/line.go
diff -u pkgsrc/pkgtools/pkglint/files/line.go:1.23 pkgsrc/pkgtools/pkglint/files/line.go:1.24
--- pkgsrc/pkgtools/pkglint/files/line.go:1.23 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/line.go Thu Jul 12 16:23:36 2018
@@ -160,6 +160,8 @@ func (line *LineImpl) String() string {
return line.Filename + ":" + line.Linenos() + ": " + line.Text
}
+// Autofix returns the autofix instance belonging to the line.
+//
// Usage:
//
// fix := line.Autofix()
Index: pkgsrc/pkgtools/pkglint/files/mkline.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.31 pkgsrc/pkgtools/pkglint/files/mkline.go:1.32
--- pkgsrc/pkgtools/pkglint/files/mkline.go:1.31 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/mkline.go Thu Jul 12 16:23:36 2018
@@ -40,7 +40,7 @@ type mkLineConditional struct {
args string
}
type mkLineInclude struct {
- mustexist bool
+ mustExist bool
sys bool
indent string
includeFile string
@@ -156,12 +156,12 @@ func (mkline *MkLineImpl) IsCommentedVar
return ok && data.commented
}
-// IsShellcmd returns true for tab-indented lines that are assigned to a Make
+// IsShellCommand returns true for tab-indented lines that are assigned to a Make
// target. Example:
//
// pre-configure: # IsDependency
-// ${ECHO} # IsShellcmd
-func (mkline *MkLineImpl) IsShellcmd() bool {
+// ${ECHO} # IsShellCommand
+func (mkline *MkLineImpl) IsShellCommand() bool {
_, ok := mkline.data.(mkLineShell)
return ok
}
@@ -227,7 +227,7 @@ func (mkline *MkLineImpl) Value() string
// In the above line, the comment is "# comment".
// The leading "#" is included so that pkglint can distinguish between no comment at all and an empty comment.
func (mkline *MkLineImpl) VarassignComment() string { return mkline.data.(mkLineAssign).comment }
-func (mkline *MkLineImpl) Shellcmd() string { return mkline.data.(mkLineShell).command }
+func (mkline *MkLineImpl) ShellCommand() string { return mkline.data.(mkLineShell).command }
func (mkline *MkLineImpl) Indent() string {
if mkline.IsCond() {
return mkline.data.(mkLineConditional).indent
@@ -237,8 +237,8 @@ func (mkline *MkLineImpl) Indent() strin
}
func (mkline *MkLineImpl) Directive() string { return mkline.data.(mkLineConditional).directive }
func (mkline *MkLineImpl) Args() string { return mkline.data.(mkLineConditional).args }
-func (mkline *MkLineImpl) MustExist() bool { return mkline.data.(mkLineInclude).mustexist }
-func (mkline *MkLineImpl) Includefile() string { return mkline.data.(mkLineInclude).includeFile }
+func (mkline *MkLineImpl) MustExist() bool { return mkline.data.(mkLineInclude).mustExist }
+func (mkline *MkLineImpl) IncludeFile() string { return mkline.data.(mkLineInclude).includeFile }
func (mkline *MkLineImpl) Targets() string { return mkline.data.(mkLineDependency).targets }
func (mkline *MkLineImpl) Sources() string { return mkline.data.(mkLineDependency).sources }
Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.34 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.35
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.34 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go Thu Jul 12 16:23:36 2018
@@ -139,8 +139,8 @@ func (s *Suite) Test_NewMkLine(c *check.
c.Check(ln[0].Value(), equals, "value")
c.Check(ln[0].VarassignComment(), equals, "# varassign comment")
- c.Check(ln[1].IsShellcmd(), equals, true)
- c.Check(ln[1].Shellcmd(), equals, "shell command # shell comment")
+ c.Check(ln[1].IsShellCommand(), equals, true)
+ c.Check(ln[1].ShellCommand(), equals, "shell command # shell comment")
c.Check(ln[2].IsComment(), equals, true)
@@ -154,12 +154,12 @@ func (s *Suite) Test_NewMkLine(c *check.
c.Check(ln[5].IsInclude(), equals, true)
c.Check(ln[5].Indent(), equals, " ")
c.Check(ln[5].MustExist(), equals, true)
- c.Check(ln[5].Includefile(), equals, "../../mk/bsd.prefs.mk")
+ c.Check(ln[5].IncludeFile(), equals, "../../mk/bsd.prefs.mk")
c.Check(ln[6].IsSysinclude(), equals, true)
c.Check(ln[6].Indent(), equals, " ")
c.Check(ln[6].MustExist(), equals, true)
- c.Check(ln[6].Includefile(), equals, "subdir.mk")
+ c.Check(ln[6].IncludeFile(), equals, "subdir.mk")
c.Check(ln[7].IsDependency(), equals, true)
c.Check(ln[7].Targets(), equals, "target1 target2")
@@ -247,12 +247,12 @@ func (s *Suite) Test_NewMkLine_numbersig
mklineCommandEscaped := t.NewMkLine("fname", 1, "\tsed -e 's,\\#,hash,g'")
- c.Check(mklineCommandEscaped.Shellcmd(), equals, "sed -e 's,\\#,hash,g'")
+ c.Check(mklineCommandEscaped.ShellCommand(), equals, "sed -e 's,\\#,hash,g'")
// From shells/zsh/Makefile.common, rev. 1.78
mklineCommandUnescaped := t.NewMkLine("fname", 1, "\t# $ sha1 patches/patch-ac")
- c.Check(mklineCommandUnescaped.Shellcmd(), equals, "# $ sha1 patches/patch-ac")
+ c.Check(mklineCommandUnescaped.ShellCommand(), equals, "# $ sha1 patches/patch-ac")
t.CheckOutputEmpty() // No warning about parsing the lonely dollar sign.
mklineVarassignUnescaped := t.NewMkLine("fname", 1, "SED_CMD=\t's,#,hash,'")
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.12 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.13
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.12 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go Thu Jul 12 16:23:36 2018
@@ -24,10 +24,10 @@ func (ck MkLineChecker) Check() {
case mkline.IsVarassign():
ck.checkVarassign()
- case mkline.IsShellcmd():
- shellcmd := mkline.Shellcmd()
- ck.checkText(shellcmd)
- NewShellLine(mkline).CheckShellCommandLine(shellcmd)
+ case mkline.IsShellCommand():
+ shellCommand := mkline.ShellCommand()
+ ck.checkText(shellCommand)
+ NewShellLine(mkline).CheckShellCommandLine(shellCommand)
case mkline.IsComment():
if hasPrefix(mkline.Text, "# url2pkg-marker") {
@@ -49,7 +49,7 @@ func (ck MkLineChecker) checkInclude() {
ck.checkDirectiveIndentation(G.Mk.indentation.Depth("include"))
}
- includefile := mkline.Includefile()
+ includefile := mkline.IncludeFile()
mustExist := mkline.MustExist()
if trace.Tracing {
trace.Step2("includingFile=%s includefile=%s", mkline.Filename, includefile)
@@ -309,7 +309,7 @@ func (ck MkLineChecker) CheckVaruse(varu
!varIsUsed(varname) &&
!(G.Mk != nil && G.Mk.forVars[varname]) &&
!containsVarRef(varname) {
- mkline.Warnf("%s is used but not defined. Spelling mistake?", varname)
+ mkline.Warnf("%s is used but not defined.", varname)
}
if hasPrefix(varuse.Mod(), ":=") && vartype != nil && !vartype.IsConsideredList() {
@@ -674,7 +674,7 @@ func (ck MkLineChecker) checkVarassign()
} else if deprecated := G.Pkgsrc.Deprecated; deprecated[varname] != "" || deprecated[varcanon] != "" {
// Ok
} else {
- mkline.Warnf("%s is defined but not used. Spelling mistake?", varname)
+ mkline.Warnf("%s is defined but not used.", varname)
}
}
Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.24 pkgsrc/pkgtools/pkglint/files/mklines.go:1.25
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.24 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/mklines.go Thu Jul 12 16:23:36 2018
@@ -108,7 +108,7 @@ func (mklines *MkLines) Check() {
case mkline.IsInclude():
mklines.target = ""
- switch path.Base(mkline.Includefile()) {
+ switch path.Base(mkline.IncludeFile()) {
case "bsd.prefs.mk", "bsd.fast.prefs.mk", "bsd.builtin.mk":
mklines.setSeenBsdPrefsMk()
}
@@ -124,8 +124,8 @@ func (mklines *MkLines) Check() {
ck.checkDependencyRule(allowedTargets)
mklines.target = mkline.Targets()
- case mkline.IsShellcmd():
- mkline.Tokenize(mkline.Shellcmd())
+ case mkline.IsShellCommand():
+ mkline.Tokenize(mkline.ShellCommand())
}
}
lastMkline := mklines.mklines[len(mklines.mklines)-1]
Index: pkgsrc/pkgtools/pkglint/files/shell_test.go
diff -u pkgsrc/pkgtools/pkglint/files/shell_test.go:1.24 pkgsrc/pkgtools/pkglint/files/shell_test.go:1.25
--- pkgsrc/pkgtools/pkglint/files/shell_test.go:1.24 Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/shell_test.go Thu Jul 12 16:23:36 2018
@@ -14,7 +14,7 @@ func (s *Suite) Test_splitIntoShellToken
c.Check(rest, equals, "\\")
t.CheckOutputLines(
- "WARN: Pkglint parse error in ShTokenizer.ShAtom at \"\\\\\" (quoting=plain)")
+ "WARN: Pkglint parse error in ShTokenizer.ShAtom at \"\\\\\" (quoting=plain).")
}
func (s *Suite) Test_splitIntoShellTokens__dollar_slash(c *check.C) {
@@ -116,7 +116,7 @@ func (s *Suite) Test_ShellLine_CheckShel
"\t"+shellCommand)
shline := NewShellLine(G.Mk.mklines[0])
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
}
checkShellCommandLine("@# Comment")
@@ -168,7 +168,7 @@ func (s *Suite) Test_ShellLine_CheckShel
checkShellCommandLine("echo \"$$\"") // As seen by make(1); the shell sees: echo "$"
t.CheckOutputLines(
- "WARN: fname:1: Pkglint parse error in ShTokenizer.ShAtom at \"$$\\\"\" (quoting=d)",
+ "WARN: fname:1: Pkglint parse error in ShTokenizer.ShAtom at \"$$\\\"\" (quoting=d).",
"WARN: fname:1: Pkglint ShellLine.CheckShellCommand: parse error at [\"]")
checkShellCommandLine("echo \"\\n\"")
@@ -202,13 +202,13 @@ func (s *Suite) Test_ShellLine_CheckShel
"done")
t.CheckOutputLines(
- "WARN: fname:1: XPI_FILES is used but not defined. Spelling mistake?",
+ "WARN: fname:1: XPI_FILES is used but not defined.",
"WARN: fname:1: The exitcode of \"${UNZIP_CMD}\" at the left of the | operator is ignored.",
- "WARN: fname:1: UNZIP_CMD is used but not defined. Spelling mistake?",
+ "WARN: fname:1: UNZIP_CMD is used but not defined.",
"WARN: fname:1: Unknown shell command \"awk\".",
"WARN: fname:1: Unknown shell command \"${MKDIR}\".",
- "WARN: fname:1: MKDIR is used but not defined. Spelling mistake?",
- "WARN: fname:1: UNZIP_CMD is used but not defined. Spelling mistake?")
+ "WARN: fname:1: MKDIR is used but not defined.",
+ "WARN: fname:1: UNZIP_CMD is used but not defined.")
// From x11/wxGTK28/Makefile
checkShellCommandLine("" +
@@ -264,14 +264,14 @@ func (s *Suite) Test_ShellLine_CheckShel
"\t"+shellCommand)
shline := NewShellLine(G.Mk.mklines[0])
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
}
checkShellCommandLine("${STRIP} executable")
t.CheckOutputLines(
"WARN: fname:1: Unknown shell command \"${STRIP}\".",
- "WARN: fname:1: STRIP is used but not defined. Spelling mistake?")
+ "WARN: fname:1: STRIP is used but not defined.")
t.SetupVartypes()
@@ -336,7 +336,7 @@ func (s *Suite) Test_ShellLine_CheckShel
for _, mkline := range G.Mk.mklines {
shline := NewShellLine(mkline)
- shline.CheckShellCommandLine(mkline.Shellcmd())
+ shline.CheckShellCommandLine(mkline.ShellCommand())
}
t.CheckOutputLines(
@@ -493,7 +493,7 @@ func (s *Suite) Test_ShellLine_CheckShel
text := "\tfor f in *.pl; do ${SED} s,@PREFIX@,${PREFIX}, < $f > $f.tmp && ${MV} $f.tmp $f; done"
shline := t.NewShellLine("Makefile", 3, text)
- shline.mkline.Tokenize(shline.mkline.Shellcmd())
+ shline.mkline.Tokenize(shline.mkline.ShellCommand())
shline.CheckShellCommandLine(text)
t.CheckOutputLines(
@@ -558,7 +558,7 @@ func (s *Suite) Test_ShellLine_CheckShel
shline := t.NewShellLine("Makefile", 85, "\t${RUN} ${SED} 's,#,// comment:,g' fname > fname.tmp; ${MV} fname.tmp fname")
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
t.CheckOutputLines(
"NOTE: Makefile:85: Please use the SUBST framework instead of ${SED} and ${MV}.")
@@ -569,7 +569,7 @@ func (s *Suite) Test_ShellLine_CheckShel
shline := t.NewShellLine("Makefile", 85, "\t${RUN} uname=$$(uname)")
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
t.CheckOutputLines(
"WARN: Makefile:85: Invoking subshells via $(...) is not portable enough.")
@@ -580,7 +580,7 @@ func (s *Suite) Test_ShellLine_CheckShel
shline := t.NewShellLine("Makefile", 85, "\t${RUN} ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/dir1 ${DESTDIR}${PREFIX}/dir2")
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
t.CheckOutputLines(
"NOTE: Makefile:85: You can use \"INSTALLATION_DIRS+= dir1\" instead of \"${INSTALL_DATA_DIR}\".",
@@ -606,7 +606,7 @@ func (s *Suite) Test_ShellLine_CheckShel
shline := t.NewShellLine("Makefile", 85, "\t${RUN} ${INSTALL} -d ${DESTDIR}${PREFIX}/dir1 ${DESTDIR}${PREFIX}/dir2")
- shline.CheckShellCommandLine(shline.mkline.Shellcmd())
+ shline.CheckShellCommandLine(shline.mkline.ShellCommand())
t.CheckOutputLines(
"NOTE: Makefile:85: You can use \"INSTALLATION_DIRS+= dir1\" instead of \"${INSTALL} -d\".",
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.30 pkgsrc/pkgtools/pkglint/files/package.go:1.31
--- pkgsrc/pkgtools/pkglint/files/package.go:1.30 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/package.go Thu Jul 12 16:23:36 2018
@@ -11,7 +11,7 @@ import (
"strings"
)
-const rePkgname = `^([\w\-.+]+)-(\d(?:\w|\.\d)*)$`
+const rePkgname = `^([\w\-.+]+)-(\d[.0-9A-Z_a-z]*)$`
// Package contains data for the pkgsrc package that is currently checked.
type Package struct {
@@ -103,7 +103,7 @@ func (pkg *Package) checkPossibleDowngra
if change.Action == "Updated" {
changeVersion := regex.Compile(`nb\d+$`).ReplaceAllString(change.Version, "")
if pkgver.Compare(pkgversion, changeVersion) < 0 {
- mkline.Warnf("The package is being downgraded from %s (see %s) to %s", change.Version, change.Line.ReferenceFrom(mkline.Line), pkgversion)
+ mkline.Warnf("The package is being downgraded from %s (see %s) to %s.", change.Version, change.Line.ReferenceFrom(mkline.Line), pkgversion)
Explain(
"The files in doc/CHANGES-*, in which all version changes are",
"recorded, have a higher version number than what the package says.",
@@ -122,7 +122,7 @@ func (pkg *Package) checklinesBuildlink3
includedFiles := make(map[string]MkLine)
for _, mkline := range mklines.mklines {
if mkline.IsInclude() {
- file := mkline.Includefile()
+ file := mkline.IncludeFile()
if m, bl3 := match1(file, `^\.\./\.\./(.*)/buildlink3\.mk`); m {
includedFiles[bl3] = mkline
if pkg.bl3[bl3] == nil {
@@ -320,7 +320,7 @@ func (pkg *Package) readMakefile(fname s
var includeFile, incDir, incBase string
if mkline.IsInclude() {
- inc := mkline.Includefile()
+ inc := mkline.IncludeFile()
includeFile = resolveVariableRefs(mkline.ResolveVarsInRelativePath(inc, true))
if containsVarRef(includeFile) {
if !contains(fname, "/mk/") {
@@ -420,7 +420,7 @@ func (pkg *Package) checkfilePackageMake
!vars.Defined("META_PACKAGE") &&
!fileExists(G.CurrentDir+"/"+pkg.Pkgdir+"/PLIST") &&
!fileExists(G.CurrentDir+"/"+pkg.Pkgdir+"/PLIST.common") {
- NewLineWhole(fname).Warnf("Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset. Are you sure PLIST handling is ok?")
+ NewLineWhole(fname).Warnf("Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset.")
}
if (vars.Defined("NO_CHECKSUM") || vars.Defined("META_PACKAGE")) && isEmptyDir(G.CurrentDir+"/"+pkg.Patchdir) {
@@ -918,7 +918,7 @@ func (pkg *Package) CheckInclude(mkline
}
if path.Dir(abspath(mkline.Filename)) == abspath(G.CurrentDir) {
- includefile := mkline.Includefile()
+ includefile := mkline.IncludeFile()
if indentation.IsConditional() {
pkg.conditionalIncludes[includefile] = mkline
Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.22 pkgsrc/pkgtools/pkglint/files/package_test.go:1.23
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.22 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/package_test.go Thu Jul 12 16:23:36 2018
@@ -295,7 +295,7 @@ func (s *Suite) Test_Package_checkPossib
G.Pkg.checkPossibleDowngrade()
t.CheckOutputLines(
- "WARN: category/pkgbase/Makefile:5: The package is being downgraded from 1.8 (see ../../doc/CHANGES:116) to 1.0nb15")
+ "WARN: category/pkgbase/Makefile:5: The package is being downgraded from 1.8 (see ../../doc/CHANGES:116) to 1.0nb15.")
G.Pkgsrc.LastChange["category/pkgbase"].Version = "1.0nb22"
@@ -314,7 +314,7 @@ func (s *Suite) Test_checkdirPackage(c *
G.checkdirPackage(t.TmpDir())
t.CheckOutputLines(
- "WARN: ~/Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset. Are you sure PLIST handling is ok?",
+ "WARN: ~/Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset.",
"WARN: ~/distinfo: File not found. Please run \""+confMake+" makesum\" or define NO_CHECKSUM=yes in the package Makefile.",
"ERROR: ~/Makefile: Each package must define its LICENSE.",
"WARN: ~/Makefile: No COMMENT given.")
@@ -509,7 +509,7 @@ func (s *Suite) Test_Package_includeAfte
G.checkdirPackage(G.CurrentDir)
t.CheckOutputLines(
- "WARN: ~/category/package/Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset. Are you sure PLIST handling is ok?",
+ "WARN: ~/category/package/Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset.",
"WARN: ~/category/package/distinfo: File not found. Please run \"@BMAKE@ makesum\" or define NO_CHECKSUM=yes in the package Makefile.",
"ERROR: ~/category/package/Makefile: Each package must define its LICENSE.",
"WARN: ~/category/package/Makefile: No COMMENT given.",
Index: pkgsrc/pkgtools/pkglint/files/patches.go
diff -u pkgsrc/pkgtools/pkglint/files/patches.go:1.20 pkgsrc/pkgtools/pkglint/files/patches.go:1.21
--- pkgsrc/pkgtools/pkglint/files/patches.go:1.20 Mon Feb 19 12:40:38 2018
+++ pkgsrc/pkgtools/pkglint/files/patches.go Thu Jul 12 16:23:36 2018
@@ -110,7 +110,7 @@ func (ck *PatchChecker) checkUnifiedDiff
defer trace.Call0()()
}
- patchedFileType := guessFileType(ck.exp.CurrentLine(), patchedFile)
+ patchedFileType := guessFileType(patchedFile)
if trace.Tracing {
trace.Stepf("guessFileType(%q) = %s", patchedFile, patchedFileType)
}
@@ -156,7 +156,7 @@ func (ck *PatchChecker) checkUnifiedDiff
// this by looking only at the patch file.
if linesToAdd != linesToDel {
line := ck.exp.PreviousLine()
- line.Warnf("Premature end of patch hunk (expected %d lines to be deleted and %d lines to be added)",
+ line.Warnf("Premature end of patch hunk (expected %d lines to be deleted and %d lines to be added).",
linesToDel, linesToAdd)
}
}
@@ -306,7 +306,7 @@ func (ft FileType) String() string {
}
// This is used to select the proper subroutine for detecting absolute pathnames.
-func guessFileType(line Line, fname string) (fileType FileType) {
+func guessFileType(fname string) (fileType FileType) {
if trace.Tracing {
defer trace.Call(fname, "=>", &fileType)()
}
Index: pkgsrc/pkgtools/pkglint/files/pkglint_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.19 pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.20
--- pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.19 Tue May 1 23:30:11 2018
+++ pkgsrc/pkgtools/pkglint/files/pkglint_test.go Thu Jul 12 16:23:36 2018
@@ -251,7 +251,7 @@ func (s *Suite) Test_Pkglint_Main__compl
"(distinfo has asdfasdf, patch file has e775969de639ec703866c0336c4c8e0fdd96309c). "+
"Run \""+confMake+" makepatchsum\".",
"WARN: ~/sysutils/checkperms/patches/patch-checkperms.c:12: Premature end of patch hunk "+
- "(expected 1 lines to be deleted and 0 lines to be added)",
+ "(expected 1 lines to be deleted and 0 lines to be added).",
"2 errors and 2 warnings found.",
"(Run \"pkglint -e\" to show explanations.)",
"(Run \"pkglint -fs\" to show what can be fixed automatically.)",
Index: pkgsrc/pkgtools/pkglint/files/plist.go
diff -u pkgsrc/pkgtools/pkglint/files/plist.go:1.25 pkgsrc/pkgtools/pkglint/files/plist.go:1.26
--- pkgsrc/pkgtools/pkglint/files/plist.go:1.25 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/plist.go Thu Jul 12 16:23:36 2018
@@ -238,6 +238,11 @@ func (ck *PlistChecker) checkDuplicate(p
func (ck *PlistChecker) checkpathBin(pline *PlistLine, dirname, basename string) {
if contains(dirname, "/") {
pline.line.Warnf("The bin/ directory should not have subdirectories.")
+ Explain(
+ "The programs in bin/ are collected there to be executable by the",
+ "user without having to type an absolute path. This advantage does",
+ "not apply to programs in subdirectories of bin/. These programs",
+ "should rather be placed in libexec/PKGBASE.")
return
}
}
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.25 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.26
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.25 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go Thu Jul 12 16:23:36 2018
@@ -413,6 +413,26 @@ func (s *Suite) Test_VartypeCheck_Perms(
"ERROR: fname:2: ROOT_USER must not be used in permission definitions. Use REAL_ROOT_USER instead.")
}
+func (s *Suite) Test_VartypeCheck_Pkgname(c *check.C) {
+ t := s.Init(c)
+
+ runVartypeChecks(t, "PKGNAME", opAssign, (*VartypeCheck).PkgName,
+ "pkgbase-0",
+ "pkgbase-1.0",
+ "pkgbase-1.1234567890",
+ "pkgbase-1z",
+ "pkgbase-client-11a",
+ "pkgbase-client-1.a",
+ "pkgbase-client-1_20180101",
+ "pkgbase-z1",
+ "pkgbase-3.1.4.1.5.9.2.6.5.3.5.8.9.7.9")
+
+ t.CheckOutputLines(
+ "WARN: fname:8: \"pkgbase-z1\" is not a valid package name. " +
+ "A valid package name has the form packagename-version, " +
+ "where version consists only of digits, letters and dots.")
+}
+
func (s *Suite) Test_VartypeCheck_PkgOptionsVar(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/shtokenizer.go
diff -u pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.8 pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.9
--- pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.8 Sun Mar 4 20:34:33 2018
+++ pkgsrc/pkgtools/pkglint/files/shtokenizer.go Thu Jul 12 16:23:36 2018
@@ -39,7 +39,7 @@ func (p *ShTokenizer) ShAtom(quoting ShQ
case shqBackt:
atom = p.shAtomBackt()
case shqSubsh:
- atom = p.shAtomSub()
+ atom = p.shAtomSubsh()
case shqDquotBackt:
atom = p.shAtomDquotBackt()
case shqBacktDquot:
@@ -57,9 +57,9 @@ func (p *ShTokenizer) ShAtom(quoting ShQ
if atom == nil {
repl.Reset(mark)
if hasPrefix(repl.Rest(), "${") {
- p.parser.Line.Warnf("Unclosed Make variable starting at %q", shorten(repl.Rest(), 20))
+ p.parser.Line.Warnf("Unclosed Make variable starting at %q.", shorten(repl.Rest(), 20))
} else {
- p.parser.Line.Warnf("Pkglint parse error in ShTokenizer.ShAtom at %q (quoting=%s)", repl.Rest(), quoting)
+ p.parser.Line.Warnf("Pkglint parse error in ShTokenizer.ShAtom at %q (quoting=%s).", repl.Rest(), quoting)
}
}
return atom
@@ -137,7 +137,9 @@ func (p *ShTokenizer) shAtomBackt() *ShA
return nil
}
-func (p *ShTokenizer) shAtomSub() *ShAtom {
+// In pkgsrc, the $(...) subshell syntax is not used to preserve
+// compatibility with /bin/sh from Solaris 7.
+func (p *ShTokenizer) shAtomSubsh() *ShAtom {
const q = shqSubsh
if op := p.shOperator(q); op != nil {
return op
Index: pkgsrc/pkgtools/pkglint/files/substcontext.go
diff -u pkgsrc/pkgtools/pkglint/files/substcontext.go:1.10 pkgsrc/pkgtools/pkglint/files/substcontext.go:1.11
--- pkgsrc/pkgtools/pkglint/files/substcontext.go:1.10 Wed Jan 10 00:39:52 2018
+++ pkgsrc/pkgtools/pkglint/files/substcontext.go Thu Jul 12 16:23:36 2018
@@ -60,7 +60,11 @@ func (ctx *SubstContext) Varassign(mklin
mkline.Warnf("Please add only one class at a time to SUBST_CLASSES.")
}
if ctx.id != "" && ctx.id != classes[0] {
- mkline.Warnf("SUBST_CLASSES should only appear once in a SUBST block.")
+ if ctx.IsComplete() {
+ ctx.Finish(mkline)
+ } else {
+ mkline.Warnf("SUBST_CLASSES should only appear once in a SUBST block.")
+ }
}
ctx.id = classes[0]
return
@@ -97,6 +101,21 @@ func (ctx *SubstContext) Varassign(mklin
switch varbase {
case "SUBST_STAGE":
ctx.dupString(mkline, &ctx.stage, varname, value)
+ if value == "pre-patch" || value == "post-patch" {
+ fix := mkline.Autofix()
+ fix.Warnf("Substitutions should not happen in the patch phase.")
+ fix.Explain(
+ "Performing substitutions during post-patch breaks tools such as",
+ "mkpatches, making it very difficult to regenerate correct patches",
+ "after making changes, and often leading to substituted string",
+ "replacements being committed.",
+ "",
+ "Instead of pre-patch, use post-extract.",
+ "Instead of post-patch, use pre-configure.")
+ fix.Replace("pre-patch", "post-extract")
+ fix.Replace("post-patch", "pre-configure")
+ fix.Apply()
+ }
case "SUBST_MESSAGE":
ctx.dupString(mkline, &ctx.message, varname, value)
case "SUBST_FILES":
Index: pkgsrc/pkgtools/pkglint/files/toplevel.go
diff -u pkgsrc/pkgtools/pkglint/files/toplevel.go:1.10 pkgsrc/pkgtools/pkglint/files/toplevel.go:1.11
--- pkgsrc/pkgtools/pkglint/files/toplevel.go:1.10 Sat May 19 12:58:25 2018
+++ pkgsrc/pkgtools/pkglint/files/toplevel.go Thu Jul 12 16:23:36 2018
@@ -61,7 +61,7 @@ func (ctx *Toplevel) checkSubdir(line Li
case subdir == "archivers" && prev == "x11":
// This exception is documented in the top-level Makefile.
default:
- line.Warnf("%s should come before %s", subdir, prev)
+ line.Warnf("%s should come before %s.", subdir, prev)
}
ctx.previousSubdir = subdir
Index: pkgsrc/pkgtools/pkglint/files/toplevel_test.go
diff -u pkgsrc/pkgtools/pkglint/files/toplevel_test.go:1.10 pkgsrc/pkgtools/pkglint/files/toplevel_test.go:1.11
--- pkgsrc/pkgtools/pkglint/files/toplevel_test.go:1.10 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/toplevel_test.go Thu Jul 12 16:23:36 2018
@@ -28,5 +28,5 @@ func (s *Suite) Test_CheckdirToplevel(c
"WARN: ~/Makefile:3: Indentation should be a single tab character.",
"ERROR: ~/Makefile:6: Each subdir must only appear once.",
"WARN: ~/Makefile:7: \"ignoreme\" commented out without giving a reason.",
- "WARN: ~/Makefile:9: bbb should come before ccc")
+ "WARN: ~/Makefile:9: bbb should come before ccc.")
}
Index: pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.1 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.2
--- pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go:1.1 Sun Jan 1 15:15:47 2017
+++ pkgsrc/pkgtools/pkglint/files/pkgver/vercmp.go Thu Jul 12 16:23:36 2018
@@ -95,7 +95,7 @@ func (v *version) Add(i int) {
v.v = append(v.v, i)
}
func isdigit(b byte) bool {
- return b-'0' <= 9
+ return '0' <= b && b <= '9'
}
func (v *version) Place(i int) int {
if i < len(v.v) {
Index: pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.2 pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.3
--- pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go:1.2 Tue Jan 17 22:37:28 2017
+++ pkgsrc/pkgtools/pkglint/files/pkgver/vercmp_test.go Thu Jul 12 16:23:36 2018
@@ -1,7 +1,7 @@
package pkgver
import (
- check "gopkg.in/check.v1"
+ "gopkg.in/check.v1"
"testing"
)
@@ -24,6 +24,7 @@ func (s *Suite) Test_newVersion(c *check
c.Check(newVersion("1.0.1a"), check.DeepEquals, &version{[]int{1, 0, 0, 0, 1, 1}, 0})
c.Check(newVersion("1.0.1z"), check.DeepEquals, &version{[]int{1, 0, 0, 0, 1, 26}, 0})
c.Check(newVersion("0pre20160620"), check.DeepEquals, &version{[]int{0, -1, 20160620}, 0})
+ c.Check(newVersion("3.5.DEV1710"), check.DeepEquals, &version{[]int{3, 0, 5, 0, 4, 5, 22, 1710}, 0})
}
func (s *Suite) Test_Compare(c *check.C) {
@@ -37,8 +38,9 @@ func (s *Suite) Test_Compare(c *check.C)
{"1", "1.0", "1.0.0"},
{"1.0nb1"},
{"1.0nb2"},
- {"1.0.1a"},
+ {"1.0.1a", "1.0.a1", "1.0.aa"},
{"1.0.1z"},
+ {"1.0.11", "1.0.k"},
{"2.0pre", "2.0rc"},
{"2.0", "2.0pl"},
{"2.0.1nb4"},
Home |
Main Index |
Thread Index |
Old Index