61
62
'restricted': ['main', 'restricted'],
62
63
'universe': ['main', 'universe'],
63
64
'multiverse': ['main', 'restricted', 'universe', 'multiverse'],
64
'partner' : ['partner'],
65
'partner': ['partner'],
67
68
pocket_dependencies = {
128
129
return 'universe'
131
def expand_dependencies(archive, distro_series, pocket, component,
132
def expand_dependencies(archive, distro_arch_series, pocket, component,
132
133
source_package_name):
133
134
"""Return the set of dependency archives, pockets and components.
135
136
:param archive: the context `IArchive`.
136
:param distro_series: the context `IDistroSeries`.
137
:param distro_arch_series: the context `IDistroArchSeries`.
137
138
:param pocket: the context `PackagePublishingPocket`.
138
139
:param component: the context `IComponent`.
139
140
:param source_package_name: A source package name (as text)
140
:return: a list of (archive, pocket, [component]), representing the
141
dependencies defined by the given build context.
141
:return: a list of (archive, distro_arch_series, pocket, [component]),
142
representing the dependencies defined by the given build context.
144
distro_series = distro_arch_series.distroseries
145
147
# Add implicit self-dependency for non-primary contexts.
146
148
if archive.purpose in ALLOW_RELEASE_BUILDS:
148
archive, PackagePublishingPocket.RELEASE,
150
archive, distro_arch_series, PackagePublishingPocket.RELEASE,
149
151
get_components_for_context(component, pocket)))
151
153
primary_component = get_primary_current_component(
163
165
# Follow pocket dependencies.
164
166
for pocket in pocket_dependencies[archive_dependency.pocket]:
166
(archive_dependency.dependency, pocket, components))
168
(archive_dependency.dependency, distro_arch_series, pocket,
168
171
# Consider primary archive dependency override. Add the default
169
172
# primary archive dependencies if it's not present.
170
173
if archive.getArchiveDependency(
171
174
archive.distribution.main_archive) is None:
172
175
primary_dependencies = _get_default_primary_dependencies(
173
archive, component, pocket)
176
archive, distro_arch_series, component, pocket)
174
177
deps.extend(primary_dependencies)
179
# Add dependencies for overlay archives defined in DistroSeriesParent.
180
# This currently only applies for derived distributions but in the future
181
# should be merged with ArchiveDependency so we don't have two separate
182
# tables essentially doing the same thing.
183
dsp_set = getUtility(IDistroSeriesParentSet)
184
for dsp in dsp_set.getFlattenedOverlayTree(distro_series):
186
dep_arch_series = dsp.parent_series.getDistroArchSeries(
187
distro_arch_series.architecturetag)
188
dep_archive = dsp.parent_series.distribution.main_archive
189
components = component_dependencies[dsp.component.name]
190
# Follow pocket dependencies.
191
for pocket in pocket_dependencies[dsp.pocket]:
193
(dep_archive, dep_arch_series, pocket, components))
194
except NotFoundError:
191
212
:return: a deb sources_list entries (lines).
193
214
deps = expand_dependencies(
194
build.archive, distroarchseries.distroseries, build.pocket,
215
build.archive, distroarchseries, build.pocket,
195
216
build.current_component, sourcepackagename)
196
217
sources_list_lines = \
197
_get_sources_list_for_dependencies(deps, distroarchseries)
218
_get_sources_list_for_dependencies(deps)
199
220
external_dep_lines = []
200
221
# Append external sources_list lines for this archive if it's
259
280
return 'deb %s %s %s' % (url, suite, ' '.join(components))
262
def _get_sources_list_for_dependencies(dependencies, distroarchseries):
283
def _get_sources_list_for_dependencies(dependencies):
263
284
"""Return a list of sources_list lines.
265
286
Process the given list of dependency tuples for the given
266
287
`DistroArchseries`.
268
289
:param dependencies: list of 3 elements tuples as:
269
(`IArchive`, `PackagePublishingPocket`, list of `IComponent` names)
290
(`IArchive`, `IDistroArchSeries`, `PackagePublishingPocket`,
291
list of `IComponent` names)
270
292
:param distroarchseries: target `IDistroArchSeries`;
272
294
:return: a list of sources_list formatted lines.
274
296
sources_list_lines = []
275
for archive, pocket, components in dependencies:
297
for archive, distro_arch_series, pocket, components in dependencies:
276
298
has_published_binaries = _has_published_binaries(
277
archive, distroarchseries, pocket)
299
archive, distro_arch_series, pocket)
278
300
if not has_published_binaries:
280
302
sources_list_line = _get_binary_sources_list_line(
281
archive, distroarchseries, pocket, components)
303
archive, distro_arch_series, pocket, components)
282
304
sources_list_lines.append(sources_list_line)
284
306
return sources_list_lines
287
def _get_default_primary_dependencies(archive, component, pocket):
309
def _get_default_primary_dependencies(archive, distro_series, component,
288
311
"""Return the default primary dependencies for a given context.
290
313
:param archive: the context `IArchive`.
314
:param distro_series: the context `IDistroSeries`.
291
315
:param component: the context `IComponent`.
292
316
:param pocket: the context `PackagePublishingPocket`.
306
330
primary_dependencies = []
307
331
for pocket in primary_pockets:
308
332
primary_dependencies.append(
309
(archive.distribution.main_archive, pocket,
333
(archive.distribution.main_archive, distro_series, pocket,
310
334
primary_components))
312
336
return primary_dependencies