version 1.81, 2020/05/17 07:07:19 |
version 1.82, 2020/06/01 20:49:54 |
Line 43 type Pkglint struct { |
|
Line 43 type Pkglint struct { |
|
Username string // For checking against OWNER and MAINTAINER |
Username string // For checking against OWNER and MAINTAINER |
|
|
cvsEntriesDir CurrPath // Cached to avoid I/O |
cvsEntriesDir CurrPath // Cached to avoid I/O |
cvsEntries map[string]CvsEntry |
cvsEntries map[RelPath]CvsEntry |
|
|
Logger Logger |
Logger Logger |
|
|
Line 308 func (p *Pkglint) checkMode(dirent CurrP |
|
Line 308 func (p *Pkglint) checkMode(dirent CurrP |
|
dir = dirent.Dir() |
dir = dirent.Dir() |
} |
} |
|
|
basename := dirent.Base() |
|
pkgsrcRel := p.Pkgsrc.Rel(dirent) |
pkgsrcRel := p.Pkgsrc.Rel(dirent) |
|
|
p.Wip = pkgsrcRel.HasPrefixPath("wip") |
p.Wip = pkgsrcRel.HasPrefixPath("wip") |
Line 323 func (p *Pkglint) checkMode(dirent CurrP |
|
Line 322 func (p *Pkglint) checkMode(dirent CurrP |
|
|
|
if isReg { |
if isReg { |
p.checkExecutable(dirent, mode) |
p.checkExecutable(dirent, mode) |
p.checkReg(dirent, basename, pkgsrcRel.Count(), nil) |
p.checkReg(dirent, dirent.Base(), pkgsrcRel.Count(), nil) |
return |
return |
} |
} |
|
|
Line 549 func CheckFileMk(filename CurrPath, pkg |
|
Line 548 func CheckFileMk(filename CurrPath, pkg |
|
// checkReg checks the given regular file. |
// checkReg checks the given regular file. |
// depth is 3 for files in the package directory, and 4 or more for files |
// depth is 3 for files in the package directory, and 4 or more for files |
// deeper in the directory hierarchy, such as in files/ or patches/. |
// deeper in the directory hierarchy, such as in files/ or patches/. |
func (p *Pkglint) checkReg(filename CurrPath, basename string, depth int, pkg *Package) { |
func (p *Pkglint) checkReg(filename CurrPath, basename RelPath, depth int, pkg *Package) { |
|
|
if depth == 3 && !p.Wip { |
if depth == 3 && !p.Wip { |
if contains(basename, "TODO") { |
if basename.ContainsText("TODO") { |
NewLineWhole(filename).Errorf("Packages in main pkgsrc must not have a %s file.", basename) |
NewLineWhole(filename).Errorf("Packages in main pkgsrc must not have a %s file.", basename) |
// TODO: Add a convincing explanation. |
// TODO: Add a convincing explanation. |
return |
return |
Line 560 func (p *Pkglint) checkReg(filename Curr |
|
Line 559 func (p *Pkglint) checkReg(filename Curr |
|
} |
} |
|
|
switch { |
switch { |
case hasSuffix(basename, "~"), |
case basename.HasSuffixText("~"), |
hasSuffix(basename, ".orig"), |
basename.HasSuffixText(".orig"), |
hasSuffix(basename, ".rej"), |
basename.HasSuffixText(".rej"), |
contains(basename, "TODO") && depth == 3: |
basename.ContainsText("TODO") && depth == 3: |
if p.Import { |
if p.Import { |
NewLineWhole(filename).Errorf("Must be cleaned up before committing the package.") |
NewLineWhole(filename).Errorf("Must be cleaned up before committing the package.") |
} |
} |
Line 584 func (p *Pkglint) checkReg(filename Curr |
|
Line 583 func (p *Pkglint) checkReg(filename Curr |
|
case p.Wip && basename == "COMMIT_MSG": |
case p.Wip && basename == "COMMIT_MSG": |
// https://mail-index.netbsd.org/pkgsrc-users/2020/05/10/msg031174.html |
// https://mail-index.netbsd.org/pkgsrc-users/2020/05/10/msg031174.html |
|
|
case hasPrefix(basename, "DESCR"): |
case basename.HasPrefixText("DESCR"): |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
CheckLinesDescr(lines) |
CheckLinesDescr(lines) |
} |
} |
Line 597 func (p *Pkglint) checkReg(filename Curr |
|
Line 596 func (p *Pkglint) checkReg(filename Curr |
|
case basename == "DEINSTALL" || basename == "INSTALL": |
case basename == "DEINSTALL" || basename == "INSTALL": |
CheckFileOther(filename) |
CheckFileOther(filename) |
|
|
case hasPrefix(basename, "MESSAGE"): |
case basename.HasPrefixText("MESSAGE"): |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
CheckLinesMessage(lines, pkg) |
CheckLinesMessage(lines, pkg) |
} |
} |
Line 611 func (p *Pkglint) checkReg(filename Curr |
|
Line 610 func (p *Pkglint) checkReg(filename Curr |
|
CheckLinesOptionsMk(mklines, buildlinkID) |
CheckLinesOptionsMk(mklines, buildlinkID) |
} |
} |
|
|
case matches(basename, `^patch-[-\w.~+]*\w$`): |
case matches(basename.String(), `^patch-[-\w.~+]*\w$`): |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
CheckLinesPatch(lines, pkg) |
CheckLinesPatch(lines, pkg) |
} |
} |
|
|
case filename.Dir().Base() == "patches" && matches(filename.Base(), `^manual[^/]*$`): |
case filename.Dir().HasBase("patches") && filename.Base().HasPrefixText("manual"): |
if trace.Tracing { |
if trace.Tracing { |
trace.Stepf("Unchecked file %q.", filename) |
trace.Stepf("Unchecked file %q.", filename) |
} |
} |
|
|
case filename.Dir().Base() == "patches": |
case filename.Dir().HasBase("patches"): |
NewLineWhole(filename).Warnf("Patch files should be named \"patch-\", followed by letters, '-', '_', '.', and digits only.") |
NewLineWhole(filename).Warnf("Patch files should be named \"patch-\", followed by letters, '-', '_', '.', and digits only.") |
|
|
case (hasPrefix(basename, "Makefile") || hasSuffix(basename, ".mk")) && |
case (basename.HasPrefixText("Makefile") || basename.HasSuffixText(".mk")) && |
!G.Pkgsrc.Rel(filename).AsPath().ContainsPath("files"): |
!G.Pkgsrc.Rel(filename).AsPath().ContainsPath("files"): |
CheckFileMk(filename, pkg) |
CheckFileMk(filename, pkg) |
|
|
case hasPrefix(basename, "PLIST"): |
case basename.HasPrefixText("PLIST"): |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
if lines := Load(filename, NotEmpty|LogErrors); lines != nil { |
CheckLinesPlist(pkg, lines) |
CheckLinesPlist(pkg, lines) |
} |
} |
|
|
case contains(basename, "README"): |
case basename.ContainsText("README"): |
break |
break |
|
|
case hasPrefix(basename, "CHANGES-"): |
case basename.HasPrefixText("CHANGES-"): |
// This only checks the file but doesn't register the changes globally. |
// This only checks the file but doesn't register the changes globally. |
_ = p.Pkgsrc.loadDocChangesFromFile(filename) |
_ = p.Pkgsrc.loadDocChangesFromFile(filename) |
|
|
case filename.Dir().Base() == "files": |
case filename.Dir().HasBase("files"): |
// Skip files directly in the files/ directory, but not those further down. |
// Skip files directly in the files/ directory, but not those further down. |
|
|
case basename == "spec": |
case basename == "spec": |
Line 674 func (p *Pkglint) checkRegCvsSubst(filen |
|
Line 673 func (p *Pkglint) checkRegCvsSubst(filen |
|
"For more information, see", |
"For more information, see", |
"https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Substitution-modes.html.", |
"https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Substitution-modes.html.", |
"", |
"", |
sprintf("To fix this, run \"cvs admin -kkv %s\"", shquote(filename.Base()))) |
sprintf("To fix this, run \"cvs admin -kkv %s\"", shquote(filename.Base().String()))) |
} |
} |
|
|
func (p *Pkglint) checkExecutable(filename CurrPath, mode os.FileMode) { |
func (p *Pkglint) checkExecutable(filename CurrPath, mode os.FileMode) { |
Line 757 func (p *Pkglint) tools(mklines *MkLines |
|
Line 756 func (p *Pkglint) tools(mklines *MkLines |
|
} |
} |
} |
} |
|
|
func (p *Pkglint) loadCvsEntries(filename CurrPath) map[string]CvsEntry { |
func (p *Pkglint) loadCvsEntries(filename CurrPath) map[RelPath]CvsEntry { |
dir := filename.Dir().Clean() |
dir := filename.Dir().Clean() |
if dir == p.cvsEntriesDir { |
if dir == p.cvsEntriesDir { |
return p.cvsEntries |
return p.cvsEntries |
} |
} |
|
|
var entries map[string]CvsEntry |
var entries map[RelPath]CvsEntry |
|
|
handle := func(line *Line, add bool, text string) { |
handle := func(line *Line, add bool, text string) { |
if !hasPrefix(text, "/") { |
if !hasPrefix(text, "/") { |
Line 776 func (p *Pkglint) loadCvsEntries(filenam |
|
Line 775 func (p *Pkglint) loadCvsEntries(filenam |
|
return |
return |
} |
} |
|
|
|
key := NewRelPathString(fields[1]) |
if add { |
if add { |
entries[fields[1]] = CvsEntry{fields[1], fields[2], fields[3], fields[4], fields[5]} |
entries[key] = CvsEntry{key, fields[2], fields[3], fields[4], fields[5]} |
} else { |
} else { |
delete(entries, fields[1]) |
delete(entries, key) |
} |
} |
} |
} |
|
|
lines := Load(dir.JoinNoClean("CVS/Entries"), 0) |
lines := Load(dir.JoinNoClean("CVS/Entries"), 0) |
if lines != nil { |
if lines != nil { |
entries = make(map[string]CvsEntry) |
entries = make(map[RelPath]CvsEntry) |
for _, line := range lines.Lines { |
for _, line := range lines.Lines { |
handle(line, true, line.Text) |
handle(line, true, line.Text) |
} |
} |