commit: 7b48d08d50a9da5514190abc3c70a30372bd7c5d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 2 01:00:05 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 2 01:00:05 2014 +0000
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7b48d08d
repoman/main.py: Create IsEbuild class and check
Split the code from main.py into checks/ebuilds/isebuild.py.
---
pym/repoman/checks/ebuilds/isebuild.py | 70 ++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 50 +++++-------------------
2 files changed, 79 insertions(+), 41 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/isebuild.py
b/pym/repoman/checks/ebuilds/isebuild.py
new file mode 100644
index 0000000..2369ea6
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/isebuild.py
@@ -0,0 +1,70 @@
+
+import stat
+
+from _emerge.Package import Package
+from _emerge.RootConfig import RootConfig
+
+import portage
+from portage import os
+
+from repoman.qa_data import no_exec, allvars
+
+
+class IsEbuild(object):
+
+
+ def __init__(self, repoman_settings, repo_settings, portdb, qatracker):
+ ''''''
+ self.portdb = portdb
+ self.qatracker = qatracker
+ self.root_config = RootConfig(repoman_settings,
+ repo_settings.trees[repo_settings.root], None)
+
+
+ def check(self, checkdirlist, checkdir, xpkg):
+ self.continue_ = False
+ ebuildlist = []
+ pkgs = {}
+ allvalid = True
+ for y in checkdirlist:
+ file_is_ebuild = y.endswith(".ebuild")
+ file_should_be_non_executable = y in no_exec or
file_is_ebuild
+
+ if file_should_be_non_executable:
+ file_is_executable = stat.S_IMODE(
+ os.stat(os.path.join(checkdir,
y)).st_mode) & 0o111
+
+ if file_is_executable:
+
self.qatracker.add_error("file.executable", os.path.join(checkdir, y))
+ if file_is_ebuild:
+ pf = y[:-7]
+ ebuildlist.append(pf)
+ catdir = xpkg.split("/")[0]
+ cpv = "%s/%s" % (catdir, pf)
+ try:
+ myaux = dict(zip(allvars,
self.portdb.aux_get(cpv, allvars)))
+ except KeyError:
+ allvalid = False
+
self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y))
+ continue
+ except IOError:
+ allvalid = False
+
self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y))
+ continue
+ if not portage.eapi_is_supported(myaux["EAPI"]):
+ allvalid = False
+
self.qatracker.add_error("EAPI.unsupported", os.path.join(xpkg, y))
+ continue
+ pkgs[pf] = Package(
+ cpv=cpv, metadata=myaux,
root_config=self.root_config,
+ type_name="ebuild")
+
+ if len(pkgs) != len(ebuildlist):
+ # If we can't access all the metadata then it's totally
unsafe to
+ # commit since there's no way to generate a correct
Manifest.
+ # Do not try to do any more QA checks on this package
since missing
+ # metadata leads to false positives for several checks,
and false
+ # positives confuse users.
+ self.continue_ = True
+
+ return pkgs, allvalid
diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 3a1ff7a..6a7ada7 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -11,7 +11,6 @@ import io
import logging
import re
import signal
-import stat
import subprocess
import sys
import tempfile
@@ -45,7 +44,6 @@ from portage import os
from portage import _encodings
from portage import _unicode_encode
from _emerge.Package import Package
-from _emerge.RootConfig import RootConfig
from _emerge.userquery import userquery
import portage.checksum
import portage.const
@@ -65,6 +63,7 @@ from portage.eapi import eapi_has_iuse_defaults,
eapi_has_required_use
from repoman.argparser import parse_args
from repoman.checks.ebuilds.checks import run_checks, checks_init
+from repoman.checks.ebuilds.isebuild import IsEbuild
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.checks.ebuilds.manifests import Manifests
from repoman.checks.herds.herdbase import make_herd_base
@@ -75,7 +74,7 @@ from repoman.metadata import (metadata_xml_encoding,
metadata_doctype_name,
from repoman.modules import commit
from repoman.profile import check_profiles, dev_keywords, setup_profile
from repoman.qa_data import (format_qa_output, format_qa_output_column, qahelp,
- qawarnings, qacats, no_exec, allvars, max_desc_len, missingvars,
+ qawarnings, qacats, max_desc_len, missingvars,
ruby_deprecated, suspect_virtual, suspect_rdepend, valid_restrict)
from qa_tracker import QATracker
from repoman.repos import has_global_mask, RepoSettings, repo_metadata
@@ -206,7 +205,6 @@ repoman_settings.categories = frozenset(
categories = repoman_settings.categories
portdb.settings = repoman_settings
-root_config = RootConfig(repoman_settings,
repo_settings.trees[repo_settings.root], None)
# We really only need to cache the metadata that's necessary for visibility
# filtering. Anything else can be discarded to reduce memory consumption.
portdb._aux_cache_keys.clear()
@@ -351,44 +349,11 @@ for xpkg in effective_scanlist:
continue
checkdirlist = os.listdir(checkdir)
- ebuildlist = []
- pkgs = {}
- allvalid = True
- for y in checkdirlist:
- file_is_ebuild = y.endswith(".ebuild")
- file_should_be_non_executable = y in no_exec or file_is_ebuild
-
- if file_should_be_non_executable:
- file_is_executable = stat.S_IMODE(
- os.stat(os.path.join(checkdir, y)).st_mode) &
0o111
-
- if file_is_executable:
- qatracker.add_error("file.executable",
os.path.join(checkdir, y))
- if file_is_ebuild:
- pf = y[:-7]
- ebuildlist.append(pf)
- cpv = "%s/%s" % (catdir, pf)
- try:
- myaux = dict(zip(allvars, portdb.aux_get(cpv,
allvars)))
- except KeyError:
- allvalid = False
- qatracker.add_error("ebuild.syntax",
os.path.join(xpkg, y))
- continue
- except IOError:
- allvalid = False
- qatracker.add_error("ebuild.output",
os.path.join(xpkg, y))
- continue
- if not portage.eapi_is_supported(myaux["EAPI"]):
- allvalid = False
- qatracker.add_error("EAPI.unsupported",
os.path.join(xpkg, y))
- continue
- pkgs[pf] = Package(
- cpv=cpv, metadata=myaux,
root_config=root_config,
- type_name="ebuild")
- slot_keywords = {}
-
- if len(pkgs) != len(ebuildlist):
+######################
+ is_ebuild = IsEbuild(repoman_settings, repo_settings, portdb, qatracker)
+ pkgs, allvalid = is_ebuild.check(checkdirlist, checkdir, xpkg)
+ if is_ebuild.continue_:
# If we can't access all the metadata then it's totally unsafe
to
# commit since there's no way to generate a correct Manifest.
# Do not try to do any more QA checks on this package since
missing
@@ -396,6 +361,9 @@ for xpkg in effective_scanlist:
# positives confuse users.
can_force = False
continue
+######################
+
+ slot_keywords = {}
# Sort ebuilds in ascending order for the KEYWORDS.dropped check.
ebuildlist = sorted(pkgs.values())