Merge lp:~wgrant/launchpad/bug-598345-restrict-dep-contexts into lp:launchpad
- bug-598345-restrict-dep-contexts
- Merge into devel
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Robert Collins | ||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||
Merged at revision: | 11175 | ||||||||||||
Proposed branch: | lp:~wgrant/launchpad/bug-598345-restrict-dep-contexts | ||||||||||||
Merge into: | lp:launchpad | ||||||||||||
Diff against target: |
770 lines (+326/-182) 10 files modified
lib/lp/soyuz/adapters/archivedependencies.py (+83/-55) lib/lp/soyuz/doc/archive-dependencies.txt (+3/-3) lib/lp/soyuz/doc/archive.txt (+1/-67) lib/lp/soyuz/doc/binarypackagebuild.txt (+5/-3) lib/lp/soyuz/interfaces/archive.py (+18/-5) lib/lp/soyuz/model/archive.py (+19/-15) lib/lp/soyuz/model/binarypackagebuild.py (+16/-25) lib/lp/soyuz/tests/test_archive.py (+138/-3) lib/lp/soyuz/tests/test_binarypackagebuild.py (+39/-4) lib/lp/soyuz/tests/test_publishing.py (+4/-2) |
||||||||||||
To merge this branch: | bzr merge lp:~wgrant/launchpad/bug-598345-restrict-dep-contexts | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+30203@code.launchpad.net |
Commit message
Only retry depwait builds if the candidate is in an available pocket and component.
Description of the change
This branches fixes bug #52698 and bug #598345. At present some depwait builds are retried prematurely, as the candidate query in Archive.
A related (and also fixed here) issue is bug #606789: findDepCandidat
I've fixed the first problem by refactoring the archive dependency expansion logic in lp.soyuz.
For the second issue, findDepCandidat
I've also removed some manual ogre-model logic from _isDependencySa
The findDepCandidat
Preview Diff
1 | === modified file 'lib/lp/soyuz/adapters/archivedependencies.py' | |||
2 | --- lib/lp/soyuz/adapters/archivedependencies.py 2010-05-10 19:49:02 +0000 | |||
3 | +++ lib/lp/soyuz/adapters/archivedependencies.py 2010-07-20 09:26:10 +0000 | |||
4 | @@ -12,8 +12,9 @@ | |||
5 | 12 | 12 | ||
6 | 13 | Auxiliary functions exposed for testing purposes: | 13 | Auxiliary functions exposed for testing purposes: |
7 | 14 | 14 | ||
10 | 15 | * get_components_for_building: return the corresponding component | 15 | * get_components_for_context: return the corresponding component |
11 | 16 | dependencies for a build, this result is known as 'ogre_components'; | 16 | dependencies for a component and pocket, this result is known as |
12 | 17 | 'ogre_components'; | ||
13 | 17 | * get_primary_current_component: return the component name where the | 18 | * get_primary_current_component: return the component name where the |
14 | 18 | building source is published in the primary archive. | 19 | building source is published in the primary archive. |
15 | 19 | 20 | ||
16 | @@ -30,7 +31,8 @@ | |||
17 | 30 | 'component_dependencies', | 31 | 'component_dependencies', |
18 | 31 | 'default_component_dependency_name', | 32 | 'default_component_dependency_name', |
19 | 32 | 'default_pocket_dependency', | 33 | 'default_pocket_dependency', |
21 | 33 | 'get_components_for_building', | 34 | 'expand_dependencies', |
22 | 35 | 'get_components_for_context', | ||
23 | 34 | 'get_primary_current_component', | 36 | 'get_primary_current_component', |
24 | 35 | 'get_sources_list_for_building', | 37 | 'get_sources_list_for_building', |
25 | 36 | 'pocket_dependencies', | 38 | 'pocket_dependencies', |
26 | @@ -86,19 +88,20 @@ | |||
27 | 86 | default_component_dependency_name = 'multiverse' | 88 | default_component_dependency_name = 'multiverse' |
28 | 87 | 89 | ||
29 | 88 | 90 | ||
31 | 89 | def get_components_for_building(build): | 91 | def get_components_for_context(component, pocket): |
32 | 90 | """Return the components allowed to be used in the build context. | 92 | """Return the components allowed to be used in the build context. |
33 | 91 | 93 | ||
35 | 92 | :param build: a context `IBuild`. | 94 | :param component: the context `IComponent`. |
36 | 95 | :param pocket: the context `IPocket`. | ||
37 | 93 | :return: a list of component names. | 96 | :return: a list of component names. |
38 | 94 | """ | 97 | """ |
39 | 95 | # BACKPORTS should be able to fetch build dependencies from any | 98 | # BACKPORTS should be able to fetch build dependencies from any |
40 | 96 | # component in order to cope with component changes occurring | 99 | # component in order to cope with component changes occurring |
43 | 97 | # accross distroseries. See bug #198936 for further information. | 100 | # across distroseries. See bug #198936 for further information. |
44 | 98 | if build.pocket == PackagePublishingPocket.BACKPORTS: | 101 | if pocket == PackagePublishingPocket.BACKPORTS: |
45 | 99 | return component_dependencies['multiverse'] | 102 | return component_dependencies['multiverse'] |
46 | 100 | 103 | ||
48 | 101 | return component_dependencies[build.current_component.name] | 104 | return component_dependencies[component.name] |
49 | 102 | 105 | ||
50 | 103 | 106 | ||
51 | 104 | def get_primary_current_component(archive, distroseries, sourcepackagename): | 107 | def get_primary_current_component(archive, distroseries, sourcepackagename): |
52 | @@ -119,6 +122,54 @@ | |||
53 | 119 | return 'universe' | 122 | return 'universe' |
54 | 120 | 123 | ||
55 | 121 | 124 | ||
56 | 125 | def expand_dependencies(archive, distro_series, pocket, component, | ||
57 | 126 | source_package_name): | ||
58 | 127 | """Return the set of dependency archives, pockets and components. | ||
59 | 128 | |||
60 | 129 | :param archive: the context `IArchive`. | ||
61 | 130 | :param distro_series: the context `IDistroSeries`. | ||
62 | 131 | :param pocket: the context `PackagePublishingPocket`. | ||
63 | 132 | :param component: the context `IComponent`. | ||
64 | 133 | :param source_package_name: A source package name (as text) | ||
65 | 134 | :return: a list of (archive, pocket, [component]), representing the | ||
66 | 135 | dependencies defined by the given build context. | ||
67 | 136 | """ | ||
68 | 137 | deps = [] | ||
69 | 138 | |||
70 | 139 | # Add implicit self-dependency for non-primary contexts. | ||
71 | 140 | if archive.purpose in ALLOW_RELEASE_BUILDS: | ||
72 | 141 | deps.append(( | ||
73 | 142 | archive, PackagePublishingPocket.RELEASE, | ||
74 | 143 | get_components_for_context(component, pocket))) | ||
75 | 144 | |||
76 | 145 | primary_component = get_primary_current_component( | ||
77 | 146 | archive, distro_series, source_package_name) | ||
78 | 147 | # Consider user-selected archive dependencies. | ||
79 | 148 | for archive_dependency in archive.dependencies: | ||
80 | 149 | # When the dependency component is undefined, we should use | ||
81 | 150 | # the component where the source is published in the primary | ||
82 | 151 | # archive. | ||
83 | 152 | if archive_dependency.component is None: | ||
84 | 153 | components = component_dependencies[primary_component] | ||
85 | 154 | else: | ||
86 | 155 | components = component_dependencies[ | ||
87 | 156 | archive_dependency.component.name] | ||
88 | 157 | # Follow pocket dependencies. | ||
89 | 158 | for pocket in pocket_dependencies[archive_dependency.pocket]: | ||
90 | 159 | deps.append( | ||
91 | 160 | (archive_dependency.dependency, pocket, components)) | ||
92 | 161 | |||
93 | 162 | # Consider primary archive dependency override. Add the default | ||
94 | 163 | # primary archive dependencies if it's not present. | ||
95 | 164 | if archive.getArchiveDependency( | ||
96 | 165 | archive.distribution.main_archive) is None: | ||
97 | 166 | primary_dependencies = _get_default_primary_dependencies( | ||
98 | 167 | archive, component, pocket) | ||
99 | 168 | deps.extend(primary_dependencies) | ||
100 | 169 | |||
101 | 170 | return deps | ||
102 | 171 | |||
103 | 172 | |||
104 | 122 | def get_sources_list_for_building(build, distroarchseries, sourcepackagename): | 173 | def get_sources_list_for_building(build, distroarchseries, sourcepackagename): |
105 | 123 | """Return the sources_list entries required to build the given item. | 174 | """Return the sources_list entries required to build the given item. |
106 | 124 | 175 | ||
107 | @@ -133,17 +184,13 @@ | |||
108 | 133 | :param sourcepackagename: A source package name (as text) | 184 | :param sourcepackagename: A source package name (as text) |
109 | 134 | :return: a deb sources_list entries (lines). | 185 | :return: a deb sources_list entries (lines). |
110 | 135 | """ | 186 | """ |
122 | 136 | deps = [] | 187 | deps = expand_dependencies( |
123 | 137 | sources_list_lines = [] | 188 | build.archive, distroarchseries.distroseries, build.pocket, |
124 | 138 | 189 | build.current_component, sourcepackagename) | |
125 | 139 | # Add implicit self-dependency for non-primary contexts. | 190 | sources_list_lines = \ |
126 | 140 | if build.archive.purpose in ALLOW_RELEASE_BUILDS: | 191 | _get_sources_list_for_dependencies(deps, distroarchseries) |
127 | 141 | self_dep = [( | 192 | |
128 | 142 | build.archive, PackagePublishingPocket.RELEASE, | 193 | external_dep_lines = [] |
118 | 143 | get_components_for_building(build))] | ||
119 | 144 | sources_list_lines = _get_sources_list_for_dependencies( | ||
120 | 145 | self_dep, distroarchseries) | ||
121 | 146 | |||
129 | 147 | # Append external sources_list lines for this archive if it's | 194 | # Append external sources_list lines for this archive if it's |
130 | 148 | # specified in the configuration. | 195 | # specified in the configuration. |
131 | 149 | try: | 196 | try: |
132 | @@ -152,7 +199,7 @@ | |||
133 | 152 | for archive_dep in dependencies.splitlines(): | 199 | for archive_dep in dependencies.splitlines(): |
134 | 153 | line = archive_dep % ( | 200 | line = archive_dep % ( |
135 | 154 | {'series': distroarchseries.distroseries.name}) | 201 | {'series': distroarchseries.distroseries.name}) |
137 | 155 | sources_list_lines.append(line) | 202 | external_dep_lines.append(line) |
138 | 156 | except StandardError, e: | 203 | except StandardError, e: |
139 | 157 | # Malformed external dependencies can incapacitate the build farm | 204 | # Malformed external dependencies can incapacitate the build farm |
140 | 158 | # manager (lp:516169). That's obviously not acceptable. | 205 | # manager (lp:516169). That's obviously not acceptable. |
141 | @@ -166,34 +213,13 @@ | |||
142 | 166 | if build.archive.enabled == True: | 213 | if build.archive.enabled == True: |
143 | 167 | build.archive.disable() | 214 | build.archive.disable() |
144 | 168 | 215 | ||
173 | 169 | # Consider user-selected archive dependencies. | 216 | # For an unknown reason (perhaps because OEM has archives with |
174 | 170 | primary_component = get_primary_current_component( | 217 | # binaries that need to override primary binaries of the same |
175 | 171 | build.archive, build.distro_series, sourcepackagename) | 218 | # version), we want the external dependency lines to show up second: |
176 | 172 | for archive_dependency in build.archive.dependencies: | 219 | # after the archive itself, but before any other dependencies. |
177 | 173 | # When the dependency component is undefined, we should use | 220 | return [sources_list_lines[0]] + external_dep_lines + \ |
178 | 174 | # the component where the source is published in the primary | 221 | sources_list_lines[1:] |
179 | 175 | # archive. | 222 | |
152 | 176 | if archive_dependency.component is None: | ||
153 | 177 | components = component_dependencies[primary_component] | ||
154 | 178 | else: | ||
155 | 179 | components = component_dependencies[ | ||
156 | 180 | archive_dependency.component.name] | ||
157 | 181 | # Follow pocket dependencies. | ||
158 | 182 | for pocket in pocket_dependencies[archive_dependency.pocket]: | ||
159 | 183 | deps.append( | ||
160 | 184 | (archive_dependency.dependency, pocket, components) | ||
161 | 185 | ) | ||
162 | 186 | |||
163 | 187 | # Consider primary archive dependency override. Add the default | ||
164 | 188 | # primary archive dependencies if it's not present. | ||
165 | 189 | if build.archive.getArchiveDependency( | ||
166 | 190 | build.archive.distribution.main_archive) is None: | ||
167 | 191 | primary_dependencies = _get_default_primary_dependencies(build) | ||
168 | 192 | deps.extend(primary_dependencies) | ||
169 | 193 | |||
170 | 194 | sources_list_lines.extend( | ||
171 | 195 | _get_sources_list_for_dependencies(deps, distroarchseries)) | ||
172 | 196 | return sources_list_lines | ||
180 | 197 | 223 | ||
181 | 198 | def _has_published_binaries(archive, distroarchseries, pocket): | 224 | def _has_published_binaries(archive, distroarchseries, pocket): |
182 | 199 | """Whether or not the archive dependency has published binaries.""" | 225 | """Whether or not the archive dependency has published binaries.""" |
183 | @@ -252,27 +278,29 @@ | |||
184 | 252 | return sources_list_lines | 278 | return sources_list_lines |
185 | 253 | 279 | ||
186 | 254 | 280 | ||
189 | 255 | def _get_default_primary_dependencies(build): | 281 | def _get_default_primary_dependencies(archive, component, pocket): |
190 | 256 | """Return the default primary dependencies for a given build. | 282 | """Return the default primary dependencies for a given context. |
191 | 257 | 283 | ||
193 | 258 | :param build: the `IBuild` context; | 284 | :param archive: the context `IArchive`. |
194 | 285 | :param component: the context `IComponent`. | ||
195 | 286 | :param pocket: the context `PackagePublishingPocket`. | ||
196 | 259 | 287 | ||
197 | 260 | :return: a list containing the default dependencies to primary | 288 | :return: a list containing the default dependencies to primary |
198 | 261 | archive. | 289 | archive. |
199 | 262 | """ | 290 | """ |
201 | 263 | if build.archive.purpose in ALLOW_RELEASE_BUILDS: | 291 | if archive.purpose in ALLOW_RELEASE_BUILDS: |
202 | 264 | primary_pockets = pocket_dependencies[ | 292 | primary_pockets = pocket_dependencies[ |
203 | 265 | default_pocket_dependency] | 293 | default_pocket_dependency] |
204 | 266 | primary_components = component_dependencies[ | 294 | primary_components = component_dependencies[ |
205 | 267 | default_component_dependency_name] | 295 | default_component_dependency_name] |
206 | 268 | else: | 296 | else: |
209 | 269 | primary_pockets = pocket_dependencies[build.pocket] | 297 | primary_pockets = pocket_dependencies[pocket] |
210 | 270 | primary_components = get_components_for_building(build) | 298 | primary_components = get_components_for_context(component, pocket) |
211 | 271 | 299 | ||
212 | 272 | primary_dependencies = [] | 300 | primary_dependencies = [] |
213 | 273 | for pocket in primary_pockets: | 301 | for pocket in primary_pockets: |
214 | 274 | primary_dependencies.append( | 302 | primary_dependencies.append( |
216 | 275 | (build.distro_series.distribution.main_archive, pocket, | 303 | (archive.distribution.main_archive, pocket, |
217 | 276 | primary_components)) | 304 | primary_components)) |
218 | 277 | 305 | ||
219 | 278 | return primary_dependencies | 306 | return primary_dependencies |
220 | 279 | 307 | ||
221 | === modified file 'lib/lp/soyuz/doc/archive-dependencies.txt' | |||
222 | --- lib/lp/soyuz/doc/archive-dependencies.txt 2010-05-10 19:49:02 +0000 | |||
223 | +++ lib/lp/soyuz/doc/archive-dependencies.txt 2010-07-20 09:26:10 +0000 | |||
224 | @@ -97,7 +97,7 @@ | |||
225 | 97 | ... 'main', 'restricted', 'universe', 'multiverse', 'partner'] | 97 | ... 'main', 'restricted', 'universe', 'multiverse', 'partner'] |
226 | 98 | 98 | ||
227 | 99 | >>> from lp.soyuz.adapters.archivedependencies import ( | 99 | >>> from lp.soyuz.adapters.archivedependencies import ( |
229 | 100 | ... get_components_for_building) | 100 | ... get_components_for_context) |
230 | 101 | 101 | ||
231 | 102 | >>> ogre_pub = test_publisher.getPubSource(sourcename='ogre') | 102 | >>> ogre_pub = test_publisher.getPubSource(sourcename='ogre') |
232 | 103 | >>> [ogre_build] = ogre_pub.createMissingBuilds() | 103 | >>> [ogre_build] = ogre_pub.createMissingBuilds() |
233 | @@ -111,7 +111,8 @@ | |||
234 | 111 | ... syncUpdate(ogre_pub) | 111 | ... syncUpdate(ogre_pub) |
235 | 112 | ... flush_database_caches() | 112 | ... flush_database_caches() |
236 | 113 | ... components_term = " ".join( | 113 | ... components_term = " ".join( |
238 | 114 | ... get_components_for_building(ogre_build)) | 114 | ... get_components_for_context( |
239 | 115 | ... ogre_build.current_component, ogre_build.pocket)) | ||
240 | 115 | ... print '%10s | %s' % (ogre_build.current_component.name, | 116 | ... print '%10s | %s' % (ogre_build.current_component.name, |
241 | 116 | ... components_term) | 117 | ... components_term) |
242 | 117 | 118 | ||
243 | @@ -566,4 +567,3 @@ | |||
244 | 566 | main restricted universe multiverse | 567 | main restricted universe multiverse |
245 | 567 | deb http://ftpmaster.internal/ubuntu hoary-updates | 568 | deb http://ftpmaster.internal/ubuntu hoary-updates |
246 | 568 | main restricted universe multiverse | 569 | main restricted universe multiverse |
247 | 569 | |||
248 | 570 | 570 | ||
249 | === modified file 'lib/lp/soyuz/doc/archive.txt' | |||
250 | --- lib/lp/soyuz/doc/archive.txt 2010-07-02 21:25:36 +0000 | |||
251 | +++ lib/lp/soyuz/doc/archive.txt 2010-07-20 09:26:10 +0000 | |||
252 | @@ -1285,72 +1285,6 @@ | |||
253 | 1285 | ... | 1285 | ... |
254 | 1286 | AssertionError: This dependency does not exist. | 1286 | AssertionError: This dependency does not exist. |
255 | 1287 | 1287 | ||
256 | 1288 | == Find binary package dependency candidates == | ||
257 | 1289 | |||
258 | 1290 | Archive allows a lookup on a single binary package dependency | ||
259 | 1291 | candidate by its name, via the `PublishedPackage` table: | ||
260 | 1292 | |||
261 | 1293 | >>> warty_i386 = warty['i386'] | ||
262 | 1294 | |||
263 | 1295 | >>> candidate = ubuntu.main_archive.findDepCandidateByName( | ||
264 | 1296 | ... warty_i386, "pmount") | ||
265 | 1297 | >>> print candidate.binarypackagerelease.binarypackagename.name | ||
266 | 1298 | pmount | ||
267 | 1299 | |||
268 | 1300 | >>> candidate = cprov.archive.findDepCandidateByName( | ||
269 | 1301 | ... warty_i386, "pmount") | ||
270 | 1302 | >>> print candidate.binarypackagerelease.binarypackagename.name | ||
271 | 1303 | pmount | ||
272 | 1304 | |||
273 | 1305 | Since 'python2.4' isn't available in our sampledata (not even | ||
274 | 1306 | published), None is returned: | ||
275 | 1307 | |||
276 | 1308 | >>> print ubuntu.main_archive.findDepCandidateByName( | ||
277 | 1309 | ... warty_i386, "python2.4") | ||
278 | 1310 | None | ||
279 | 1311 | |||
280 | 1312 | >>> print cprov.archive.findDepCandidateByName( | ||
281 | 1313 | ... warty_i386, "python2.4") | ||
282 | 1314 | None | ||
283 | 1315 | |||
284 | 1316 | This method is aware of the archive dependency tree. So, even when a | ||
285 | 1317 | package is not published on the context PPA but is available somewhere | ||
286 | 1318 | in the archive dependency domain it will be found. | ||
287 | 1319 | |||
288 | 1320 | We also add another archive dependency here to exercise findDepCandidateByName | ||
289 | 1321 | a little more. | ||
290 | 1322 | |||
291 | 1323 | >>> joe = factory.makePerson(email='joe@example.com') | ||
292 | 1324 | >>> second_ppa = factory.makeArchive(name="secondppa", owner=joe) | ||
293 | 1325 | >>> second_archive_dep = cprov.archive.addArchiveDependency( | ||
294 | 1326 | ... second_ppa, release_pocket, main_component) | ||
295 | 1327 | |||
296 | 1328 | 'at' binary package is not present in Celso's PPA. | ||
297 | 1329 | |||
298 | 1330 | >>> cprov_archive.getAllPublishedBinaries(name='at').count() | ||
299 | 1331 | 0 | ||
300 | 1332 | |||
301 | 1333 | But it is available in PRIMARY ubuntu archive. | ||
302 | 1334 | |||
303 | 1335 | >>> primary_candidate = ubuntu.main_archive.findDepCandidateByName( | ||
304 | 1336 | ... warty_i386, "at") | ||
305 | 1337 | >>> primary_candidate is not None | ||
306 | 1338 | True | ||
307 | 1339 | |||
308 | 1340 | Then a lookup on Celso's PPA will find it. | ||
309 | 1341 | |||
310 | 1342 | >>> ppa_candidate = cprov.archive.findDepCandidateByName( | ||
311 | 1343 | ... warty_i386, "at") | ||
312 | 1344 | >>> ppa_candidate is not None | ||
313 | 1345 | True | ||
314 | 1346 | |||
315 | 1347 | >>> primary_candidate == ppa_candidate | ||
316 | 1348 | True | ||
317 | 1349 | |||
318 | 1350 | And clean-up after ourselves: | ||
319 | 1351 | |||
320 | 1352 | >>> ignore = cprov.archive.removeArchiveDependency(second_ppa) | ||
321 | 1353 | |||
322 | 1354 | == Creating a package copy request from an IArchive == | 1288 | == Creating a package copy request from an IArchive == |
323 | 1355 | 1289 | ||
324 | 1356 | The IArchive interface includes a convenience method for creating a | 1290 | The IArchive interface includes a convenience method for creating a |
325 | @@ -1529,7 +1463,7 @@ | |||
326 | 1529 | 1463 | ||
327 | 1530 | >>> archive_purposes = [archive.purpose.name for archive in archive_set] | 1464 | >>> archive_purposes = [archive.purpose.name for archive in archive_set] |
328 | 1531 | >>> len(archive_purposes) | 1465 | >>> len(archive_purposes) |
330 | 1532 | 19 | 1466 | 18 |
331 | 1533 | 1467 | ||
332 | 1534 | >>> print sorted(set(archive_purposes)) | 1468 | >>> print sorted(set(archive_purposes)) |
333 | 1535 | ['COPY', 'DEBUG', 'PARTNER', 'PPA', 'PRIMARY'] | 1469 | ['COPY', 'DEBUG', 'PARTNER', 'PPA', 'PRIMARY'] |
334 | 1536 | 1470 | ||
335 | === modified file 'lib/lp/soyuz/doc/binarypackagebuild.txt' | |||
336 | --- lib/lp/soyuz/doc/binarypackagebuild.txt 2010-06-10 22:12:08 +0000 | |||
337 | +++ lib/lp/soyuz/doc/binarypackagebuild.txt 2010-07-20 09:26:10 +0000 | |||
338 | @@ -987,8 +987,9 @@ | |||
339 | 987 | main | 987 | main |
340 | 988 | 988 | ||
341 | 989 | >>> from lp.soyuz.adapters.archivedependencies import ( | 989 | >>> from lp.soyuz.adapters.archivedependencies import ( |
344 | 990 | ... get_components_for_building) | 990 | ... get_components_for_context) |
345 | 991 | >>> print get_components_for_building(depwait_build) | 991 | >>> print get_components_for_context( |
346 | 992 | ... depwait_build.current_component, depwait_build.pocket) | ||
347 | 992 | ['main'] | 993 | ['main'] |
348 | 993 | 994 | ||
349 | 994 | Thus the 'pmount' dependency remains unsatisfied. | 995 | Thus the 'pmount' dependency remains unsatisfied. |
350 | @@ -1036,7 +1037,8 @@ | |||
351 | 1036 | >>> flush_database_caches() | 1037 | >>> flush_database_caches() |
352 | 1037 | >>> login(ANONYMOUS) | 1038 | >>> login(ANONYMOUS) |
353 | 1038 | 1039 | ||
355 | 1039 | >>> print get_components_for_building(depwait_build) | 1040 | >>> print get_components_for_context( |
356 | 1041 | ... depwait_build.current_component, depwait_build.pocket) | ||
357 | 1040 | ['main'] | 1042 | ['main'] |
358 | 1041 | 1043 | ||
359 | 1042 | >>> print pmount_pub.component.name | 1044 | >>> print pmount_pub.component.name |
360 | 1043 | 1045 | ||
361 | === modified file 'lib/lp/soyuz/interfaces/archive.py' | |||
362 | --- lib/lp/soyuz/interfaces/archive.py 2010-07-12 08:45:32 +0000 | |||
363 | +++ lib/lp/soyuz/interfaces/archive.py 2010-07-20 09:26:10 +0000 | |||
364 | @@ -443,11 +443,24 @@ | |||
365 | 443 | Person table indexes while searching. | 443 | Person table indexes while searching. |
366 | 444 | """ | 444 | """ |
367 | 445 | 445 | ||
373 | 446 | def findDepCandidateByName(distroarchseries, name): | 446 | def findDepCandidates(distro_arch_series, pocket, component, |
374 | 447 | """Return the last published binarypackage by given name. | 447 | source_package_name, dep_name): |
375 | 448 | 448 | """Return matching binaries in this archive and its dependencies. | |
376 | 449 | Return the `BinaryPackagePublishingHistory` record by distroarchseries | 449 | |
377 | 450 | and name, or None if not found. | 450 | Return all published `IBinaryPackagePublishingHistory` records with |
378 | 451 | the given name, in this archive and dependencies as specified by the | ||
379 | 452 | given build context, using the usual archive dependency rules. | ||
380 | 453 | |||
381 | 454 | We can't just use the first, since there may be other versions | ||
382 | 455 | published in other dependency archives. | ||
383 | 456 | |||
384 | 457 | :param distro_arch_series: the context `IDistroArchSeries`. | ||
385 | 458 | :param pocket: the context `PackagePublishingPocket`. | ||
386 | 459 | :param component: the context `IComponent`. | ||
387 | 460 | :param source_package_name: the context source package name (as text). | ||
388 | 461 | :param dep_name: the name of the binary package to look up. | ||
389 | 462 | :return: a sequence of matching `IBinaryPackagePublishingHistory` | ||
390 | 463 | records. | ||
391 | 451 | """ | 464 | """ |
392 | 452 | 465 | ||
393 | 453 | def removeArchiveDependency(dependency): | 466 | def removeArchiveDependency(dependency): |
394 | 454 | 467 | ||
395 | === modified file 'lib/lp/soyuz/model/archive.py' | |||
396 | --- lib/lp/soyuz/model/archive.py 2010-07-12 08:45:32 +0000 | |||
397 | +++ lib/lp/soyuz/model/archive.py 2010-07-20 09:26:10 +0000 | |||
398 | @@ -37,6 +37,7 @@ | |||
399 | 37 | from lp.buildmaster.model.buildfarmjob import BuildFarmJob | 37 | from lp.buildmaster.model.buildfarmjob import BuildFarmJob |
400 | 38 | from lp.buildmaster.model.packagebuild import PackageBuild | 38 | from lp.buildmaster.model.packagebuild import PackageBuild |
401 | 39 | from lp.services.job.interfaces.job import JobStatus | 39 | from lp.services.job.interfaces.job import JobStatus |
402 | 40 | from lp.soyuz.adapters.archivedependencies import expand_dependencies | ||
403 | 40 | from lp.soyuz.adapters.packagelocation import PackageLocation | 41 | from lp.soyuz.adapters.packagelocation import PackageLocation |
404 | 41 | from canonical.launchpad.components.tokens import ( | 42 | from canonical.launchpad.components.tokens import ( |
405 | 42 | create_unique_token_for_table) | 43 | create_unique_token_for_table) |
406 | @@ -47,6 +48,7 @@ | |||
407 | 47 | from lp.soyuz.model.binarypackagerelease import ( | 48 | from lp.soyuz.model.binarypackagerelease import ( |
408 | 48 | BinaryPackageReleaseDownloadCount) | 49 | BinaryPackageReleaseDownloadCount) |
409 | 49 | from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild | 50 | from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild |
410 | 51 | from lp.soyuz.model.component import Component | ||
411 | 50 | from lp.soyuz.model.distributionsourcepackagecache import ( | 52 | from lp.soyuz.model.distributionsourcepackagecache import ( |
412 | 51 | DistributionSourcePackageCache) | 53 | DistributionSourcePackageCache) |
413 | 52 | from lp.soyuz.model.distroseriespackagecache import DistroSeriesPackageCache | 54 | from lp.soyuz.model.distroseriespackagecache import DistroSeriesPackageCache |
414 | @@ -807,30 +809,32 @@ | |||
415 | 807 | self.sources_cached = sources_cached.count() | 809 | self.sources_cached = sources_cached.count() |
416 | 808 | self.binaries_cached = binaries_cached.count() | 810 | self.binaries_cached = binaries_cached.count() |
417 | 809 | 811 | ||
419 | 810 | def findDepCandidateByName(self, distroarchseries, name): | 812 | def findDepCandidates(self, distro_arch_series, pocket, component, |
420 | 813 | source_package_name, dep_name): | ||
421 | 811 | """See `IArchive`.""" | 814 | """See `IArchive`.""" |
429 | 812 | archives = [] | 815 | deps = expand_dependencies( |
430 | 813 | if self.is_ppa: | 816 | self, distro_arch_series.distroseries, pocket, component, |
431 | 814 | archives.append(self.distribution.main_archive.id) | 817 | source_package_name) |
432 | 815 | archives.append(self.id) | 818 | archive_clause = Or([And( |
433 | 816 | archives.extend( | 819 | BinaryPackagePublishingHistory.archiveID == archive.id, |
434 | 817 | IResultSet(self.dependencies).values( | 820 | BinaryPackagePublishingHistory.pocket == pocket, |
435 | 818 | ArchiveDependency.dependencyID)) | 821 | Component.name.is_in(components)) |
436 | 822 | for (archive, pocket, components) in deps]) | ||
437 | 819 | 823 | ||
438 | 820 | store = ISlaveStore(BinaryPackagePublishingHistory) | 824 | store = ISlaveStore(BinaryPackagePublishingHistory) |
440 | 821 | candidate = store.find( | 825 | return store.find( |
441 | 822 | BinaryPackagePublishingHistory, | 826 | BinaryPackagePublishingHistory, |
443 | 823 | BinaryPackageName.name == name, | 827 | BinaryPackageName.name == dep_name, |
444 | 824 | BinaryPackageRelease.binarypackagename == BinaryPackageName.id, | 828 | BinaryPackageRelease.binarypackagename == BinaryPackageName.id, |
445 | 825 | BinaryPackagePublishingHistory.binarypackagerelease == | 829 | BinaryPackagePublishingHistory.binarypackagerelease == |
446 | 826 | BinaryPackageRelease.id, | 830 | BinaryPackageRelease.id, |
447 | 827 | BinaryPackagePublishingHistory.distroarchseries == | 831 | BinaryPackagePublishingHistory.distroarchseries == |
450 | 828 | distroarchseries, | 832 | distro_arch_series, |
449 | 829 | In(BinaryPackagePublishingHistory.archiveID, archives), | ||
451 | 830 | BinaryPackagePublishingHistory.status == | 833 | BinaryPackagePublishingHistory.status == |
455 | 831 | PackagePublishingStatus.PUBLISHED | 834 | PackagePublishingStatus.PUBLISHED, |
456 | 832 | ).order_by(Desc(BinaryPackagePublishingHistory.id)) | 835 | BinaryPackagePublishingHistory.componentID == Component.id, |
457 | 833 | return candidate.first() | 836 | archive_clause).order_by( |
458 | 837 | Desc(BinaryPackagePublishingHistory.id)) | ||
459 | 834 | 838 | ||
460 | 835 | def getArchiveDependency(self, dependency): | 839 | def getArchiveDependency(self, dependency): |
461 | 836 | """See `IArchive`.""" | 840 | """See `IArchive`.""" |
462 | 837 | 841 | ||
463 | === modified file 'lib/lp/soyuz/model/binarypackagebuild.py' | |||
464 | --- lib/lp/soyuz/model/binarypackagebuild.py 2010-06-15 11:11:27 +0000 | |||
465 | +++ lib/lp/soyuz/model/binarypackagebuild.py 2010-07-20 09:26:10 +0000 | |||
466 | @@ -50,7 +50,6 @@ | |||
467 | 50 | from lp.buildmaster.model.packagebuild import ( | 50 | from lp.buildmaster.model.packagebuild import ( |
468 | 51 | PackageBuild, PackageBuildDerived) | 51 | PackageBuild, PackageBuildDerived) |
469 | 52 | from lp.services.job.model.job import Job | 52 | from lp.services.job.model.job import Job |
470 | 53 | from lp.soyuz.adapters.archivedependencies import get_components_for_building | ||
471 | 54 | from lp.soyuz.interfaces.archive import ArchivePurpose | 53 | from lp.soyuz.interfaces.archive import ArchivePurpose |
472 | 55 | from lp.soyuz.interfaces.binarypackagebuild import ( | 54 | from lp.soyuz.interfaces.binarypackagebuild import ( |
473 | 56 | BuildSetStatus, CannotBeRescored, IBinaryPackageBuild, | 55 | BuildSetStatus, CannotBeRescored, IBinaryPackageBuild, |
474 | @@ -387,33 +386,25 @@ | |||
475 | 387 | def _isDependencySatisfied(self, token): | 386 | def _isDependencySatisfied(self, token): |
476 | 388 | """Check if the given dependency token is satisfied. | 387 | """Check if the given dependency token is satisfied. |
477 | 389 | 388 | ||
480 | 390 | Check if the dependency exists, if its version constraint is | 389 | Check if the dependency exists and that its version constraint is |
481 | 391 | satisfied and if it is reachable in the build context. | 390 | satisfied. |
482 | 392 | """ | 391 | """ |
483 | 393 | name, version, relation = self._parseDependencyToken(token) | 392 | name, version, relation = self._parseDependencyToken(token) |
484 | 394 | 393 | ||
507 | 395 | dep_candidate = self.archive.findDepCandidateByName( | 394 | # There may be several published versions in the available |
508 | 396 | self.distro_arch_series, name) | 395 | # archives and pockets. If any one of them satisifies our |
509 | 397 | 396 | # constraints, the dependency is satisfied. | |
510 | 398 | if not dep_candidate: | 397 | dep_candidates = self.archive.findDepCandidates( |
511 | 399 | return False | 398 | self.distro_arch_series, self.pocket, self.current_component, |
512 | 400 | 399 | self.source_package_release.sourcepackagename.name, name) | |
513 | 401 | if not self._checkDependencyVersion( | 400 | |
514 | 402 | dep_candidate.binarypackagerelease.version, version, relation): | 401 | for dep_candidate in dep_candidates: |
515 | 403 | return False | 402 | if self._checkDependencyVersion( |
516 | 404 | 403 | dep_candidate.binarypackagerelease.version, version, | |
517 | 405 | # Only PRIMARY archive build dependencies should be restricted | 404 | relation): |
518 | 406 | # to the ogre_components. Both PARTNER and PPA can reach | 405 | return True |
519 | 407 | # dependencies from all components in the PRIMARY archive. | 406 | |
520 | 408 | # Moreover, PARTNER and PPA component domain is single, i.e, | 407 | return False |
499 | 409 | # PARTNER only contains packages in 'partner' component and PPAs | ||
500 | 410 | # only contains packages in 'main' component. | ||
501 | 411 | ogre_components = get_components_for_building(self) | ||
502 | 412 | if (self.archive.purpose == ArchivePurpose.PRIMARY and | ||
503 | 413 | dep_candidate.component.name not in ogre_components): | ||
504 | 414 | return False | ||
505 | 415 | |||
506 | 416 | return True | ||
521 | 417 | 408 | ||
522 | 418 | def _toAptFormat(self, token): | 409 | def _toAptFormat(self, token): |
523 | 419 | """Rebuild dependencies line in apt format.""" | 410 | """Rebuild dependencies line in apt format.""" |
524 | 420 | 411 | ||
525 | === modified file 'lib/lp/soyuz/tests/test_archive.py' | |||
526 | --- lib/lp/soyuz/tests/test_archive.py 2010-07-12 13:32:53 +0000 | |||
527 | +++ lib/lp/soyuz/tests/test_archive.py 2010-07-20 09:26:10 +0000 | |||
528 | @@ -4,9 +4,10 @@ | |||
529 | 4 | """Test Archive features.""" | 4 | """Test Archive features.""" |
530 | 5 | 5 | ||
531 | 6 | from datetime import date, datetime, timedelta | 6 | from datetime import date, datetime, timedelta |
532 | 7 | import unittest | ||
533 | 8 | |||
534 | 7 | import pytz | 9 | import pytz |
537 | 8 | import unittest | 10 | import transaction |
536 | 9 | |||
538 | 10 | from zope.component import getUtility | 11 | from zope.component import getUtility |
539 | 11 | from zope.security.interfaces import Unauthorized | 12 | from zope.security.interfaces import Unauthorized |
540 | 12 | from zope.security.proxy import removeSecurityProxy | 13 | from zope.security.proxy import removeSecurityProxy |
541 | @@ -1099,7 +1100,141 @@ | |||
542 | 1099 | login("commercial-member@canonical.com") | 1100 | login("commercial-member@canonical.com") |
543 | 1100 | self.setCommercial(self.archive, True) | 1101 | self.setCommercial(self.archive, True) |
544 | 1101 | self.assertTrue(self.archive.commercial) | 1102 | self.assertTrue(self.archive.commercial) |
546 | 1102 | 1103 | ||
547 | 1104 | |||
548 | 1105 | class TestFindDepCandidates(TestCaseWithFactory): | ||
549 | 1106 | """Tests for Archive.findDepCandidates.""" | ||
550 | 1107 | |||
551 | 1108 | layer = LaunchpadZopelessLayer | ||
552 | 1109 | |||
553 | 1110 | def setUp(self): | ||
554 | 1111 | super(TestFindDepCandidates, self).setUp() | ||
555 | 1112 | self.archive = self.factory.makeArchive() | ||
556 | 1113 | self.publisher = SoyuzTestPublisher() | ||
557 | 1114 | login('admin@canonical.com') | ||
558 | 1115 | self.publisher.prepareBreezyAutotest() | ||
559 | 1116 | |||
560 | 1117 | def assertDep(self, arch_tag, name, expected, archive=None, | ||
561 | 1118 | pocket=PackagePublishingPocket.RELEASE, component=None, | ||
562 | 1119 | source_package_name='something-new'): | ||
563 | 1120 | """Helper to check that findDepCandidates works. | ||
564 | 1121 | |||
565 | 1122 | Searches for the given dependency name in the given architecture and | ||
566 | 1123 | archive, and compares it to the given expected value. | ||
567 | 1124 | The archive defaults to self.archive. | ||
568 | 1125 | |||
569 | 1126 | Also commits, since findDepCandidates uses the slave store. | ||
570 | 1127 | """ | ||
571 | 1128 | transaction.commit() | ||
572 | 1129 | |||
573 | 1130 | if component is None: | ||
574 | 1131 | component = getUtility(IComponentSet)['main'] | ||
575 | 1132 | if archive is None: | ||
576 | 1133 | archive = self.archive | ||
577 | 1134 | |||
578 | 1135 | self.assertEquals( | ||
579 | 1136 | list( | ||
580 | 1137 | archive.findDepCandidates( | ||
581 | 1138 | self.publisher.distroseries[arch_tag], pocket, component, | ||
582 | 1139 | source_package_name, name)), | ||
583 | 1140 | expected) | ||
584 | 1141 | |||
585 | 1142 | def test_finds_candidate_in_same_archive(self): | ||
586 | 1143 | # A published candidate in the same archive should be found. | ||
587 | 1144 | bins = self.publisher.getPubBinaries( | ||
588 | 1145 | binaryname='foo', archive=self.archive, | ||
589 | 1146 | status=PackagePublishingStatus.PUBLISHED) | ||
590 | 1147 | self.assertDep('i386', 'foo', [bins[0]]) | ||
591 | 1148 | self.assertDep('hppa', 'foo', [bins[1]]) | ||
592 | 1149 | |||
593 | 1150 | def test_does_not_find_pending_publication(self): | ||
594 | 1151 | # A pending candidate in the same archive should not be found. | ||
595 | 1152 | bins = self.publisher.getPubBinaries( | ||
596 | 1153 | binaryname='foo', archive=self.archive) | ||
597 | 1154 | self.assertDep('i386', 'foo', []) | ||
598 | 1155 | |||
599 | 1156 | def test_ppa_searches_primary_archive(self): | ||
600 | 1157 | # PPA searches implicitly look in the primary archive too. | ||
601 | 1158 | self.assertEquals(self.archive.purpose, ArchivePurpose.PPA) | ||
602 | 1159 | self.assertDep('i386', 'foo', []) | ||
603 | 1160 | |||
604 | 1161 | bins = self.publisher.getPubBinaries( | ||
605 | 1162 | binaryname='foo', archive=self.archive.distribution.main_archive, | ||
606 | 1163 | status=PackagePublishingStatus.PUBLISHED) | ||
607 | 1164 | |||
608 | 1165 | self.assertDep('i386', 'foo', [bins[0]]) | ||
609 | 1166 | |||
610 | 1167 | def test_searches_dependencies(self): | ||
611 | 1168 | # Candidates from archives on which the target explicitly depends | ||
612 | 1169 | # should be found. | ||
613 | 1170 | bins = self.publisher.getPubBinaries( | ||
614 | 1171 | binaryname='foo', archive=self.archive, | ||
615 | 1172 | status=PackagePublishingStatus.PUBLISHED) | ||
616 | 1173 | other_archive = self.factory.makeArchive() | ||
617 | 1174 | self.assertDep('i386', 'foo', [], archive=other_archive) | ||
618 | 1175 | |||
619 | 1176 | other_archive.addArchiveDependency( | ||
620 | 1177 | self.archive, PackagePublishingPocket.RELEASE) | ||
621 | 1178 | self.assertDep('i386', 'foo', [bins[0]], archive=other_archive) | ||
622 | 1179 | |||
623 | 1180 | def test_obeys_dependency_pockets(self): | ||
624 | 1181 | # Only packages published in a pocket matching the dependency should | ||
625 | 1182 | # be found. | ||
626 | 1183 | release_bins = self.publisher.getPubBinaries( | ||
627 | 1184 | binaryname='foo-release', archive=self.archive, | ||
628 | 1185 | status=PackagePublishingStatus.PUBLISHED) | ||
629 | 1186 | updates_bins = self.publisher.getPubBinaries( | ||
630 | 1187 | binaryname='foo-updates', archive=self.archive, | ||
631 | 1188 | status=PackagePublishingStatus.PUBLISHED, | ||
632 | 1189 | pocket=PackagePublishingPocket.UPDATES) | ||
633 | 1190 | proposed_bins = self.publisher.getPubBinaries( | ||
634 | 1191 | binaryname='foo-proposed', archive=self.archive, | ||
635 | 1192 | status=PackagePublishingStatus.PUBLISHED, | ||
636 | 1193 | pocket=PackagePublishingPocket.PROPOSED) | ||
637 | 1194 | |||
638 | 1195 | # Temporarily turn our test PPA into a copy archive, so we can | ||
639 | 1196 | # add non-RELEASE dependencies on it. | ||
640 | 1197 | removeSecurityProxy(self.archive).purpose = ArchivePurpose.COPY | ||
641 | 1198 | |||
642 | 1199 | other_archive = self.factory.makeArchive() | ||
643 | 1200 | other_archive.addArchiveDependency( | ||
644 | 1201 | self.archive, PackagePublishingPocket.UPDATES) | ||
645 | 1202 | self.assertDep( | ||
646 | 1203 | 'i386', 'foo-release', [release_bins[0]], archive=other_archive) | ||
647 | 1204 | self.assertDep( | ||
648 | 1205 | 'i386', 'foo-updates', [updates_bins[0]], archive=other_archive) | ||
649 | 1206 | self.assertDep('i386', 'foo-proposed', [], archive=other_archive) | ||
650 | 1207 | |||
651 | 1208 | other_archive.removeArchiveDependency(self.archive) | ||
652 | 1209 | other_archive.addArchiveDependency( | ||
653 | 1210 | self.archive, PackagePublishingPocket.PROPOSED) | ||
654 | 1211 | self.assertDep( | ||
655 | 1212 | 'i386', 'foo-proposed', [proposed_bins[0]], archive=other_archive) | ||
656 | 1213 | |||
657 | 1214 | def test_obeys_dependency_components(self): | ||
658 | 1215 | # Only packages published in a component matching the dependency | ||
659 | 1216 | # should be found. | ||
660 | 1217 | primary = self.archive.distribution.main_archive | ||
661 | 1218 | main_bins = self.publisher.getPubBinaries( | ||
662 | 1219 | binaryname='foo-main', archive=primary, component='main', | ||
663 | 1220 | status=PackagePublishingStatus.PUBLISHED) | ||
664 | 1221 | universe_bins = self.publisher.getPubBinaries( | ||
665 | 1222 | binaryname='foo-universe', archive=primary, | ||
666 | 1223 | component='universe', | ||
667 | 1224 | status=PackagePublishingStatus.PUBLISHED) | ||
668 | 1225 | |||
669 | 1226 | self.archive.addArchiveDependency( | ||
670 | 1227 | primary, PackagePublishingPocket.RELEASE, | ||
671 | 1228 | component=getUtility(IComponentSet)['main']) | ||
672 | 1229 | self.assertDep('i386', 'foo-main', [main_bins[0]]) | ||
673 | 1230 | self.assertDep('i386', 'foo-universe', []) | ||
674 | 1231 | |||
675 | 1232 | self.archive.removeArchiveDependency(primary) | ||
676 | 1233 | self.archive.addArchiveDependency( | ||
677 | 1234 | primary, PackagePublishingPocket.RELEASE, | ||
678 | 1235 | component=getUtility(IComponentSet)['universe']) | ||
679 | 1236 | self.assertDep('i386', 'foo-main', [main_bins[0]]) | ||
680 | 1237 | self.assertDep('i386', 'foo-universe', [universe_bins[0]]) | ||
681 | 1103 | 1238 | ||
682 | 1104 | 1239 | ||
683 | 1105 | def test_suite(): | 1240 | def test_suite(): |
684 | 1106 | 1241 | ||
685 | === modified file 'lib/lp/soyuz/tests/test_binarypackagebuild.py' | |||
686 | --- lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-06-21 07:26:51 +0000 | |||
687 | +++ lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-07-20 09:26:10 +0000 | |||
688 | @@ -164,13 +164,13 @@ | |||
689 | 164 | Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending on a | 164 | Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending on a |
690 | 165 | binary that exists and is reachable. | 165 | binary that exists and is reachable. |
691 | 166 | """ | 166 | """ |
694 | 167 | test_publisher = SoyuzTestPublisher() | 167 | self.publisher = SoyuzTestPublisher() |
695 | 168 | test_publisher.prepareBreezyAutotest() | 168 | self.publisher.prepareBreezyAutotest() |
696 | 169 | 169 | ||
698 | 170 | depwait_source = test_publisher.getPubSource( | 170 | depwait_source = self.publisher.getPubSource( |
699 | 171 | sourcename='depwait-source') | 171 | sourcename='depwait-source') |
700 | 172 | 172 | ||
702 | 173 | test_publisher.getPubBinaries( | 173 | self.publisher.getPubBinaries( |
703 | 174 | binaryname='dep-bin', | 174 | binaryname='dep-bin', |
704 | 175 | status=PackagePublishingStatus.PUBLISHED) | 175 | status=PackagePublishingStatus.PUBLISHED) |
705 | 176 | 176 | ||
706 | @@ -273,6 +273,41 @@ | |||
707 | 273 | depwait_build.updateDependencies() | 273 | depwait_build.updateDependencies() |
708 | 274 | self.assertEquals(depwait_build.dependencies, '') | 274 | self.assertEquals(depwait_build.dependencies, '') |
709 | 275 | 275 | ||
710 | 276 | def testVersionedDependencies(self): | ||
711 | 277 | # `IBinaryPackageBuild.updateDependencies` supports versioned | ||
712 | 278 | # dependencies. A build will not be retried unless the candidate | ||
713 | 279 | # complies with the version restriction. | ||
714 | 280 | # In this case, dep-bin 666 is available. >> 666 isn't | ||
715 | 281 | # satisified, but >= 666 is. | ||
716 | 282 | depwait_build = self._setupSimpleDepwaitContext() | ||
717 | 283 | self.layer.txn.commit() | ||
718 | 284 | |||
719 | 285 | depwait_build.dependencies = u'dep-bin (>> 666)' | ||
720 | 286 | depwait_build.updateDependencies() | ||
721 | 287 | self.assertEquals(depwait_build.dependencies, u'dep-bin (>> 666)') | ||
722 | 288 | depwait_build.dependencies = u'dep-bin (>= 666)' | ||
723 | 289 | depwait_build.updateDependencies() | ||
724 | 290 | self.assertEquals(depwait_build.dependencies, u'') | ||
725 | 291 | |||
726 | 292 | def testVersionedDependencyOnOldPublication(self): | ||
727 | 293 | # `IBinaryPackageBuild.updateDependencies` doesn't just consider | ||
728 | 294 | # the latest publication. There may be older publications which | ||
729 | 295 | # satisfy the version constraints (in other archives or pockets). | ||
730 | 296 | # In this case, dep-bin 666 and 999 are available, so both = 666 | ||
731 | 297 | # and = 999 are satisfied. | ||
732 | 298 | depwait_build = self._setupSimpleDepwaitContext() | ||
733 | 299 | self.publisher.getPubBinaries( | ||
734 | 300 | binaryname='dep-bin', version='999', | ||
735 | 301 | status=PackagePublishingStatus.PUBLISHED) | ||
736 | 302 | self.layer.txn.commit() | ||
737 | 303 | |||
738 | 304 | depwait_build.dependencies = u'dep-bin (= 666)' | ||
739 | 305 | depwait_build.updateDependencies() | ||
740 | 306 | self.assertEquals(depwait_build.dependencies, u'') | ||
741 | 307 | depwait_build.dependencies = u'dep-bin (= 999)' | ||
742 | 308 | depwait_build.updateDependencies() | ||
743 | 309 | self.assertEquals(depwait_build.dependencies, u'') | ||
744 | 310 | |||
745 | 276 | 311 | ||
746 | 277 | class BaseTestCaseWithThreeBuilds(TestCaseWithFactory): | 312 | class BaseTestCaseWithThreeBuilds(TestCaseWithFactory): |
747 | 278 | 313 | ||
748 | 279 | 314 | ||
749 | === modified file 'lib/lp/soyuz/tests/test_publishing.py' | |||
750 | --- lib/lp/soyuz/tests/test_publishing.py 2010-07-20 09:16:14 +0000 | |||
751 | +++ lib/lp/soyuz/tests/test_publishing.py 2010-07-20 09:26:10 +0000 | |||
752 | @@ -267,7 +267,8 @@ | |||
753 | 267 | pub_source=None, | 267 | pub_source=None, |
754 | 268 | version='666', | 268 | version='666', |
755 | 269 | architecturespecific=False, | 269 | architecturespecific=False, |
757 | 270 | builder=None): | 270 | builder=None, |
758 | 271 | component='main'): | ||
759 | 271 | """Return a list of binary publishing records.""" | 272 | """Return a list of binary publishing records.""" |
760 | 272 | if distroseries is None: | 273 | if distroseries is None: |
761 | 273 | distroseries = self.distroseries | 274 | distroseries = self.distroseries |
762 | @@ -285,7 +286,8 @@ | |||
763 | 285 | pub_source = self.getPubSource( | 286 | pub_source = self.getPubSource( |
764 | 286 | sourcename=sourcename, status=status, pocket=pocket, | 287 | sourcename=sourcename, status=status, pocket=pocket, |
765 | 287 | archive=archive, distroseries=distroseries, | 288 | archive=archive, distroseries=distroseries, |
767 | 288 | version=version, architecturehintlist=architecturehintlist) | 289 | version=version, architecturehintlist=architecturehintlist, |
768 | 290 | component=component) | ||
769 | 289 | else: | 291 | else: |
770 | 290 | archive = pub_source.archive | 292 | archive = pub_source.archive |
771 | 291 | 293 |
Please say /why/ here: list_lines[ 0]] + external_dep_lines + \
+ # We want the external dependency lines to show up second: after the
174 + # archive itself, but before any other dependencies.
175 + return [sources_
e.g. 'for an unknown reason We want ...