26
31
from canonical.launchpad.interfaces.lpstorm import IStore
27
32
from lp.registry.model.sourcepackagename import SourcePackageName
28
33
from lp.services.database import bulk
34
from lp.soyuz.interfaces.component import IComponentSet
29
35
from lp.soyuz.interfaces.publishing import active_publishing_status
30
36
from lp.soyuz.model.binarypackagename import BinaryPackageName
31
37
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
39
45
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
48
class IOverridePolicy(Interface):
51
An override policy returns overrides suitable for the given archive,
52
distroseries, pocket for source or binary publications.
54
For example, an implementation might allow existing publications to
55
keep the same component and section as their ancestor publications.
58
def calculateSourceOverrides(archive, distroseries, pocket, sources):
59
"""Calculate source overrides.
61
:param archive: The target `IArchive`.
62
:param distroseries: The target `IDistroSeries`.
63
:param pocket: The target `PackagePublishingPocket`.
64
:param sources: A tuple of `ISourcePackageName`s.
66
:return: A list of tuples containing `ISourcePackageName`,
67
`IComponent` and `ISection`.
71
def calculateBinaryOverrides(archive, distroseries, pocket, binaries):
72
"""Calculate binary overrides.
74
:param archive: The target `IArchive`.
75
:param distroseries: The target `IDistroSeries`.
76
:param pocket: The target `PackagePublishingPocket`.
77
:param binaries: A tuple of `IBinaryPackageName`, architecturetag
78
pairs. Architecturetag can be None for architecture-independent
81
:return: A list of tuples containing `IBinaryPackageName`,
82
`IDistroArchSeries`, `IComponent`, `ISection` and
83
`PackagePublishingPriority`.
42
88
class BaseOverridePolicy:
90
implements(IOverridePolicy)
44
92
def calculateSourceOverrides(self, archive, distroseries, pocket,
46
94
raise NotImplementedError()
69
117
(SourcePackageRelease.sourcepackagenameID,
70
118
SourcePackagePublishingHistory.componentID,
71
119
SourcePackagePublishingHistory.sectionID),
72
SourcePackagePublishingHistory.pocket == pocket,
73
120
SourcePackagePublishingHistory.archiveID == archive.id,
74
121
SourcePackagePublishingHistory.distroseriesID ==
105
152
BinaryPackagePublishingHistory.componentID,
106
153
BinaryPackagePublishingHistory.sectionID,
107
154
BinaryPackagePublishingHistory.priority),
108
BinaryPackagePublishingHistory.pocket == pocket,
109
155
BinaryPackagePublishingHistory.status.is_in(
110
156
active_publishing_status),
111
157
BinaryPackageRelease.id ==
137
183
def calculateSourceOverrides(self, archive, distroseries, pocket,
139
default_component = archive.default_component or 'universe'
185
default_component = archive.default_component or getUtility(
186
IComponentSet)['universe']
140
187
return [(source, default_component, None) for source in sources]
142
189
def calculateBinaryOverrides(self, archive, distroseries, pocket,
144
default_component = archive.default_component or 'universe'
191
default_component = archive.default_component or getUtility(
192
IComponentSet)['universe']
146
194
(binary, das, default_component, None, None)
147
195
for binary, das in calculate_target_das(distroseries, binaries)]