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:           Mon Jul  1 22:25:52 UTC 2019

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: autofix.go autofix_test.go linelexer.go
            mklines.go mkparser.go package.go package_test.go pkglint_test.go
            pkgsrc.go pkgsrc_test.go shtokenizer.go substcontext_test.go
            util.go

Log Message:
pkgtools/pkglint: update to 5.7.15

Changes since 5.7.14:

* Added a check for packages that have been removed from the file system
  but not been recorded in doc/CHANGES. This will help produce more
  accurate release statistics.

* Small refactorings, as usual.


To generate a diff of this commit:
cvs rdiff -u -r1.586 -r1.587 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.25 -r1.26 pkgsrc/pkgtools/pkglint/files/autofix.go \
    pkgsrc/pkgtools/pkglint/files/autofix_test.go \
    pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
cvs rdiff -u -r1.4 -r1.5 pkgsrc/pkgtools/pkglint/files/linelexer.go
cvs rdiff -u -r1.51 -r1.52 pkgsrc/pkgtools/pkglint/files/mklines.go
cvs rdiff -u -r1.30 -r1.31 pkgsrc/pkgtools/pkglint/files/mkparser.go
cvs rdiff -u -r1.57 -r1.58 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.48 -r1.49 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.44 -r1.45 pkgsrc/pkgtools/pkglint/files/pkglint_test.go
cvs rdiff -u -r1.29 -r1.30 pkgsrc/pkgtools/pkglint/files/pkgsrc.go
cvs rdiff -u -r1.18 -r1.19 pkgsrc/pkgtools/pkglint/files/shtokenizer.go
cvs rdiff -u -r1.27 -r1.28 pkgsrc/pkgtools/pkglint/files/substcontext_test.go
cvs rdiff -u -r1.47 -r1.48 pkgsrc/pkgtools/pkglint/files/util.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.586 pkgsrc/pkgtools/pkglint/Makefile:1.587
--- pkgsrc/pkgtools/pkglint/Makefile:1.586      Sun Jun 30 20:56:18 2019
+++ pkgsrc/pkgtools/pkglint/Makefile    Mon Jul  1 22:25:52 2019
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.586 2019/06/30 20:56:18 rillig Exp $
+# $NetBSD: Makefile,v 1.587 2019/07/01 22:25:52 rillig Exp $
 
-PKGNAME=       pkglint-5.7.14
+PKGNAME=       pkglint-5.7.15
 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.25 pkgsrc/pkgtools/pkglint/files/autofix.go:1.26
--- pkgsrc/pkgtools/pkglint/files/autofix.go:1.25       Sun Jun 30 20:56:18 2019
+++ pkgsrc/pkgtools/pkglint/files/autofix.go    Mon Jul  1 22:25:52 2019
@@ -52,9 +52,6 @@ const SilentAutofixFormat = "SilentAutof
 const AutofixFormat = "AutofixFormat"
 
 func NewAutofix(line *Line) *Autofix {
-       // FIXME: replacing the returned value with
-       //  &Autofix{line: line, autofixShortTerm: autofixShortTerm{anyway: true}}
-       //  makes some tests output source code without diagnostic.
        return &Autofix{line: line}
 }
 
Index: pkgsrc/pkgtools/pkglint/files/autofix_test.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.25 pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.26
--- pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.25  Sun Jun 30 20:56:18 2019
+++ pkgsrc/pkgtools/pkglint/files/autofix_test.go       Mon Jul  1 22:25:52 2019
@@ -988,6 +988,31 @@ func (s *Suite) Test_Autofix_Apply__anyw
        t.CheckOutputEmpty()
 }
 
+func (s *Suite) Test_Autofix_Apply__source_autofix_no_change(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("--autofix", "--source")
+       lines := t.SetUpFileLines("filename",
+               "word word word")
+
+       fix := lines.Lines[0].Autofix()
+       fix.Notef("Word should be replaced, but pkglint is not sure which one.")
+       fix.Replace("word", "replacement")
+       fix.Anyway()
+       fix.Apply()
+
+       lines.SaveAutofixChanges()
+
+       // Nothing is replaced since, as of June 2019, pkglint doesn't
+       // know which of the three "word" should be replaced.
+       //
+       // The note is not logged since fix.Anyway only applies when neither
+       // --show-autofix nor --autofix is given in the command line.
+       t.CheckOutputEmpty()
+       t.CheckFileLines("filename",
+               "word word word")
+}
+
 // Ensures that without explanations, the separator between the individual
 // diagnostics are generated.
 func (s *Suite) Test_Autofix_Apply__source_without_explain(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.25 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.26
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.25   Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go        Mon Jul  1 22:25:52 2019
@@ -259,6 +259,45 @@ func (s *Suite) Test_Pkgsrc_loadDocChang
        t.Check(G.Pkgsrc.LastChange["pkgpath"].Action, equals, Moved)
 }
 
