218
223
self.logger.debug("Creating %s.", path)
219
224
os.makedirs(path)
221
def copyOverrides(self):
222
"""Copy overrides into the content archive."""
223
if file_exists(self.config.overrideroot):
226
def copyOverrides(self, override_root):
227
"""Copy overrides into the content archive.
229
This method won't access the database.
231
if file_exists(override_root):
224
232
execute(self.logger, "cp", [
226
self.config.overrideroot,
227
235
"%s/" % self.content_archive,
230
238
self.logger.debug("Did not find overrides; not copying.")
232
def writeContentsTop(self):
233
"""Write Contents.top file."""
240
def writeContentsTop(self, distro_name, distro_title):
241
"""Write Contents.top file.
243
This method won't access the database.
234
245
output_filename = os.path.join(
235
self.content_archive, '%s-misc' % self.distribution.name,
246
self.content_archive, '%s-misc' % distro_name, "Contents.top")
238
'distrotitle': self.distribution.title,
248
'distrotitle': distro_title,
240
250
output_file = file(output_filename, 'w')
241
251
text = file(get_template("Contents.top")).read() % parameters
242
252
output_file.write(text)
243
253
output_file.close()
245
def runAptFTPArchive(self):
246
"""Run apt-ftparchive to produce the Contents files."""
255
def runAptFTPArchive(self, distro_name):
256
"""Run apt-ftparchive to produce the Contents files.
258
This method may take a long time to run.
259
This method won't access the database.
247
261
execute(self.logger, "apt-ftparchive", [
250
self.content_archive, "%s-misc" % self.distribution.name,
264
self.content_archive, "%s-misc" % distro_name,
251
265
"apt-contents.conf"),
254
def generateContentsFiles(self):
255
"""Generate Contents files."""
268
def generateContentsFiles(self, override_root, distro_name, distro_title):
269
"""Generate Contents files.
271
This method may take a long time to run.
272
This method won't access the database.
274
:param override_root: Copy of `self.config.overrideroot` that can be
275
evaluated without accessing the database.
276
:param distro_name: Copy of `self.distribution.name` that can be
277
evaluated without accessing the database.
278
:param distro_title: Copy of `self.distribution.title` that can be
279
evaluated without accessing the database.
256
281
self.logger.debug(
257
282
"Running apt in private tree to generate new contents.")
259
self.writeContentsTop()
260
self.runAptFTPArchive()
283
self.copyOverrides(override_root)
284
self.writeContentsTop(distro_name, distro_title)
285
self.runAptFTPArchive(distro_name)
262
287
def updateContentsFile(self, suite, arch):
263
288
"""Update Contents file, if it has changed."""
340
365
self.updateLegacyContentArchiveRoot()
341
366
self.setUpContentArchive()
344
"""See `LaunchpadScript`."""
369
"""Do the bulk of the work."""
346
371
suites = self.getPockets()
347
372
archs = self.getArchs()
348
373
self.writeAptContentsConf(suites, archs)
349
374
self.createComponentDirs(suites, archs)
350
self.generateContentsFiles()
376
overrideroot = self.config.overrideroot
377
distro_name = self.distribution.name
378
distro_title = self.distribution.title
380
# This takes a while. Ensure that we do it without keeping a
381
# database transaction open.
383
with DatabaseBlockedPolicy():
384
self.generateContentsFiles(
385
overrideroot, distro_name, distro_title)
351
387
self.updateContentsFiles(suites, archs)
390
"""See `LaunchpadScript`."""
391
# This code has no need to alter the database.
392
with SlaveOnlyDatabasePolicy():