Received: by mail.netbsd.org (Postfix, from userid 605) id E678C84D9C; Thu, 23 Jul 2020 18:40:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 6EA3284D8C for ; Thu, 23 Jul 2020 18:40:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id xgPafLpoZYLr for ; Thu, 23 Jul 2020 18:40:41 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id A547E84D3C for ; Thu, 23 Jul 2020 18:40:41 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id A13A8FB28; Thu, 23 Jul 2020 18:40:41 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1595529641232410" MIME-Version: 1.0 Date: Thu, 23 Jul 2020 18:40:41 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/pkgtools/pkglint To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200723184041.A13A8FB28@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1595529641232410 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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. --_----------=_1595529641232410 Content-Disposition: inline Content-Length: 4682 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii 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) --_----------=_1595529641232410--