1 |
On Sat, 18 Jun 2016 18:01:11 +0100 |
2 |
Sergei Trofimovich <slyfox@g.o> wrote: |
3 |
|
4 |
> From: Sergei Trofimovich <siarheit@××××××.com> |
5 |
> |
6 |
> A few links discussing what can go wrong with slot operator under |
7 |
> '||': |
8 |
> https://archives.gentoo.org/gentoo-dev/message/81a4e1a1f5767e20009628ecd33da8d4 |
9 |
> https://archives.gentoo.org/gentoo-dev/message/66ff016a055e57b6027abcd36734e0e3 |
10 |
> |
11 |
> The main problem here is how vdb gets updated when you have a |
12 |
> dependency of style: RDEPEND="|| ( foo:= bar:= )" |
13 |
> depending on what you have installed in system: only 'foo'/'bar' or |
14 |
> both 'foo' and 'bar'. |
15 |
> |
16 |
> I'm about to add actual test for some examples to gen-b0rk. |
17 |
> |
18 |
> New repoman complains on them as follows: |
19 |
> |
20 |
> RDEPEND="|| ( =not-broken/pkg1-subslot-0:= |
21 |
> =not-broken/pkg1-subslot-1:0= )" |
22 |
> |
23 |
> Yields: |
24 |
> |
25 |
> dependency.badslotop [fatal] 2 |
26 |
> ebuild-test/RDEPEND-any-of-slotop/RDEPEND-any-of-slotop-0.ebuild: |
27 |
> RDEPEND: '=not-broken/pkg1-subslot-0:=' uses ':=' slot operator under |
28 |
> '||' dep clause. |
29 |
> ebuild-test/RDEPEND-any-of-slotop/RDEPEND-any-of-slotop-0.ebuild: |
30 |
> RDEPEND: '=not-broken/pkg1-subslot-1:0=' uses ':=' slot operator |
31 |
> under '||' dep clause. |
32 |
> |
33 |
> CC: qa@g.o |
34 |
> CC: mgorny@g.o |
35 |
> Signed-off-by: Sergei Trofimovich <siarheit@××××××.com> |
36 |
> --- |
37 |
> repoman/pym/repoman/check_slotop.py | 32 |
38 |
> ++++++++++++++++++++++ .../repoman/modules/scan/depend/_depend_checks.py |
39 |
> | 17 ++++++++++++ repoman/pym/repoman/qa_data.py |
40 |
> | 2 ++ 3 files changed, 51 insertions(+) |
41 |
> create mode 100644 repoman/pym/repoman/check_slotop.py |
42 |
> |
43 |
|
44 |
|
45 |
Hmm, this file should be in the module namespace, not in the base |
46 |
repoman namespace. It is not used anywhere else, so should be in the |
47 |
module like _depend_checks.py |
48 |
|
49 |
Another alternative is just add it to _depend_checks.py, it isn't a |
50 |
very large file and is the only place this code is used. |
51 |
|
52 |
|
53 |
> diff --git a/repoman/pym/repoman/check_slotop.py |
54 |
> b/repoman/pym/repoman/check_slotop.py new file mode 100644 |
55 |
> index 0000000..3c3aec1 |
56 |
> --- /dev/null |
57 |
> +++ b/repoman/pym/repoman/check_slotop.py |
58 |
> @@ -0,0 +1,32 @@ |
59 |
> +# -*- coding:utf-8 -*- |
60 |
> +# repoman: missing slot check |
61 |
> +# Copyright 2016 Gentoo Foundation |
62 |
> +# Distributed under the terms of the GNU General Public License v2 |
63 |
> + |
64 |
> +"""This module contains the check used to find ':=' slot operator |
65 |
> +uses in '||' style dependencies.""" |
66 |
> + |
67 |
> +from portage.dep import Atom |
68 |
> + |
69 |
> +def check_slotop(dep_tree, mytype, qatracker, relative_path): |
70 |
> + def _traverse_tree(dep_tree, is_under_any_of): |
71 |
> + # leaf |
72 |
> + if isinstance(dep_tree, Atom): |
73 |
> + atom = dep_tree |
74 |
> + if is_under_any_of and atom.slot_operator: |
75 |
> + |
76 |
> qatracker.add_error("dependency.badslotop", relative_path + |
77 |
> + ": %s: '%s' uses ':=' slot |
78 |
> operator under '||' dep clause." % |
79 |
> + (mytype, atom)) |
80 |
> + |
81 |
> + # branches |
82 |
> + if isinstance(dep_tree, list): |
83 |
> + if len(dep_tree) == 0: |
84 |
> + return |
85 |
> + # any-of |
86 |
> + if dep_tree[0] == '||': |
87 |
> + _traverse_tree(dep_tree[1:], True) |
88 |
> + else: |
89 |
> + for branch in dep_tree: |
90 |
> + _traverse_tree(branch, |
91 |
> is_under_any_of) + |
92 |
> + _traverse_tree(dep_tree, False) |
93 |
> diff --git |
94 |
> a/repoman/pym/repoman/modules/scan/depend/_depend_checks.py |
95 |
> b/repoman/pym/repoman/modules/scan/depend/_depend_checks.py index |
96 |
> 4e1d216..1fd69d4 100644 --- |
97 |
> a/repoman/pym/repoman/modules/scan/depend/_depend_checks.py +++ |
98 |
> b/repoman/pym/repoman/modules/scan/depend/_depend_checks.py @@ -4,6 |
99 |
> +4,7 @@ from _emerge.Package import Package |
100 |
> from repoman.check_missingslot import check_missingslot |
101 |
> +from repoman.check_slotop import check_slotop |
102 |
> # import our initialized portage instance |
103 |
> from repoman._portage import portage |
104 |
> from repoman.qa_data import suspect_virtual, suspect_rdepend |
105 |
> @@ -117,6 +118,22 @@ def _depend_checks(ebuild, pkg, portdb, |
106 |
> qatracker, repo_metadata): |
107 |
> type_list.extend([mytype] * (len(badsyntax) - |
108 |
> len(type_list))) |
109 |
|
110 |
|
111 |
|
112 |
|
113 |
> + if runtime: |
114 |
> + try: |
115 |
> + # to find use of ':=' in '||' we |
116 |
> preserve |
117 |
> + # tree structure of dependencies |
118 |
> + hier_atoms = portage.dep.use_reduce( |
119 |
> + mydepstr, |
120 |
> + flat=False, |
121 |
> + matchall=1, |
122 |
> + |
123 |
> is_valid_flag=pkg.iuse.is_valid_flag, |
124 |
> + opconvert=True, |
125 |
> + token_class=token_class) |
126 |
> + except portage.exception.InvalidDependString |
127 |
> as e: |
128 |
> + hier_atoms = None |
129 |
> + badsyntax.append(str(e)) |
130 |
> + check_slotop(hier_atoms, mytype, qatracker, |
131 |
> ebuild.relative_path) |
132 |
|
133 |
|
134 |
Is there a special reason this code can not be part of the |
135 |
check_slotop()? All it has is the one statement calling it's internal |
136 |
recursive function. Then all this code would would be replaced here by |
137 |
the one check_slotop() which adds to badsyntax. |
138 |
|
139 |
|
140 |
|
141 |
> for m, b in zip(type_list, badsyntax): |
142 |
> if m.endswith("DEPEND"): |
143 |
> qacat = "dependency.syntax" |
144 |
> diff --git a/repoman/pym/repoman/qa_data.py |
145 |
> b/repoman/pym/repoman/qa_data.py index b9475e8..48ab389 100644 |
146 |
> --- a/repoman/pym/repoman/qa_data.py |
147 |
> +++ b/repoman/pym/repoman/qa_data.py |
148 |
> @@ -58,6 +58,8 @@ qahelp = { |
149 |
> "Ebuild has a dependency that refers to an unknown |
150 |
> package" " (which may be valid if it is a blocker for a |
151 |
> renamed/removed package," " or is an alternative choice provided by |
152 |
> an overlay)"), |
153 |
> + "dependency.badslotop": ( |
154 |
> + "RDEPEND contains ':=' slot operator under '||' |
155 |
> dependency."), "file.executable": ( |
156 |
> "Ebuilds, digests, metadata.xml, Manifest, and |
157 |
> ChangeLog do not need" " the executable bit"), |
158 |
|
159 |
|
160 |
|
161 |
-- |
162 |
Brian Dolbec <dolsen> |