summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-08-02 13:27:17 +0000
committerrillig <rillig@pkgsrc.org>2020-08-02 13:27:17 +0000
commitc3103567051da695cded6ba1ad3a6fd88553ed47 (patch)
tree58ee3400c3084d630b948522d65986588d34b215 /pkgtools
parentcf7370e02c96cb234993a0bd771cc9053024fcf7 (diff)
downloadpkgsrc-c3103567051da695cded6ba1ad3a6fd88553ed47.tar.gz
pkgtools/pkglint: update to 20.2.6
Changes since 20.2.5: Some selected absolute paths, such as /etc/passwd, /etc/shadow and /etc/hosts are allowed in patch files. Other files in /etc should still use PKG_SYSCONFDIR, to keep the package portable between platforms and also in unprivileged mode. (Fixes PR pkg/55524.) Absolute pathnames are also allowed in C-style end-of-line comments (fixes PR pkg/55516) and in continuations of C-style block comments (fixes PR pkg/55524). The explanation for make's :ts modifier has been adjusted to the 2020 bmake update. The modifier :ts\040 is now interpreted as octal, as opposed to decimal.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/Makefile4
-rw-r--r--pkgtools/pkglint/files/mklexer.go4
-rw-r--r--pkgtools/pkglint/files/mklexer_test.go4
-rw-r--r--pkgtools/pkglint/files/patches.go17
-rw-r--r--pkgtools/pkglint/files/patches_test.go28
5 files changed, 47 insertions, 10 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index 401eb9be0c8..b45b6f43371 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.666 2020/07/31 22:39:36 rillig Exp $
+# $NetBSD: Makefile,v 1.667 2020/08/02 13:27:17 rillig Exp $
-PKGNAME= pkglint-20.2.5
+PKGNAME= pkglint-20.2.6
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff --git a/pkgtools/pkglint/files/mklexer.go b/pkgtools/pkglint/files/mklexer.go
index a3f0ca70a90..71efe5cb20d 100644
--- a/pkgtools/pkglint/files/mklexer.go
+++ b/pkgtools/pkglint/files/mklexer.go
@@ -367,7 +367,7 @@ func (p *MkLexer) varUseModifierTs(
mod string, closing byte, lexer *textproc.Lexer, varname string,
mark textproc.LexerMark) MkVarUseModifier {
- // See devel/bmake/files/var.c:/case 't'
+ // See devel/bmake/files/var.c:/^ApplyModifier_ToSep/
sep := mod[2:] + p.varUseText(closing)
switch {
case sep == "":
@@ -380,7 +380,7 @@ func (p *MkLexer) varUseModifierTs(
p.Warnf("Invalid separator %q for :ts modifier of %q.", sep, varname)
p.Explain(
"The separator for the :ts modifier must be either a single character",
- "or an escape sequence like \\t or \\n or an octal or decimal escape",
+ "or an escape sequence like \\t or \\n or an octal or hexadecimal escape",
"sequence; see the bmake man page for further details.")
}
return MkVarUseModifier(lexer.Since(mark))
diff --git a/pkgtools/pkglint/files/mklexer_test.go b/pkgtools/pkglint/files/mklexer_test.go
index 5532c7be525..c8952e821a4 100644
--- a/pkgtools/pkglint/files/mklexer_test.go
+++ b/pkgtools/pkglint/files/mklexer_test.go
@@ -641,8 +641,8 @@ func (s *Suite) Test_MkLexer_varUseModifier__invalid_ts_modifier_with_warning(c
"WARN: filename.mk:123: Invalid separator \"abc\" for :ts modifier of \"VAR\".",
"",
"\tThe separator for the :ts modifier must be either a single character",
- "\tor an escape sequence like \\t or \\n or an octal or decimal escape",
- "\tsequence; see the bmake man page for further details.",
+ "\tor an escape sequence like \\t or \\n or an octal or hexadecimal",
+ "\tescape sequence; see the bmake man page for further details.",
"")
}
diff --git a/pkgtools/pkglint/files/patches.go b/pkgtools/pkglint/files/patches.go
index 8239756ef54..7abe6a5d742 100644
--- a/pkgtools/pkglint/files/patches.go
+++ b/pkgtools/pkglint/files/patches.go
@@ -296,11 +296,21 @@ func (ck *PatchChecker) checkAddedAbsPath(before string, dir Path, after string)
return
}
- // Ignore paths inside C-style comments.
+ // Ignore paths inside C-style block comments.
if contains(before, "/*") && contains(after, "*/") {
return
}
+ // Ignore paths inside multiline C-style block comments.
+ if hasPrefix(trimHspace(before), "*") {
+ return
+ }
+
+ // Ignore paths inside C-style end-of-line comments.
+ if contains(before, "//") {
+ return
+ }
+
// Ignore composed C string literals such as PREFIX "/etc".
if matches(before, `\w+[ \t]*"$`) {
return
@@ -313,6 +323,11 @@ func (ck *PatchChecker) checkAddedAbsPath(before string, dir Path, after string)
return
}
+ // Allow well-known pathnames that belong to the base system.
+ if matches(after, `hosts|passwd|shadow`) {
+ return
+ }
+
switch dir {
case "/usr/pkg":
diff --git a/pkgtools/pkglint/files/patches_test.go b/pkgtools/pkglint/files/patches_test.go
index 86967364e7e..d7f040f2aec 100644
--- a/pkgtools/pkglint/files/patches_test.go
+++ b/pkgtools/pkglint/files/patches_test.go
@@ -975,13 +975,15 @@ func (s *Suite) Test_PatchChecker_checkAddedAbsPath(c *check.C) {
// The dot before the "/etc" makes it a relative pathname.
test(
- "cp ./etc/hostname /tmp")
+ "cp ./etc/hostname /tmp",
+ nil...)
// +> +# from /etc/inittab (SYSV systems)
// +ERROR: devel/tet3/patches/patch-ac:51: Patches must not hard-code the pkgsrc PKG_SYSCONFDIR.
test(
- "# SysV /etc/install, /usr/sbin/install")
+ "# SysV /etc/install, /usr/sbin/install",
+ nil...)
// C or C++ program, macro definition.
// This is an absolute path since the PID_FILE is the macro name,
@@ -995,8 +997,28 @@ func (s *Suite) Test_PatchChecker_checkAddedAbsPath(c *check.C) {
"#define PID_FILE PREFIX \"/etc/conf\"",
nil...)
+ // In C-style block comments, absolute pathnames are ok,
+ // even though they could still be confusing.
+ test(
+ "#define L 150 /* Length of a line in /etc/some/file */",
+ nil...)
+
+ // In multiline C-style block comment, absolute pathnames are ok,
+ // even though they could still be confusing.
+ test(
+ " * Length of a line in /etc/some/file",
+ nil...)
+
+ // In C-style end-of-line comments, absolute pathnames are ok,
+ // // even though they could still be confusing.
+ test(
+ "#define L 150 // Length of a line in /etc/some/file",
+ nil...)
+
+ // Allow /etc/passwd, /etc/shadow, /etc/hosts and their variants.
+ // These belong to the base system, not to pkgsrc.
test(
- "#define L 150 /* Length of a line in /etc/passwd */",
+ "#define PATH_SHADOW \"/etc/master.passwd\"",
nil...)
test(