From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/ebuild/
Date: Fri, 29 Apr 2016 17:24:45 +0000 (UTC) [thread overview]
Message-ID: <1461679721.695492024a9ca40fd14148a980a960a8551dab29.dolsen@gentoo> (raw)
Message-ID: <20160429172445.ki3hk6X6sS_BHilFvmUBs8xYblfi4OU1rNTFzg5EPqU@z> (raw)
commit: 695492024a9ca40fd14148a980a960a8551dab29
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 26 14:08:41 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Apr 26 14:08:41 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=69549202
Repoman: Merge IsEbuild class into ebuild
This reduces the need to import the pkgs data, it is now an internal class instance variable.
'pkgs' is still needed, but only to assign it the new pkgs dictionary which the scanner
requires for the ebuild loop.
pym/repoman/modules/scan/ebuild/__init__.py | 27 ++------
pym/repoman/modules/scan/ebuild/ebuild.py | 84 ++++++++++++++++++++++--
pym/repoman/modules/scan/ebuild/isebuild.py | 99 -----------------------------
pym/repoman/scanner.py | 4 +-
4 files changed, 88 insertions(+), 126 deletions(-)
diff --git a/pym/repoman/modules/scan/ebuild/__init__.py b/pym/repoman/modules/scan/ebuild/__init__.py
index b243314..8666e78 100644
--- a/pym/repoman/modules/scan/ebuild/__init__.py
+++ b/pym/repoman/modules/scan/ebuild/__init__.py
@@ -10,25 +10,6 @@ module_spec = {
'name': 'ebuild',
'description': doc,
'provides':{
- 'isebuild-module': {
- 'name': "isebuild",
- 'sourcefile': "isebuild",
- 'class': "IsEbuild",
- 'description': doc,
- 'functions': ['check'],
- 'func_desc': {
- },
- 'mod_kwargs': ['portdb', 'qatracker', 'repo_settings'
- ],
- 'func_kwargs': {
- 'can_force': (None, None),
- 'checkdir': (None, None),
- 'checkdirlist': (None, None),
- 'pkgs': ('Future', 'dict'),
- 'validity_future': ('Future', True),
- 'xpkg': (None, None),
- },
- },
'ebuild-module': {
'name': "ebuild",
'sourcefile': "ebuild",
@@ -37,16 +18,20 @@ module_spec = {
'functions': ['check'],
'func_desc': {
},
- 'mod_kwargs': ['qatracker', 'repo_settings', 'vcs_settings', 'checks',
+ 'mod_kwargs': ['qatracker', 'repo_settings', 'vcs_settings',
+ 'checks', 'portdb'
],
'func_kwargs': {
+ 'can_force': (None, None),
'catdir': (None, None),
'changed': (None, None),
'changelog_modified': (None, None),
+ 'checkdir': (None, None),
+ 'checkdirlist': (None, None),
'ebuild': ('Future', 'UNSET'),
'pkg': ('Future', 'UNSET'),
'pkgdir': (None, None),
- 'pkgs': (None, None),
+ 'pkgs': ('Future', 'dict'),
'repolevel': (None, None),
'validity_future': (None, None),
'xpkg': (None, None),
diff --git a/pym/repoman/modules/scan/ebuild/ebuild.py b/pym/repoman/modules/scan/ebuild/ebuild.py
index 92b1ea4..c247a7f 100644
--- a/pym/repoman/modules/scan/ebuild/ebuild.py
+++ b/pym/repoman/modules/scan/ebuild/ebuild.py
@@ -3,8 +3,13 @@
from __future__ import print_function, unicode_literals
import re
+import stat
+
+from _emerge.Package import Package
+from _emerge.RootConfig import RootConfig
from repoman.modules.scan.scanbase import ScanBase
+from repoman.qa_data import no_exec, allvars
# import our initialized portage instance
from repoman._portage import portage
from portage import os
@@ -19,16 +24,19 @@ class Ebuild(ScanBase):
'''Class init
@param qatracker: QATracker instance
+ @param portdb: portdb instance
@param repo_settings: repository settings instance
@param vcs_settings: VCSSettings instance
- @param changed: changes dictionary
@param checks: checks dictionary
'''
super(Ebuild, self).__init__(**kwargs)
self.qatracker = kwargs.get('qatracker')
+ self.portdb = kwargs.get('portdb')
self.repo_settings = kwargs.get('repo_settings')
self.vcs_settings = kwargs.get('vcs_settings')
self.checks = kwargs.get('checks')
+ self.root_config = RootConfig(self.repo_settings.repoman_settings,
+ self.repo_settings.trees[self.repo_settings.root], None)
self.changed = None
self.xpkg = None
self.y_ebuild = None
@@ -37,6 +45,7 @@ class Ebuild(ScanBase):
self.eapi = None
self.inherited = None
self.keywords = None
+ self.pkgs = {}
def _set_paths(self, **kwargs):
repolevel = kwargs.get('repolevel')
@@ -93,11 +102,9 @@ class Ebuild(ScanBase):
def set_pkg_data(self, **kwargs):
'''Sets some classwide data needed for some of the checks
- @param pkgs: the dynamic list of ebuilds
@returns: dictionary
'''
- pkgs = kwargs.get('pkgs').get()
- self.pkg = pkgs[self.y_ebuild]
+ self.pkg = self.pkgs[self.y_ebuild]
self.metadata = self.pkg._metadata
self.eapi = self.metadata["EAPI"]
self.inherited = self.pkg.inherited
@@ -148,6 +155,75 @@ class Ebuild(ScanBase):
dyn_pkg.set(self.pkg)
return False
+ def check_isebuild(self, **kwargs):
+ '''Test the file for qualifications that is is an ebuild
+
+ @param checkdirlist: list of files in the current package directory
+ @param checkdir: current package directory path
+ @param xpkg: current package directory being checked
+ @param validity_future: Future instance
+ @returns: dictionary, including {pkgs, can_force}
+ '''
+ checkdirlist = kwargs.get('checkdirlist').get()
+ checkdir = kwargs.get('checkdir')
+ xpkg = kwargs.get('xpkg')
+ fuse = kwargs.get('validity_future')
+ can_force = kwargs.get('can_force')
+ self.continue_ = False
+ ebuildlist = []
+ pkgs = {}
+ 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:
+ fuse.set(False, ignore_InvalidState=True)
+ self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y))
+ continue
+ except IOError:
+ fuse.set(False, ignore_InvalidState=True)
+ self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y))
+ continue
+ if not portage.eapi_is_supported(myaux["EAPI"]):
+ fuse.set(False, ignore_InvalidState=True)
+ 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
+ can_force.set(False, ignore_InvalidState=True)
+ self.pkgs = pkgs
+ # set our updated data
+ dyn_pkgs = kwargs.get('pkgs')
+ dyn_pkgs.set(pkgs)
+ return self.continue_
+
+ @property
+ def runInPkgs(self):
+ '''Package level scans'''
+ return (True, [self.check_isebuild])
+
@property
def runInEbuilds(self):
'''Ebuild level scans'''
diff --git a/pym/repoman/modules/scan/ebuild/isebuild.py b/pym/repoman/modules/scan/ebuild/isebuild.py
deleted file mode 100644
index 7277ad0..0000000
--- a/pym/repoman/modules/scan/ebuild/isebuild.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# -*- coding:utf-8 -*-
-
-import stat
-
-from _emerge.Package import Package
-from _emerge.RootConfig import RootConfig
-
-# import our initialized portage instance
-from repoman._portage import portage
-
-from portage import os
-
-from repoman.qa_data import no_exec, allvars
-from repoman.modules.scan.scanbase import ScanBase
-
-
-class IsEbuild(ScanBase):
- '''Performs basic tests to confirm it is an ebuild'''
-
- def __init__(self, **kwargs):
- '''
- @param portdb: portdb instance
- @param qatracker: QATracker instance
- @param repo_settings: repository settings instance
- '''
- super(IsEbuild, self).__init__(**kwargs)
- self.portdb = kwargs.get('portdb')
- self.qatracker = kwargs.get('qatracker')
- repo_settings = kwargs.get('repo_settings')
- self.root_config = RootConfig(repo_settings.repoman_settings,
- repo_settings.trees[repo_settings.root], None)
-
- def check(self, **kwargs):
- '''Test the file for qualifications that is is an ebuild
-
- @param checkdirlist: list of files in the current package directory
- @param checkdir: current package directory path
- @param xpkg: current package directory being checked
- @param validity_future: Future instance
- @returns: dictionary, including {pkgs, can_force}
- '''
- checkdirlist = kwargs.get('checkdirlist').get()
- checkdir = kwargs.get('checkdir')
- xpkg = kwargs.get('xpkg')
- fuse = kwargs.get('validity_future')
- can_force = kwargs.get('can_force')
- self.continue_ = False
- ebuildlist = []
- pkgs = {}
- 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:
- fuse.set(False, ignore_InvalidState=True)
- self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y))
- continue
- except IOError:
- fuse.set(False, ignore_InvalidState=True)
- self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y))
- continue
- if not portage.eapi_is_supported(myaux["EAPI"]):
- fuse.set(False, ignore_InvalidState=True)
- 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
- can_force.set(False, ignore_InvalidState=True)
- # set our updated data
- dyn_pkgs = kwargs.get('pkgs')
- dyn_pkgs.set(pkgs)
- return self.continue_
-
- @property
- def runInPkgs(self):
- '''Package level scans'''
- return (True, [self.check])
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 1fd5b77..23d666d 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -299,6 +299,7 @@ class Scanner(object):
self.vcs_settings.status.check(checkdir, checkdir_relative, xpkg)
dynamic_data = {
+ 'changelog_modified': False,
'checkdirlist': ExtendedFuture(checkdirlist),
'checkdir': checkdir,
'xpkg': xpkg,
@@ -308,7 +309,6 @@ class Scanner(object):
'repolevel': self.repolevel,
'catdir': catdir,
'pkgdir': pkgdir,
- 'pkgs': ExtendedFuture({}),
'validity_future': ExtendedFuture(True),
'y_ebuild': None,
# this needs to be reset at the pkg level only,
@@ -324,7 +324,7 @@ class Scanner(object):
'validity_future',
]
# need to set it up for ==> self.modules or some other ordered list
- for mod in [('manifests', 'Manifests'), ('isebuild', 'IsEbuild'),
+ for mod in [('manifests', 'Manifests'), ('ebuild', 'Ebuild'),
('keywords', 'KeywordChecks'), ('files', 'FileChecks'),
('fetches', 'FetchChecks'),
('pkgmetadata', 'PkgMetadata'),
next reply other threads:[~2016-04-29 17:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 14:47 Brian Dolbec [this message]
2016-04-29 17:24 ` [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/ebuild/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2016-04-25 15:32 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/ebuild/, pym/repoman/ Brian Dolbec
2016-03-16 17:12 Brian Dolbec
2016-03-12 18:10 Brian Dolbec
2016-01-06 4:21 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461679721.695492024a9ca40fd14148a980a960a8551dab29.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox