* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2014-10-01 23:02 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2014-10-01 23:02 UTC (permalink / raw
To: gentoo-commits
commit: c3e9c8eeffaed90af9f055daf17f4c4cd53c6974
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 14:17:49 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Oct 1 22:58:14 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c3e9c8ee
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:
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2014-10-01 23:02 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2014-10-01 23:02 UTC (permalink / raw
To: gentoo-commits
commit: dd24fd95705454fc3faa80d17bf483691e2de9ef
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Oct 1 22:58:14 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dd24fd95
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
---
pym/repoman/checks/ebuilds/keywords.py | 67 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 32 ++++------------
2 files changed, 75 insertions(+), 24 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..29de0db
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,67 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 8a1a043..05d9a14 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -49,6 +49,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -281,7 +282,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -322,7 +323,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -427,32 +428,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2014-10-01 23:46 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2014-10-01 23:46 UTC (permalink / raw
To: gentoo-commits
commit: c1446992fe4f537c0310a994e5d47dd7a80b2075
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 14:17:49 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Oct 1 23:45:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c1446992
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:
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2014-11-17 0:55 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2014-11-17 0:55 UTC (permalink / raw
To: gentoo-commits
commit: 928ffe7cf1074c2cf797891fa3fda8148d155a41
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 19:20:43 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Nov 17 00:53:13 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=928ffe7c
Repoman: Refactor PkgMetadata and XmlLint classes for variable data passed in
Move all non-consistent data to be passed in via the check functions.
Initialize XmlLint once in the PkgMetadata class __init__().
---
pym/repoman/_xml.py | 33 ++++++++++++++++++++++---------
pym/repoman/checks/ebuilds/pkgmetadata.py | 12 +++++------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index b97c027..d5b5a5e 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -14,6 +14,8 @@ from repoman._subprocess import repoman_getstatusoutput
class _XMLParser(xml.etree.ElementTree.XMLParser):
+
+
def __init__(self, data, **kwargs):
xml.etree.ElementTree.XMLParser.__init__(self, **kwargs)
self._portage_data = data
@@ -25,11 +27,13 @@ class _XMLParser(xml.etree.ElementTree.XMLParser):
self.parser.StartDoctypeDeclHandler = \
self._portage_StartDoctypeDeclHandler
+
def _portage_XmlDeclHandler(self, version, encoding, standalone):
if self._base_XmlDeclHandler is not None:
self._base_XmlDeclHandler(version, encoding, standalone)
self._portage_data["XML_DECLARATION"] = (version, encoding, standalone)
+
def _portage_StartDoctypeDeclHandler(
self, doctypeName, systemId, publicId, has_internal_subset):
if self._base_StartDoctypeDeclHandler is not None:
@@ -49,33 +53,44 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repolevel, repoman_settings):
+ def __init__(self, options, repoman_settings):
self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')
+ self.options = options
+ self.repoman_settings = repoman_settings
self._is_capable = False
self.binary = None
- self._check_capable(options, repolevel, repoman_settings)
+ self._check_capable()
+
- def _check_capable(self, options, repolevel, repoman_settings):
- if options.mode == "manifest":
+ def _check_capable(self):
+ if self.options.mode == "manifest":
return
self.binary = find_binary('xmllint')
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
- if options.xml_parse or repolevel == 3:
- print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
- sys.exit(1)
else:
- if not fetch_metadata_dtd(self.metadata_dtd, repoman_settings):
+ if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
+
@property
def capable(self):
return self._is_capable
- def check(self, checkdir):
+
+ def check(self, checkdir, repolevel):
+ '''Runs checks on the package metadata.xml file
+
+ @param checkdir: string, path
+ @param repolevel: integer
+ @return boolean, False == bad metadata
+ '''
if not self.capable:
+ if self.options.xml_parse or repolevel == 3:
+ print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
+ sys.exit(1)
return True
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py
index 0778696..674d32f 100644
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py
@@ -38,27 +38,28 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
class PkgMetadata(object):
'''Package metadata.xml checks'''
- def __init__(self, options, qatracker, repolevel, repoman_settings):
+ def __init__(self, options, qatracker, repoman_settings):
'''PkgMetadata init function
@param options: ArgumentParser.parse_known_args(argv[1:]) options
@param qatracker: QATracker instance
- @param repolevel: integer
@param repoman_settings: settings instance
'''
self.options = options
self.qatracker = qatracker
- self.repolevel = repolevel
self.repoman_settings = repoman_settings
self.musedict = {}
+ self.xmllint = XmlLint(self.options, self.repoman_settings)
+
- def check(self, xpkg, checkdir, checkdirlist):
+ def check(self, xpkg, checkdir, checkdirlist, repolevel):
'''Performs the checks on the metadata.xml for the package
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdirlist: list of checkdir's
+ @param repolevel: integer
'''
self.musedict = {}
@@ -165,8 +166,7 @@ class PkgMetadata(object):
# Only carry out if in package directory or check forced
if not metadata_bad:
- xmllint = XmlLint(self.options, self.repolevel, self.repoman_settings)
- if not xmllint.check(checkdir):
+ if not self.xmllint.check(checkdir, repolevel):
self.qatracker.add_error("metadata.bad", xpkg + "/metadata.xml")
del metadata_bad
return
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-10 13:44 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-08-10 13:44 UTC (permalink / raw
To: gentoo-commits
commit: 01beae294db8f3d02c4fa8d4fad48b23aeda94d7
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Jul 21 05:47:28 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=01beae29
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index d398bb3..79a24da 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-10 14:45 Michał Górny
0 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-08-10 14:45 UTC (permalink / raw
To: gentoo-commits
commit: 5c94871e6cee314e87000f47e28c4da83f31fb12
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 11:15:10 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 10 14:45:19 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5c94871e
repoman/main.py: Split USE flag checks to checks/ebuilds/use_flags.py
pym/repoman/checks/ebuilds/misc.py | 2 +-
pym/repoman/checks/ebuilds/use_flags.py | 85 +++++++++++++++++++++++++++++++++
pym/repoman/main.py | 52 ++++----------------
3 files changed, 95 insertions(+), 44 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/misc.py b/pym/repoman/checks/ebuilds/misc.py
index 3bf61f0..744784a 100644
--- a/pym/repoman/checks/ebuilds/misc.py
+++ b/pym/repoman/checks/ebuilds/misc.py
@@ -39,7 +39,7 @@ def bad_split_check(xpkg, y_ebuild, pkgdir, qatracker):
return False
-def pkg_invalid(pkg, qatracker):
+def pkg_invalid(pkg, qatracker, ebuild):
'''Checks for invalid packages
@param pkg: _emerge.Package instance
diff --git a/pym/repoman/checks/ebuilds/use_flags.py b/pym/repoman/checks/ebuilds/use_flags.py
new file mode 100644
index 0000000..bc09ed7
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/use_flags.py
@@ -0,0 +1,85 @@
+
+'''use_flags.py
+Performs USE flag related checks
+'''
+
+# import our centrally initialized portage instance
+from repoman._portage import portage
+
+from portage import eapi
+from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
+
+
+class USEFlagChecks(object):
+ '''Performs checks on USE flags listed in the ebuilds and metadata.xml'''
+
+ def __init__(self, qatracker, globalUseFlags):
+ '''
+ @param qatracker: QATracker instance
+ @param globalUseFlags: Global USE flags
+ '''
+ self.qatracker = qatracker
+ self.useFlags = []
+ self.defaultUseFlags = []
+ self.usedUseFlags = set()
+ self.globalUseFlags = globalUseFlags
+
+ def check(self, pkg, package, ebuild, y_ebuild, localUseFlags):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param localUseFlags: Local USE flags of the package
+ '''
+ self._checkGlobal(pkg)
+ self._checkMetadata(package, ebuild, y_ebuild, localUseFlags)
+ self._checkRequiredUSE(pkg, ebuild)
+
+ def getUsedUseFlags(self):
+ '''Get the USE flags that this check has seen'''
+ return self.usedUseFlags
+
+ def _checkGlobal(self, pkg):
+ for myflag in pkg._metadata["IUSE"].split():
+ flag_name = myflag.lstrip("+-")
+ self.usedUseFlags.add(flag_name)
+ if myflag != flag_name:
+ self.defaultUseFlags.append(myflag)
+ if flag_name not in self.globalUseFlags:
+ self.useFlags.append(flag_name)
+
+ def _checkMetadata(self, package, ebuild, y_ebuild, localUseFlags):
+ for mypos in range(len(self.useFlags) - 1, -1, -1):
+ if self.useFlags[mypos] and (self.useFlags[mypos] in localUseFlags):
+ del self.useFlags[mypos]
+
+ if self.defaultUseFlags and not eapi_has_iuse_defaults(eapi):
+ for myflag in self.defaultUseFlags:
+ self.qatracker.add_error(
+ 'EAPI.incompatible', "%s: IUSE defaults"
+ " not supported with EAPI='%s': '%s'" % (
+ ebuild.relative_path, eapi, myflag))
+
+ for mypos in range(len(self.useFlags)):
+ self.qatracker.add_error(
+ "IUSE.invalid",
+ "%s/%s.ebuild: %s" % (package, y_ebuild, self.useFlags[mypos]))
+
+ def _checkRequiredUSE(self, pkg, ebuild):
+ required_use = pkg._metadata["REQUIRED_USE"]
+ if required_use:
+ if not eapi_has_required_use(eapi):
+ self.qatracker.add_error(
+ 'EAPI.incompatible', "%s: REQUIRED_USE"
+ " not supported with EAPI='%s'"
+ % (ebuild.relative_path, eapi,))
+ try:
+ portage.dep.check_required_use(
+ required_use, (), pkg.iuse.is_valid_flag, eapi=eapi)
+ except portage.exception.InvalidDependString as e:
+ self.qatracker.add_error(
+ "REQUIRED_USE.syntax",
+ "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
+ del e
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 90c0c14..95af4d4 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -46,7 +46,6 @@ from portage.output import ConsoleStyleFile, StyleWriter
from portage.util import formatter
from portage.util import writemsg_level
from portage.package.ebuild.digestgen import digestgen
-from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
@@ -58,6 +57,7 @@ from repoman.checks.ebuilds.manifests import Manifests
from repoman.check_missingslot import check_missingslot
from repoman.checks.ebuilds.misc import bad_split_check, pkg_invalid
from repoman.checks.ebuilds.pkgmetadata import PkgMetadata
+from repoman.checks.ebuilds.use_flags import USEFlagChecks
from repoman.ebuild import Ebuild
from repoman.errors import err
from repoman.modules.commit import repochecks
@@ -370,7 +370,7 @@ for xpkg in effective_scanlist:
continue
###################
pkg = pkgs[y_ebuild]
- if pkg_invalid(pkg, qatracker):
+ if pkg_invalid(pkg, qatracker, ebuild):
allvalid = False
continue
@@ -633,32 +633,13 @@ for xpkg in effective_scanlist:
badlicsyntax = badlicsyntax > 0
badprovsyntax = badprovsyntax > 0
- # uselist checks - global
- myuse = []
- default_use = []
- for myflag in myaux["IUSE"].split():
- flag_name = myflag.lstrip("+-")
- used_useflags.add(flag_name)
- if myflag != flag_name:
- default_use.append(myflag)
- if flag_name not in uselist:
- myuse.append(flag_name)
-
- # uselist checks - metadata
- for mypos in range(len(myuse) - 1, -1, -1):
- if myuse[mypos] and (myuse[mypos] in muselist):
- del myuse[mypos]
-
- if default_use and not eapi_has_iuse_defaults(eapi):
- for myflag in default_use:
- qatracker.add_error('EAPI.incompatible',
- "%s: IUSE defaults"
- " not supported with EAPI='%s': '%s'" %
- (ebuild.relative_path, eapi, myflag))
-
- for mypos in range(len(myuse)):
- qatracker.add_error("IUSE.invalid",
- xpkg + "/" + y_ebuild + ".ebuild: %s" % myuse[mypos])
+ #################
+ use_flag_checks = USEFlagChecks(qatracker, uselist)
+ use_flag_checks.check(pkg, xpkg, ebuild, y_ebuild, muselist)
+
+ ebuild_used_useflags = use_flag_checks.getUsedUseFlags()
+ used_useflags = used_useflags.union(ebuild_used_useflags)
+ #################
# Check for outdated RUBY targets
old_ruby_eclasses = ["ruby-ng", "ruby-fakegem", "ruby"]
@@ -722,21 +703,6 @@ for xpkg in effective_scanlist:
for mybad in mybadrestrict:
qatracker.add_error("RESTRICT.invalid",
xpkg + "/" + y_ebuild + ".ebuild: %s" % mybad)
- # REQUIRED_USE check
- required_use = myaux["REQUIRED_USE"]
- if required_use:
- if not eapi_has_required_use(eapi):
- qatracker.add_error('EAPI.incompatible',
- "%s: REQUIRED_USE"
- " not supported with EAPI='%s'"
- % (ebuild.relative_path, eapi,))
- try:
- portage.dep.check_required_use(
- required_use, (), pkg.iuse.is_valid_flag, eapi=eapi)
- except portage.exception.InvalidDependString as e:
- qatracker.add_error("REQUIRED_USE.syntax",
- "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
- del e
# Syntax Checks
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-10 14:45 Michał Górny
0 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-08-10 14:45 UTC (permalink / raw
To: gentoo-commits
commit: 55449663254569b78eee04e210d55ad4c8a7036c
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 10 14:45:20 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=55449663
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index a77b2f2..1d2a3fb 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-10 14:45 Michał Górny
0 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-08-10 14:45 UTC (permalink / raw
To: gentoo-commits
commit: adbd092dd1cc152d14a0c8e91a8e578727aa4534
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 19:20:43 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 10 14:45:20 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=adbd092d
Repoman: Refactor PkgMetadata and XmlLint classes for variable data passed in
Move all non-consistent data to be passed in via the check functions.
Initialize XmlLint once in the PkgMetadata class __init__().
pym/repoman/_xml.py | 33 ++++++++++++++++++++++---------
pym/repoman/checks/ebuilds/pkgmetadata.py | 12 +++++------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index b97c027..d5b5a5e 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -14,6 +14,8 @@ from repoman._subprocess import repoman_getstatusoutput
class _XMLParser(xml.etree.ElementTree.XMLParser):
+
+
def __init__(self, data, **kwargs):
xml.etree.ElementTree.XMLParser.__init__(self, **kwargs)
self._portage_data = data
@@ -25,11 +27,13 @@ class _XMLParser(xml.etree.ElementTree.XMLParser):
self.parser.StartDoctypeDeclHandler = \
self._portage_StartDoctypeDeclHandler
+
def _portage_XmlDeclHandler(self, version, encoding, standalone):
if self._base_XmlDeclHandler is not None:
self._base_XmlDeclHandler(version, encoding, standalone)
self._portage_data["XML_DECLARATION"] = (version, encoding, standalone)
+
def _portage_StartDoctypeDeclHandler(
self, doctypeName, systemId, publicId, has_internal_subset):
if self._base_StartDoctypeDeclHandler is not None:
@@ -49,33 +53,44 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repolevel, repoman_settings):
+ def __init__(self, options, repoman_settings):
self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')
+ self.options = options
+ self.repoman_settings = repoman_settings
self._is_capable = False
self.binary = None
- self._check_capable(options, repolevel, repoman_settings)
+ self._check_capable()
+
- def _check_capable(self, options, repolevel, repoman_settings):
- if options.mode == "manifest":
+ def _check_capable(self):
+ if self.options.mode == "manifest":
return
self.binary = find_binary('xmllint')
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
- if options.xml_parse or repolevel == 3:
- print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
- sys.exit(1)
else:
- if not fetch_metadata_dtd(self.metadata_dtd, repoman_settings):
+ if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
+
@property
def capable(self):
return self._is_capable
- def check(self, checkdir):
+
+ def check(self, checkdir, repolevel):
+ '''Runs checks on the package metadata.xml file
+
+ @param checkdir: string, path
+ @param repolevel: integer
+ @return boolean, False == bad metadata
+ '''
if not self.capable:
+ if self.options.xml_parse or repolevel == 3:
+ print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
+ sys.exit(1)
return True
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py
index 0778696..674d32f 100644
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py
@@ -38,27 +38,28 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
class PkgMetadata(object):
'''Package metadata.xml checks'''
- def __init__(self, options, qatracker, repolevel, repoman_settings):
+ def __init__(self, options, qatracker, repoman_settings):
'''PkgMetadata init function
@param options: ArgumentParser.parse_known_args(argv[1:]) options
@param qatracker: QATracker instance
- @param repolevel: integer
@param repoman_settings: settings instance
'''
self.options = options
self.qatracker = qatracker
- self.repolevel = repolevel
self.repoman_settings = repoman_settings
self.musedict = {}
+ self.xmllint = XmlLint(self.options, self.repoman_settings)
+
- def check(self, xpkg, checkdir, checkdirlist):
+ def check(self, xpkg, checkdir, checkdirlist, repolevel):
'''Performs the checks on the metadata.xml for the package
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdirlist: list of checkdir's
+ @param repolevel: integer
'''
self.musedict = {}
@@ -165,8 +166,7 @@ class PkgMetadata(object):
# Only carry out if in package directory or check forced
if not metadata_bad:
- xmllint = XmlLint(self.options, self.repolevel, self.repoman_settings)
- if not xmllint.check(checkdir):
+ if not self.xmllint.check(checkdir, repolevel):
self.qatracker.add_error("metadata.bad", xpkg + "/metadata.xml")
del metadata_bad
return
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-11 23:54 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-08-11 23:54 UTC (permalink / raw
To: gentoo-commits
commit: 743ea1a59add87186c1d3d5e29526dcda025130b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 19:20:43 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Aug 11 23:52:53 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=743ea1a5
Repoman: Refactor PkgMetadata and XmlLint classes for variable data passed in
Move all non-consistent data to be passed in via the check functions.
Initialize XmlLint once in the PkgMetadata class __init__().
pym/repoman/_xml.py | 33 ++++++++++++++++++++++---------
pym/repoman/checks/ebuilds/pkgmetadata.py | 12 +++++------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index b97c027..d5b5a5e 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -14,6 +14,8 @@ from repoman._subprocess import repoman_getstatusoutput
class _XMLParser(xml.etree.ElementTree.XMLParser):
+
+
def __init__(self, data, **kwargs):
xml.etree.ElementTree.XMLParser.__init__(self, **kwargs)
self._portage_data = data
@@ -25,11 +27,13 @@ class _XMLParser(xml.etree.ElementTree.XMLParser):
self.parser.StartDoctypeDeclHandler = \
self._portage_StartDoctypeDeclHandler
+
def _portage_XmlDeclHandler(self, version, encoding, standalone):
if self._base_XmlDeclHandler is not None:
self._base_XmlDeclHandler(version, encoding, standalone)
self._portage_data["XML_DECLARATION"] = (version, encoding, standalone)
+
def _portage_StartDoctypeDeclHandler(
self, doctypeName, systemId, publicId, has_internal_subset):
if self._base_StartDoctypeDeclHandler is not None:
@@ -49,33 +53,44 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repolevel, repoman_settings):
+ def __init__(self, options, repoman_settings):
self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')
+ self.options = options
+ self.repoman_settings = repoman_settings
self._is_capable = False
self.binary = None
- self._check_capable(options, repolevel, repoman_settings)
+ self._check_capable()
+
- def _check_capable(self, options, repolevel, repoman_settings):
- if options.mode == "manifest":
+ def _check_capable(self):
+ if self.options.mode == "manifest":
return
self.binary = find_binary('xmllint')
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
- if options.xml_parse or repolevel == 3:
- print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
- sys.exit(1)
else:
- if not fetch_metadata_dtd(self.metadata_dtd, repoman_settings):
+ if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
+
@property
def capable(self):
return self._is_capable
- def check(self, checkdir):
+
+ def check(self, checkdir, repolevel):
+ '''Runs checks on the package metadata.xml file
+
+ @param checkdir: string, path
+ @param repolevel: integer
+ @return boolean, False == bad metadata
+ '''
if not self.capable:
+ if self.options.xml_parse or repolevel == 3:
+ print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
+ sys.exit(1)
return True
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py
index 0778696..674d32f 100644
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py
@@ -38,27 +38,28 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
class PkgMetadata(object):
'''Package metadata.xml checks'''
- def __init__(self, options, qatracker, repolevel, repoman_settings):
+ def __init__(self, options, qatracker, repoman_settings):
'''PkgMetadata init function
@param options: ArgumentParser.parse_known_args(argv[1:]) options
@param qatracker: QATracker instance
- @param repolevel: integer
@param repoman_settings: settings instance
'''
self.options = options
self.qatracker = qatracker
- self.repolevel = repolevel
self.repoman_settings = repoman_settings
self.musedict = {}
+ self.xmllint = XmlLint(self.options, self.repoman_settings)
+
- def check(self, xpkg, checkdir, checkdirlist):
+ def check(self, xpkg, checkdir, checkdirlist, repolevel):
'''Performs the checks on the metadata.xml for the package
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdirlist: list of checkdir's
+ @param repolevel: integer
'''
self.musedict = {}
@@ -165,8 +166,7 @@ class PkgMetadata(object):
# Only carry out if in package directory or check forced
if not metadata_bad:
- xmllint = XmlLint(self.options, self.repolevel, self.repoman_settings)
- if not xmllint.check(checkdir):
+ if not self.xmllint.check(checkdir, repolevel):
self.qatracker.add_error("metadata.bad", xpkg + "/metadata.xml")
del metadata_bad
return
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-08-11 23:54 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-08-11 23:54 UTC (permalink / raw
To: gentoo-commits
commit: e99d6246072c06c193dc512bc76f4bc1e31a3cb0
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Aug 11 23:52:54 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e99d6246
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index a77b2f2..1d2a3fb 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-05 21:27 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-05 21:27 UTC (permalink / raw
To: gentoo-commits
commit: 1e94e75c15a2f402ba3c9e47bbea60a5d20066f9
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 11:15:10 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 21:26:57 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1e94e75c
repoman/main.py: Split USE flag checks to checks/ebuilds/use_flags.py
pym/repoman/checks/ebuilds/misc.py | 2 +-
pym/repoman/checks/ebuilds/use_flags.py | 85 +++++++++++++++++++++++++++++++++
pym/repoman/main.py | 52 ++++----------------
3 files changed, 95 insertions(+), 44 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/misc.py b/pym/repoman/checks/ebuilds/misc.py
index 3bf61f0..744784a 100644
--- a/pym/repoman/checks/ebuilds/misc.py
+++ b/pym/repoman/checks/ebuilds/misc.py
@@ -39,7 +39,7 @@ def bad_split_check(xpkg, y_ebuild, pkgdir, qatracker):
return False
-def pkg_invalid(pkg, qatracker):
+def pkg_invalid(pkg, qatracker, ebuild):
'''Checks for invalid packages
@param pkg: _emerge.Package instance
diff --git a/pym/repoman/checks/ebuilds/use_flags.py b/pym/repoman/checks/ebuilds/use_flags.py
new file mode 100644
index 0000000..bc09ed7
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/use_flags.py
@@ -0,0 +1,85 @@
+
+'''use_flags.py
+Performs USE flag related checks
+'''
+
+# import our centrally initialized portage instance
+from repoman._portage import portage
+
+from portage import eapi
+from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
+
+
+class USEFlagChecks(object):
+ '''Performs checks on USE flags listed in the ebuilds and metadata.xml'''
+
+ def __init__(self, qatracker, globalUseFlags):
+ '''
+ @param qatracker: QATracker instance
+ @param globalUseFlags: Global USE flags
+ '''
+ self.qatracker = qatracker
+ self.useFlags = []
+ self.defaultUseFlags = []
+ self.usedUseFlags = set()
+ self.globalUseFlags = globalUseFlags
+
+ def check(self, pkg, package, ebuild, y_ebuild, localUseFlags):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param localUseFlags: Local USE flags of the package
+ '''
+ self._checkGlobal(pkg)
+ self._checkMetadata(package, ebuild, y_ebuild, localUseFlags)
+ self._checkRequiredUSE(pkg, ebuild)
+
+ def getUsedUseFlags(self):
+ '''Get the USE flags that this check has seen'''
+ return self.usedUseFlags
+
+ def _checkGlobal(self, pkg):
+ for myflag in pkg._metadata["IUSE"].split():
+ flag_name = myflag.lstrip("+-")
+ self.usedUseFlags.add(flag_name)
+ if myflag != flag_name:
+ self.defaultUseFlags.append(myflag)
+ if flag_name not in self.globalUseFlags:
+ self.useFlags.append(flag_name)
+
+ def _checkMetadata(self, package, ebuild, y_ebuild, localUseFlags):
+ for mypos in range(len(self.useFlags) - 1, -1, -1):
+ if self.useFlags[mypos] and (self.useFlags[mypos] in localUseFlags):
+ del self.useFlags[mypos]
+
+ if self.defaultUseFlags and not eapi_has_iuse_defaults(eapi):
+ for myflag in self.defaultUseFlags:
+ self.qatracker.add_error(
+ 'EAPI.incompatible', "%s: IUSE defaults"
+ " not supported with EAPI='%s': '%s'" % (
+ ebuild.relative_path, eapi, myflag))
+
+ for mypos in range(len(self.useFlags)):
+ self.qatracker.add_error(
+ "IUSE.invalid",
+ "%s/%s.ebuild: %s" % (package, y_ebuild, self.useFlags[mypos]))
+
+ def _checkRequiredUSE(self, pkg, ebuild):
+ required_use = pkg._metadata["REQUIRED_USE"]
+ if required_use:
+ if not eapi_has_required_use(eapi):
+ self.qatracker.add_error(
+ 'EAPI.incompatible', "%s: REQUIRED_USE"
+ " not supported with EAPI='%s'"
+ % (ebuild.relative_path, eapi,))
+ try:
+ portage.dep.check_required_use(
+ required_use, (), pkg.iuse.is_valid_flag, eapi=eapi)
+ except portage.exception.InvalidDependString as e:
+ self.qatracker.add_error(
+ "REQUIRED_USE.syntax",
+ "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
+ del e
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 90c0c14..95af4d4 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -46,7 +46,6 @@ from portage.output import ConsoleStyleFile, StyleWriter
from portage.util import formatter
from portage.util import writemsg_level
from portage.package.ebuild.digestgen import digestgen
-from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
@@ -58,6 +57,7 @@ from repoman.checks.ebuilds.manifests import Manifests
from repoman.check_missingslot import check_missingslot
from repoman.checks.ebuilds.misc import bad_split_check, pkg_invalid
from repoman.checks.ebuilds.pkgmetadata import PkgMetadata
+from repoman.checks.ebuilds.use_flags import USEFlagChecks
from repoman.ebuild import Ebuild
from repoman.errors import err
from repoman.modules.commit import repochecks
@@ -370,7 +370,7 @@ for xpkg in effective_scanlist:
continue
###################
pkg = pkgs[y_ebuild]
- if pkg_invalid(pkg, qatracker):
+ if pkg_invalid(pkg, qatracker, ebuild):
allvalid = False
continue
@@ -633,32 +633,13 @@ for xpkg in effective_scanlist:
badlicsyntax = badlicsyntax > 0
badprovsyntax = badprovsyntax > 0
- # uselist checks - global
- myuse = []
- default_use = []
- for myflag in myaux["IUSE"].split():
- flag_name = myflag.lstrip("+-")
- used_useflags.add(flag_name)
- if myflag != flag_name:
- default_use.append(myflag)
- if flag_name not in uselist:
- myuse.append(flag_name)
-
- # uselist checks - metadata
- for mypos in range(len(myuse) - 1, -1, -1):
- if myuse[mypos] and (myuse[mypos] in muselist):
- del myuse[mypos]
-
- if default_use and not eapi_has_iuse_defaults(eapi):
- for myflag in default_use:
- qatracker.add_error('EAPI.incompatible',
- "%s: IUSE defaults"
- " not supported with EAPI='%s': '%s'" %
- (ebuild.relative_path, eapi, myflag))
-
- for mypos in range(len(myuse)):
- qatracker.add_error("IUSE.invalid",
- xpkg + "/" + y_ebuild + ".ebuild: %s" % myuse[mypos])
+ #################
+ use_flag_checks = USEFlagChecks(qatracker, uselist)
+ use_flag_checks.check(pkg, xpkg, ebuild, y_ebuild, muselist)
+
+ ebuild_used_useflags = use_flag_checks.getUsedUseFlags()
+ used_useflags = used_useflags.union(ebuild_used_useflags)
+ #################
# Check for outdated RUBY targets
old_ruby_eclasses = ["ruby-ng", "ruby-fakegem", "ruby"]
@@ -722,21 +703,6 @@ for xpkg in effective_scanlist:
for mybad in mybadrestrict:
qatracker.add_error("RESTRICT.invalid",
xpkg + "/" + y_ebuild + ".ebuild: %s" % mybad)
- # REQUIRED_USE check
- required_use = myaux["REQUIRED_USE"]
- if required_use:
- if not eapi_has_required_use(eapi):
- qatracker.add_error('EAPI.incompatible',
- "%s: REQUIRED_USE"
- " not supported with EAPI='%s'"
- % (ebuild.relative_path, eapi,))
- try:
- portage.dep.check_required_use(
- required_use, (), pkg.iuse.is_valid_flag, eapi=eapi)
- except portage.exception.InvalidDependString as e:
- qatracker.add_error("REQUIRED_USE.syntax",
- "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
- del e
# Syntax Checks
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-05 21:27 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-05 21:27 UTC (permalink / raw
To: gentoo-commits
commit: df0cf443e9edf69a90dc684dd35254c68bf90999
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: Sat Sep 5 21:26:59 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=df0cf443
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:
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-05 21:27 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-05 21:27 UTC (permalink / raw
To: gentoo-commits
commit: d692db0bba4377e4127b5900e0a134f7e590a0a1
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 21:26:59 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d692db0b
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index a77b2f2..1d2a3fb 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-05 21:27 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-05 21:27 UTC (permalink / raw
To: gentoo-commits
commit: 972523f5847d57708725486b08691f46ac29bce1
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 19:20:43 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 21:26:58 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=972523f5
Repoman: Refactor PkgMetadata and XmlLint classes for variable data passed in
Move all non-consistent data to be passed in via the check functions.
Initialize XmlLint once in the PkgMetadata class __init__().
pym/repoman/_xml.py | 33 ++++++++++++++++++++++---------
pym/repoman/checks/ebuilds/pkgmetadata.py | 12 +++++------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index b97c027..d5b5a5e 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -14,6 +14,8 @@ from repoman._subprocess import repoman_getstatusoutput
class _XMLParser(xml.etree.ElementTree.XMLParser):
+
+
def __init__(self, data, **kwargs):
xml.etree.ElementTree.XMLParser.__init__(self, **kwargs)
self._portage_data = data
@@ -25,11 +27,13 @@ class _XMLParser(xml.etree.ElementTree.XMLParser):
self.parser.StartDoctypeDeclHandler = \
self._portage_StartDoctypeDeclHandler
+
def _portage_XmlDeclHandler(self, version, encoding, standalone):
if self._base_XmlDeclHandler is not None:
self._base_XmlDeclHandler(version, encoding, standalone)
self._portage_data["XML_DECLARATION"] = (version, encoding, standalone)
+
def _portage_StartDoctypeDeclHandler(
self, doctypeName, systemId, publicId, has_internal_subset):
if self._base_StartDoctypeDeclHandler is not None:
@@ -49,33 +53,44 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repolevel, repoman_settings):
+ def __init__(self, options, repoman_settings):
self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')
+ self.options = options
+ self.repoman_settings = repoman_settings
self._is_capable = False
self.binary = None
- self._check_capable(options, repolevel, repoman_settings)
+ self._check_capable()
+
- def _check_capable(self, options, repolevel, repoman_settings):
- if options.mode == "manifest":
+ def _check_capable(self):
+ if self.options.mode == "manifest":
return
self.binary = find_binary('xmllint')
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
- if options.xml_parse or repolevel == 3:
- print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
- sys.exit(1)
else:
- if not fetch_metadata_dtd(self.metadata_dtd, repoman_settings):
+ if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
+
@property
def capable(self):
return self._is_capable
- def check(self, checkdir):
+
+ def check(self, checkdir, repolevel):
+ '''Runs checks on the package metadata.xml file
+
+ @param checkdir: string, path
+ @param repolevel: integer
+ @return boolean, False == bad metadata
+ '''
if not self.capable:
+ if self.options.xml_parse or repolevel == 3:
+ print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
+ sys.exit(1)
return True
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py
index 0778696..674d32f 100644
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py
@@ -38,27 +38,28 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
class PkgMetadata(object):
'''Package metadata.xml checks'''
- def __init__(self, options, qatracker, repolevel, repoman_settings):
+ def __init__(self, options, qatracker, repoman_settings):
'''PkgMetadata init function
@param options: ArgumentParser.parse_known_args(argv[1:]) options
@param qatracker: QATracker instance
- @param repolevel: integer
@param repoman_settings: settings instance
'''
self.options = options
self.qatracker = qatracker
- self.repolevel = repolevel
self.repoman_settings = repoman_settings
self.musedict = {}
+ self.xmllint = XmlLint(self.options, self.repoman_settings)
+
- def check(self, xpkg, checkdir, checkdirlist):
+ def check(self, xpkg, checkdir, checkdirlist, repolevel):
'''Performs the checks on the metadata.xml for the package
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdirlist: list of checkdir's
+ @param repolevel: integer
'''
self.musedict = {}
@@ -165,8 +166,7 @@ class PkgMetadata(object):
# Only carry out if in package directory or check forced
if not metadata_bad:
- xmllint = XmlLint(self.options, self.repolevel, self.repoman_settings)
- if not xmllint.check(checkdir):
+ if not self.xmllint.check(checkdir, repolevel):
self.qatracker.add_error("metadata.bad", xpkg + "/metadata.xml")
del metadata_bad
return
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-05 21:48 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-05 21:48 UTC (permalink / raw
To: gentoo-commits
commit: d96f1eb255464fd2b48a7439e0a73f520b172555
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 21:47:37 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d96f1eb2
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 26fa50a..6e9dc22 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-17 3:08 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-17 3:08 UTC (permalink / raw
To: gentoo-commits
commit: 321ffc9ffa64be7dde4cba356f03b9e8a996b431
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Sep 17 03:06:47 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=321ffc9f
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 26fa50a..6e9dc22 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
@ 2015-09-17 4:51 Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-17 4:51 UTC (permalink / raw
To: gentoo-commits
commit: 05f33f1b767c00dbd7409a66b4525499a33001de
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 4 09:17:12 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Sep 17 04:41:26 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=05f33f1b
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py
pym/repoman/checks/ebuilds/keywords.py | 69 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 33 ++++------------
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py
new file mode 100644
index 0000000..b724269
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/keywords.py
@@ -0,0 +1,69 @@
+
+'''keywords.py
+Perform KEYWORDS related checks
+'''
+
+
+class KeywordChecks(object):
+ '''Perform checks on the KEYWORDS of an ebuild'''
+
+ def __init__(self, qatracker, options):
+ '''
+ @param qatracker: QATracker instance
+ '''
+ self.qatracker = qatracker
+ self.options = options
+ self.slot_keywords = {}
+
+ def prepare(self):
+ '''Prepare the checks for the next package.'''
+ self.slot_keywords = {}
+
+ def check(
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild):
+ '''Perform the check.
+
+ @param pkg: Package in which we check (object).
+ @param package: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ @param keywords: All the keywords (including -...) of the ebuild.
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild.
+ @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.
+ '''
+ if not self.options.straight_to_stable:
+ self._checkAddedWithStableKeywords(
+ package, ebuild, y_ebuild, keywords, changed)
+ self._checkForDroppedKeywords(
+ pkg, ebuild, ebuild_archs, live_ebuild)
+
+ self.slot_keywords[pkg.slot].update(ebuild_archs)
+
+ 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))
+ if stable_keywords:
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
+ stable_keywords.sort()
+ self.qatracker.add_error(
+ "KEYWORDS.stable",
+ "%s/%s.ebuild added with stable keywords: %s" %
+ (package, y_ebuild, " ".join(stable_keywords)))
+
+ def _checkForDroppedKeywords(
+ self, pkg, ebuild, ebuild_archs, live_ebuild):
+ previous_keywords = self.slot_keywords.get(pkg.slot)
+ if previous_keywords is None:
+ self.slot_keywords[pkg.slot] = set()
+ 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))))
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 5950c53..63eed0a 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -51,6 +51,7 @@ from repoman.argparser import parse_args
from repoman.checks.directories.files import FileChecks
from repoman.checks.ebuilds.checks import run_checks, checks_init
from repoman.checks.ebuilds.fetches import FetchChecks
+from repoman.checks.ebuilds.keywords import KeywordChecks
from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
@@ -284,7 +285,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
pkgmeta = PkgMetadata(options, qatracker, repoman_settings)
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker)
use_flag_checks = USEFlagChecks(qatracker, uselist)
-
+keywordcheck = KeywordChecks(qatracker, options)
for xpkg in effective_scanlist:
# ebuilds and digests added to cvs respectively.
@@ -325,7 +326,7 @@ for xpkg in effective_scanlist:
continue
######################
- slot_keywords = {}
+ keywordcheck.prepare()
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())
@@ -430,33 +431,15 @@ for xpkg in effective_scanlist:
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
keywords = myaux["KEYWORDS"].split()
- if not options.straight_to_stable:
- stable_keywords = []
- for keyword in keywords:
- if not keyword.startswith("~") and \
- not keyword.startswith("-"):
- stable_keywords.append(keyword)
- if stable_keywords:
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
- stable_keywords.sort()
- qatracker.add_error("KEYWORDS.stable",
- "%s/%s.ebuild added with stable keywords: %s" %
- (xpkg, y_ebuild, " ".join(stable_keywords)))
ebuild_archs = set(
kw.lstrip("~") for kw in keywords if not kw.startswith("-"))
- previous_keywords = slot_keywords.get(pkg.slot)
- if previous_keywords is None:
- slot_keywords[pkg.slot] = set()
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild:
- dropped_keywords = previous_keywords.difference(ebuild_archs)
- if dropped_keywords:
- qatracker.add_error("KEYWORDS.dropped",
- "%s: %s" %
- (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
-
- slot_keywords[pkg.slot].update(ebuild_archs)
+ #######################
+ keywordcheck.check(
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed,
+ live_ebuild)
+ #######################
# KEYWORDS="-*" is a stupid replacement for package.mask
# and screws general KEYWORDS semantics
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2015-09-21 23:47 ` Brian Dolbec
0 siblings, 0 replies; 18+ messages in thread
From: Brian Dolbec @ 2015-09-21 23:47 UTC (permalink / raw
To: gentoo-commits
commit: 1850a6ebe46abcee14fbf6d28901b186150c2a18
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: Mon Sep 21 23:42:44 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1850a6eb
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:
^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-09-21 23:48 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 23:54 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-17 4:51 Brian Dolbec
2015-09-17 3:08 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 13:44 Brian Dolbec
2014-11-17 0:55 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox