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 1F9151389F5 for ; Mon, 17 Nov 2014 00:55:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D6D17E0D7E; Mon, 17 Nov 2014 00:55:32 +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 448FEE0D7F for ; Mon, 17 Nov 2014 00:55:31 +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 BC6AB34052F for ; Mon, 17 Nov 2014 00:55:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D822AA482 for ; Mon, 17 Nov 2014 00:55:25 +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: <1416185594.177a5b647a326784e2274476feaf5a6bd6596075.dol-sen@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/checks/ebuilds/ pym/repoman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 177a5b647a326784e2274476feaf5a6bd6596075 X-VCS-Branch: repoman Date: Mon, 17 Nov 2014 00:55:25 +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: d518fb97-790f-4f0c-a358-1edfd4675d15 X-Archives-Hash: f0db79293019227fbb62c3ff9b696cad commit: 177a5b647a326784e2274476feaf5a6bd6596075 Author: Tom Wijsman gentoo org> AuthorDate: Wed Jun 4 14:17:49 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Nov 17 00:53:14 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=177a5b64 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 29de0db..bec7a1d 100644 --- a/pym/repoman/checks/ebuilds/keywords.py +++ b/pym/repoman/checks/ebuilds/keywords.py @@ -20,7 +20,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). @@ -32,20 +32,31 @@ 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. ''' 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() @@ -62,6 +73,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)))) \ No newline at end of file + 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 1107c63..e338d82 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -442,22 +442,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( @@ -631,23 +618,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: