Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/, repoman/man/, repoman/pym/repoman/modules/scan/ebuild/
Date: Tue, 27 Jun 2017 20:06:09
Message-Id: 1492720728.674ed22900df3e6a2054adb1b49f3e0fddbd64b2.dolsen@gentoo
1 commit: 674ed22900df3e6a2054adb1b49f3e0fddbd64b2
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 15 10:43:13 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 20 20:38:48 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=674ed229
7
8 repoman: Add a check for relative dosym candidates
9
10 Add a check for dosym with target path matching absolute paths
11 controlled by the package manager, e.g. /bin, /etc...
12
13 Example output:
14
15 ebuild.absdosym 5
16 app-editors/nano/nano-2.5.3.ebuild: dosym '/bin/nano'... could use relative path on line: 81
17
18 Approved-by: Brian Dolbec <dolsen <AT> gentoo.org> (on IRC)
19
20 repoman/man/repoman.1 | 4 ++++
21 repoman/pym/repoman/modules/scan/ebuild/checks.py | 13 +++++++++++++
22 repoman/pym/repoman/qa_data.py | 4 ++++
23 3 files changed, 21 insertions(+)
24
25 diff --git a/repoman/man/repoman.1 b/repoman/man/repoman.1
26 index 9b106906f..78e4b7275 100644
27 --- a/repoman/man/repoman.1
28 +++ b/repoman/man/repoman.1
29 @@ -292,6 +292,10 @@ Some files listed in SRC_URI aren't referenced in the Manifest
30 .B digest.unused
31 Some files listed in the Manifest aren't referenced in SRC_URI
32 .TP
33 +.B ebuild.absdosym
34 +Ebuild uses 'dosym' with explicit absolute path where relative path
35 +could be used
36 +.TP
37 .B ebuild.badheader
38 This ebuild has a malformed header
39 .TP
40
41 diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py
42 index db6b6c8b4..e6e5d78ba 100644
43 --- a/repoman/pym/repoman/modules/scan/ebuild/checks.py
44 +++ b/repoman/pym/repoman/modules/scan/ebuild/checks.py
45 @@ -911,6 +911,19 @@ class PortageInternalVariableAssignment(LineCheck):
46 e += ' on line: %d'
47 return e
48
49 +
50 +class EbuildNonRelativeDosym(LineCheck):
51 + """Check ebuild for dosym using absolute paths instead of relative."""
52 + repoman_check_name = 'ebuild.absdosym'
53 + regex = re.compile(
54 + r'^\s*dosym\s+["\']?(/(bin|etc|lib|opt|sbin|srv|usr|var)\S*)')
55 +
56 + def check(self, num, line):
57 + match = self.regex.match(line)
58 + if match:
59 + return "dosym '%s'... could use relative path" % (match.group(1), ) + " on line: %d"
60 +
61 +
62 _base_check_classes = (InheritEclass, LineCheck, PhaseCheck)
63 _constant_checks = None
64
65
66 diff --git a/repoman/pym/repoman/qa_data.py b/repoman/pym/repoman/qa_data.py
67 index 132a55be3..a59fed778 100644
68 --- a/repoman/pym/repoman/qa_data.py
69 +++ b/repoman/pym/repoman/qa_data.py
70 @@ -195,6 +195,9 @@ qahelp = {
71 "Some files listed in SRC_URI aren't referenced in the Manifest"),
72 "digest.unused": (
73 "Some files listed in the Manifest aren't referenced in SRC_URI"),
74 + "ebuild.absdosym": (
75 + "This ebuild uses absolute target to dosym where relative symlink"
76 + " could be used instead"),
77 "ebuild.majorsyn": (
78 "This ebuild has a major syntax error"
79 " that may cause the ebuild to fail partially or fully"),
80 @@ -262,6 +265,7 @@ qawarnings = set((
81 "RDEPEND.suspect",
82 "virtual.suspect",
83 "RESTRICT.invalid",
84 + "ebuild.absdosym",
85 "ebuild.minorsyn",
86 "ebuild.badheader",
87 "ebuild.patches",