public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 3/3] repoman: Add check for missing slot values/slot operators
Date: Wed, 13 Aug 2014 19:20:35 +0200	[thread overview]
Message-ID: <1407950435-2520-4-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1407950435-2520-1-git-send-email-mgorny@gentoo.org>

The idea if that a particular dependency atom matches more than one slot
of a package, you are supposed to either use := or :* operator
(or a specific :slot dependency), whichever is appropriate.

This will help catching mistakes (when packages become slotted) and make
cross-slot behavior clear (it is undefined with no slot operator). I
will estimate the amount of new warnings later.
---
 bin/repoman                      |  6 ++++++
 pym/repoman/check_missingslot.py | 25 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 pym/repoman/check_missingslot.py

diff --git a/bin/repoman b/bin/repoman
index 5a6ee5b..6c54917 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -58,6 +58,7 @@ from portage import _encodings
 from portage import _unicode_encode
 import repoman.checks
 from repoman.checks import run_checks
+from repoman.check_missingslot import check_missingslot
 from repoman import utilities
 from repoman.herdbase import make_herd_base
 from _emerge.Package import Package
@@ -299,6 +300,7 @@ qahelp = {
 	"dependency.badindev": "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch",
 	"dependency.badmaskedindev": "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch",
 	"dependency.badtilde": "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)",
+	"dependency.missingslot": "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator",
 	"dependency.perlcore": "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead.",
 	"dependency.syntax": "Syntax error in dependency string (usually an extra/missing space/parenthesis)",
 	"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)",
@@ -386,6 +388,7 @@ qawarnings = set((
 "dependency.badindev",
 "dependency.badmaskedindev",
 "dependency.badtilde",
+"dependency.missingslot",
 "dependency.perlcore",
 "DESCRIPTION.toolong",
 "EAPI.deprecated",
@@ -2090,6 +2093,9 @@ for x in effective_scanlist:
 							 " with a non-zero revision:" + \
 							 " '%s'") % (mytype, atom))
 
+					check_missingslot(atom, mytype, eapi, portdb, stats, fails,
+						relative_path)
+
 			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
 
 		for m, b in zip(type_list, badsyntax):
diff --git a/pym/repoman/check_missingslot.py b/pym/repoman/check_missingslot.py
new file mode 100644
index 0000000..1da2ac1
--- /dev/null
+++ b/pym/repoman/check_missingslot.py
@@ -0,0 +1,25 @@
+# repoman: missing slot check
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""This module contains the check used to find missing slot values
+in dependencies."""
+
+from portage.eapi import eapi_has_slot_operator
+
+def check_missingslot(atom, mytype, eapi, portdb, stats, fails, relative_path):
+	# If no slot or slot operator is specified in RDEP...
+	if (not atom.blocker and not atom.slot and not atom.slot_operator
+			and mytype == 'RDEPEND' and eapi_has_slot_operator(eapi)):
+		# Check whether it doesn't match more than one.
+		atom_matches = portdb.xmatch("match-all", atom)
+		dep_slots = frozenset(
+				portdb.aux_get(cpv, ['SLOT'])[0].split('/')[0]
+					for cpv in atom_matches)
+
+		if len(dep_slots) > 1:
+			stats["dependency.missingslot"] += 1
+			fails["dependency.missingslot"].append(
+				relative_path +
+				": %s: '%s' matches more than one slot, please specify an explicit slot and/or use the := or :* slot operator" %
+				(mytype, atom))
-- 
2.0.4



  parent reply	other threads:[~2014-08-13 17:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 17:20 [gentoo-portage-dev] [PATCHES] @changed-deps + missing slot check reposted for bernalex Michał Górny
2014-08-13 17:20 ` [gentoo-portage-dev] [PATCH 1/3] vardb: Do not remove := from vdb on unmatched dependencies Michał Górny
2014-08-13 17:20 ` [gentoo-portage-dev] [PATCH 2/3] sets: Introduce @changed-deps to update packages which need dep changes Michał Górny
2014-08-13 17:20 ` Michał Górny [this message]
2014-08-13 21:09 ` [gentoo-portage-dev] [PATCHES] @changed-deps + missing slot check reposted for bernalex Alexander Berntsen
2014-08-14  6:58   ` Brian Dolbec
2014-08-27 20:53 ` Brian Dolbec
2014-08-28  9:00 ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407950435-2520-4-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox