~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/scripts/populate_archive.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-07-16 17:15:56 UTC
  • mfrom: (11017.2.12 test-package-cloner)
  • Revision ID: launchpad@pqm.canonical.com-20100716171556-lqd8diiac9n493rq
[r=rockstar][ui=none] Make PackageCloner create builds,
        and add some tests for it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
248
248
                """Extract the processor family from an `IArchiveArch`."""
249
249
                return removeSecurityProxy(archivearch).processorfamily
250
250
 
251
 
            proc_families = [
252
 
                get_family(archivearch) for archivearch
253
 
                in getUtility(IArchiveArchSet).getByArchive(copy_archive)]
254
 
 
255
251
        # Now instantiate the package copy request that will capture the
256
252
        # archive population parameters in the database.
257
253
        pcr = getUtility(IPackageCopyRequestSet).new(
269
265
        if merge_copy_flag:
270
266
            pkg_cloner.mergeCopy(the_origin, the_destination)
271
267
        else:
272
 
            pkg_cloner.clonePackages(the_origin, the_destination)
273
 
 
274
 
        # Create builds for the cloned packages.
275
 
        self._createMissingBuilds(
276
 
            the_destination.distroseries, the_destination.archive,
277
 
            proc_families)
 
268
            pkg_cloner.clonePackages(
 
269
                the_origin, the_destination, proc_families=proc_families)
278
270
 
279
271
        # Mark the package copy request as completed.
280
272
        pcr.markAsCompleted()
399
391
            "--nonvirtualized", dest="nonvirtualized", default=False,
400
392
            action="store_true",
401
393
            help='Create the archive as nonvirtual if specified.')
402
 
 
403
 
    def _createMissingBuilds(
404
 
        self, distroseries, archive, proc_families):
405
 
        """Create builds for all cloned source packages.
406
 
 
407
 
        :param distroseries: the distro series for which to create builds.
408
 
        :param archive: the archive for which to create builds.
409
 
        :param proc_families: the list of processor families for
410
 
            which to create builds.
411
 
        """
412
 
        # Avoid circular imports.
413
 
        from lp.soyuz.interfaces.publishing import active_publishing_status
414
 
 
415
 
        self.logger.info("Processing %s." % distroseries.name)
416
 
 
417
 
        # Listify the architectures to avoid hitting this MultipleJoin
418
 
        # multiple times.
419
 
        architectures = list(distroseries.architectures)
420
 
 
421
 
        # Filter the list of DistroArchSeries so that only the ones
422
 
        # specified on the command line remain.
423
 
        architectures = [architecture for architecture in architectures
424
 
             if architecture.processorfamily in proc_families]
425
 
 
426
 
        if len(architectures) == 0:
427
 
            self.logger.info(
428
 
                "No DistroArchSeries left for %s, done." % distroseries.name)
429
 
            return
430
 
 
431
 
        self.logger.info(
432
 
            "Supported architectures: %s." %
433
 
            " ".join(arch_series.architecturetag
434
 
                     for arch_series in architectures))
435
 
 
436
 
        # Both, PENDING and PUBLISHED sources will be considered for
437
 
        # as PUBLISHED. It's part of the assumptions made in:
438
 
        # https://launchpad.net/soyuz/+spec/build-unpublished-source
439
 
        sources_published = archive.getPublishedSources(
440
 
            distroseries=distroseries, status=active_publishing_status)
441
 
 
442
 
        self.logger.info(
443
 
            "Found %d source(s) published." % sources_published.count())
444
 
 
445
 
        def get_spn(pub):
446
 
            """Return the source package name for a publishing record."""
447
 
            return pub.sourcepackagerelease.sourcepackagename.name
448
 
 
449
 
        archindep_unavailable = distroseries.nominatedarchindep not in (
450
 
            architectures)
451
 
 
452
 
        for pubrec in sources_published:
453
 
            if (pubrec.sourcepackagerelease.architecturehintlist == "all"
454
 
                and archindep_unavailable):
455
 
                self.logger.info(
456
 
                    "Skipping %s, arch-all package can't be built since %s "
457
 
                    "is not requested" % (
458
 
                        get_spn(pubrec),
459
 
                        distroseries.nominatedarchindep.architecturetag))
460
 
                continue
461
 
 
462
 
            builds = pubrec.createMissingBuilds(
463
 
                architectures_available=architectures, logger=self.logger)
464
 
            if len(builds) == 0:
465
 
                self.logger.info("%s has no builds." % get_spn(pubrec))
466
 
            else:
467
 
                self.logger.info(
468
 
                    "%s has %s build(s)." % (get_spn(pubrec), len(builds)))
469
 
            self.txn.commit()