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 v2] repoman: check for ebuilds not using slot operator against multi-slot packages.
Date: Mon, 04 Aug 2014 21:15:43
Message-Id: 1407186959-20037-1-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] repoman: check for ebuilds not using slot operator against multi-slot packages. 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 | 28 +++++++++++++++++++++++-----
10 1 file changed, 23 insertions(+), 5 deletions(-)
11
12 diff --git a/bin/repoman b/bin/repoman
13 index 71fc7f0..4809f52 100755
14 --- a/bin/repoman
15 +++ b/bin/repoman
16 @@ -78,7 +78,8 @@ from portage.output import ConsoleStyleFile, StyleWriter
17 from portage.util import writemsg_level
18 from portage.util._argparse import ArgumentParser
19 from portage.package.ebuild.digestgen import digestgen
20 -from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
21 +from portage.eapi import (eapi_has_iuse_defaults, eapi_has_required_use,
22 + eapi_has_slot_operator)
23
24 if sys.hexversion >= 0x3000000:
25 basestring = str
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 @@ -387,6 +389,7 @@ qawarnings = set((
35 "dependency.badindev",
36 "dependency.badmaskedindev",
37 "dependency.badtilde",
38 +"dependency.missingslot",
39 "dependency.perlcore",
40 "DESCRIPTION.punctuation",
41 "DESCRIPTION.toolong",
42 @@ -2047,10 +2050,25 @@ for x in effective_scanlist:
43 # Skip dependency.unknown for blockers, so that we
44 # don't encourage people to remove necessary blockers,
45 # as discussed in bug #382407.
46 - if not is_blocker and \
47 - not portdb.xmatch("match-all", atom) and \
48 - not atom.cp.startswith("virtual/"):
49 - unknown_pkgs.add((mytype, atom.unevaluated_atom))
50 + # Also skip it for slot operator checks.
51 + if not is_blocker:
52 + atom_matches = portdb.xmatch("match-all", atom)
53 + if not atom_matches and not atom.cp.startswith("virtual/"):
54 + unknown_pkgs.add((mytype, atom.unevaluated_atom))
55 +
56 + # If no slot or slot operator is specified in RDEP...
57 + if (not atom.slot and not atom.slot_operator
58 + and mytype == 'RDEPEND' and eapi_has_slot_operator(eapi)):
59 + # Check whether it doesn't match more than one.
60 + dep_slots = frozenset(
61 + [portdb.aux_get(cpv, ['SLOT'])[0].split('/')[0]
62 + for cpv in atom_matches])
63 + if len(dep_slots) > 1:
64 + stats["dependency.missingslot"] += 1
65 + fails["dependency.missingslot"].append(
66 + relative_path +
67 + ": %s: '%s' matches more than one slot, please specify an explicit slot and/or use the := or :* slot operator" %
68 + (mytype, atom))
69
70 if catdir != "virtual":
71 if not is_blocker and \
72 --
73 2.0.4

Replies