From 9e6b9ce6a8d03db0b08e9ba6463383d2e15958d4 Mon Sep 17 00:00:00 2001 From: Andreas Grapentin Date: Sun, 3 Mar 2019 20:52:00 +0100 Subject: extending depends check to makedepends and checkdepends --- README.rst | 18 +++ parabola_repolint/linter_checks/dependencies.py | 162 ++++++++++++++++-------- parabola_repolint/repocache.py | 10 ++ 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 @@ -383,6 +383,16 @@ class PkgEntry(): ''' produce the install time dependencies of the package ''' 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 ''' -- cgit v1.2.2