public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/
Date: Tue, 11 Aug 2015 23:54:09 +0000 (UTC)	[thread overview]
Message-ID: <1439337175.c7923fcab6f9ce5ee29afd87e1baad5975312223.dolsen@gentoo> (raw)

commit:     c7923fcab6f9ce5ee29afd87e1baad5975312223
Author:     Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  4 14:17:49 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Aug 11 23:52:55 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c7923fca

repoman/main.py: More KEYWORDS checks to checks/ebuilds/keywords.py

 pym/repoman/checks/ebuilds/keywords.py | 64 ++++++++++++++++++++++++++++++----
 pym/repoman/main.py                    | 32 +----------------
 2 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
index b724269..235c751 100644
--- a/pym/repoman/checks/ebuilds/keywords.py
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -21,7 +21,7 @@ class KeywordChecks(object):
 
 	def check(
 		self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
-		live_ebuild):
+		live_ebuild, kwlist, profiles):
 		'''Perform the check.
 
 		@param pkg: Package in which we check (object).
@@ -33,21 +33,32 @@ class KeywordChecks(object):
 		@param changed: Changes instance
 		@param slot_keywords: A dictionary of keywords per slot.
 		@param live_ebuild: A boolean that determines if this is a live ebuild.
+		@param kwlist: A list of all global keywords.
+		@param profiles: A list of all profiles.
 		'''
 		if not self.options.straight_to_stable:
 			self._checkAddedWithStableKeywords(
 				package, ebuild, y_ebuild, keywords, changed)
+
 		self._checkForDroppedKeywords(
 			pkg, ebuild, ebuild_archs, live_ebuild)
 
+		self._checkForInvalidKeywords(
+			pkg, package, y_ebuild, kwlist, profiles)
+
+		self._checkForMaskLikeKeywords(
+			package, y_ebuild, keywords, kwlist)
+
 		self.slot_keywords[pkg.slot].update(ebuild_archs)
 
+	def _isKeywordStable(self, keyword):
+		return not keyword.startswith("~") and not keyword.startswith("-")
+
 	def _checkAddedWithStableKeywords(
 		self, package, ebuild, y_ebuild, keywords, changed):
 		catdir, pkgdir = package.split("/")
 
-		is_stable = lambda kw: not kw.startswith("~") and not kw.startswith("-")
-		stable_keywords = list(filter(is_stable, keywords))
+		stable_keywords = list(filter(self._isKeywordStable, keywords))
 		if stable_keywords:
 			if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
 				stable_keywords.sort()
@@ -64,6 +75,47 @@ class KeywordChecks(object):
 		elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
 			dropped_keywords = previous_keywords.difference(ebuild_archs)
 			if dropped_keywords:
-				self.qatracker.add_error("KEYWORDS.dropped",
-					"%s: %s" %
-					(ebuild.relative_path, " ".join(sorted(dropped_keywords))))
+				self.qatracker.add_error(
+					"KEYWORDS.dropped", "%s: %s" % (
+						ebuild.relative_path,
+						" ".join(sorted(dropped_keywords))))
+
+	def _checkForInvalidKeywords(
+		self, pkg, package, y_ebuild, kwlist, profiles):
+		myuse = pkg._metadata["KEYWORDS"].split()
+
+		for mykey in myuse:
+			if mykey not in ("-*", "*", "~*"):
+				myskey = mykey
+
+				if not self._isKeywordStable(myskey[:1]):
+					myskey = myskey[1:]
+
+				if myskey not in kwlist:
+					self.qatracker.add_error(
+						"KEYWORDS.invalid",
+						"%s/%s.ebuild: %s" % (
+							package, y_ebuild, mykey))
+				elif myskey not in profiles:
+					self.qatracker.add_error(
+						"KEYWORDS.invalid",
+						"%s/%s.ebuild: %s (profile invalid)" % (
+							package, y_ebuild, mykey))
+
+	def _checkForMaskLikeKeywords(
+		self, package, y_ebuild, keywords, kwlist):
+
+		# KEYWORDS="-*" is a stupid replacement for package.mask
+		# and screws general KEYWORDS semantics
+		if "-*" in keywords:
+			haskeyword = False
+
+			for kw in keywords:
+				if kw[0] == "~":
+					kw = kw[1:]
+				if kw in kwlist:
+					haskeyword = True
+
+			if not haskeyword:
+				self.qatracker.add_error(
+					"KEYWORDS.stupid", package + "/" + y_ebuild + ".ebuild")

diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index bcd2174..d6532f9 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -445,22 +445,9 @@ for xpkg in effective_scanlist:
 		#######################
 		keywordcheck.check(
 			pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
-			live_ebuild)
+			live_ebuild, kwlist, profiles)
 		#######################
 
-		# KEYWORDS="-*" is a stupid replacement for package.mask
-		# and screws general KEYWORDS semantics
-		if "-*" in keywords:
-			haskeyword = False
-			for kw in keywords:
-				if kw[0] == "~":
-					kw = kw[1:]
-				if kw in kwlist:
-					haskeyword = True
-			if not haskeyword:
-				qatracker.add_error("KEYWORDS.stupid",
-					xpkg + "/" + y_ebuild + ".ebuild")
-
 		if live_ebuild and repo_settings.repo_config.name == "gentoo":
 			#######################
 			liveeclasscheck.check(
@@ -637,23 +624,6 @@ for xpkg in effective_scanlist:
 					qatracker.add_error("LICENSE.deprecated",
 						"%s: %s" % (ebuild.relative_path, lic))
 
-		# keyword checks
-		myuse = myaux["KEYWORDS"].split()
-		for mykey in myuse:
-			if mykey not in ("-*", "*", "~*"):
-				myskey = mykey
-				if myskey[:1] == "-":
-					myskey = myskey[1:]
-				if myskey[:1] == "~":
-					myskey = myskey[1:]
-				if myskey not in kwlist:
-					qatracker.add_error("KEYWORDS.invalid",
-						"%s/%s.ebuild: %s" % (xpkg, y_ebuild, mykey))
-				elif myskey not in profiles:
-					qatracker.add_error("KEYWORDS.invalid",
-						"%s/%s.ebuild: %s (profile invalid)"
-						% (xpkg, y_ebuild, mykey))
-
 		# restrict checks
 		myrestrict = None
 		try:


             reply	other threads:[~2015-08-11 23:54 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-11 23:54 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-09-20  2:06 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/ Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-10 14:45 Michał Górny
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-06-04 14:18 Tom Wijsman
2014-06-04  9:18 Tom Wijsman
2014-06-03 19:33 Brian Dolbec
2014-06-03 11:16 Tom Wijsman
2014-06-02  6:44 Brian Dolbec
2014-06-02  6:05 Brian Dolbec
2014-06-02  3:35 Brian Dolbec
2014-06-02  1:10 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
2014-05-30 13:03 Brian Dolbec

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=1439337175.c7923fcab6f9ce5ee29afd87e1baad5975312223.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-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