pkgtools/pkglint: fix alternatives check The alternatives implementation may have command line arguments.diff -r1.9 -r1.10 pkgsrc/pkgtools/pkglint/files/alternatives.go
(rillig)
@@ -35,27 +35,27 @@ func CheckFileAlternatives(filename stri | @@ -35,27 +35,27 @@ func CheckFileAlternatives(filename stri | |||
35 | // It's possible but unusual to refer to a fixed absolute path. | 35 | // It's possible but unusual to refer to a fixed absolute path. | |
36 | // These cannot be mentioned in the PLIST since they are not part of the package. | 36 | // These cannot be mentioned in the PLIST since they are not part of the package. | |
37 | break | 37 | break | |
38 | 38 | |||
39 | case plistName == alternative: | 39 | case plistName == alternative: | |
40 | line.Errorf("Alternative implementation %q must appear in the PLIST.", alternative) | 40 | line.Errorf("Alternative implementation %q must appear in the PLIST.", alternative) | |
41 | 41 | |||
42 | default: | 42 | default: | |
43 | line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", alternative, plistName) | 43 | line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", alternative, plistName) | |
44 | } | 44 | } | |
45 | } | 45 | } | |
46 | 46 | |||
47 | for _, line := range lines.Lines { | 47 | for _, line := range lines.Lines { | |
48 | m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)$`) | 48 | m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)`) | |
49 | if !m { | 49 | if !m { | |
50 | line.Errorf("Invalid line %q.", line.Text) | 50 | line.Errorf("Invalid line %q.", line.Text) | |
51 | G.Explain( | 51 | G.Explain( | |
52 | sprintf("Run %q for more information.", makeHelp("alternatives"))) | 52 | sprintf("Run %q for more information.", makeHelp("alternatives"))) | |
53 | continue | 53 | continue | |
54 | } | 54 | } | |
55 | 55 | |||
56 | if plist.Files != nil { | 56 | if plist.Files != nil { | |
57 | checkPlistWrapper(line, wrapper) | 57 | checkPlistWrapper(line, wrapper) | |
58 | checkPlistAlternative(line, alternative) | 58 | checkPlistAlternative(line, alternative) | |
59 | } | 59 | } | |
60 | 60 | |||
61 | switch { | 61 | switch { |
@@ -20,39 +20,40 @@ func (s *Suite) Test_CheckFileAlternativ | @@ -20,39 +20,40 @@ func (s *Suite) Test_CheckFileAlternativ | |||
20 | PlistRcsID, | 20 | PlistRcsID, | |
21 | "bin/echo", | 21 | "bin/echo", | |
22 | "bin/vim", | 22 | "bin/vim", | |
23 | "sbin/sendmail.exim${EXIMVER}") | 23 | "sbin/sendmail.exim${EXIMVER}") | |
24 | 24 | |||
25 | G.Check(".") | 25 | G.Check(".") | |
26 | 26 | |||
27 | t.CheckOutputLines( | 27 | t.CheckOutputLines( | |
28 | "ERROR: ALTERNATIVES:1: Alternative implementation \"@PREFIX@/sbin/sendmail.postfix@POSTFIXVER@\" "+ | 28 | "ERROR: ALTERNATIVES:1: Alternative implementation \"@PREFIX@/sbin/sendmail.postfix@POSTFIXVER@\" "+ | |
29 | "must appear in the PLIST as \"sbin/sendmail.postfix${POSTFIXVER}\".", | 29 | "must appear in the PLIST as \"sbin/sendmail.postfix${POSTFIXVER}\".", | |
30 | "ERROR: ALTERNATIVES:3: Alternative wrapper \"bin/echo\" must not appear in the PLIST.", | 30 | "ERROR: ALTERNATIVES:3: Alternative wrapper \"bin/echo\" must not appear in the PLIST.", | |
31 | "ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must appear in the PLIST.", | 31 | "ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must appear in the PLIST.", | |
32 | "ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must be an absolute path.", | 32 | "ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must be an absolute path.", | |
33 | "ERROR: ALTERNATIVES:4: Invalid line \"bin/editor bin/vim -e\".", | 33 | "ERROR: ALTERNATIVES:4: Alternative implementation \"bin/vim\" must be an absolute path.", | |
34 | "ERROR: ALTERNATIVES:5: Invalid line \"invalid\".", | 34 | "ERROR: ALTERNATIVES:5: Invalid line \"invalid\".", | |
35 | "ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must appear in the PLIST.", | 35 | "ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must appear in the PLIST.", | |
36 | "ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must be an absolute path.", | 36 | "ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must be an absolute path.", | |
37 | "ERROR: ALTERNATIVES:7: Alternative implementation \"@VARBASE@/game/scores\" "+ | 37 | "ERROR: ALTERNATIVES:7: Alternative implementation \"@VARBASE@/game/scores\" "+ | |
38 | "must appear in the PLIST as \"${VARBASE}/game/scores\".") | 38 | "must appear in the PLIST as \"${VARBASE}/game/scores\".") | |
39 | 39 | |||
40 | t.SetupCommandLine("--autofix") | 40 | t.SetupCommandLine("--autofix") | |
41 | 41 | |||
42 | G.Check(".") | 42 | G.Check(".") | |
43 | 43 | |||
44 | t.CheckOutputLines( | 44 | t.CheckOutputLines( | |
45 | "AUTOFIX: ALTERNATIVES:3: Replacing \"bin/gnu-echo\" with \"@PREFIX@/bin/gnu-echo\".") | 45 | "AUTOFIX: ALTERNATIVES:3: Replacing \"bin/gnu-echo\" with \"@PREFIX@/bin/gnu-echo\".", | |
46 | "AUTOFIX: ALTERNATIVES:4: Replacing \"bin/vim\" with \"@PREFIX@/bin/vim\".") | |||
46 | } | 47 | } | |
47 | 48 | |||
48 | func (s *Suite) Test_CheckFileAlternatives__empty(c *check.C) { | 49 | func (s *Suite) Test_CheckFileAlternatives__empty(c *check.C) { | |
49 | t := s.Init(c) | 50 | t := s.Init(c) | |
50 | 51 | |||
51 | t.Chdir("category/package") | 52 | t.Chdir("category/package") | |
52 | t.CreateFileLines("ALTERNATIVES") | 53 | t.CreateFileLines("ALTERNATIVES") | |
53 | 54 | |||
54 | G.Pkg = NewPackage(".") | 55 | G.Pkg = NewPackage(".") | |
55 | 56 | |||
56 | CheckFileAlternatives("ALTERNATIVES") | 57 | CheckFileAlternatives("ALTERNATIVES") | |
57 | 58 | |||
58 | t.CheckOutputLines( | 59 | t.CheckOutputLines( |
@@ -47,18 +47,18 @@ func (s *Suite) Test_Lines_CheckRcsID__w | @@ -47,18 +47,18 @@ func (s *Suite) Test_Lines_CheckRcsID__w | |||
47 | G.Check(t.File("wip/package")) | 47 | G.Check(t.File("wip/package")) | |
48 | 48 | |||
49 | t.CheckOutputLines( | 49 | t.CheckOutputLines( | |
50 | "NOTE: ~/wip/package/file1.mk:1: Expected exactly \"# $"+"NetBSD$\".", | 50 | "NOTE: ~/wip/package/file1.mk:1: Expected exactly \"# $"+"NetBSD$\".", | |
51 | "ERROR: ~/wip/package/file3.mk:1: Expected \"# $"+"NetBSD$\".", | 51 | "ERROR: ~/wip/package/file3.mk:1: Expected \"# $"+"NetBSD$\".", | |
52 | "ERROR: ~/wip/package/file4.mk:1: Expected \"# $"+"NetBSD$\".", | 52 | "ERROR: ~/wip/package/file4.mk:1: Expected \"# $"+"NetBSD$\".", | |
53 | "ERROR: ~/wip/package/file5.mk:1: Expected \"# $"+"NetBSD$\".") | 53 | "ERROR: ~/wip/package/file5.mk:1: Expected \"# $"+"NetBSD$\".") | |
54 | 54 | |||
55 | G.Logger.Opts.Autofix = true | 55 | G.Logger.Opts.Autofix = true | |
56 | 56 | |||
57 | G.Check(t.File("wip/package")) | 57 | G.Check(t.File("wip/package")) | |
58 | 58 | |||
59 | t.CheckOutputLines( | 59 | t.CheckOutputLines( | |
60 | "AUTOFIX: ~/wip/package/file1.mk:1: Replacing \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" with \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\".", | 60 | "AUTOFIX: ~/wip/package/file1.mk:1: Replacing \"# $"+"NetBSD: dummy $\" with \"# $"+"NetBSD$\".", | |
61 | "AUTOFIX: ~/wip/package/file3.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.", | 61 | "AUTOFIX: ~/wip/package/file3.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.", | |
62 | "AUTOFIX: ~/wip/package/file4.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.", | 62 | "AUTOFIX: ~/wip/package/file4.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.", | |
63 | "AUTOFIX: ~/wip/package/file5.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.") | 63 | "AUTOFIX: ~/wip/package/file5.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.") | |
64 | } | 64 | } |