Received: by mail.netbsd.org (Postfix, from userid 605) id 4749A84D77; Thu, 26 Mar 2020 07:02:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id C1D7D84D4D for ; Thu, 26 Mar 2020 07:02:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id Wv3TJi-dFLU3 for ; Thu, 26 Mar 2020 07:02:45 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 4B3EA84CD5 for ; Thu, 26 Mar 2020 07:02:45 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 39DF6FB27; Thu, 26 Mar 2020 07:02:45 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1585206165145030" MIME-Version: 1.0 Date: Thu, 26 Mar 2020 07:02:45 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/pkgtools/pkglint To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200326070245.39DF6FB27@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1585206165145030 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Thu Mar 26 07:02:44 UTC 2020 Modified Files: pkgsrc/pkgtools/pkglint: Makefile pkgsrc/pkgtools/pkglint/files: distinfo.go distinfo_test.go mkline.go mklines.go package.go package_test.go pkglint.go shell.go shell_test.go util.go vardefs.go Log Message: pkgtools/pkglint: update to 20.1.1 Changes since 20.1.0: In UNLIMIT_RESOURCES, the recently added virtualsize is allowed. Packages that have distfiles without any digit in their name should define DIST_SUBDIR to avoid polluting the global namespace. The top-level distfiles directory should only contain versioned filenames. To generate a diff of this commit: cvs rdiff -u -r1.638 -r1.639 pkgsrc/pkgtools/pkglint/Makefile cvs rdiff -u -r1.42 -r1.43 pkgsrc/pkgtools/pkglint/files/distinfo.go cvs rdiff -u -r1.38 -r1.39 pkgsrc/pkgtools/pkglint/files/distinfo_test.go cvs rdiff -u -r1.76 -r1.77 pkgsrc/pkgtools/pkglint/files/mkline.go cvs rdiff -u -r1.70 -r1.71 pkgsrc/pkgtools/pkglint/files/mklines.go cvs rdiff -u -r1.85 -r1.86 pkgsrc/pkgtools/pkglint/files/package.go cvs rdiff -u -r1.72 -r1.73 pkgsrc/pkgtools/pkglint/files/package_test.go cvs rdiff -u -r1.78 -r1.79 pkgsrc/pkgtools/pkglint/files/pkglint.go cvs rdiff -u -r1.60 -r1.61 pkgsrc/pkgtools/pkglint/files/shell.go cvs rdiff -u -r1.66 -r1.67 pkgsrc/pkgtools/pkglint/files/shell_test.go cvs rdiff -u -r1.75 -r1.76 pkgsrc/pkgtools/pkglint/files/util.go cvs rdiff -u -r1.91 -r1.92 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. --_----------=_1585206165145030 Content-Disposition: inline Content-Length: 19192 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/pkgtools/pkglint/Makefile diff -u pkgsrc/pkgtools/pkglint/Makefile:1.638 pkgsrc/pkgtools/pkglint/Makefile:1.639 --- pkgsrc/pkgtools/pkglint/Makefile:1.638 Mon Mar 23 19:55:08 2020 +++ pkgsrc/pkgtools/pkglint/Makefile Thu Mar 26 07:02:44 2020 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.638 2020/03/23 19:55:08 rillig Exp $ +# $NetBSD: Makefile,v 1.639 2020/03/26 07:02:44 rillig Exp $ -PKGNAME= pkglint-20.1.0 +PKGNAME= pkglint-20.1.1 CATEGORIES= pkgtools DISTNAME= tools MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} Index: pkgsrc/pkgtools/pkglint/files/distinfo.go diff -u pkgsrc/pkgtools/pkglint/files/distinfo.go:1.42 pkgsrc/pkgtools/pkglint/files/distinfo.go:1.43 --- pkgsrc/pkgtools/pkglint/files/distinfo.go:1.42 Sat Feb 15 13:48:40 2020 +++ pkgsrc/pkgtools/pkglint/files/distinfo.go Thu Mar 26 07:02:44 2020 @@ -34,6 +34,13 @@ func CheckLinesDistinfo(pkg *Package, li CheckLinesTrailingEmptyLines(lines) ck.checkUnrecordedPatches() + if pkg != nil { + pkg.distinfoDistfiles = make(map[string]bool) + for path := range ck.infos { + pkg.distinfoDistfiles[path.Base()] = true + } + } + SaveAutofixChanges(lines) } @@ -106,6 +113,7 @@ func (ck *distinfoLinesChecker) check() for _, filename := range ck.filenames { info := ck.infos[filename] + ck.checkFilename(filename, info) ck.checkAlgorithms(info) for _, hash := range info.hashes { ck.checkGlobalDistfileMismatch(hash) @@ -116,6 +124,18 @@ func (ck *distinfoLinesChecker) check() } } +func (ck *distinfoLinesChecker) checkFilename(filename RelPath, info distinfoFileInfo) { + if info.isPatch != no || !info.hasDistfileAlgorithms() || matches(filename.String(), `\d`) { + return + } + + line := info.line() + line.Warnf( + "Distfiles without version number should be placed in a versioned DIST_SUBDIR.") + line.Explain( + seeGuide("How to handle modified distfiles with the 'old' name", "modified-distfiles-same-name")) +} + func (ck *distinfoLinesChecker) checkAlgorithms(info distinfoFileInfo) { filename := info.filename() algorithms := info.algorithms() @@ -419,6 +439,15 @@ func (info *distinfoFileInfo) algorithms return strings.Join(algs, ", ") } +func (info *distinfoFileInfo) hasDistfileAlgorithms() bool { + h := info.hashes + return len(h) == 4 && + h[0].algorithm == "SHA1" && + h[1].algorithm == "RMD160" && + h[2].algorithm == "SHA512" && + h[3].algorithm == "Size" +} + type distinfoHash struct { line *Line filename RelPath Index: pkgsrc/pkgtools/pkglint/files/distinfo_test.go diff -u pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.38 pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.39 --- pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.38 Sun Mar 22 17:43:15 2020 +++ pkgsrc/pkgtools/pkglint/files/distinfo_test.go Thu Mar 26 07:02:44 2020 @@ -14,8 +14,8 @@ func (s *Suite) Test_CheckLinesDistinfo_ lines := t.SetUpFileLines("distinfo", "should be the CVS ID", "should be empty", - "MD5 (distfile.tar.gz) = 12345678901234567890123456789012", - "SHA1 (distfile.tar.gz) = 1234567890123456789012345678901234567890", + "MD5 (distfile-1.0.tar.gz) = 12345678901234567890123456789012", + "SHA1 (distfile-1.0.tar.gz) = 1234567890123456789012345678901234567890", "SHA1 (patch-aa) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7", "Size (patch-aa) = 104", "SHA1 (patch-ab) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7", @@ -31,7 +31,7 @@ func (s *Suite) Test_CheckLinesDistinfo_ "ERROR: distinfo:1: Invalid line: should be the CVS ID", "ERROR: distinfo:2: Invalid line: should be empty", "ERROR: distinfo:8: Invalid line: Another invalid line", - "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile.tar.gz\", got MD5, SHA1.", + "ERROR: distinfo:3: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile-1.0.tar.gz\", got MD5, SHA1.", "ERROR: distinfo:5: Expected SHA1 hash for patch-aa, got SHA1, Size.", "WARN: distinfo:9: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".") } @@ -204,6 +204,41 @@ func (s *Suite) Test_distinfoLinesChecke t.CheckOutputEmpty() } +func (s *Suite) Test_distinfoLinesChecker_checkFilename(c *check.C) { + t := s.Init(c) + + t.SetUpPackage("category/package") + t.CreateFileLines("category/package/distinfo", + CvsID, + "", + "SHA1 (ok-1.0.tar.gz) = 1234", + "RMD160 (ok-1.0.tar.gz) = 1234", + "SHA512 (ok-1.0.tar.gz) = 1234", + "Size (ok-1.0.tar.gz) = 1234", + "SHA1 (not-ok.tar.gz) = 1234", + "RMD160 (not-ok.tar.gz) = 1234", + "SHA512 (not-ok.tar.gz) = 1234", + "Size (not-ok.tar.gz) = 1234", + "SHA1 (non-versioned/not-ok.tar.gz) = 1234", + "RMD160 (non-versioned/not-ok.tar.gz) = 1234", + "SHA512 (non-versioned/not-ok.tar.gz) = 1234", + "Size (non-versioned/not-ok.tar.gz) = 1234", + "SHA1 (versioned-1/ok.tar.gz) = 1234", + "RMD160 (versioned-1/ok.tar.gz) = 1234", + "SHA512 (versioned-1/ok.tar.gz) = 1234", + "Size (versioned-1/ok.tar.gz) = 1234") + t.Chdir("category/package") + t.FinishSetUp() + + G.Check(".") + + t.CheckOutputLines( + "WARN: distinfo:7: Distfiles without version number "+ + "should be placed in a versioned DIST_SUBDIR.", + "WARN: distinfo:11: Distfiles without version number "+ + "should be placed in a versioned DIST_SUBDIR.") +} + func (s *Suite) Test_distinfoLinesChecker_checkAlgorithms__nonexistent_distfile_called_patch(c *check.C) { t := s.Init(c) @@ -653,6 +688,7 @@ func (s *Suite) Test_distinfoLinesChecke G.checkdirPackage(".") t.CheckOutputLines( + "WARN: distinfo:3: Distfiles without version number should be placed in a versioned DIST_SUBDIR.", "ERROR: distinfo: Patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".", "ERROR: distinfo: Patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".") } Index: pkgsrc/pkgtools/pkglint/files/mkline.go diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.76 pkgsrc/pkgtools/pkglint/files/mkline.go:1.77 --- pkgsrc/pkgtools/pkglint/files/mkline.go:1.76 Sat Feb 15 13:48:40 2020 +++ pkgsrc/pkgtools/pkglint/files/mkline.go Thu Mar 26 07:02:44 2020 @@ -293,12 +293,18 @@ func (mkline *MkLine) Args() string { re func (mkline *MkLine) Cond() *MkCond { cond := mkline.data.(*mkLineDirective).cond if cond == nil { + assert(mkline.HasCond()) cond = NewMkParser(mkline.Line, mkline.Args()).MkCond() mkline.data.(*mkLineDirective).cond = cond } return cond } +func (mkline *MkLine) HasCond() bool { + directive := mkline.Directive() + return directive == "if" || directive == "elif" +} + // DirectiveComment is the trailing end-of-line comment, typically at a deeply nested .endif or .endfor. func (mkline *MkLine) DirectiveComment() string { return mkline.data.(*mkLineDirective).comment } Index: pkgsrc/pkgtools/pkglint/files/mklines.go diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.70 pkgsrc/pkgtools/pkglint/files/mklines.go:1.71 --- pkgsrc/pkgtools/pkglint/files/mklines.go:1.70 Wed Mar 18 08:24:49 2020 +++ pkgsrc/pkgtools/pkglint/files/mklines.go Thu Mar 26 07:02:44 2020 @@ -653,6 +653,18 @@ func (mklines *MkLines) ExpandLoopVar(va return nil } +// IsUnreachable determines whether the given line is unreachable because a +// condition on the way to that line is not satisfied. +// If unsure, returns false. +func (mklines *MkLines) IsUnreachable(mkline *MkLine) bool { + // To make this code as simple as possible, the code should operate + // on a high-level AST, where the nodes are If, For and BasicBlock. + // + // See lang/ghc*/bootstrap.mk for good examples how pkglint should + // treat variable assignments. It's getting complicated. + return false +} + func (mklines *MkLines) SaveAutofixChanges() { mklines.lines.SaveAutofixChanges() } Index: pkgsrc/pkgtools/pkglint/files/package.go diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.85 pkgsrc/pkgtools/pkglint/files/package.go:1.86 --- pkgsrc/pkgtools/pkglint/files/package.go:1.85 Sun Mar 22 17:43:15 2020 +++ pkgsrc/pkgtools/pkglint/files/package.go Thu Mar 26 07:02:44 2020 @@ -86,6 +86,10 @@ type Package struct { IgnoreMissingPatches bool // In distinfo, don't warn about patches that cannot be found. Once Once + + // Contains the basenames of the distfiles that are mentioned in distinfo, + // for example "package-1.0.tar.gz", even if that file is in a DIST_SUBDIR. + distinfoDistfiles map[string]bool } func NewPackage(dir CurrPath) *Package { @@ -121,6 +125,7 @@ func NewPackage(dir CurrPath) *Package { pkg.vars.Fallback("PATCHDIR", "patches") pkg.vars.Fallback("KRB5_TYPE", "heimdal") pkg.vars.Fallback("PGSQL_VERSION", "95") + pkg.vars.Fallback("EXTRACT_SUFX", ".tar.gz") // In reality, this is an absolute pathname. Since this variable is // typically used in the form ${.CURDIR}/../../somewhere, this doesn't @@ -132,6 +137,9 @@ func NewPackage(dir CurrPath) *Package { func (pkg *Package) Check() { files, mklines, allLines := pkg.load() + if files == nil { + return + } pkg.check(files, mklines, allLines) } @@ -588,6 +596,8 @@ func (pkg *Package) check(filenames []Cu pkg.checkDescr(filenames, mklines) } + + pkg.checkDistfilesInDistinfo(allLines) } func (pkg *Package) checkDescr(filenames []CurrPath, mklines *MkLines) { @@ -605,6 +615,43 @@ func (pkg *Package) checkDescr(filenames mklines.Whole().Errorf("Each package must have a DESCR file.") } +func (pkg *Package) checkDistfilesInDistinfo(mklines *MkLines) { + // Needs more work; see MkLines.IsUnreachable. + if !G.Experimental { + return + } + + if pkg.distinfoDistfiles == nil { + return + } + + redundant := pkg.redundant + distfiles := redundant.get("DISTFILES") + if distfiles == nil { + return + } + + for _, mkline := range distfiles.vari.WriteLocations() { + unreachable := newLazyBool( + func() bool { return mklines.IsUnreachable(mkline) }) + resolved := resolveVariableRefs(mkline.Value(), nil, pkg) + + for _, distfile := range mkline.ValueFields(resolved) { + if containsVarUse(distfile) { + continue + } + if pkg.distinfoDistfiles[NewPath(distfile).Base()] { + continue + } + if unreachable.get() { + continue + } + mkline.Warnf("Distfile %q is not mentioned in %s.", + distfile, mkline.Rel(pkg.File(pkg.DistinfoFile))) + } + } +} + func (pkg *Package) checkfilePackageMakefile(filename CurrPath, mklines *MkLines, allLines *MkLines) { if trace.Tracing { defer trace.Call(filename)() Index: pkgsrc/pkgtools/pkglint/files/package_test.go diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.72 pkgsrc/pkgtools/pkglint/files/package_test.go:1.73 --- pkgsrc/pkgtools/pkglint/files/package_test.go:1.72 Sun Mar 22 17:43:15 2020 +++ pkgsrc/pkgtools/pkglint/files/package_test.go Thu Mar 26 07:02:44 2020 @@ -1344,6 +1344,124 @@ func (s *Suite) Test_Package_checkDescr_ t.CheckOutputEmpty() } +// All files that can possibly be added to DISTFILES need a corresponding +// entry in the distinfo file. +// +// https://mail-index.netbsd.org/pkgsrc-changes/2020/02/05/msg206172.html +// https://mail-index.netbsd.org/pkgsrc-changes/2020/03/25/msg209445.html +func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_conditional_DISTFILES(c *check.C) { + G.Experimental = true + + t := s.Init(c) + + t.SetUpPackage("category/package", + ".include \"../../mk/bsd.prefs.mk\"", + "", + "DISTFILES.i386=\t\tdistfile-i386.tar.gz", + "DISTFILES.other=\tdistfile-other.tar.gz", + "", + ".if ${MACHINE_ARCH} == i386", + "DISTFILES+=\t${DISTFILES.i386}", + ".else", + "DISTFILES+=\t${DISTFILES.other}", + ".endif", + "", + "DISTFILES+=\tok-3.tar.gz") + t.CreateFileLines("category/package/distinfo", + CvsID, + "", + "SHA1 (ok-3.tar.gz) = 1234", + "RMD160 (ok-3.tar.gz) = 1234", + "SHA512 (ok-3.tar.gz) = 1234", + "Size (ok-3.tar.gz) = 1234", + "SHA1 (package-1.0.tar.gz) = 1234", + "RMD160 (package-1.0.tar.gz) = 1234", + "SHA512 (package-1.0.tar.gz) = 1234", + "Size (package-1.0.tar.gz) = 1234") + t.Chdir("category/package") + t.FinishSetUp() + + G.Check(".") + + t.CheckOutputLines( + "WARN: Makefile:26: Distfile \"distfile-i386.tar.gz\" is not mentioned in distinfo.", + "WARN: Makefile:28: Distfile \"distfile-other.tar.gz\" is not mentioned in distinfo.") +} + +func (s *Suite) Test_Package_checkDistfilesInDistinfo__indirect_DIST_SUBDIR(c *check.C) { + G.Experimental = true + + t := s.Init(c) + + t.SetUpPackage("category/package", + ".include \"../../mk/bsd.prefs.mk\"", + "", + // As of 2020-03-26, pkglint doesn't know how to resolve PKGNAME_NOREV. + "DIST_SUBDIR=\t${PKGNAME_NOREV}", + // Strictly speaking, this is redundant, but as of 2020-03-26, + // pkglint doesn't infer the default DISTFILES, so it needs a bit of help here. + "DISTFILES+=\tdistfile-1.0.tar.gz", + "DISTFILES+=\tdistfile-other.tar.gz") + t.CreateFileLines("distinfo", + CvsID, + "", + "SHA1 (package-1.0/distfile-other.tar.gz) = 1234", + "RMD160 (package-1.0/distfile-other.tar.gz) = 1234", + "SHA512 (package-1.0/distfile-other.tar.gz) = 1234", + "Size (package-1.0/distfile-other.tar.gz) = 1234", + "SHA1 (package-1.0/package-1.0.tar.gz) = 1234", + "RMD160 (package-1.0/package-1.0.tar.gz) = 1234", + "SHA512 (package-1.0/package-1.0.tar.gz) = 1234", + "Size (package-1.0/package-1.0.tar.gz) = 1234") + t.Chdir("category/package") + t.FinishSetUp() + + G.Check(".") + + t.CheckOutputLines( + "WARN: Makefile:24: Distfile \"distfile-other.tar.gz\" is not mentioned in distinfo.") +} + +func (s *Suite) Test_Package_checkDistfilesInDistinfo__depending_on_package_settable(c *check.C) { + G.Experimental = true + + t := s.Init(c) + + t.SetUpPackage("print/tex-varisize", + "DISTNAME=\tvarisize", + "PKGNAME=\ttex-${DISTNAME}-2014", + "TEXLIVE_REV=\t15878", + "", + "TEXLIVE_UNVERSIONED=\tyes", + "", + ".include \"../../print/texlive/package.mk\"") + t.CreateFileLines("print/tex-varisize/distinfo", + CvsID, + "", + "SHA1 (tex-varisize-15878/varisize.tar.xz) = 1234", + "RMD160 (tex-varisize-15878/varisize.tar.xz) = 1234", + "SHA512 (tex-varisize-15878/varisize.tar.xz) = 1234", + "Size (tex-varisize-15878/varisize.tar.xz) = 3176 bytes") + t.CreateFileLines("print/texlive/package.mk", + MkCvsID, + "", + ".if empty(TEXLIVE_UNVERSIONED)", + "DISTFILES?=\t${DISTNAME}.r${TEXLIVE_REV}${EXTRACT_SUFX}", + ".endif") + t.Chdir("print/tex-varisize") + t.FinishSetUp() + + G.Check(".") + + // The package-settable TEXLIVE_UNVERSIONED is definitely not empty, + // therefore the line in package.mk doesn't apply. + // FIXME: This warning is wrong because the line in package.mk is unreachable. + // See MkLines.IsUnreachable. + t.CheckOutputLines( + "WARN: ../../print/texlive/package.mk:4: Distfile \"varisize.r15878.tar.gz\" " + + "is not mentioned in ../../print/tex-varisize/distinfo.") +} + func (s *Suite) Test_Package_checkfilePackageMakefile__GNU_CONFIGURE(c *check.C) { t := s.Init(c) Index: pkgsrc/pkgtools/pkglint/files/pkglint.go diff -u pkgsrc/pkgtools/pkglint/files/pkglint.go:1.78 pkgsrc/pkgtools/pkglint/files/pkglint.go:1.79 --- pkgsrc/pkgtools/pkglint/files/pkglint.go:1.78 Mon Mar 23 19:55:08 2020 +++ pkgsrc/pkgtools/pkglint/files/pkglint.go Thu Mar 26 07:02:44 2020 @@ -401,7 +401,7 @@ func resolveVariableRefs(text string, mk str := text for { // TODO: Replace regular expression with full parser. - replaced := replaceAllFunc(str, `\$\{([\w.]+)\}`, replace) + replaced := replaceAllFunc(str, `\$\{([\w.\-]+)\}`, replace) if replaced == str { if trace.Tracing && str != text { trace.Stepf("resolveVariableRefs %q => %q", text, replaced) Index: pkgsrc/pkgtools/pkglint/files/shell.go diff -u pkgsrc/pkgtools/pkglint/files/shell.go:1.60 pkgsrc/pkgtools/pkglint/files/shell.go:1.61 --- pkgsrc/pkgtools/pkglint/files/shell.go:1.60 Wed Mar 18 08:24:49 2020 +++ pkgsrc/pkgtools/pkglint/files/shell.go Thu Mar 26 07:02:44 2020 @@ -657,6 +657,8 @@ func (ck *ShellLineChecker) CheckShellCo line.Errorf("Use of _PKG_SILENT and _PKG_DEBUG is obsolete. Use ${RUN} instead.") } } + lexer.SkipHspace() + lexer.SkipString("${_ULIMIT_CMD}") // It brings its own semicolon, just like ${RUN}. ck.CheckShellCommand(lexer.Rest(), &setE, RunTime) ck.checkMultiLineComment() Index: pkgsrc/pkgtools/pkglint/files/shell_test.go diff -u pkgsrc/pkgtools/pkglint/files/shell_test.go:1.66 pkgsrc/pkgtools/pkglint/files/shell_test.go:1.67 --- pkgsrc/pkgtools/pkglint/files/shell_test.go:1.66 Wed Mar 18 08:24:49 2020 +++ pkgsrc/pkgtools/pkglint/files/shell_test.go Thu Mar 26 07:02:44 2020 @@ -587,6 +587,21 @@ func (s *Suite) Test_SimpleCommandChecke "WARN: Makefile:4: Please use ${ECHO_N} instead of \"echo -n\".") } +// Before 2020-03-25, pkglint ran into a parse error since it didn't +// know that _ULIMIT_CMD brings its own semicolon. +func (s *Suite) Test_ShellLineChecker__skip_ULIMIT_CMD(c *check.C) { + t := s.Init(c) + + mklines := t.NewMkLines("Makefile", + MkCvsID, + "pre-configure:", + "\t${RUN} ${_ULIMIT_CMD} while :; do :; done") + + mklines.Check() + + t.CheckOutputEmpty() +} + func (s *Suite) Test_ShellLineChecker_checkConditionalCd(c *check.C) { t := s.Init(c) Index: pkgsrc/pkgtools/pkglint/files/util.go diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.75 pkgsrc/pkgtools/pkglint/files/util.go:1.76 --- pkgsrc/pkgtools/pkglint/files/util.go:1.75 Wed Mar 18 08:24:49 2020 +++ pkgsrc/pkgtools/pkglint/files/util.go Thu Mar 26 07:02:44 2020 @@ -1540,3 +1540,18 @@ type bagEntry struct { key interface{} count int } + +type lazyBool struct { + fn func() bool + value bool +} + +func newLazyBool(fn func() bool) *lazyBool { return &lazyBool{fn, false} } + +func (b *lazyBool) get() bool { + if b.fn != nil { + b.value = b.fn() + b.fn = nil + } + return b.value +} Index: pkgsrc/pkgtools/pkglint/files/vardefs.go diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.91 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.92 --- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.91 Wed Mar 18 08:24:49 2020 +++ pkgsrc/pkgtools/pkglint/files/vardefs.go Thu Mar 26 07:02:44 2020 @@ -287,7 +287,7 @@ func (reg *VarTypeRegistry) compilerLang } } - if mkline.IsDirective() && mkline.Cond() != nil { + if mkline.IsDirective() && mkline.HasCond() && mkline.Cond() != nil { mkline.Cond().Walk(&MkCondCallback{ VarUse: func(varuse *MkVarUse) { if varuse.varname == "USE_LANGUAGES" && len(varuse.modifiers) == 1 { @@ -1691,7 +1691,7 @@ func (reg *VarTypeRegistry) Init(src *Pk reg.syslist("TOUCH_FLAGS", BtShellWord) reg.pkglist("UAC_REQD_EXECS", BtPrefixPathname) reg.pkglistbl3("UNLIMIT_RESOURCES", - enum("cputime datasize memorysize stacksize")) + enum("cputime datasize memorysize stacksize virtualsize")) reg.usr("UNPRIVILEGED_USER", BtUserGroupName) reg.usr("UNPRIVILEGED_GROUP", BtUserGroupName) reg.pkglist("UNWRAP_FILES", BtPathPattern) @@ -1767,6 +1767,7 @@ func (reg *VarTypeRegistry) Init(src *Pk reg.pkglist("X11_LDFLAGS", BtLdFlag) reg.sys("X11_PKGSRCDIR.*", BtPathname) reg.pkglist("XMKMF_FLAGS", BtShellWord) + reg.sys("_ULIMIT_CMD", BtShellCommands) reg.pkglist("_WRAP_EXTRA_ARGS.*", BtShellWord) reg.infralist("_VARGROUPS", BtIdentifierDirect) --_----------=_1585206165145030--