From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 517241393F1 for ; Thu, 17 Sep 2015 04:51:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7F3FA21C049; Thu, 17 Sep 2015 04:51:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6518A21C033 for ; Thu, 17 Sep 2015 04:51:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 865AA340C47 for ; Thu, 17 Sep 2015 04:51:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C503220C for ; Thu, 17 Sep 2015 04:51:38 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1442464887.0983c08bedbda4efd645e29624f093ae4167c346.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/keywords.py pym/repoman/main.py X-VCS-Directories: pym/repoman/ pym/repoman/checks/ebuilds/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 0983c08bedbda4efd645e29624f093ae4167c346 X-VCS-Branch: repoman Date: Thu, 17 Sep 2015 04:51:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 214ba776-fd47-4d2d-b019-4009366a8616 X-Archives-Hash: b2460a236de8e5b97b04ac9bc3c0ec03 commit: 0983c08bedbda4efd645e29624f093ae4167c346 Author: Tom Wijsman gentoo org> AuthorDate: Wed Jun 4 14:17:49 2014 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Thu Sep 17 04:41:27 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0983c08b 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 4ded687..ea54ec4 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: