32
from canonical.launchpad.components.decoratedresultset import (
35
from canonical.launchpad.interfaces.lpstorm import IStore
32
36
from lp.registry.model.sourcepackagename import SourcePackageName
33
37
from lp.services.database import bulk
34
from lp.services.database.decoratedresultset import DecoratedResultSet
35
from lp.services.database.lpstorm import IStore
36
38
from lp.soyuz.interfaces.component import IComponentSet
37
39
from lp.soyuz.interfaces.publishing import active_publishing_status
38
40
from lp.soyuz.model.binarypackagename import BinaryPackageName
137
139
keep the same component and section as their ancestor publications.
140
def calculateSourceOverrides(archive, distroseries, pocket, sources,
141
source_component=None):
142
def calculateSourceOverrides(archive, distroseries, pocket, sources):
142
143
"""Calculate source overrides.
144
145
:param archive: The target `IArchive`.
145
146
:param distroseries: The target `IDistroSeries`.
146
147
:param pocket: The target `PackagePublishingPocket`.
147
148
:param sources: A tuple of `ISourcePackageName`s.
148
:param source_component: The sources' `IComponent` (optional).
150
150
:return: A list of `ISourceOverride`
171
171
implements(IOverridePolicy)
173
173
def calculateSourceOverrides(self, archive, distroseries, pocket,
174
sources, source_component=None):
175
175
raise NotImplementedError()
177
177
def calculateBinaryOverrides(self, archive, distroseries, pocket,
188
188
for the latest published binary publication.
191
def calculateSourceOverrides(self, archive, distroseries, pocket, spns,
192
source_component=None):
191
def calculateSourceOverrides(self, archive, distroseries, pocket, spns):
193
192
# Avoid circular imports.
194
193
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
195
194
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
237
236
store = IStore(BinaryPackagePublishingHistory)
238
237
expanded = calculate_target_das(distroseries, binaries)
241
239
make_package_condition(archive, das, bpn)
242
for bpn, das in expanded if das is not None]
243
if len(candidates) == 0:
240
for bpn, das in expanded)
245
241
already_published = DecoratedResultSet(
247
243
(BinaryPackageRelease.binarypackagenameID,
278
274
Override policy that assumes everything passed in doesn't exist, so
279
275
returns the defaults.
281
Newly-uploaded files have a default set of overrides to be applied.
282
This reduces the amount of work that archive admins have to do
283
since they override the majority of new uploads with the same
284
values. The rules for overriding are: (See bug #120052)
285
'contrib' -> 'multiverse'
286
'non-free' -> 'multiverse'
287
everything else -> 'universe'
288
This mainly relates to Debian syncs, where the default component
289
is 'main' but should not be in main for Ubuntu.
292
DEBIAN_COMPONENT_OVERRIDE_MAP = {
293
'contrib': 'multiverse',
294
'non-free': 'multiverse',
297
DEFAULT_OVERRIDE_COMPONENT = 'universe'
300
def getComponentOverride(cls, component=None, return_component=False):
301
# component can be a Component object or a component name.
302
if isinstance(component, Component):
303
component = component.name
304
override_component_name = cls.DEBIAN_COMPONENT_OVERRIDE_MAP.get(
305
component, cls.DEFAULT_OVERRIDE_COMPONENT)
307
return getUtility(IComponentSet)[override_component_name]
309
return override_component_name
311
278
def calculateSourceOverrides(self, archive, distroseries, pocket,
312
sources, source_component=None):
313
default_component = (
314
archive.default_component or
315
UnknownOverridePolicy.getComponentOverride(
316
source_component, return_component=True))
280
default_component = archive.default_component or getUtility(
281
IComponentSet)['universe']
318
283
SourceOverride(source, default_component, None)
319
284
for source in sources]
338
303
def calculateSourceOverrides(self, archive, distroseries, pocket,
339
sources, source_component=None):
340
305
total = set(sources)
341
306
overrides = FromExistingOverridePolicy.calculateSourceOverrides(
342
self, archive, distroseries, pocket, sources, source_component)
307
self, archive, distroseries, pocket, sources)
343
308
existing = set(override.source_package_name for override in overrides)
344
309
missing = total.difference(existing)
346
311
unknown = UnknownOverridePolicy.calculateSourceOverrides(
347
self, archive, distroseries, pocket, missing,
312
self, archive, distroseries, pocket, missing)
349
313
overrides.extend(unknown)