Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 3/3] repoman: Add check for missing slot values/slot operators
Date: Wed, 13 Aug 2014 17:20:35
Message-Id: 1407950435-2520-4-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCHES] @changed-deps + missing slot check reposted for bernalex by "Michał Górny"
1 The idea if that a particular dependency atom matches more than one slot
2 of a package, you are supposed to either use := or :* operator
3 (or a specific :slot dependency), whichever is appropriate.
4
5 This will help catching mistakes (when packages become slotted) and make
6 cross-slot behavior clear (it is undefined with no slot operator). I
7 will estimate the amount of new warnings later.
8 ---
9 bin/repoman | 6 ++++++
10 pym/repoman/check_missingslot.py | 25 +++++++++++++++++++++++++
11 2 files changed, 31 insertions(+)
12 create mode 100644 pym/repoman/check_missingslot.py
13
14 diff --git a/bin/repoman b/bin/repoman
15 index 5a6ee5b..6c54917 100755
16 --- a/bin/repoman
17 +++ b/bin/repoman
18 @@ -58,6 +58,7 @@ from portage import _encodings
19 from portage import _unicode_encode
20 import repoman.checks
21 from repoman.checks import run_checks
22 +from repoman.check_missingslot import check_missingslot
23 from repoman import utilities
24 from repoman.herdbase import make_herd_base
25 from _emerge.Package import Package
26 @@ -299,6 +300,7 @@ qahelp = {
27 "dependency.badindev": "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch",
28 "dependency.badmaskedindev": "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch",
29 "dependency.badtilde": "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)",
30 + "dependency.missingslot": "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator",
31 "dependency.perlcore": "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead.",
32 "dependency.syntax": "Syntax error in dependency string (usually an extra/missing space/parenthesis)",
33 "dependency.unknown": "Ebuild has a dependency that refers to an unknown package (which may be valid if it is a blocker for a renamed/removed package, or is an alternative choice provided by an overlay)",
34 @@ -386,6 +388,7 @@ qawarnings = set((
35 "dependency.badindev",
36 "dependency.badmaskedindev",
37 "dependency.badtilde",
38 +"dependency.missingslot",
39 "dependency.perlcore",
40 "DESCRIPTION.toolong",
41 "EAPI.deprecated",
42 @@ -2090,6 +2093,9 @@ for x in effective_scanlist:
43 " with a non-zero revision:" + \
44 " '%s'") % (mytype, atom))
45
46 + check_missingslot(atom, mytype, eapi, portdb, stats, fails,
47 + relative_path)
48 +
49 type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
50
51 for m, b in zip(type_list, badsyntax):
52 diff --git a/pym/repoman/check_missingslot.py b/pym/repoman/check_missingslot.py
53 new file mode 100644
54 index 0000000..1da2ac1
55 --- /dev/null
56 +++ b/pym/repoman/check_missingslot.py
57 @@ -0,0 +1,25 @@
58 +# repoman: missing slot check
59 +# Copyright 2014 Gentoo Foundation
60 +# Distributed under the terms of the GNU General Public License v2
61 +
62 +"""This module contains the check used to find missing slot values
63 +in dependencies."""
64 +
65 +from portage.eapi import eapi_has_slot_operator
66 +
67 +def check_missingslot(atom, mytype, eapi, portdb, stats, fails, relative_path):
68 + # If no slot or slot operator is specified in RDEP...
69 + if (not atom.blocker and not atom.slot and not atom.slot_operator
70 + and mytype == 'RDEPEND' and eapi_has_slot_operator(eapi)):
71 + # Check whether it doesn't match more than one.
72 + atom_matches = portdb.xmatch("match-all", atom)
73 + dep_slots = frozenset(
74 + portdb.aux_get(cpv, ['SLOT'])[0].split('/')[0]
75 + for cpv in atom_matches)
76 +
77 + if len(dep_slots) > 1:
78 + stats["dependency.missingslot"] += 1
79 + fails["dependency.missingslot"].append(
80 + relative_path +
81 + ": %s: '%s' matches more than one slot, please specify an explicit slot and/or use the := or :* slot operator" %
82 + (mytype, atom))
83 --
84 2.0.4