Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 20.2.6



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fa0834056461
branches:  trunk
changeset: 436418:fa0834056461
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Aug 02 13:27:17 2020 +0000

description:
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:

 pkgtools/pkglint/Makefile              |   4 ++--
 pkgtools/pkglint/files/mklexer.go      |   4 ++--
 pkgtools/pkglint/files/mklexer_test.go |   4 ++--
 pkgtools/pkglint/files/patches.go      |  17 ++++++++++++++++-
 pkgtools/pkglint/files/patches_test.go |  28 +++++++++++++++++++++++++---
 5 files changed, 47 insertions(+), 10 deletions(-)

diffs (136 lines):

diff -r 08a3501f5039 -r fa0834056461 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Aug 02 12:49:08 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sun Aug 02 13:27:17 2020 +0000
@@ -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 -r 08a3501f5039 -r fa0834056461 pkgtools/pkglint/files/mklexer.go
--- a/pkgtools/pkglint/files/mklexer.go Sun Aug 02 12:49:08 2020 +0000
+++ b/pkgtools/pkglint/files/mklexer.go Sun Aug 02 13:27:17 2020 +0000
@@ -367,7 +367,7 @@
        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 @@
                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 -r 08a3501f5039 -r fa0834056461 pkgtools/pkglint/files/mklexer_test.go
--- a/pkgtools/pkglint/files/mklexer_test.go    Sun Aug 02 12:49:08 2020 +0000
+++ b/pkgtools/pkglint/files/mklexer_test.go    Sun Aug 02 13:27:17 2020 +0000
@@ -641,8 +641,8 @@
                "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 -r 08a3501f5039 -r fa0834056461 pkgtools/pkglint/files/patches.go
--- a/pkgtools/pkglint/files/patches.go Sun Aug 02 12:49:08 2020 +0000
+++ b/pkgtools/pkglint/files/patches.go Sun Aug 02 13:27:17 2020 +0000
@@ -296,11 +296,21 @@
                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 @@
                return
        }
 
+       // Allow well-known pathnames that belong to the base system.
+       if matches(after, `hosts|passwd|shadow`) {
+               return
+       }
+
        switch dir {
        case "/usr/pkg":
 
diff -r 08a3501f5039 -r fa0834056461 pkgtools/pkglint/files/patches_test.go
--- a/pkgtools/pkglint/files/patches_test.go    Sun Aug 02 12:49:08 2020 +0000
+++ b/pkgtools/pkglint/files/patches_test.go    Sun Aug 02 13:27:17 2020 +0000
@@ -975,13 +975,15 @@
 
        // 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 @@
                "#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/passwd */",
+               "#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 PATH_SHADOW \"/etc/master.passwd\"",
                nil...)
 
        test(



Home | Main Index | Thread Index | Old Index