pkgtools/pkglint: update to 5.7.11 Changes since 5.7.10: Fixed wrong warnings about autoconf being an unknown shell command when an included file had defined USE_TOOLS+=autoconf213.diff -r1.580 -r1.581 pkgsrc/pkgtools/pkglint/Makefile
(rillig)
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | # $NetBSD: Makefile,v 1.580 2019/05/21 17:59:48 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.581 2019/05/22 16:07:16 rillig Exp $ | |
2 | 2 | |||
3 | PKGNAME= pkglint-5.7.10 | 3 | PKGNAME= pkglint-5.7.11 | |
4 | CATEGORIES= pkgtools | 4 | CATEGORIES= pkgtools | |
5 | DISTNAME= tools | 5 | DISTNAME= tools | |
6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} | 6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} | |
7 | GITHUB_PROJECT= tools | 7 | GITHUB_PROJECT= tools | |
8 | GITHUB_TAG= 92d8274bd7b8a4c65f24bafe401a029e58392704 | 8 | GITHUB_TAG= 92d8274bd7b8a4c65f24bafe401a029e58392704 | |
9 | 9 | |||
10 | MAINTAINER= rillig@NetBSD.org | 10 | MAINTAINER= rillig@NetBSD.org | |
11 | HOMEPAGE= https://github.com/rillig/pkglint | 11 | HOMEPAGE= https://github.com/rillig/pkglint | |
12 | COMMENT= Verifier for NetBSD packages | 12 | COMMENT= Verifier for NetBSD packages | |
13 | LICENSE= 2-clause-bsd | 13 | LICENSE= 2-clause-bsd | |
14 | CONFLICTS+= pkglint4-[0-9]* | 14 | CONFLICTS+= pkglint4-[0-9]* | |
15 | 15 | |||
16 | USE_TOOLS+= pax | 16 | USE_TOOLS+= pax |
@@ -283,28 +283,28 @@ func (pkg *Package) loadPackageMakefile( | @@ -283,28 +283,28 @@ func (pkg *Package) loadPackageMakefile( | |||
283 | // TODO: Is this still necessary? This code is 20 years old and was introduced | 283 | // TODO: Is this still necessary? This code is 20 years old and was introduced | |
284 | // when pkglint loaded the package Makefile including all included files into | 284 | // when pkglint loaded the package Makefile including all included files into | |
285 | // a single string. Maybe it makes sense to print the file inclusion hierarchy | 285 | // a single string. Maybe it makes sense to print the file inclusion hierarchy | |
286 | // to quickly see files that cannot be included because of unresolved variables. | 286 | // to quickly see files that cannot be included because of unresolved variables. | |
287 | if G.Opts.DumpMakefile { | 287 | if G.Opts.DumpMakefile { | |
288 | G.Logger.out.WriteLine("Whole Makefile (with all included files) follows:") | 288 | G.Logger.out.WriteLine("Whole Makefile (with all included files) follows:") | |
289 | for _, line := range allLines.lines.Lines { | 289 | for _, line := range allLines.lines.Lines { | |
290 | G.Logger.out.WriteLine(line.String()) | 290 | G.Logger.out.WriteLine(line.String()) | |
291 | } | 291 | } | |
292 | } | 292 | } | |
293 | 293 | |||
294 | // See mk/tools/cmake.mk | 294 | // See mk/tools/cmake.mk | |
295 | if pkg.vars.Defined("USE_CMAKE") { | 295 | if pkg.vars.Defined("USE_CMAKE") { | |
296 | mainLines.Tools.def("cmake", "", false, AtRunTime, nil) | 296 | allLines.Tools.def("cmake", "", false, AtRunTime, nil) | |
297 | mainLines.Tools.def("cpack", "", false, AtRunTime, nil) | 297 | allLines.Tools.def("cpack", "", false, AtRunTime, nil) | |
298 | } | 298 | } | |
299 | 299 | |||
300 | allLines.collectUsedVariables() | 300 | allLines.collectUsedVariables() | |
301 | 301 | |||
302 | pkg.Pkgdir = pkg.vars.LastValue("PKGDIR") | 302 | pkg.Pkgdir = pkg.vars.LastValue("PKGDIR") | |
303 | pkg.DistinfoFile = pkg.vars.LastValue("DISTINFO_FILE") | 303 | pkg.DistinfoFile = pkg.vars.LastValue("DISTINFO_FILE") | |
304 | pkg.Filesdir = pkg.vars.LastValue("FILESDIR") | 304 | pkg.Filesdir = pkg.vars.LastValue("FILESDIR") | |
305 | pkg.Patchdir = pkg.vars.LastValue("PATCHDIR") | 305 | pkg.Patchdir = pkg.vars.LastValue("PATCHDIR") | |
306 | 306 | |||
307 | // See lang/php/ext.mk | 307 | // See lang/php/ext.mk | |
308 | if pkg.vars.DefinedSimilar("PHPEXT_MK") { | 308 | if pkg.vars.DefinedSimilar("PHPEXT_MK") { | |
309 | if !pkg.vars.DefinedSimilar("USE_PHP_EXT_PATCHES") { | 309 | if !pkg.vars.DefinedSimilar("USE_PHP_EXT_PATCHES") { | |
310 | pkg.Patchdir = "patches" | 310 | pkg.Patchdir = "patches" | |
@@ -590,26 +590,28 @@ func (pkg *Package) checkfilePackageMake | @@ -590,26 +590,28 @@ func (pkg *Package) checkfilePackageMake | |||
590 | if !vars.Defined("COMMENT") { | 590 | if !vars.Defined("COMMENT") { | |
591 | NewLineWhole(filename).Warnf("Each package should define a COMMENT.") | 591 | NewLineWhole(filename).Warnf("Each package should define a COMMENT.") | |
592 | } | 592 | } | |
593 | 593 | |||
594 | if imake := vars.FirstDefinition("USE_IMAKE"); imake != nil { | 594 | if imake := vars.FirstDefinition("USE_IMAKE"); imake != nil { | |
595 | if x11 := vars.FirstDefinition("USE_X11"); x11 != nil { | 595 | if x11 := vars.FirstDefinition("USE_X11"); x11 != nil { | |
596 | if !hasSuffix(x11.Filename, "/mk/x11.buildlink3.mk") { | 596 | if !hasSuffix(x11.Filename, "/mk/x11.buildlink3.mk") { | |
597 | imake.Notef("USE_IMAKE makes USE_X11 in %s redundant.", imake.RefTo(x11)) | 597 | imake.Notef("USE_IMAKE makes USE_X11 in %s redundant.", imake.RefTo(x11)) | |
598 | } | 598 | } | |
599 | } | 599 | } | |
600 | } | 600 | } | |
601 | 601 | |||
602 | pkg.checkUpdate() | 602 | pkg.checkUpdate() | |
603 | allLines.collectDefinedVariables() // To get the tool definitions | |||
604 | mklines.Tools = allLines.Tools // TODO: also copy the other collected data | |||
603 | mklines.Check() | 605 | mklines.Check() | |
604 | pkg.CheckVarorder(mklines) | 606 | pkg.CheckVarorder(mklines) | |
605 | SaveAutofixChanges(mklines.lines) | 607 | SaveAutofixChanges(mklines.lines) | |
606 | } | 608 | } | |
607 | 609 | |||
608 | func (pkg *Package) checkGnuConfigureUseLanguages(s *RedundantScope) { | 610 | func (pkg *Package) checkGnuConfigureUseLanguages(s *RedundantScope) { | |
609 | 611 | |||
610 | gnuConfigure := s.vars["GNU_CONFIGURE"] | 612 | gnuConfigure := s.vars["GNU_CONFIGURE"] | |
611 | if gnuConfigure == nil || !gnuConfigure.vari.Constant() { | 613 | if gnuConfigure == nil || !gnuConfigure.vari.Constant() { | |
612 | return | 614 | return | |
613 | } | 615 | } | |
614 | 616 | |||
615 | useLanguages := s.vars["USE_LANGUAGES"] | 617 | useLanguages := s.vars["USE_LANGUAGES"] |
@@ -292,45 +292,60 @@ func (tr *Tools) addAlias(tool *Tool, al | @@ -292,45 +292,60 @@ func (tr *Tools) addAlias(tool *Tool, al | |||
292 | // parseUseTools interprets a "USE_TOOLS+=" line from a Makefile fragment. | 292 | // parseUseTools interprets a "USE_TOOLS+=" line from a Makefile fragment. | |
293 | // It determines the validity of the tool, i.e. in which places it may be used. | 293 | // It determines the validity of the tool, i.e. in which places it may be used. | |
294 | // | 294 | // | |
295 | // If createIfAbsent is true and the tools is unknown, it is registered. | 295 | // If createIfAbsent is true and the tools is unknown, it is registered. | |
296 | // This can be done only in the pkgsrc infrastructure files, where the | 296 | // This can be done only in the pkgsrc infrastructure files, where the | |
297 | // actual definition is assumed to be in some other file. In packages | 297 | // actual definition is assumed to be in some other file. In packages | |
298 | // though, this assumption cannot be made and pkglint needs to be strict. | 298 | // though, this assumption cannot be made and pkglint needs to be strict. | |
299 | func (tr *Tools) parseUseTools(mkline MkLine, createIfAbsent bool, addToUseTools bool) { | 299 | func (tr *Tools) parseUseTools(mkline MkLine, createIfAbsent bool, addToUseTools bool) { | |
300 | value := mkline.Value() | 300 | value := mkline.Value() | |
301 | if containsVarRef(value) { | 301 | if containsVarRef(value) { | |
302 | return | 302 | return | |
303 | } | 303 | } | |
304 | 304 | |||
305 | deps := mkline.ValueFields(value) | |||
306 | ||||
307 | // See mk/tools/autoconf.mk:/^\.if !defined/ | |||
308 | if matches(value, `\bautoconf213\b`) { | |||
309 | deps = append(deps, "autoconf-2.13", "autoheader-2.13", "autoreconf-2.13", "autoscan-2.13", "autoupdate-2.13", "ifnames-2.13") | |||
310 | } | |||
311 | if matches(value, `\bautoconf\b`) { | |||
312 | deps = append(deps, "autoheader", "autom4te", "autoreconf", "autoscan", "autoupdate", "ifnames") | |||
313 | } | |||
314 | ||||
315 | validity := tr.validity(mkline.Basename, addToUseTools) | 305 | validity := tr.validity(mkline.Basename, addToUseTools) | |
316 | for _, dep := range deps { | 306 | for _, dep := range mkline.ValueFields(value) { | |
317 | name := strings.Split(dep, ":")[0] | 307 | name := strings.Split(dep, ":")[0] | |
318 | if createIfAbsent || tr.ByName(name) != nil { | 308 | if createIfAbsent || tr.ByName(name) != nil { | |
319 | tr.def(name, "", false, validity, nil) | 309 | tr.def(name, "", false, validity, nil) | |
310 | for _, implicitName := range tr.implicitTools(name) { | |||
311 | tr.def(implicitName, "", false, validity, nil) | |||
312 | } | |||
320 | } | 313 | } | |
321 | } | 314 | } | |
322 | } | 315 | } | |
323 | 316 | |||
317 | func (tr *Tools) implicitTools(toolName string) []string { | |||
318 | ||||
319 | // See mk/tools/autoconf.mk:/^\.if !defined/ | |||
320 | ||||
321 | if toolName == "autoconf213" { | |||
322 | return []string{ | |||
323 | "autoconf-2.13", "autoheader-2.13", "autoreconf-2.13", | |||
324 | "autoscan-2.13", "autoupdate-2.13", "ifnames-2.13", | |||
325 | "autoconf", | |||
326 | "autoheader", "autom4te", "autoreconf", | |||
327 | "autoscan", "autoupdate", "ifnames"} | |||
328 | } | |||
329 | ||||
330 | if toolName == "autoconf" { | |||
331 | return []string{ | |||
332 | "autoheader", "autom4te", "autoreconf", | |||
333 | "autoscan", "autoupdate", "ifnames"} | |||
334 | } | |||
335 | ||||
336 | return nil | |||
337 | } | |||
338 | ||||
324 | func (tr *Tools) validity(basename string, useTools bool) Validity { | 339 | func (tr *Tools) validity(basename string, useTools bool) Validity { | |
325 | switch { | 340 | switch { | |
326 | case IsPrefs(basename): // IsPrefs is not 100% accurate here but good enough | 341 | case IsPrefs(basename): // IsPrefs is not 100% accurate here but good enough | |
327 | return AfterPrefsMk | 342 | return AfterPrefsMk | |
328 | case basename == "Makefile" && !tr.SeenPrefs: | 343 | case basename == "Makefile" && !tr.SeenPrefs: | |
329 | return AfterPrefsMk | 344 | return AfterPrefsMk | |
330 | case useTools, basename == "bsd.pkg.mk": | 345 | case useTools, basename == "bsd.pkg.mk": | |
331 | return AtRunTime | 346 | return AtRunTime | |
332 | default: | 347 | default: | |
333 | return Nowhere | 348 | return Nowhere | |
334 | } | 349 | } | |
335 | } | 350 | } | |
336 | 351 |
@@ -596,13 +596,31 @@ func (s *Suite) Test_Tools__gmake(c *che | @@ -596,13 +596,31 @@ func (s *Suite) Test_Tools__gmake(c *che | |||
596 | ".include \"make.mk\"") | 596 | ".include \"make.mk\"") | |
597 | t.CreateFileLines("mk/tools/make.mk", | 597 | t.CreateFileLines("mk/tools/make.mk", | |
598 | "TOOLS_CREATE+=\tmake", | 598 | "TOOLS_CREATE+=\tmake", | |
599 | "TOOLS_PATH.make=\t/usr/bin/make") | 599 | "TOOLS_PATH.make=\t/usr/bin/make") | |
600 | t.CreateFileLines("mk/tools/replace.mk", | 600 | t.CreateFileLines("mk/tools/replace.mk", | |
601 | "TOOLS_CREATE+=\tgmake", | 601 | "TOOLS_CREATE+=\tgmake", | |
602 | "TOOLS_PATH.gmake=\t/usr/bin/gnu-make") | 602 | "TOOLS_PATH.gmake=\t/usr/bin/gnu-make") | |
603 | t.FinishSetUp() | 603 | t.FinishSetUp() | |
604 | 604 | |||
605 | G.Check(t.File("category/package")) | 605 | G.Check(t.File("category/package")) | |
606 | 606 | |||
607 | t.CheckOutputEmpty() | 607 | t.CheckOutputEmpty() | |
608 | } | 608 | } | |
609 | ||||
610 | func (s *Suite) Test_Tools__autoconf213(c *check.C) { | |||
611 | t := s.Init(c) | |||
612 | ||||
613 | t.SetUpPackage("category/package", | |||
614 | "USE_TOOLS=\tautoconf213", | |||
615 | "", | |||
616 | "do-test:", | |||
617 | "\tautoconf") | |||
618 | t.CreateFileLines("mk/tools/defaults.mk", | |||
619 | "_TOOLS_DEPMETHOD.autoconf213=\tDEPENDS") | |||
620 | t.FinishSetUp() | |||
621 | ||||
622 | G.Check(t.File("category/package")) | |||
623 | ||||
624 | // No warning, since autoconf213 defines autoconf implicitly. | |||
625 | t.CheckOutputEmpty() | |||
626 | } |