diff options
author | rillig <rillig@pkgsrc.org> | 2018-05-01 23:30:11 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2018-05-01 23:30:11 +0000 |
commit | 1aff4e1ee6b092616d03675ec7df57751fa8f930 (patch) | |
tree | 70050f0d83cf1c823d236db2a0d87ffad5aec1b2 /pkgtools/pkglint | |
parent | 7dffebc2bbf5a1aa55c1a2c2fc8f8d98c357e73a (diff) | |
download | pkgsrc-1aff4e1ee6b092616d03675ec7df57751fa8f930.tar.gz |
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.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkline.go | 31 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkline_test.go | 5 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklinechecker.go | 24 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklines.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklines_test.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/package.go | 33 | ||||
-rw-r--r-- | pkgtools/pkglint/files/package_test.go | 69 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkglint.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkglint_test.go | 16 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkgsrc.go | 44 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkgsrc_test.go | 6 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vardefs.go | 2 |
13 files changed, 180 insertions, 64 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index 767e68ac1eb..cd4f2f9c911 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -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 diff --git a/pkgtools/pkglint/files/mkline.go b/pkgtools/pkglint/files/mkline.go index 8852d7afb51..0f814ae5041 100644 --- a/pkgtools/pkglint/files/mkline.go +++ b/pkgtools/pkglint/files/mkline.go @@ -724,19 +724,28 @@ func (vuc *VarUseContext) String() string { } // 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() string { 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) diff --git a/pkgtools/pkglint/files/mkline_test.go b/pkgtools/pkglint/files/mkline_test.go index 02dfb4554e0..6f97bd96571 100644 --- a/pkgtools/pkglint/files/mkline_test.go +++ b/pkgtools/pkglint/files/mkline_test.go @@ -850,12 +850,13 @@ func (s *Suite) Test_Indentation(c *check.C) { 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") diff --git a/pkgtools/pkglint/files/mklinechecker.go b/pkgtools/pkglint/files/mklinechecker.go index 8ea2c934945..d391066428f 100644 --- a/pkgtools/pkglint/files/mklinechecker.go +++ b/pkgtools/pkglint/files/mklinechecker.go @@ -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(forVars map[string]bool, indentation *Indentat 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(forVars map[string]bool, indentation *Indentat } } - 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 { diff --git a/pkgtools/pkglint/files/mklines.go b/pkgtools/pkglint/files/mklines.go index df1b0c2b152..cc2c7cede59 100644 --- a/pkgtools/pkglint/files/mklines.go +++ b/pkgtools/pkglint/files/mklines.go @@ -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) diff --git a/pkgtools/pkglint/files/mklines_test.go b/pkgtools/pkglint/files/mklines_test.go index 53db263025d..ca2f5ad365a 100644 --- a/pkgtools/pkglint/files/mklines_test.go +++ b/pkgtools/pkglint/files/mklines_test.go @@ -414,8 +414,8 @@ func (s *Suite) Test_MkLines_Check_indentation(c *check.C) { "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. diff --git a/pkgtools/pkglint/files/package.go b/pkgtools/pkglint/files/package.go index d2c7eb5a02d..cc79fdf70a4 100644 --- a/pkgtools/pkglint/files/package.go +++ b/pkgtools/pkglint/files/package.go @@ -286,6 +286,28 @@ func (pkg *Package) readMakefile(fname string, mainLines *MkLines, allLines *MkL 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 string, mainLines *MkLines, allLines *MkL // 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 string, mainLines *MkLines, allLines *MkL 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 } } diff --git a/pkgtools/pkglint/files/package_test.go b/pkgtools/pkglint/files/package_test.go index aeae8bc13e7..67137ebcbab 100644 --- a/pkgtools/pkglint/files/package_test.go +++ b/pkgtools/pkglint/files/package_test.go @@ -469,3 +469,72 @@ func (s *Suite) Test_Package_conditionalAndUnconditionalInclude(c *check.C) { "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.") +} diff --git a/pkgtools/pkglint/files/pkglint.go b/pkgtools/pkglint/files/pkglint.go index d2a9c8878a1..220a14d5bab 100644 --- a/pkgtools/pkglint/files/pkglint.go +++ b/pkgtools/pkglint/files/pkglint.go @@ -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. diff --git a/pkgtools/pkglint/files/pkglint_test.go b/pkgtools/pkglint/files/pkglint_test.go index ada17e57259..e187adde2ee 100644 --- a/pkgtools/pkglint/files/pkglint_test.go +++ b/pkgtools/pkglint/files/pkglint_test.go @@ -128,7 +128,7 @@ func (s *Suite) Test_Pkglint_Main__complete_package(c *check.C) { 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__complete_package(c *check.C) { "", "\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__complete_package(c *check.C) { "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__autofix(c *check.C) { "===========================================================================") } -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_no_basedir(c *check.C) { "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_no_subdirs(c *check.C) { "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_single(c *check.C) { 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_multi(c *check.C) { 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") diff --git a/pkgtools/pkglint/files/pkgsrc.go b/pkgtools/pkglint/files/pkgsrc.go index ccd963ceccf..ea4ed936de1 100644 --- a/pkgtools/pkglint/files/pkgsrc.go +++ b/pkgtools/pkglint/files/pkgsrc.go @@ -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 string, re regex.Pattern, repl string) st } // 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) parseSuggestedUpdates(lines []Line) []SuggestedUpdate { 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) loadDocChangesFromFile(fname string) []*Change { 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) GetSuggestedPackageUpdates() []SuggestedUpdate { } } -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) loadUserDefinedVars() { } } -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) initDeprecatedVars() { } // 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(fileName string, joinBackslashLines boo // // 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 string) string { // // 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 { diff --git a/pkgtools/pkglint/files/pkgsrc_test.go b/pkgtools/pkglint/files/pkgsrc_test.go index 0ef60a8c539..991b4e9af56 100644 --- a/pkgtools/pkglint/files/pkgsrc_test.go +++ b/pkgtools/pkglint/files/pkgsrc_test.go @@ -61,7 +61,7 @@ func (s *Suite) Test_Pkgsrc_parseSuggestedUpdates(c *check.C) { {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_loadTools(c *check.C) { "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_loadDocChangesFromFile(c *check.C) { 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() diff --git a/pkgtools/pkglint/files/vardefs.go b/pkgtools/pkglint/files/vardefs.go index 5a80a499cc6..54e157efda3 100644 --- a/pkgtools/pkglint/files/vardefs.go +++ b/pkgtools/pkglint/files/vardefs.go @@ -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_]*)(|\*|\.\*)$`) |