+func (s *Suite) Test_Pkgsrc_checkRemovedAfterLastFreeze(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("-Wall", "--source")
+       t.SetUpPkgsrc()
+       t.CreateFileLines("doc/CHANGES-2019",
+               CvsID,
+               "",
+               "\tUpdated category/updated-before to 1.0 [updater 2019-04-01]",
+               "\tmk/bsd.pkg.mk: started freeze for pkgsrc-2019Q1 branch [freezer 2019-06-21]",
+               "\tmk/bsd.pkg.mk: freeze ended for pkgsrc-2019Q1 branch [freezer 2019-06-25]",
+               "\tUpdated category/updated-after to 1.0 [updater 2019-07-01]",
+               "\tAdded category/added-after version 1.0 [updater 2019-07-01]",
+               "\tMoved category/moved-from to category/moved-to [author 2019-07-02]",
+               "\tDowngraded category/downgraded to 1.0 [author 2019-07-03]")
+       t.FinishSetUp()
+
+       // It doesn't matter whether the last visible package change was before
+       // or after the latest freeze. The crucial point is that the most
+       // interesting change is the invisible one, which is the removal.
+       // And for finding the removal reliably, it doesn't matter how long ago
+       // the last package change was.
+
+       // The empty lines in the following output demonstrate the cheating
+       // by creating fake lines from Change.Location.
+       t.CheckOutputLines(
+               "ERROR: ~/doc/CHANGES-2019:3: Package category/updated-before "+
+                       "must either exist or be marked as removed.",
+               "",
+               "ERROR: ~/doc/CHANGES-2019:6: Package category/updated-after "+
+                       "must either exist or be marked as removed.",
+               "",
+               "ERROR: ~/doc/CHANGES-2019:7: Package category/added-after "+
+                       "must either exist or be marked as removed.",
+               "",
+               "ERROR: ~/doc/CHANGES-2019:9: Package category/downgraded "+
+                       "must either exist or be marked as removed.")
+}
+
 func (s *Suite) Test_Pkgsrc_loadDocChanges__not_found(c *check.C) {
        t := s.Init(c)
 
@@ -925,7 +964,7 @@ func (s *Suite) Test_Pkgsrc__frozen(c *c
                "\tmk/bsd.pkg.mk: started freeze for pkgsrc-2018Q2 branch [freezer 2018-03-25]")
        t.FinishSetUp()
 
-       t.Check(G.Pkgsrc.FreezeStart, equals, "2018-03-25")
+       t.Check(G.Pkgsrc.LastFreezeStart, equals, "2018-03-25")
 }
 
 func (s *Suite) Test_Pkgsrc__not_frozen(c *check.C) {
@@ -937,7 +976,8 @@ func (s *Suite) Test_Pkgsrc__not_frozen(
                "\tmk/bsd.pkg.mk: freeze ended for pkgsrc-2018Q2 branch [freezer 2018-03-27]")
        t.FinishSetUp()
 
-       t.Check(G.Pkgsrc.FreezeStart, equals, "")
+       t.Check(G.Pkgsrc.LastFreezeStart, equals, "2018-03-25")
+       t.Check(G.Pkgsrc.LastFreezeEnd, equals, "2018-03-27")
 }
 
 func (s *Suite) Test_Pkgsrc__frozen_with_typo(c *check.C) {
@@ -949,7 +989,7 @@ func (s *Suite) Test_Pkgsrc__frozen_with
                "\tmk/bsd.pkg.mk: started freeze for pkgsrc-2018Q2 branch [freezer 2018-03-25")
        t.FinishSetUp()
 
