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:           Tue May  1 23:30:11 UTC 2018

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: mkline.go mkline_test.go
            mklinechecker.go mklines.go mklines_test.go package.go
            package_test.go pkglint.go pkglint_test.go pkgsrc.go pkgsrc_test.go
            vardefs.go

Log Message:
Update pkglint to 5.5.10.

Changes since 5.5.9:

* Fix wrong pkglint behavior for .include lines that are guarded by
  corresponding .if exists(...)
* A little bit of refactoring, as always.


To generate a diff of this commit:
cvs rdiff -u -r1.536 -r1.537 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.30 -r1.31 pkgsrc/pkgtools/pkglint/files/mkline.go
cvs rdiff -u -r1.33 -r1.34 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.11 -r1.12 pkgsrc/pkgtools/pkglint/files/mklinechecker.go
cvs rdiff -u -r1.23 -r1.24 pkgsrc/pkgtools/pkglint/files/mklines.go
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/pkglint/files/mklines_test.go
cvs rdiff -u -r1.28 -r1.29 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.21 -r1.22 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.31 -r1.32 pkgsrc/pkgtools/pkglint/files/pkglint.go
cvs rdiff -u -r1.18 -r1.19 pkgsrc/pkgtools/pkglint/files/pkglint_test.go
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/pkglint/files/pkgsrc.go \
    pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
cvs rdiff -u -r1.39 -r1.40 pkgsrc/pkgtools/pkglint/files/vardefs.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.536 pkgsrc/pkgtools/pkglint/Makefile:1.537
--- pkgsrc/pkgtools/pkglint/Makefile:1.536      Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/Makefile    Tue May  1 23:30:11 2018
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.536 2018/04/28 23:32:52 rillig Exp $
+# $NetBSD: Makefile,v 1.537 2018/05/01 23:30:11 rillig Exp $
 
-PKGNAME=       pkglint-5.5.9
+PKGNAME=       pkglint-5.5.10
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 

Index: pkgsrc/pkgtools/pkglint/files/mkline.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.30 pkgsrc/pkgtools/pkglint/files/mkline.go:1.31
--- pkgsrc/pkgtools/pkglint/files/mkline.go:1.30        Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/mkline.go     Tue May  1 23:30:11 2018
@@ -724,19 +724,28 @@ func (vuc *VarUseContext) String() strin
 }
 
 // Indentation remembers the stack of preprocessing directives and their
-// indentation.  By convention, each directive is indented by 2 spaces.
+// indentation. By convention, each directive is indented by 2 spaces.
 // An excepting are multiple-inclusion guards, they don't increase the
 // indentation.
 type Indentation struct {
        depth         []int      // Number of space characters; always a multiple of 2
        conditionVars [][]string // Variables on which the current path depends
+
+       // Files whose existence has been checked in a related path.
+       // The check counts for both the "if" and the "else" branch,
+       // but that sloppiness will be discovered by functional tests.
+       checkedFiles [][]string
 }
 
 func (ind *Indentation) Len() int {
        return len(ind.depth)
 }
 
