pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkglint
Module Name: pkgsrc
Committed By: rillig
Date: Thu Jul 23 18:40:41 UTC 2020
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: patches.go patches_test.go
Log Message:
pkgtools/pkglint: update to 20.2.3
Changes since 20.2.2:
Complain about patches that add a hard-coded interpreter. Even if that
interpreter is /bin/sh, which is available on most platforms, it is still
inappropriate on old Solaris installations. Other popular paths start
with /usr/pkg or /usr/local, and these are not controlled by pkgsrc either.
To generate a diff of this commit:
cvs rdiff -u -r1.663 -r1.664 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.43 -r1.44 pkgsrc/pkgtools/pkglint/files/patches.go
cvs rdiff -u -r1.41 -r1.42 pkgsrc/pkgtools/pkglint/files/patches_test.go
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.663 pkgsrc/pkgtools/pkglint/Makefile:1.664
--- pkgsrc/pkgtools/pkglint/Makefile:1.663 Wed Jul 22 19:26:29 2020
+++ pkgsrc/pkgtools/pkglint/Makefile Thu Jul 23 18:40:41 2020
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.663 2020/07/22 19:26:29 rillig Exp $
+# $NetBSD: Makefile,v 1.664 2020/07/23 18:40:41 rillig Exp $
-PKGNAME= pkglint-20.2.2
+PKGNAME= pkglint-20.2.3
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/patches.go
diff -u pkgsrc/pkgtools/pkglint/files/patches.go:1.43 pkgsrc/pkgtools/pkglint/files/patches.go:1.44
--- pkgsrc/pkgtools/pkglint/files/patches.go:1.43 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/patches.go Thu Jul 23 18:40:41 2020
@@ -148,20 +148,26 @@ func (ck *PatchChecker) checkUnifiedDiff
// all the patch programs can handle this situation.
linesToDel--
linesToAdd--
+ linenoDel++
+ linenoAdd++
case hasPrefix(text, " "), hasPrefix(text, "\t"):
linesToDel--
linesToAdd--
+ linenoDel++
+ linenoAdd++
ck.checktextCvsID(text)
case hasPrefix(text, "-"):
linesToDel--
+ linenoDel++
case hasPrefix(text, "+"):
linesToAdd--
ck.checktextCvsID(text)
ck.checkConfigure(text[1:], isConfigure)
- ck.checkAddedLine(text[1:])
+ ck.checkAddedLine(text[1:], linenoAdd)
+ linenoAdd++
case hasPrefix(text, "\\"):
// \ No newline at end of file (or a translation of that message)
@@ -248,13 +254,32 @@ func (ck *PatchChecker) checkConfigure(a
"mk/configure/gnu-configure.mk.")
}
-func (ck *PatchChecker) checkAddedLine(addedText string) {
+func (ck *PatchChecker) checkAddedLine(addedText string, lineno int) {
dirs := regcomp(`(?:^|[^.@)}])(/usr/pkg|/var|/etc)([^\w-]|$)`)
for _, m := range dirs.FindAllStringSubmatchIndex(addedText, -1) {
before := addedText[:m[2]]
dir := NewPath(addedText[m[2]:m[3]])
ck.checkAddedAbsPath(before, dir, addedText[m[4]:])
}
+ if lineno == 1 {
+ if m, interp := match1(addedText, `^#!\s*(/\S+)`); m {
+ line := ck.llex.PreviousLine()
+ line.Errorf("Patches must not add a hard-coded interpreter (%s).", interp)
+ line.Explain(
+ "If a patch modifies the first line of a script,",
+ "it should use the established pattern of setting the",
+ "interpreter to a @PLACEHOLDER@ and later replace this",
+ "placeholder with the actual path, for example by using",
+ "REPLACE_INTERPRETER (or its specialized variants",
+ "REPLACE_BASH, REPLACE_PERL, etc.), or by using the",
+ "SUBST framework.",
+ "",
+ sprintf("For more information, run %q or %q.",
+ bmakeHelp("interp"), bmakeHelp("subst")),
+ seeGuide("The SUBST framework", "fixes.subst"),
+ "for more information about the @PLACEHOLDER@.")
+ }
+ }
}
func (ck *PatchChecker) checkAddedAbsPath(before string, dir Path, after string) {
Index: pkgsrc/pkgtools/pkglint/files/patches_test.go
diff -u pkgsrc/pkgtools/pkglint/files/patches_test.go:1.41 pkgsrc/pkgtools/pkglint/files/patches_test.go:1.42
--- pkgsrc/pkgtools/pkglint/files/patches_test.go:1.41 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/patches_test.go Thu Jul 23 18:40:41 2020
@@ -778,6 +778,66 @@ func (s *Suite) Test_PatchChecker_checkC
"ERROR: ~/patch-aa:9: This code must not be included in patches.")
}
+func (s *Suite) Test_PatchChecker_checkAddedLine__interpreter(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("patch-aa",
+ CvsID,
+ "",
+ "Documentation.",
+ "",
+ "--- a/aa",
+ "+++ b/aa",
+ "@@ -1,1 +1,1 @@",
+ "-old",
+ "+#! /home/my/pkgsrc/pkg/bin/bash")
+
+ CheckLinesPatch(lines, nil)
+
+ t.CheckOutputLines(
+ "ERROR: patch-aa:9: Patches must not add a hard-coded interpreter " +
+ "(/home/my/pkgsrc/pkg/bin/bash).")
+}
+
+func (s *Suite) Test_PatchChecker_checkAddedLine__interpreter_in_line_2(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("patch-aa",
+ CvsID,
+ "",
+ "Documentation.",
+ "",
+ "--- a/aa",
+ "+++ b/aa",
+ "@@ -1,1 +1,2 @@",
+ "-old",
+ "+new",
+ "+#! /home/my/pkgsrc/pkg/bin/bash")
+
+ CheckLinesPatch(lines, nil)
+
+ t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_PatchChecker_checkAddedLine__interpreter_placeholder(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("patch-aa",
+ CvsID,
+ "",
+ "Documentation.",
+ "",
+ "--- a/aa",
+ "+++ b/aa",
+ "@@ -1,1 +1,1 @@",
+ "-old",
+ "+#! @PREFIX@/bin/bash")
+
+ CheckLinesPatch(lines, nil)
+
+ t.CheckOutputEmpty()
+}
+
func (s *Suite) Test_PatchChecker_checkAddedAbsPath(c *check.C) {
t := s.Init(c)
Home |
Main Index |
Thread Index |
Old Index