~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/scripts/generate_contents_files.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-13 16:23:34 UTC
  • mfrom: (13405.3.3 bug-809211)
  • Revision ID: launchpad@pqm.canonical.com-20110713162334-ytyhsr0zp32wgbhl
[r=julian-edwards][bug=809211] Move archive contents dirs inside
        distro roots.

Show diffs side-by-side

added added

removed removed

Lines of Context:
292
292
            for arch in archs:
293
293
                self.updateContentsFile(suite, arch)
294
294
 
 
295
    def updateLegacyContentArchiveRoot(self):
 
296
        """Replace content archive root with new contents location.
 
297
 
 
298
        If there is a legacy content_archive_root, move it to the new
 
299
        location.
 
300
 
 
301
        This is a temporary migration tool for the fix to bug 809211.
 
302
        After this has run at least once on each system that needs it, for
 
303
        each distribution archive, this method can go away.
 
304
        """
 
305
        content_archive_root = getattr(
 
306
            config.archivepublisher, 'content_archive_root', None)
 
307
        if content_archive_root is None:
 
308
            # No legacy configuration; nothing to do.
 
309
            return
 
310
        old_content_dir = os.path.join(
 
311
            content_archive_root, self.distribution.name + "-contents")
 
312
        if not file_exists(old_content_dir):
 
313
            # The data has already been moved (or didn't exist at all).
 
314
            return
 
315
        if file_exists(self.content_archive):
 
316
            # The new contents directory has already been created.
 
317
            # Confusing!
 
318
            self.logger.warn(
 
319
                "New contents directory %s has been created, "
 
320
                "but legacy directory %s still exists.  Ignoring the latter.",
 
321
                self.content_archive, old_content_dir)
 
322
            return
 
323
 
 
324
        self.logger.info(
 
325
            "Moving legacy contents directory %s into %s.",
 
326
            old_content_dir, self.content_archive)
 
327
        os.rename(old_content_dir, self.content_archive)
 
328
 
295
329
    def setUp(self):
296
330
        """Prepare configuration and filesystem state for the script's work.
297
331
 
302
336
        self.processOptions()
303
337
        self.config = getPubConfig(self.distribution.main_archive)
304
338
        self.content_archive = os.path.join(
305
 
            config.archivepublisher.content_archive_root,
306
 
            self.distribution.name + "-contents")
 
339
            self.config.distroroot, "contents-generation")
 
340
        self.updateLegacyContentArchiveRoot()
307
341
        self.setUpContentArchive()
308
342
 
309
343
    def main(self):