-func (ind *Indentation) Depth() int {
+func (ind *Indentation) Depth(directive string) int {
+       switch directive {
+       case "elif", "else", "endfor", "endif":
+               return ind.depth[imax(0, len(ind.depth)-2)]
+       }
        return ind.depth[len(ind.depth)-1]
 }
 
@@ -744,11 +753,13 @@ func (ind *Indentation) Pop() {
        newlen := ind.Len() - 1
        ind.depth = ind.depth[:newlen]
        ind.conditionVars = ind.conditionVars[:newlen]
+       ind.checkedFiles = ind.checkedFiles[:newlen]
 }
 
 func (ind *Indentation) Push(indent int) {
        ind.depth = append(ind.depth, indent)
        ind.conditionVars = append(ind.conditionVars, nil)
+       ind.checkedFiles = append(ind.checkedFiles, nil)
 }
 
 func (ind *Indentation) AddVar(varname string) {
@@ -797,6 +808,22 @@ func (ind *Indentation) Varnames() strin
        return varnames
 }
 
+func (ind *Indentation) AddCheckedFile(filename string) {
+       level := ind.Len() - 1
+       ind.checkedFiles[level] = append(ind.checkedFiles[level], filename)
+}
+
+func (ind *Indentation) IsCheckedFile(filename string) bool {
+       for _, levelFilenames := range ind.checkedFiles {
+               for _, levelFilename := range levelFilenames {
+                       if filename == levelFilename {
+                               return true
+                       }
+               }
+       }
+       return false
+}
+
 func MatchVarassign(text string) (m, commented bool, varname, spaceAfterVarname, op, valueAlign, value, spaceAfterValue, comment string) {
        i, n := 0, len(text)
 

Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.33 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.34
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.33   Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go        Tue May  1 23:30:11 2018
@@ -850,12 +850,13 @@ func (s *Suite) Test_Indentation(c *chec
 
        ind.Push(0)
 
-       c.Check(ind.Depth(), equals, 0)
+       c.Check(ind.Depth("if"), equals, 0)
        c.Check(ind.DependsOn("VARNAME"), equals, false)
 
        ind.Push(2)
 
-       c.Check(ind.Depth(), equals, 2)
+       c.Check(ind.Depth("if"), equals, 2)
+       c.Check(ind.Depth("endfor"), equals, 0)
 
        ind.AddVar("LEVEL1.VAR1")
 

Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.11 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.12
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.11 Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go      Tue May  1 23:30:11 2018
@@ -46,7 +46,7 @@ func (ck MkLineChecker) checkInclude() {
 
        mkline := ck.MkLine
        if mkline.Indent() != "" {
-               ck.checkDirectiveIndentation(G.Mk.indentation.Depth())
+               ck.checkDirectiveIndentation(G.Mk.indentation.Depth("include"))
        }
 
        includefile := mkline.Includefile()
@@ -98,8 +98,14 @@ func (ck MkLineChecker) checkCond(forVar
        directive := mkline.Directive()
        args := mkline.Args()
 
-       switch directive {
-       case "endif", "endfor":
+       expectedDepth := indentation.Depth(directive)
+       ck.checkDirectiveIndentation(expectedDepth)
+
+       if directive == "if" && matches(args, `^!defined\([\w]+_MK\)$`) {
+               indentation.Push(indentation.Depth(directive))
+       } else if matches(directive, `^(?:if|ifdef|ifndef|for)$`) {
+               indentation.Push(indentation.Depth(directive) + 2)
+       } else if directive == "endfor" || directive == "endif" {
                if indentation.Len() > 1 {
                        indentation.Pop()
                } else {
@@ -107,18 +113,6 @@ func (ck MkLineChecker) checkCond(forVar
                }
        }
 
-       expectedDepth := indentation.Depth()
-       if directive == "elif" || directive == "else" {
-               expectedDepth = indentation.depth[len(indentation.depth)-2]
-       }
-       ck.checkDirectiveIndentation(expectedDepth)
-
-       if directive == "if" && matches(args, `^!defined\([\w]+_MK\)$`) {
-               indentation.Push(indentation.Depth())
-       } else if matches(directive, `^(?:if|ifdef|ifndef|for)$`) {
-               indentation.Push(indentation.Depth() + 2)
-       }
-
        needsArgument := matches(directive, `^(?:if|ifdef|ifndef|elif|for|undef)$`)
        if needsArgument != (args != "") {
                if needsArgument {

Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.23 pkgsrc/pkgtools/pkglint/files/mklines.go:1.24
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.23       Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/mklines.go    Tue May  1 23:30:11 2018
@@ -134,8 +134,8 @@ func (mklines *MkLines) Check() {
 
        ChecklinesTrailingEmptyLines(mklines.lines)
 
-       if indentation.Len() != 1 && indentation.Depth() != 0 {
-               lastMkline.Errorf("Directive indentation is not 0, but %d.", indentation.Depth())
+       if indentation.Len() != 1 && indentation.Depth("") != 0 {
+               lastMkline.Errorf("Directive indentation is not 0, but %d.", indentation.Depth(""))
        }
 
        SaveAutofixChanges(mklines.lines)

Index: pkgsrc/pkgtools/pkglint/files/mklines_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.19 pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.20
--- pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.19  Sat Mar 24 14:32:49 2018
+++ pkgsrc/pkgtools/pkglint/files/mklines_test.go       Tue May  1 23:30:11 2018
@@ -414,8 +414,8 @@ func (s *Suite) Test_MkLines_Check_inden
                "NOTE: options.mk:12: This directive should be indented by 2 spaces.",
                "NOTE: options.mk:13: This directive should be indented by 0 spaces.",
                "NOTE: options.mk:14: This directive should be indented by 0 spaces.",
-               "ERROR: options.mk:15: Unmatched .endif.",
-               "NOTE: options.mk:15: This directive should be indented by 0 spaces.")
+               "NOTE: options.mk:15: This directive should be indented by 0 spaces.",
+               "ERROR: options.mk:15: Unmatched .endif.")
 }
 
 // Demonstrates how to define your own make(1) targets.

Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.28 pkgsrc/pkgtools/pkglint/files/package.go:1.29
--- pkgsrc/pkgtools/pkglint/files/package.go:1.28       Fri Apr  6 21:04:22 2018
+++ pkgsrc/pkgtools/pkglint/files/package.go    Tue May  1 23:30:11 2018
@@ -286,6 +286,28 @@ func (pkg *Package) readMakefile(fname s
                allLines.mklines = append(allLines.mklines, mkline)
                allLines.lines = append(allLines.lines, mkline.Line)
 
+               if mkline.IsCond() {
+                       ind := &fileMklines.indentation
+                       switch mkline.Directive() {
+                       case "if", "ifdef", "ifndef", "for":
+                               ind.Push(0) // Dummy indentation, only the checkedFiles are interesting
+                       case "endfor", "endif":
+                               if ind.Len() > 1 {
+                                       ind.Pop()
+                               }
+                       }
+
+                       if mkline.Directive() == "if" {
+                               args := mkline.Args()
+                               if contains(args, "exists") {
+                                       cond := NewMkParser(mkline.Line, args, false).MkCond()
+                                       cond.Visit("exists", func(node *Tree) {
+                                               ind.AddCheckedFile(node.args[0].(string))
+                                       })
+                               }
+                       }
+               }
+
                var includeFile, incDir, incBase string
                if mkline.IsInclude() {
                        inc := mkline.Includefile()
@@ -334,7 +356,11 @@ func (pkg *Package) readMakefile(fname s
                                // current file and in the current working directory.
                                // Pkglint doesn't have an include dir list, like make(1) does.
                                if !fileExists(dirname + "/" + includeFile) {
-                                       if dirname != G.CurrentDir { // Prevent unnecessary syscalls
+
+                                       if fileMklines.indentation.IsCheckedFile(includeFile) {
+                                               continue // See https://github.com/rillig/pkglint/issues/1
+
+                                       } else if dirname != G.CurrentDir { // Prevent unnecessary syscalls
                                                dirname = G.CurrentDir
                                                if !fileExists(dirname + "/" + includeFile) {
                                                        mkline.Errorf("Cannot read %q.", dirname+"/"+includeFile)
@@ -346,8 +372,9 @@ func (pkg *Package) readMakefile(fname s
                                if trace.Tracing {
                                        trace.Step1("Including %q.", dirname+"/"+includeFile)
                                }
-                               includingFname := ifelseStr(incBase == "Makefile.common" && incDir != "", fname, "")
-                               if !pkg.readMakefile(dirname+"/"+includeFile, mainLines, allLines, includingFname) {
+                               absIncluding := ifelseStr(incBase == "Makefile.common" && incDir != "", fname, "")
+                               absIncluded := dirname + "/" + includeFile
+                               if !pkg.readMakefile(absIncluded, mainLines, allLines, absIncluding) {
                                        return false
                                }
                        }

Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.21 pkgsrc/pkgtools/pkglint/files/package_test.go:1.22
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.21  Fri Apr  6 21:04:22 2018
+++ pkgsrc/pkgtools/pkglint/files/package_test.go       Tue May  1 23:30:11 2018
@@ -469,3 +469,72 @@ func (s *Suite) Test_Package_conditional
                "WARN: ~/category/package/options.mk:6: \"../../sysutils/coreutils/buildlink3.mk\" is "+
                        "included unconditionally here and conditionally in Makefile:7 (depending on OPSYS).")
 }
+
+// See https://github.com/rillig/pkglint/issues/1
+func (s *Suite) Test_Package_includeWithoutExists(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupVartypes()
+       t.CreateFileLines("mk/bsd.pkg.mk")
+       t.CreateFileLines("category/package/Makefile",
+               MkRcsID,
+               "",
+               ".include \"options.mk\"",
+               "",
+               ".include \"../../mk/bsd.pkg.mk\"")
+
+       G.CurrentDir = t.TempFilename("category/package")
+       G.checkdirPackage(G.CurrentDir)
+
+       t.CheckOutputLines(
+               "ERROR: ~/category/package/options.mk: Cannot be read.")
+}
+
+// See https://github.com/rillig/pkglint/issues/1
+func (s *Suite) Test_Package_includeAfterExists(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupVartypes()
+       t.CreateFileLines("mk/bsd.pkg.mk")
+       t.CreateFileLines("category/package/Makefile",
+               MkRcsID,
+               "",
+               ".if exists(options.mk)",
+               ".  include \"options.mk\"",
+               ".endif",
+               "",
+               ".include \"../../mk/bsd.pkg.mk\"")
+
+       G.CurrentDir = t.TempFilename("category/package")
+       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/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.",
+               "ERROR: ~/category/package/Makefile:4: \"options.mk\" does not exist.",
+               "ERROR: ~/category/package/Makefile:7: \"/mk/bsd.pkg.mk\" does not exist.")
+}
+
+// See https://github.com/rillig/pkglint/issues/1
+func (s *Suite) Test_Package_includeOtherAfterExists(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupVartypes()
+       t.CreateFileLines("mk/bsd.pkg.mk")
+       t.CreateFileLines("category/package/Makefile",
+               MkRcsID,
+               "",
+               ".if exists(options.mk)",
+               ".  include \"another.mk\"",
+               ".endif",
+               "",
+               ".include \"../../mk/bsd.pkg.mk\"")
+
+       G.CurrentDir = t.TempFilename("category/package")
+       G.checkdirPackage(G.CurrentDir)
+
+       t.CheckOutputLines(
+               "ERROR: ~/category/package/another.mk: Cannot be read.")
+}

Index: pkgsrc/pkgtools/pkglint/files/pkglint.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint.go:1.31 pkgsrc/pkgtools/pkglint/files/pkglint.go:1.32
--- pkgsrc/pkgtools/pkglint/files/pkglint.go:1.31       Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/pkglint.go    Tue May  1 23:30:11 2018
@@ -27,7 +27,7 @@ const confVersion = "@VERSION@"
 //  tracing.traceDepth (not thread-safe)
 type Pkglint struct {
        opts   CmdOpts  // Command line options.
-       Pkgsrc Pkgsrc   // Global data, mostly extracted from mk/*.
+       Pkgsrc *Pkgsrc  // Global data, mostly extracted from mk/*.
        Pkg    *Package // The package that is currently checked.
        Mk     *MkLines // The Makefile (or fragment) that is currently checked.
 

Index: pkgsrc/pkgtools/pkglint/files/pkglint_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.18 pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.19
--- pkgsrc/pkgtools/pkglint/files/pkglint_test.go:1.18  Fri Apr  6 21:04:22 2018
+++ pkgsrc/pkgtools/pkglint/files/pkglint_test.go       Tue May  1 23:30:11 2018
@@ -128,7 +128,7 @@ func (s *Suite) Test_Pkglint_Main__compl
        t.CreateFileLines("mk/bsd.pkg.mk",
                "# dummy")
 
-       // See GlobalData.loadDocChanges.
+       // See Pkgsrc.loadDocChanges.
        // FIXME: pkglint should warn that the latest version in this file
        // (1.10) doesn't match the current version in the package (1.11).
        t.CreateFileLines("doc/CHANGES-2018",
@@ -138,7 +138,7 @@ func (s *Suite) Test_Pkglint_Main__compl
                "",
                "\tUpdated sysutils/checkperms to 1.10 [rillig 2018-01-05]")
 
-       // See GlobalData.loadSuggestedUpdates.
+       // See Pkgsrc.loadSuggestedUpdates.
        t.CreateFileLines("doc/TODO",
                RcsID,
                "",
@@ -158,7 +158,7 @@ func (s *Suite) Test_Pkglint_Main__compl
                "MASTER_SITE_GITHUB+=\thttps://github.com/";)
 
        // The options for the PKG_OPTIONS framework must be readable.
-       // See GlobalData.loadPkgOptions.
+       // See Pkgsrc.loadPkgOptions.
        t.CreateFileLines("mk/defaults/options.description",
                "option Description")
 
@@ -433,7 +433,7 @@ func (s *Suite) Test_ChecklinesMessage__
                "===========================================================================")
 }
 
-func (s *Suite) Test_GlobalData_Latest_no_basedir(c *check.C) {
+func (s *Suite) Test_Pkgsrc_Latest_no_basedir(c *check.C) {
        t := s.Init(c)
 
        latest1 := G.Pkgsrc.Latest("lang", `^python[0-9]+$`, "../../lang/$0")
@@ -443,7 +443,7 @@ func (s *Suite) Test_GlobalData_Latest_n
                "ERROR: Cannot find latest version of \"^python[0-9]+$\" in \"~/lang\".")
 }
 
-func (s *Suite) Test_GlobalData_Latest_no_subdirs(c *check.C) {
+func (s *Suite) Test_Pkgsrc_Latest_no_subdirs(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("lang/Makefile")
@@ -455,7 +455,7 @@ func (s *Suite) Test_GlobalData_Latest_n
                "ERROR: Cannot find latest version of \"^python[0-9]+$\" in \"~/lang\".")
 }
 
-func (s *Suite) Test_GlobalData_Latest_single(c *check.C) {
+func (s *Suite) Test_Pkgsrc_Latest_single(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("lang/Makefile")
@@ -466,7 +466,7 @@ func (s *Suite) Test_GlobalData_Latest_s
        c.Check(latest3, equals, "../../lang/python27")
 }
 
-func (s *Suite) Test_GlobalData_Latest_multi(c *check.C) {
+func (s *Suite) Test_Pkgsrc_Latest_multi(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("lang/Makefile")
@@ -478,7 +478,7 @@ func (s *Suite) Test_GlobalData_Latest_m
        c.Check(latest4, equals, "../../lang/python35")
 }
 
-func (s *Suite) Test_GlobalData_Latest_numeric(c *check.C) {
+func (s *Suite) Test_Pkgsrc_Latest_numeric(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("databases/postgresql95/Makefile")

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.2 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.3
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.2 Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go     Tue May  1 23:30:11 2018
@@ -11,9 +11,7 @@ import (
 // Pkgsrc describes a pkgsrc installation.
 // In each pkglint run, only a single pkgsrc installation is ever loaded.
 // It just doesn't make sense to check multiple pkgsrc installations at once.
-type Pkgsrc = *PkgsrcImpl
-
-type PkgsrcImpl struct {
+type Pkgsrc struct {
        // The top directory (PKGSRCDIR), either absolute or relative to
        // the current working directory.
        topdir string
@@ -39,8 +37,8 @@ type PkgsrcImpl struct {
        vartypes        map[string]*Vartype // varcanon => type
 }
 
-func NewPkgsrc(dir string) Pkgsrc {
-       src := &PkgsrcImpl{
+func NewPkgsrc(dir string) *Pkgsrc {
+       src := &Pkgsrc{
                dir,
                make(map[string]bool),
                NewToolRegistry(),
@@ -83,7 +81,7 @@ func NewPkgsrc(dir string) Pkgsrc {
 // This work is not done in the constructor to keep the tests
 // simple, since setting up a realistic pkgsrc environment requires
 // a lot of files.
-func (src *PkgsrcImpl) Load() {
+func (src *Pkgsrc) Load() {
        src.InitVartypes()
        src.loadMasterSites()
        src.loadPkgOptions()
@@ -101,7 +99,7 @@ func (src *PkgsrcImpl) Load() {
 //
 // Example:
 //  Latest("lang", `^php[0-9]+$`, "../../lang/$0") => "../../lang/php72"
-func (src *PkgsrcImpl) Latest(category string, re regex.Pattern, repl string) string {
+func (src *Pkgsrc) Latest(category string, re regex.Pattern, repl string) string {
        key := category + "/" + string(re) + " => " + repl
        if latest, found := src.latest[key]; found {
                return latest
@@ -141,7 +139,7 @@ func (src *PkgsrcImpl) Latest(category s
 }
 
 // loadTools loads the tool definitions from `mk/tools/*`.
-func (src *PkgsrcImpl) loadTools() {
+func (src *Pkgsrc) loadTools() {
        toolFiles := []string{"defaults.mk"}
        {
                toc := G.Pkgsrc.File("mk/tools/bsd.tools.mk")
@@ -221,12 +219,12 @@ func (src *PkgsrcImpl) loadTools() {
        }
 }
 
-func (src *PkgsrcImpl) loadSuggestedUpdatesFile(fname string) []SuggestedUpdate {
+func (src *Pkgsrc) loadSuggestedUpdatesFile(fname string) []SuggestedUpdate {
        lines := LoadExistingLines(fname, false)
        return src.parseSuggestedUpdates(lines)
 }
 
-func (src *PkgsrcImpl) parseSuggestedUpdates(lines []Line) []SuggestedUpdate {
+func (src *Pkgsrc) parseSuggestedUpdates(lines []Line) []SuggestedUpdate {
        var updates []SuggestedUpdate
        state := 0
        for _, line := range lines {
@@ -257,14 +255,14 @@ func (src *PkgsrcImpl) parseSuggestedUpd
        return updates
 }
 
-func (src *PkgsrcImpl) loadSuggestedUpdates() {
+func (src *Pkgsrc) loadSuggestedUpdates() {
        src.suggestedUpdates = src.loadSuggestedUpdatesFile(G.Pkgsrc.File("doc/TODO"))
        if wipFilename := G.Pkgsrc.File("wip/TODO"); fileExists(wipFilename) {
                src.suggestedWipUpdates = src.loadSuggestedUpdatesFile(wipFilename)
        }
 }
 
-func (src *PkgsrcImpl) loadDocChangesFromFile(fname string) []*Change {
+func (src *Pkgsrc) loadDocChangesFromFile(fname string) []*Change {
        lines := LoadExistingLines(fname, false)
 
        parseChange := func(line Line) *Change {
@@ -310,7 +308,7 @@ func (src *PkgsrcImpl) loadDocChangesFro
        return changes
 }
 
-func (src *PkgsrcImpl) GetSuggestedPackageUpdates() []SuggestedUpdate {
+func (src *Pkgsrc) GetSuggestedPackageUpdates() []SuggestedUpdate {
        if G.Wip {
                return src.suggestedWipUpdates
        } else {
@@ -318,7 +316,7 @@ func (src *PkgsrcImpl) GetSuggestedPacka
        }
 }
 
-func (src *PkgsrcImpl) loadDocChanges() {
+func (src *Pkgsrc) loadDocChanges() {
        docdir := G.Pkgsrc.File("doc")
        files, err := ioutil.ReadDir(docdir)
        if err != nil {
@@ -343,7 +341,7 @@ func (src *PkgsrcImpl) loadDocChanges() 
        }
 }
 
-func (src *PkgsrcImpl) loadUserDefinedVars() {
+func (src *Pkgsrc) loadUserDefinedVars() {
        lines := G.Pkgsrc.LoadExistingLines("mk/defaults/mk.conf", true)
        mklines := NewMkLines(lines)
 
@@ -354,7 +352,7 @@ func (src *PkgsrcImpl) loadUserDefinedVa
        }
 }
 
-func (src *PkgsrcImpl) initDeprecatedVars() {
+func (src *Pkgsrc) initDeprecatedVars() {
        src.Deprecated = map[string]string{
                // December 2003
                "FIX_RPATH": "It has been removed from pkgsrc in 2003.",
@@ -516,7 +514,7 @@ func (src *PkgsrcImpl) initDeprecatedVar
 }
 
 // LoadExistingLines loads the file relative to the pkgsrc top directory.
-func (src *PkgsrcImpl) LoadExistingLines(fileName string, joinBackslashLines bool) []Line {
+func (src *Pkgsrc) LoadExistingLines(fileName string, joinBackslashLines bool) []Line {
        return LoadExistingLines(src.File(fileName), joinBackslashLines)
 }
 
@@ -524,7 +522,7 @@ func (src *PkgsrcImpl) LoadExistingLines
 //
 // Example:
 //  NewPkgsrc("/usr/pkgsrc").File("distfiles") => "/usr/pkgsrc/distfiles"
-func (src *PkgsrcImpl) File(relativeName string) string {
+func (src *Pkgsrc) File(relativeName string) string {
        return src.topdir + "/" + relativeName
 }
 
@@ -532,19 +530,19 @@ func (src *PkgsrcImpl) File(relativeName
 //
 // Example:
 //  NewPkgsrc("/usr/pkgsrc").ToRel("/usr/pkgsrc/distfiles") => "distfiles"
-func (src *PkgsrcImpl) ToRel(fileName string) string {
+func (src *Pkgsrc) ToRel(fileName string) string {
        return relpath(src.topdir, fileName)
 }
 
-func (src *PkgsrcImpl) AddBuildDef(varname string) {
+func (src *Pkgsrc) AddBuildDef(varname string) {
        src.buildDefs[varname] = true
 }
 
-func (src *PkgsrcImpl) IsBuildDef(varname string) bool {
+func (src *Pkgsrc) IsBuildDef(varname string) bool {
        return src.buildDefs[varname]
 }
 
-func (src *PkgsrcImpl) loadMasterSites() {
+func (src *Pkgsrc) loadMasterSites() {
        lines := src.LoadExistingLines("mk/fetch/sites.mk", true)
 
        nameToUrl := src.MasterSiteVarToURL
@@ -572,7 +570,7 @@ func (src *PkgsrcImpl) loadMasterSites()
        }
 }
 
-func (src *PkgsrcImpl) loadPkgOptions() {
+func (src *Pkgsrc) loadPkgOptions() {
        lines := src.LoadExistingLines("mk/defaults/options.description", false)
 
        for _, line := range lines {
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.2 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.3
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.2    Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go        Tue May  1 23:30:11 2018
@@ -61,7 +61,7 @@ func (s *Suite) Test_Pkgsrc_parseSuggest
                {lines[6], "freeciv-client", "2.5.0", "(urgent)"}})
 }
 
-func (s *Suite) Test_GlobalData_loadTools(c *check.C) {
+func (s *Suite) Test_Pkgsrc_loadTools(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("mk/tools/bsd.tools.mk",
@@ -123,7 +123,7 @@ func (s *Suite) Test_GlobalData_loadTool
                "TRACE: - (*ToolRegistry).Trace()")
 }
 
-func (s *Suite) Test_GlobalData_loadDocChangesFromFile(c *check.C) {
+func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile(c *check.C) {
        t := s.Init(c)
 
        t.SetupFileLines("doc/CHANGES-2015",
@@ -147,7 +147,7 @@ func (s *Suite) Test_GlobalData_loadDocC
        c.Check(*changes[6], equals, Change{changes[6].Line, "Downgraded", "category/package", "1.2", "author7", "2015-01-07"})
 }
 
-func (s *Suite) Test_GlobalData_deprecated(c *check.C) {
+func (s *Suite) Test_Pkgsrc_deprecated(c *check.C) {
        t := s.Init(c)
 
        G.Pkgsrc.initDeprecatedVars()

Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.39 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.40
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.39       Sat Apr 28 23:32:52 2018
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go    Tue May  1 23:30:11 2018
@@ -17,7 +17,7 @@ import (
 // InitVartypes initializes the long list of predefined pkgsrc variables.
 // After this is done, ${PKGNAME}, ${MAKE_ENV} and all the other variables
 // can be used in Makefiles without triggering warnings about typos.
-func (src *PkgsrcImpl) InitVartypes() {
+func (src *Pkgsrc) InitVartypes() {
 
        acl := func(varname string, kindOfList KindOfList, checker *BasicType, aclentries string) {
                m := mustMatch(varname, `^([A-Z_.][A-Z0-9_]*)(|\*|\.\*)$`)



Home | Main Index | Thread Index | Old Index