Merge ~xnox/germinate:master into germinate:master
- Git
- lp:~xnox/germinate
- master
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | 4c88dc4435ce12968dbc608348cdc5e2660b19f6 |
Proposed branch: | ~xnox/germinate:master |
Merge into: | germinate:master |
Diff against target: |
266 lines (+75/-46) 9 files modified
germinate/archive.py (+1/-1) germinate/defaults.py (+1/-1) germinate/germinator.py (+66/-39) germinate/log.py (+1/-1) germinate/scripts/germinate_main.py (+1/-1) germinate/scripts/germinate_pkg_diff.py (+1/-1) germinate/scripts/germinate_update_metapackage.py (+1/-1) germinate/seeds.py (+1/-1) germinate/tests/test_germinator.py (+2/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson | Approve | ||
Dimitri John Ledkov (community) | Approve | ||
Steve Langasek | Approve | ||
Review via email: mp+285180@code.launchpad.net |
Commit message
Description of the change
Dimitri John Ledkov (xnox) wrote : | # |
Dimitri John Ledkov (xnox) wrote : | # |
Not sure what is easier to review, the full diff or commit-by-commit.
There are two things here:
* follow-
* built-using are now taken into consideration, and are added into dependencies as if they are a source package, which ended up added into the seeds via a binary build-dependency. I'm not sure if this is elegant or not, as there is no "reason" generated for them. Ideally it should hook something in like "pkg (Built-using bar)" or some such.
Emacs was complaining about invalid coding line, and I have refactored three Build-Depends* as an austerity measure.
Dimitri John Ledkov (xnox) wrote : | # |
Sample output is here:
http://
old -> "follow-
new -> "no-follow-
Barry Warsaw (barry) wrote : | # |
Some minor comments inlined.
I don't know why Emacs complains about uppercase coding tags. That seems... unfortunate.
Dimitri John Ledkov (xnox) wrote : | # |
> Some minor comments inlined.
>
> I don't know why Emacs complains about uppercase coding tags. That seems...
> unfortunate.
Removed unnecessory list() cast.
Added comment about Built-Using unpacking. I am unpacking the first pkg name, out of the possible multiple alternatives, for each specified Built-Using. See:
https:/
For the actual format -> list of alternatives, specified as triplets of (pkg, version, operator).
Steve Langasek (vorlon) wrote : | # |
Test component-
This looks like the correct behavior to me.
Dimitri John Ledkov (xnox) wrote : | # |
+1 from me, please merge / deploy.
Colin Watson (cjwatson) : | # |
Dimitri John Ledkov (xnox) wrote : | # |
Colin, I believe I have addressed all of your review comments in an extra commit I have just pushed. Things still work correctly as far as I can test, and invalid Built-Using packages have been spotted (golang removed, whilst not everything was rebuilt yet)
Colin Watson (cjwatson) wrote : | # |
One more efficiency improvement, but I've fixed that as part of my merge. Thanks!
Preview Diff
1 | diff --git a/germinate/archive.py b/germinate/archive.py |
2 | index 64f6ddf..4ed3348 100644 |
3 | --- a/germinate/archive.py |
4 | +++ b/germinate/archive.py |
5 | @@ -1,4 +1,4 @@ |
6 | -# -*- coding: UTF-8 -*- |
7 | +# -*- coding: utf-8 -*- |
8 | """Representations of archives for use by Germinate.""" |
9 | |
10 | # Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
11 | diff --git a/germinate/defaults.py b/germinate/defaults.py |
12 | index 4222992..bbc894c 100644 |
13 | --- a/germinate/defaults.py |
14 | +++ b/germinate/defaults.py |
15 | @@ -1,4 +1,4 @@ |
16 | -# -*- coding: UTF-8 -*- |
17 | +# -*- coding: utf-8 -*- |
18 | """Defaults for Germinate.""" |
19 | |
20 | # Copyright (c) 2011 Canonical Ltd. |
21 | diff --git a/germinate/germinator.py b/germinate/germinator.py |
22 | index 18a120d..f2152ed 100644 |
23 | --- a/germinate/germinator.py |
24 | +++ b/germinate/germinator.py |
25 | @@ -1,4 +1,4 @@ |
26 | -# -*- coding: UTF-8 -*- |
27 | +# -*- coding: utf-8 -*- |
28 | """Expand seeds into dependency-closed lists of packages.""" |
29 | |
30 | # Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Canonical Ltd. |
31 | @@ -39,6 +39,11 @@ __all__ = [ |
32 | 'Germinator', |
33 | ] |
34 | |
35 | +BUILD_DEPENDS = ( |
36 | + "Build-Depends", |
37 | + "Build-Depends-Indep", |
38 | + "Build-Depends-Arch", |
39 | +) |
40 | |
41 | _logger = logging.getLogger(__name__) |
42 | |
43 | @@ -445,7 +450,7 @@ class Germinator(object): |
44 | |
45 | self._packages[pkg]["Essential"] = section.get("Essential", "") |
46 | |
47 | - for field in "Pre-Depends", "Depends", "Recommends": |
48 | + for field in "Pre-Depends", "Depends", "Recommends", "Built-Using": |
49 | value = section.get(field, "") |
50 | self._packages[pkg][field] = self._parse_depends(value) |
51 | |
52 | @@ -569,8 +574,7 @@ class Germinator(object): |
53 | _ensure_unicode(section.get("Maintainer", "")) |
54 | self._sources[src]["Version"] = ver |
55 | |
56 | - for field in ( |
57 | - "Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch"): |
58 | + for field in BUILD_DEPENDS: |
59 | value = section.get(field, "") |
60 | self._sources[src][field] = self._parse_src_depends(value) |
61 | |
62 | @@ -1168,6 +1172,18 @@ class Germinator(object): |
63 | return False |
64 | return "follow-recommends" in structure.features |
65 | |
66 | + def _follow_build_depends(self, structure, seed=None): |
67 | + """ |
68 | + Test whether we should follow Build-Depends for this seed. |
69 | + Defaults to True, if not explicitly specified. |
70 | + """ |
71 | + if seed is not None: |
72 | + if "follow-build-depends" in seed._features: |
73 | + return True |
74 | + if "no-follow-build-depends" in seed._features: |
75 | + return False |
76 | + return "no-follow-build-depends" not in structure.features |
77 | + |
78 | def _add_reverse(self, pkg, field, rdep): |
79 | """Add a reverse dependency entry.""" |
80 | if "Reverse-Depends" not in self._packages[pkg]: |
81 | @@ -1192,9 +1208,10 @@ class Germinator(object): |
82 | self._add_reverse(depname, field, pkg) |
83 | |
84 | for src in output._all_srcs: |
85 | - for field in ( |
86 | - "Build-Depends", "Build-Depends-Indep", |
87 | - "Build-Depends-Arch"): |
88 | + fields = () |
89 | + if self._follow_build_depends(structure): |
90 | + fields = BUILD_DEPENDS |
91 | + for field in fields: |
92 | for deplist in self._sources[src][field]: |
93 | for dep in deplist: |
94 | depname = dep[0].split(":", 1)[0] |
95 | @@ -1210,8 +1227,7 @@ class Germinator(object): |
96 | if (self._follow_recommends(structure) or |
97 | self._packages[pkg]["Section"] == "metapackages"): |
98 | fields.append("Recommends") |
99 | - fields.extend([ |
100 | - "Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch"]) |
101 | + fields.extend(BUILD_DEPENDS) |
102 | for field in fields: |
103 | if field not in self._packages[pkg]["Reverse-Depends"]: |
104 | continue |
105 | @@ -1537,40 +1553,53 @@ class Germinator(object): |
106 | recommends=True) |
107 | |
108 | src = self._packages[pkg]["Source"] |
109 | - if src not in self._sources: |
110 | - _logger.error("Missing source package: %s (for %s)", src, pkg) |
111 | - return |
112 | |
113 | + # Built-Using field is in a form of apt_pkg.parse_depends For |
114 | + # common-case "pkg (= 1)" it returns |
115 | + # [[('pkg', '1', '=')]] |
116 | + # We thus unpack the first listed alternative pkg-name, for |
117 | + # each built-using source. |
118 | + built_using = [i[0][0] for i in self._packages[pkg]["Built-Using"]] |
119 | + pkg_srcs = [] |
120 | + |
121 | + # Create set of all sources needed for pkg: Source + Built-Using |
122 | + for pkg_src in built_using + [src]: |
123 | + if pkg_src in self._sources and pkg_src not in pkg_srcs: |
124 | + pkg_srcs.append(pkg_src) |
125 | + else: |
126 | + _logger.error("Missing source package: %s (for %s)", pkg_src, pkg) |
127 | + |
128 | + # Filter/exclude sources already part of an inner seed |
129 | if second_class: |
130 | - for innerseed in self._inner_seeds(seed): |
131 | - if src in innerseed._build_srcs: |
132 | - return |
133 | + excluded_srcs = "_build_srcs" |
134 | else: |
135 | - for innerseed in self._inner_seeds(seed): |
136 | - if src in innerseed._not_build_srcs: |
137 | - return |
138 | + excluded_srcs = "_not_build_srcs" |
139 | |
140 | - if build_tree: |
141 | - seed._build_sourcepkgs.add(src) |
142 | - if src in output._blacklist: |
143 | - seed._blacklisted.add(src) |
144 | + for innerseed in self._inner_seeds(seed): |
145 | + for excluded_src in getattr(innerseed, excluded_srcs): |
146 | + if excluded_src in pkg_srcs: |
147 | + pkg_srcs.remove(excluded_src) |
148 | + |
149 | + # Use build_tree flag for src |
150 | + # Treat all Built-Using as if it's part of build_tree |
151 | + for pkg_src in pkg_srcs: |
152 | + if build_tree or pkg_src in built_using: |
153 | + seed._build_sourcepkgs.add(pkg_src) |
154 | + if pkg_src in output._blacklist: |
155 | + seed._blacklisted.add(pkg_src) |
156 | + else: |
157 | + seed._not_build_srcs.add(pkg_src) |
158 | + seed._sourcepkgs.add(pkg_src) |
159 | |
160 | - else: |
161 | - seed._not_build_srcs.add(src) |
162 | - seed._sourcepkgs.add(src) |
163 | + output._all_srcs.add(pkg_src) |
164 | + seed._build_srcs.add(pkg_src) |
165 | |
166 | - output._all_srcs.add(src) |
167 | - seed._build_srcs.add(src) |
168 | + if self._follow_build_depends(seed.structure, seed): |
169 | + for build_depends in BUILD_DEPENDS: |
170 | + self._add_dependency_tree(seed, pkg, |
171 | + self._sources[pkg_src][build_depends], |
172 | + build_depend=True) |
173 | |
174 | - self._add_dependency_tree(seed, pkg, |
175 | - self._sources[src]["Build-Depends"], |
176 | - build_depend=True) |
177 | - self._add_dependency_tree(seed, pkg, |
178 | - self._sources[src]["Build-Depends-Indep"], |
179 | - build_depend=True) |
180 | - self._add_dependency_tree(seed, pkg, |
181 | - self._sources[src]["Build-Depends-Arch"], |
182 | - build_depend=True) |
183 | |
184 | def _rescue_includes(self, structure, seedname, rescue_seedname, |
185 | build_tree): |
186 | @@ -1962,9 +1991,7 @@ class Germinator(object): |
187 | if "Reverse-Depends" not in self._packages[pkg]: |
188 | return |
189 | |
190 | - for field in ("Pre-Depends", "Depends", "Recommends", |
191 | - "Build-Depends", "Build-Depends-Indep", |
192 | - "Build-Depends-Arch"): |
193 | + for field in ("Pre-Depends", "Depends", "Recommends") + BUILD_DEPENDS: |
194 | if field not in self._packages[pkg]["Reverse-Depends"]: |
195 | continue |
196 | |
197 | diff --git a/germinate/log.py b/germinate/log.py |
198 | index 3e5be54..dc7c0f2 100644 |
199 | --- a/germinate/log.py |
200 | +++ b/germinate/log.py |
201 | @@ -1,4 +1,4 @@ |
202 | -# -*- coding: UTF-8 -*- |
203 | +# -*- coding: utf-8 -*- |
204 | """Custom logging for Germinate.""" |
205 | |
206 | # Copyright (c) 2011, 2012 Canonical Ltd. |
207 | diff --git a/germinate/scripts/germinate_main.py b/germinate/scripts/germinate_main.py |
208 | index 34a930c..e27f463 100644 |
209 | --- a/germinate/scripts/germinate_main.py |
210 | +++ b/germinate/scripts/germinate_main.py |
211 | @@ -1,4 +1,4 @@ |
212 | -# -*- coding: UTF-8 -*- |
213 | +# -*- coding: utf-8 -*- |
214 | """Expand dependencies in a list of seed packages.""" |
215 | |
216 | # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
217 | diff --git a/germinate/scripts/germinate_pkg_diff.py b/germinate/scripts/germinate_pkg_diff.py |
218 | index c99b88e..15736ea 100644 |
219 | --- a/germinate/scripts/germinate_pkg_diff.py |
220 | +++ b/germinate/scripts/germinate_pkg_diff.py |
221 | @@ -1,4 +1,4 @@ |
222 | -# -*- coding: UTF-8 -*- |
223 | +# -*- coding: utf-8 -*- |
224 | |
225 | # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
226 | # Canonical Ltd. |
227 | diff --git a/germinate/scripts/germinate_update_metapackage.py b/germinate/scripts/germinate_update_metapackage.py |
228 | index 26f4728..08a697b 100644 |
229 | --- a/germinate/scripts/germinate_update_metapackage.py |
230 | +++ b/germinate/scripts/germinate_update_metapackage.py |
231 | @@ -1,4 +1,4 @@ |
232 | -# -*- coding: UTF-8 -*- |
233 | +# -*- coding: utf-8 -*- |
234 | |
235 | # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Canonical Ltd. |
236 | # Copyright (C) 2006 Gustavo Franco |
237 | diff --git a/germinate/seeds.py b/germinate/seeds.py |
238 | index e149ccb..aecec48 100644 |
239 | --- a/germinate/seeds.py |
240 | +++ b/germinate/seeds.py |
241 | @@ -1,4 +1,4 @@ |
242 | -# -*- coding: UTF-8 -*- |
243 | +# -*- coding: utf-8 -*- |
244 | """Fetch seeds from a URL collection or from a VCS.""" |
245 | |
246 | # Copyright (c) 2004, 2005, 2006, 2008, 2009, 2011, 2012 Canonical Ltd. |
247 | diff --git a/germinate/tests/test_germinator.py b/germinate/tests/test_germinator.py |
248 | index 90ff8ee..79956dc 100644 |
249 | --- a/germinate/tests/test_germinator.py |
250 | +++ b/germinate/tests/test_germinator.py |
251 | @@ -169,6 +169,7 @@ class TestGerminator(TestCase): |
252 | "Maintainer": u("Test Person <test@example.com>"), |
253 | "Essential": "", |
254 | "Pre-Depends": [], |
255 | + "Built-Using": [], |
256 | "Depends": [[("hello-dependency", "", "")]], |
257 | "Recommends": [], |
258 | "Size": 0, |
259 | @@ -186,6 +187,7 @@ class TestGerminator(TestCase): |
260 | "Maintainer": u(""), |
261 | "Essential": "", |
262 | "Pre-Depends": [], |
263 | + "Built-Using": [], |
264 | "Depends": [], |
265 | "Recommends": [], |
266 | "Size": 0, |
Mostly raising this as a WIP =) my first git merge proposal on launchpad. So wanted to see what it would look like =)