1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
'''
linter checks for repo dependency integrity
'''
import operator
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
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.
'''
name = 'unsatisfiable_depends'
check_type = LinterCheckType.PKGENTRY
header = 'repo.db entries with unsatisfiable depends'
def check(self, pkgentry):
''' run the check '''
repos = list(self._cache.repos.values()) + list(self._cache.arch_repos.values())
missing = []
for depend in pkgentry.depends:
matches = _repos_contain_depends(depend, repos, pkgentry.arch)
if not matches:
missing.append(depend)
if missing:
raise LinterIssue('%s (%s)', pkgentry, ','.join(missing))
def fixhook_base(self, issue):
''' produce a custom fixhook base '''
return '/'.join(str(issue[1]).split('/')[::2])
def fixhook_args(self, issue):
''' produce custom fixhook arguments '''
return [ str(issue[1]).split('/')[1], *issue[2].split(',') ]
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))
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))
|