17
17
from germinate.archive import TagFile
18
18
from germinate.germinator import Germinator
19
19
from germinate.log import GerminateFormatter
20
from germinate.seeds import SeedStructure
20
from germinate.seeds import (
21
24
from zope.component import getUtility
23
26
from lp.archivepublisher.config import getPubConfig
53
56
def find_operable_series(distribution):
54
"""Find a series we can operate on in this distribution.
57
"""Find all the series we can operate on in this distribution.
56
59
We are allowed to modify DEVELOPMENT or FROZEN series, but should leave
57
60
series with any other status alone.
59
series = distribution.currentseries
60
if series.status in (SeriesStatus.DEVELOPMENT, SeriesStatus.FROZEN):
63
series for series in distribution.series
64
if series.status in (SeriesStatus.DEVELOPMENT, SeriesStatus.FROZEN)]
66
67
class GenerateExtraOverrides(LaunchpadScript):
96
97
"Distribution '%s' not found." % self.options.distribution)
98
99
self.series = find_operable_series(self.distribution)
99
if self.series is None:
100
101
raise LaunchpadScriptFailure(
101
"There is no DEVELOPMENT distroseries for %s." %
102
"There is no DEVELOPMENT or FROZEN distroseries for %s." %
102
103
self.options.distribution)
104
# Even if DistroSeries.component_names starts including partner, we
105
# don't want it; this applies to the primary archive only.
106
self.components = [component
107
for component in self.series.component_names
108
if component != "partner"]
110
105
def getConfig(self):
111
106
"""Set up a configuration object for this archive."""
112
107
archive = self.distribution.main_archive
149
144
self.addLogHandler()
146
def getComponents(self, series):
147
"""Get the list of components to process for a given distroseries.
149
Even if DistroSeries.component_names starts including partner,
150
we don't want it; this applies to the primary archive only.
153
for component in series.component_names
154
if component != "partner"]
151
156
def makeSeedStructures(self, series_name, flavours, seed_bases=None):
153
158
for flavour in flavours:
154
structures[flavour] = SeedStructure(
155
"%s.%s" % (flavour, series_name), seed_bases=seed_bases)
160
structure = SeedStructure(
161
"%s.%s" % (flavour, series_name), seed_bases=seed_bases)
163
structures[flavour] = structure
166
"Skipping empty seed structure for %s.%s",
167
flavour, series_name)
170
"Failed to fetch seeds for %s.%s: %s",
171
flavour, series_name, e)
156
172
return structures
158
174
def logGerminateProgress(self, *args):
278
294
if "build-essential" in structure.names and primary_flavour:
279
295
write_overrides("build-essential", "Build-Essential", "yes")
281
def germinateArch(self, override_file, series_name, arch, flavours,
297
def germinateArch(self, override_file, series_name, components, arch,
298
flavours, structures):
283
299
"""Germinate seeds on all flavours for a single architecture."""
284
300
germinator = Germinator(arch)
286
302
# Read archive metadata.
287
303
archive = TagFile(
288
series_name, self.components, arch,
304
series_name, components, arch,
289
305
"file://%s" % self.config.archiveroot, cleanup=True)
290
306
germinator.parse_archive(archive)
302
318
override_file, germinator, series_name, arch, flavour,
303
319
structures[flavour], flavour == flavours[0])
305
def generateExtraOverrides(self, series_name, series_architectures,
321
def generateExtraOverrides(self, series_name, components, architectures,
306
322
flavours, seed_bases=None):
307
323
structures = self.makeSeedStructures(
308
324
series_name, flavours, seed_bases=seed_bases)
310
override_path = os.path.join(
311
self.config.miscroot,
312
"more-extra.override.%s.main" % series_name)
313
with AtomicFile(override_path) as override_file:
314
for arch in series_architectures:
316
override_file, series_name, arch, flavours, structures)
327
override_path = os.path.join(
328
self.config.miscroot,
329
"more-extra.override.%s.main" % series_name)
330
with AtomicFile(override_path) as override_file:
331
for arch in architectures:
333
override_file, series_name, components, arch,
334
flavours, structures)
318
336
def process(self, seed_bases=None):
319
337
"""Do the bulk of the work."""
322
series_name = self.series.name
323
series_architectures = sorted(
324
[arch.architecturetag for arch in self.series.architectures])
340
for series in self.series:
341
series_name = series.name
342
components = self.getComponents(series)
343
architectures = sorted(
344
[arch.architecturetag for arch in series.architectures])
326
# This takes a while. Ensure that we do it without keeping a
327
# database transaction open.
329
with DatabaseBlockedPolicy():
330
self.generateExtraOverrides(
331
series_name, series_architectures, self.args,
332
seed_bases=seed_bases)
346
# This takes a while. Ensure that we do it without keeping a
347
# database transaction open.
349
with DatabaseBlockedPolicy():
350
self.generateExtraOverrides(
351
series_name, components, architectures, self.args,
352
seed_bases=seed_bases)
335
355
"""See `LaunchpadScript`."""