diff options
author | rillig <rillig@pkgsrc.org> | 2019-05-06 20:27:17 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-05-06 20:27:17 +0000 |
commit | 916339bb022f0f3e4e1da5f753114ce4b8d69709 (patch) | |
tree | e2358c7c52324fbad66bfd953ea252d6197ffed5 /pkgtools/pkglint/files/pkglint.go | |
parent | 3e83a6c4d69c38a42d8a7a8b46cba5f3e4ea734d (diff) | |
download | pkgsrc-916339bb022f0f3e4e1da5f753114ce4b8d69709.tar.gz |
pkgtools/pkglint: update to 5.7.9
Changes since 5.7.8:
* Buildlink3.mk files are checked for typos in the identifier that is
used for BUILDLINK_TREE, to detect copy-and-paste mistakes.
* Having a rationale is recommended for some variables, especially those
that make a package fail to build or crash at runtime. This check is
only active when -Wextra is given, since it is still actively debated
whether such a check is actually useful.
* Files called Makefile.php can easily be mistaken to be PHP files.
Therefore the recommended naming convention is to have auxiliary files
called *.mk. There are already many more files called *.mk than those
being called Makefile.*.
* The check for unquoted sed substitution commands has been made more
detailed, but since it is completely disabled, there's nothing to see
for now.
* The definitions for MASTER_SITE_* are loaded directly from the pkgsrc
infrastructure instead of hard-coding them in pkglint.
Diffstat (limited to 'pkgtools/pkglint/files/pkglint.go')
-rw-r--r-- | pkgtools/pkglint/files/pkglint.go | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/pkgtools/pkglint/files/pkglint.go b/pkgtools/pkglint/files/pkglint.go index 2a2b609d3af..2661fcf82ea 100644 --- a/pkgtools/pkglint/files/pkglint.go +++ b/pkgtools/pkglint/files/pkglint.go @@ -45,8 +45,7 @@ type Pkglint struct { // There is no other use for it. cwd string - Hashes map[string]*Hash // Maps "alg:filename" => hash (inter-package check). - UsedLicenses map[string]bool // Maps "license name" => true (inter-package check). + InterPackage InterPackage } func NewPkglint() Pkglint { @@ -60,6 +59,58 @@ func NewPkglint() Pkglint { interner: NewStringInterner()} } +type InterPackage struct { + hashes map[string]*Hash // Maps "alg:filename" => hash (inter-package check). + usedLicenses map[string]struct{} // Maps "license name" => true (inter-package check). + bl3Names map[string]Location // Maps buildlink3 identifiers to their first occurrence. +} + +func (ip *InterPackage) Enable() { + *ip = InterPackage{ + make(map[string]*Hash), + make(map[string]struct{}), + make(map[string]Location)} +} + +func (ip *InterPackage) Enabled() bool { return ip.hashes != nil } + +func (ip *InterPackage) Hash(alg, filename string, hashBytes []byte, loc *Location) *Hash { + key := alg + ":" + filename + if otherHash := ip.hashes[key]; otherHash != nil { + return otherHash + } + + ip.hashes[key] = &Hash{hashBytes, *loc} + return nil +} + +func (ip *InterPackage) UseLicense(name string) { + if ip.usedLicenses != nil { + ip.usedLicenses[intern(name)] = struct{}{} + } +} + +func (ip *InterPackage) LicenseUsed(name string) bool { + _, used := ip.usedLicenses[name] + return used +} + +// Bl3 remembers that the given buildlink3 name is used at the given location. +// Since these names must be unique, there should be no other location where +// the same name is used. +func (ip *InterPackage) Bl3(name string, loc *Location) *Location { + if ip.bl3Names == nil { + return nil + } + + if prev, found := ip.bl3Names[name]; found { + return &prev + } + + ip.bl3Names[name] = *loc + return nil +} + type CmdOpts struct { CheckExtra, CheckGlobal bool @@ -575,6 +626,10 @@ func CheckFileMk(filename string) { return } + if G.Pkg != nil { + G.Pkg.checkFileMakefileExt(filename) + } + mklines.Check() mklines.SaveAutofixChanges() } |