summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2019-03-03 20:52:00 +0100
committerAndreas Grapentin <andreas@grapentin.org>2019-03-03 20:52:00 +0100
commit9e6b9ce6a8d03db0b08e9ba6463383d2e15958d4 (patch)
treecc5af7a6fc6d7e08448afe3e653484f20543ffd9
parent6a988dbbff817bb5a2351c4addbeb94d204ecfc9 (diff)
extending depends check to makedepends and checkdepends
-rw-r--r--README.rst18
-rw-r--r--parabola_repolint/linter_checks/dependencies.py162
-rw-r--r--parabola_repolint/repocache.py10
3 files changed, 138 insertions, 52 deletions
diff --git a/README.rst b/README.rst
index 5bcb9c8..40417cd 100644
--- a/README.rst
+++ b/README.rst
@@ -205,3 +205,21 @@ depends() array of the package are satisfiable with the provides() entries of
the packages in the repositories core, extra, community, and the ones
configured in CONFIG.parabola.repos. This check reports an issue whenever a
depends() entry is found that is not satisfiable.
+
+unsatisfiable_makedepends
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+for the list of entries in the repo.db's check that all entries in the
+makedepends() array of the package are satisfiable with the provides() entries
+of the packages in the repositories core, extra, community, and the ones
+configured in CONFIG.parabola.repos. This check reports an issue whenever a
+makedepends() entry is found that is not satisfiable.
+
+unsatisfiable_checkdepends
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+for the list of entries in the repo.db's check that all entries in the
+checkdepends() array of the package are satisfiable with the provides() entries
+of the packages in the repositories core, extra, community, and the ones
+configured in CONFIG.parabola.repos. This check reports an issue whenever a
+checkdepends() entry is found that is not satisfiable.
diff --git a/parabola_repolint/linter_checks/dependencies.py b/parabola_repolint/linter_checks/dependencies.py
index a5e76c2..08b4871 100644
--- a/parabola_repolint/linter_checks/dependencies.py
+++ b/parabola_repolint/linter_checks/dependencies.py
@@ -8,6 +8,60 @@ from parabola_repolint.repocache import PkgVersion
from parabola_repolint.linter import LinterIssue, LinterCheckBase, LinterCheckType
+def _candidate_contains_depends(depend, candidate, version):
+ ''' test whether a dependency is provided by a pkgentry '''
+ if version is None:
+ return True
+
+ provides = candidate.provides.union([candidate.pkgname])
+ pversion = candidate.pkgver
+
+ for provide in provides:
+ assert '<' not in provide
+ assert '>' not in provide
+
+ if '=' not in provide:
+ continue
+
+ provide, _pversion = provide.split('=')
+ if provide == depend:
+ pversion = PkgVersion(_pversion)
+ break
+
+ operators = {
+ '==': operator.eq,
+ '=': operator.eq,
+ '>=': operator.ge,
+ '<=': operator.le,
+ '>': operator.gt,
+ '<': operator.lt,
+ }
+
+ return operators[version[0]](pversion, version[1])
+
+
+def _repos_contain_depends(depend, repos, arch):
+ ''' test whether a dependency is provided by the list of repos '''
+ version = None
+ splits = ['==', '>=', '<=', '>', '<', '=']
+ for split in splits:
+ if split in depend:
+ depend, version = depend.split(split)
+ version = (split, PkgVersion(version))
+ break
+
+ candidates = []
+ for repo in repos:
+ candidates += repo.provides_cache.get(arch, {}).get(depend, [])
+
+ matches = []
+ for candidate in candidates:
+ if _candidate_contains_depends(depend, candidate, version):
+ matches.append(candidate)
+
+ return matches
+
+
class UnsatisfiableDepends(LinterCheckBase):
'''
for the list of entries in the repo.db's check that all entries in the
@@ -28,61 +82,65 @@ class UnsatisfiableDepends(LinterCheckBase):
missing = []
for depend in pkgentry.depends:
- matches = self._repos_contain_depends(depend, repos, pkgentry.arch)
+ matches = _repos_contain_depends(depend, repos, pkgentry.arch)
+ if not matches:
+ missing.append(depend)
+
+ if missing:
+ raise LinterIssue('%s (%s)', pkgentry, ','.join(missing))
+
+
+class UnsatisfiableMakedepends(LinterCheckBase):
+ '''
+ for the list of entries in the repo.db's check that all entries in the
+ makedepends() array of the package are satisfiable with the provides() entries
+ of the packages in the repositories core, extra, community, and the ones
+ configured in CONFIG.parabola.repos. This check reports an issue whenever a
+ makedepends() entry is found that is not satisfiable.
+'''
+
+ name = 'unsatisfiable_makedepends'
+ check_type = LinterCheckType.PKGENTRY
+
+ header = 'repo.db entries with unsatisfiable makedepends'
+
+ def check(self, pkgentry):
+ ''' run the check '''
+ repos = list(self._cache.repos.values()) + list(self._cache.arch_repos.values())
+ missing = []
+
+ for depend in pkgentry.makedepends:
+ matches = _repos_contain_depends(depend, repos, pkgentry.arch)
if not matches:
missing.append(depend)
if missing:
raise LinterIssue('%s (%s)', pkgentry, ','.join(missing))
- def _repos_contain_depends(self, depend, repos, arch):
- ''' test whether a dependency is provided by the list of repos '''
- version = None
- splits = ['==', '>=', '<=', '>', '<', '=']
- for split in splits:
- if split in depend:
- depend, version = depend.split(split)
- version = (split, PkgVersion(version))
- break
-
- candidates = []
- for repo in repos:
- candidates += repo.provides_cache.get(arch, {}).get(depend, [])
-
- matches = []
- for candidate in candidates:
- if self._candidate_contains_depends(depend, candidate, version):
- matches.append(candidate)
-
- return matches
-
- def _candidate_contains_depends(self, depend, candidate, version):
- ''' test whether a dependency is provided by a pkgentry '''
- if version is None:
- return True
-
- provides = candidate.provides.union([candidate.pkgname])
- pversion = candidate.pkgver
-
- for provide in provides:
- assert '<' not in provide
- assert '>' not in provide
-
- if '=' not in provide:
- continue
-
- provide, _pversion = provide.split('=')
- if provide == depend:
- pversion = PkgVersion(_pversion)
- break
-
- operators = {
- '==': operator.eq,
- '=': operator.eq,
- '>=': operator.ge,
- '<=': operator.le,
- '>': operator.gt,
- '<': operator.lt,
- }
-
- return operators[version[0]](pversion, version[1])
+
+class UnsatisfiableCheckdepends(LinterCheckBase):
+ '''
+ for the list of entries in the repo.db's check that all entries in the
+ checkdepends() array of the package are satisfiable with the provides() entries
+ of the packages in the repositories core, extra, community, and the ones
+ configured in CONFIG.parabola.repos. This check reports an issue whenever a
+ checkdepends() entry is found that is not satisfiable.
+'''
+
+ name = 'unsatisfiable_checkdepends'
+ check_type = LinterCheckType.PKGENTRY
+
+ header = 'repo.db entries with unsatisfiable makedepends'
+
+ def check(self, pkgentry):
+ ''' run the check '''
+ repos = list(self._cache.repos.values()) + list(self._cache.arch_repos.values())
+ missing = []
+
+ for depend in pkgentry.checkdepends:
+ matches = _repos_contain_depends(depend, repos, pkgentry.arch)
+ if not matches:
+ missing.append(depend)
+
+ if missing:
+ raise LinterIssue('%s (%s)', pkgentry, ','.join(missing))
diff --git a/parabola_repolint/repocache.py b/parabola_repolint/repocache.py
index 3f27938..784c586 100644
--- a/parabola_repolint/repocache.py
+++ b/parabola_repolint/repocache.py
@@ -384,6 +384,16 @@ class PkgEntry():
return set(self._data.get('DEPENDS', '').split())
@property
+ def makedepends(self):
+ ''' produce the build time dependencies of the package '''
+ return set(self._data.get('MAKEDEPENDS', '').split())
+
+ @property
+ def checkdepends(self):
+ ''' produce the check time dependencies of the package '''
+ return set(self._data.get('CHECKDEPENDS', '').split())
+
+ @property
def arch(self):
''' produce the architecture of the package '''
return self._repoarch