-       t.Check(G.Pkgsrc.FreezeStart, equals, "")
+       t.Check(G.Pkgsrc.LastFreezeStart, equals, "")
 }
 
 func (s *Suite) Test_Change_Version(c *check.C) {

Index: pkgsrc/pkgtools/pkglint/files/linelexer.go
diff -u pkgsrc/pkgtools/pkglint/files/linelexer.go:1.4 pkgsrc/pkgtools/pkglint/files/linelexer.go:1.5
--- pkgsrc/pkgtools/pkglint/files/linelexer.go:1.4      Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/linelexer.go  Mon Jul  1 22:25:52 2019
@@ -48,7 +48,7 @@ func (llex *LinesLexer) NextRegexp(re re
        }
 
        if !llex.EOF() {
-               if m := G.res.Match(llex.lines.Lines[llex.index].Text, re); m != nil {
+               if m := match(llex.lines.Lines[llex.index].Text, re); m != nil {
                        llex.index++
                        return m
                }

Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.51 pkgsrc/pkgtools/pkglint/files/mklines.go:1.52
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.51       Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/mklines.go    Mon Jul  1 22:25:52 2019
@@ -451,7 +451,7 @@ func (mklines *MkLines) collectDocumente
                                break
                        }
                        if hasSuffix(varname, ".") {
-                               if !parser.lexer.SkipRegexp(G.res.Compile(`^<\w+>`)) {
+                               if !parser.lexer.SkipRegexp(regcomp(`^<\w+>`)) {
                                        break
                                }
                                varname += "*"

Index: pkgsrc/pkgtools/pkglint/files/mkparser.go
diff -u pkgsrc/pkgtools/pkglint/files/mkparser.go:1.30 pkgsrc/pkgtools/pkglint/files/mkparser.go:1.31
--- pkgsrc/pkgtools/pkglint/files/mkparser.go:1.30      Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/mkparser.go   Mon Jul  1 22:25:52 2019
@@ -251,7 +251,7 @@ func (p *MkParser) varUseModifier(varnam
 
        case '=', 'D', 'M', 'N', 'U':
                lexer.Skip(1)
-               re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^$:\\}]|\$\$|\\.)+`, `^([^$:\\)]|\$\$|\\.)+`)))
+               re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^$:\\}]|\$\$|\\.)+`, `^([^$:\\)]|\$\$|\\.)+`)))
                for p.VarUse() != nil || lexer.SkipRegexp(re) {
                }
                arg := lexer.Since(mark)
@@ -268,7 +268,7 @@ func (p *MkParser) varUseModifier(varnam
                }
 
        case '[':
-               if lexer.SkipRegexp(G.res.Compile(`^\[(?:[-.\d]+|#)\]`)) {
+               if lexer.SkipRegexp(regcomp(`^\[(?:[-.\d]+|#)\]`)) {
                        return lexer.Since(mark)
                }
 
@@ -283,7 +283,7 @@ func (p *MkParser) varUseModifier(varnam
 
        lexer.Reset(mark)
 
-       re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^:$}]|\$\$)+`, `^([^:$)]|\$\$)+`)))
+       re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^:$}]|\$\$)+`, `^([^:$)]|\$\$)+`)))
        for p.VarUse() != nil || lexer.SkipRegexp(re) {
        }
        modifier := lexer.Since(mark)
@@ -309,7 +309,7 @@ func (p *MkParser) varUseModifier(varnam
 func (p *MkParser) varUseText(closing byte) string {
        lexer := p.lexer
        start := lexer.Mark()
-       re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^$:}]|\$\$)+`, `^([^$:)]|\$\$)+`)))
+       re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^$:}]|\$\$)+`, `^([^$:)]|\$\$)+`)))
        for p.VarUse() != nil || lexer.SkipRegexp(re) {
        }
        return lexer.Since(start)
@@ -391,7 +391,7 @@ func (p *MkParser) varUseModifierAt(lexe
                return false
        }
 
-       re := G.res.Compile(`^([^$@\\]|\\.)+`)
+       re := regcomp(`^([^$@\\]|\\.)+`)
        for p.VarUse() != nil || lexer.SkipString("$$") || lexer.SkipRegexp(re) {
        }
 
@@ -498,11 +498,11 @@ func (p *MkParser) mkCondAtom() *MkCond 
                if lhs != nil {
                        lexer.SkipHspace()
 
-                       if m := lexer.NextRegexp(G.res.Compile(`^(<|<=|==|!=|>=|>)[\t ]*(0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
+                       if m := lexer.NextRegexp(regcomp(`^(<|<=|==|!=|>=|>)[\t ]*(0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
                                return &MkCond{CompareVarNum: &MkCondCompareVarNum{lhs, m[1], m[2]}}
                        }
 
-                       m := lexer.NextRegexp(G.res.Compile(`^(?:<|<=|==|!=|>=|>)`))
+                       m := lexer.NextRegexp(regcomp(`^(?:<|<=|==|!=|>=|>)`))
                        if m == nil {
                                return &MkCond{Var: lhs} // See devel/bmake/files/cond.c:/\* For \.if \$/
                        }
@@ -510,7 +510,7 @@ func (p *MkParser) mkCondAtom() *MkCond 
 
                        op := m[0]
                        if op == "==" || op == "!=" {
-                               if mrhs := lexer.NextRegexp(G.res.Compile(`^"([^"\$\\]*)"`)); mrhs != nil {
+                               if mrhs := lexer.NextRegexp(regcomp(`^"([^"\$\\]*)"`)); mrhs != nil {
                                        return &MkCond{CompareVarStr: &MkCondCompareVarStr{lhs, op, mrhs[1]}}
                                }
                        }
@@ -559,7 +559,7 @@ func (p *MkParser) mkCondAtom() *MkCond 
                }
 
                // See devel/bmake/files/cond.c:/^CondCvtArg
-               if m := lexer.NextRegexp(G.res.Compile(`^(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
+               if m := lexer.NextRegexp(regcomp(`^(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
                        return &MkCond{Num: m[0]}
                }
        }
@@ -652,8 +652,8 @@ func (p *MkParser) PkgbasePattern() stri
 
        for {
                if p.VarUse() != nil ||
-                       lexer.SkipRegexp(G.res.Compile(`^[\w.*+,{}]+`)) ||
-                       lexer.SkipRegexp(G.res.Compile(`^\[[\w-]+\]`)) {
+                       lexer.SkipRegexp(regcomp(`^[\w.*+,{}]+`)) ||
+                       lexer.SkipRegexp(regcomp(`^\[[\w-]+\]`)) {
                        continue
                }
 
@@ -696,7 +696,7 @@ func (p *MkParser) Dependency() *Depende
                        return lexer.Since(mark)
                }
 
-               m := lexer.NextRegexp(G.res.Compile(`^\d[\w.]*`))
+               m := lexer.NextRegexp(regcomp(`^\d[\w.]*`))
                if m != nil {
                        return m[0]
                }
@@ -749,7 +749,7 @@ func (p *MkParser) Dependency() *Depende
        if lexer.SkipByte('-') && lexer.Rest() != "" {
                versionMark := lexer.Mark()
 
-               for p.VarUse() != nil || lexer.SkipRegexp(G.res.Compile(`^[\w\[\]*_.\-]+`)) {
+               for p.VarUse() != nil || lexer.SkipRegexp(regcomp(`^[\w\[\]*_.\-]+`)) {
                }
 
                if !lexer.SkipString("{,nb*}") {

Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.57 pkgsrc/pkgtools/pkglint/files/package.go:1.58
--- pkgsrc/pkgtools/pkglint/files/package.go:1.57       Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/package.go    Mon Jul  1 22:25:52 2019
@@ -1214,8 +1214,8 @@ func (pkg *Package) checkOwnerMaintainer
 }
 
 func (pkg *Package) checkFreeze(filename string) {
-       freezeStart := G.Pkgsrc.FreezeStart
-       if freezeStart == "" {
+       freezeStart := G.Pkgsrc.LastFreezeStart
+       if freezeStart == "" || G.Pkgsrc.LastFreezeEnd != "" {
                return
        }
 

Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.48 pkgsrc/pkgtools/pkglint/files/package_test.go:1.49
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.48  Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/package_test.go       Mon Jul  1 22:25:52 2019
@@ -962,7 +962,7 @@ func (s *Suite) Test_Package_load__extra
                "ERROR: gnu-style.mk:1: Unknown Makefile line format: \"ifeq ($(CC),gcc)\".",
                "ERROR: gnu-style.mk:3: Unknown Makefile line format: \"else\".",
                "ERROR: gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
-               "ERROR: gnu-style.mk:1: Expected \"# $NetBSD: package_test.go,v 1.48 2019/06/30 20:56:19 rillig Exp $\".",
+               "ERROR: gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: gnu-style.mk:2: IS_GCC is defined but not used.",
 
                // There is no warning about files/gnu-style.mk since pkglint
@@ -983,7 +983,7 @@ func (s *Suite) Test_Package_load__extra
                "ERROR: ../../category/other/gnu-style.mk:1: Unknown Makefile line format: \"ifeq ($(CC),gcc)\".",
                "ERROR: ../../category/other/gnu-style.mk:3: Unknown Makefile line format: \"else\".",
                "ERROR: ../../category/other/gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
-               "ERROR: ../../category/other/gnu-style.mk:1: Expected \"# $NetBSD: package_test.go,v 1.48 2019/06/30 20:56:19 rillig Exp $\".",
+               "ERROR: ../../category/other/gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: ../../category/other/gnu-style.mk:2: IS_GCC is defined but not used.",
 
                "ERROR: patches/patch-Makefile.mk: Contains no patch.",

Index: pkgsrc/pkgtools/pkglint/files/pkglint_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.44 pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.45
--- pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.44  Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/pkglint_test.go       Mon Jul  1 22:25:52 2019
@@ -246,7 +246,7 @@ func (s *Suite) Test_Pkglint_Main__autof
        exitcode := t.Main("-Wall", "--autofix", t.File("filename.mk"))
 
        t.CheckOutputLines(
-               "AUTOFIX: ~/filename.mk:1: Inserting a line \"# $NetBSD: pkglint_test.go,v 1.44 2019/06/30 20:56:19 rillig Exp $\" before this line.")
+               "AUTOFIX: ~/filename.mk:1: Inserting a line \"" + MkCvsID + "\" before this line.")
        t.Check(exitcode, equals, 0)
 }
 

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.29 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.30
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.29        Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go     Mon Jul  1 22:25:52 2019
@@ -36,8 +36,9 @@ type Pkgsrc struct {
        suggestedUpdates    []SuggestedUpdate
        suggestedWipUpdates []SuggestedUpdate
 
-       LastChange  map[string]*Change
-       FreezeStart string // e.g. "2018-01-01", or ""
+       LastChange      map[string]*Change
+       LastFreezeStart string // e.g. "2018-01-01", or ""
+       LastFreezeEnd   string // e.g. "2018-01-01", or ""
 
        listVersions map[string][]string // See Pkgsrc.ListVersions
 
@@ -64,6 +65,7 @@ func NewPkgsrc(dir string) Pkgsrc {
                nil,
                make(map[string]*Change),
                "",
+               "",
                make(map[string][]string),
                NewScope(),
                make(map[string]string),
@@ -517,11 +519,14 @@ func (src *Pkgsrc) loadDocChangesFromFil
                if hasPrefix(line.Text, "\tmk/") {
                        infra = true
                        if hasPrefix(line.Text, "\tmk/bsd.pkg.mk: started freeze for") {
-                               if m, freezeDate := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
-                                       src.FreezeStart = freezeDate
+                               if m, date := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
+                                       src.LastFreezeStart = date
+                                       src.LastFreezeEnd = ""
                                }
                        } else if hasPrefix(line.Text, "\tmk/bsd.pkg.mk: freeze ended for") {
-                               src.FreezeStart = ""
+                               if m, date := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
+                                       src.LastFreezeEnd = date
+                               }
                        }
                }
                if infra {
@@ -603,6 +608,40 @@ func (src *Pkgsrc) loadDocChanges() {
                        }
                }
        }
+
+       src.checkRemovedAfterLastFreeze()
+}
+
+func (src *Pkgsrc) checkRemovedAfterLastFreeze() {
+       if src.LastFreezeStart == "" || G.Wip {
+               return
+       }
+
+       var wrong []*Change
+       for pkgpath, change := range src.LastChange {
+               switch change.Action {
+               case Added, Updated, Downgraded:
+                       if !dirExists(src.File(pkgpath)) {
+                               wrong = append(wrong, change)
+                       }
+               }
+       }
+
+       sort.Slice(wrong, func(i, j int) bool {
+               ei, ej := wrong[i], wrong[j]
+               if ei.Date != ej.Date {
+                       return ei.Date < ej.Date
+               }
+               return ei.Location.firstLine < ej.Location.firstLine
+       })
+
+       for _, change := range wrong {
+               // It's a bit cheated to construct a Line from only a Location,
+               // without the wrong text. That's only because I'm too lazy loading
+               // the file again, and the original text is not lying around anywhere.
+               line := NewLineMulti(change.Location.Filename, int(change.Location.firstLine), int(change.Location.lastLine), "", nil)
+               line.Errorf("Package %s must either exist or be marked as removed.", change.Pkgpath)
+       }
 }
 
 func (src *Pkgsrc) loadUserDefinedVars() {

Index: pkgsrc/pkgtools/pkglint/files/shtokenizer.go
diff -u pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.18 pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.19
--- pkgsrc/pkgtools/pkglint/files/shtokenizer.go:1.18   Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/shtokenizer.go        Mon Jul  1 22:25:52 2019
@@ -137,7 +137,7 @@ func (p *ShTokenizer) shAtomBackt() *ShA
                return &ShAtom{shtText, lexer.Since(mark), shqBacktSquot, nil}
        case lexer.NextHspace() != "":
                return &ShAtom{shtSpace, lexer.Since(mark), q, nil}
-       case lexer.SkipRegexp(G.res.Compile("^#[^`]*")):
+       case lexer.SkipRegexp(regcomp("^#[^`]*")):
                return &ShAtom{shtComment, lexer.Since(mark), q, nil}
        }
        return p.shAtomInternal(q, false, false)
@@ -158,7 +158,7 @@ func (p *ShTokenizer) shAtomSubsh() *ShA
                return &ShAtom{shtText, lexer.Since(mark), shqSubshSquot, nil}
        case lexer.SkipByte('`'):
                return &ShAtom{shtText, lexer.Since(mark), shqSubshBackt, nil}
-       case lexer.SkipRegexp(G.res.Compile(`^#[^)]*`)):
+       case lexer.SkipRegexp(regcomp(`^#[^)]*`)):
                return &ShAtom{shtComment, lexer.Since(mark), q, nil}
        case lexer.SkipByte(')'):
                // The closing parenthesis can have multiple meanings:
@@ -191,7 +191,7 @@ func (p *ShTokenizer) shAtomDquotBackt()
                return &ShAtom{shtText, lexer.Since(mark), shqDquotBacktDquot, nil}
        case lexer.SkipByte('\''):
                return &ShAtom{shtText, lexer.Since(mark), shqDquotBacktSquot, nil}
-       case lexer.SkipRegexp(G.res.Compile("^#[^`]*")):
+       case lexer.SkipRegexp(regcomp("^#[^`]*")):
                return &ShAtom{shtComment, lexer.Since(mark), q, nil}
        case lexer.NextHspace() != "":
                return &ShAtom{shtSpace, lexer.Since(mark), q, nil}
@@ -300,13 +300,13 @@ loop:
                _ = `^[\t "$&'();<>\\|]+` // These are not allowed in shqPlain.
 
                switch {
-               case lexer.SkipRegexp(G.res.Compile(`^[!#%*+,\-./0-9:=?@A-Z\[\]^_a-z{}~]+`)):
+               case lexer.SkipRegexp(regcomp(`^[!#%*+,\-./0-9:=?@A-Z\[\]^_a-z{}~]+`)):
                        break
-               case dquot && lexer.SkipRegexp(G.res.Compile(`^[\t &'();<>|]+`)):
+               case dquot && lexer.SkipRegexp(regcomp(`^[\t &'();<>|]+`)):
                        break
                case squot && lexer.SkipByte('`'):
                        break
-               case squot && lexer.SkipRegexp(G.res.Compile(`^[\t "&();<>\\|]+`)):
+               case squot && lexer.SkipRegexp(regcomp(`^[\t "&();<>\\|]+`)):
                        break
                case squot && lexer.SkipString("$$"):
                        break
@@ -314,7 +314,7 @@ loop:
                        break loop
                case lexer.SkipString("\\$$"):
                        break
-               case lexer.SkipRegexp(G.res.Compile(`^\\[^$]`)):
+               case lexer.SkipRegexp(regcomp(`^\\[^$]`)):
                        break
                case matches(lexer.Rest(), `^\$\$[^!#(*\-0-9?@A-Z_a-z{]`):
                        lexer.NextString("$$")
@@ -353,7 +353,7 @@ func (p *ShTokenizer) shVarUse(q ShQuoti
        brace := lexer.SkipByte('{')
 
        varnameStart := lexer.Mark()
-       if !lexer.SkipRegexp(G.res.Compile(`^(?:[!#*\-?@]|\$\$|[A-Za-z_]\w*|\d+)`)) {
+       if !lexer.SkipRegexp(regcomp(`^(?:[!#*\-?@]|\$\$|[A-Za-z_]\w*|\d+)`)) {
                lexer.Reset(beforeDollar)
                return nil
        }
@@ -364,7 +364,7 @@ func (p *ShTokenizer) shVarUse(q ShQuoti
        }
 
        if brace {
-               lexer.SkipRegexp(G.res.Compile(`^(?:##?|%%?|:?[+\-=?])[^$\\{}]*`))
+               lexer.SkipRegexp(regcomp(`^(?:##?|%%?|:?[+\-=?])[^$\\{}]*`))
                if !lexer.SkipByte('}') {
                        lexer.Reset(beforeDollar)
                        return nil
@@ -388,7 +388,7 @@ func (p *ShTokenizer) shOperator(q ShQuo
                lexer.SkipByte('|'),
                lexer.SkipByte('&'):
                return &ShAtom{shtOperator, lexer.Since(mark), q, nil}
-       case lexer.SkipRegexp(G.res.Compile(`^\d*(?:<<-|<<|<&|<>|>>|>&|>\||<|>)`)):
+       case lexer.SkipRegexp(regcomp(`^\d*(?:<<-|<<|<&|<>|>>|>&|>\||<|>)`)):
                return &ShAtom{shtOperator, lexer.Since(mark), q, nil}
        }
        return nil

Index: pkgsrc/pkgtools/pkglint/files/substcontext_test.go
diff -u pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.27 pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.28
--- pkgsrc/pkgtools/pkglint/files/substcontext_test.go:1.27     Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/substcontext_test.go  Mon Jul  1 22:25:52 2019
@@ -694,7 +694,7 @@ func (s *Suite) Test_SubstContext_sugges
                        "with \"SUBST_VARS.pfx+=\\tPREFIX\".")
 
        t.CheckFileLinesDetab("subst.mk",
-               "# $NetBSD: substcontext_test.go,v 1.27 2019/06/30 20:56:19 rillig Exp $",
+               MkCvsID,
                "",
                "SUBST_CLASSES+=         pfx",
                "SUBST_STAGE.pfx=        pre-configure",
@@ -733,7 +733,7 @@ func (s *Suite) Test_SubstContext_sugges
                        "with \"SUBST_VARS.pfx=\\t\\tPREFIX\".")
 
        t.CheckFileLinesDetab("subst.mk",
-               "# $NetBSD: substcontext_test.go,v 1.27 2019/06/30 20:56:19 rillig Exp $",
+               MkCvsID,
                "",
                "SUBST_CLASSES+=         pfx",
                "SUBST_STAGE.pfx=        pre-configure",
@@ -767,7 +767,7 @@ func (s *Suite) Test_SubstContext_sugges
                        "with \"SUBST_VARS.id=\\tPREFIX\".")
 
        t.CheckFileLinesDetab("subst.mk",
-               "# $NetBSD: substcontext_test.go,v 1.27 2019/06/30 20:56:19 rillig Exp $",
+               MkCvsID,
                "",
                "SUBST_CLASSES+= id",
                "SUBST_STAGE.id= pre-configure",
@@ -801,7 +801,7 @@ func (s *Suite) Test_SubstContext_sugges
                        "with \"SUBST_VARS.fix-paths=\\t\\tPREFIX\".")
 
        t.CheckFileLinesDetab("subst.mk",
-               "# $NetBSD: substcontext_test.go,v 1.27 2019/06/30 20:56:19 rillig Exp $",
+               MkCvsID,
                "",
                "SUBST_CLASSES+=                 fix-paths",
                "SUBST_STAGE.fix-paths=          pre-configure",

Index: pkgsrc/pkgtools/pkglint/files/util.go
diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.47 pkgsrc/pkgtools/pkglint/files/util.go:1.48
--- pkgsrc/pkgtools/pkglint/files/util.go:1.47  Sun Jun 30 20:56:19 2019
+++ pkgsrc/pkgtools/pkglint/files/util.go       Mon Jul  1 22:25:52 2019
@@ -42,6 +42,12 @@ func hasSuffix(s, suffix string) bool {
 func sprintf(format string, args ...interface{}) string {
        return fmt.Sprintf(format, args...)
 }
+func regcomp(re regex.Pattern) *regexp.Regexp {
+       return G.res.Compile(re)
+}
+func match(s string, re regex.Pattern) []string {
+       return G.res.Match(s, re)
+}
 func matches(s string, re regex.Pattern) bool {
        return G.res.Matches(s, re)
 }



Home | Main Index | Thread Index | Old Index