def mergeCopy(self, target_archive, target_distroseries, source_archive=None, source_distroseries=None): if source_distroseries is None: source_distroseries = target_distroseries if source_archive is None: source_archive = source_distroseries.distribution.main_archive source_location = PackageLocation( source_archive, source_distroseries.distribution, source_distroseries, PackagePublishingPocket.RELEASE) target_location = PackageLocation( target_archive, target_distroseries.distribution, target_distroseries, PackagePublishingPocket.RELEASE) cloner = getUtility(IPackageCloner) return cloner.mergeCopy(source_location, target_location)
def diffArchives(self, target_archive, target_distroseries, source_archive=None, source_distroseries=None): """Run a packageSetDiff of two archives.""" if source_distroseries is None: source_distroseries = target_distroseries if source_archive is None: source_archive = source_distroseries.distribution.main_archive source_location = PackageLocation( source_archive, source_distroseries.distribution, source_distroseries, PackagePublishingPocket.RELEASE) target_location = PackageLocation( target_archive, target_distroseries.distribution, target_distroseries, PackagePublishingPocket.RELEASE) cloner = getUtility(IPackageCloner) return cloner.packageSetDiff(source_location, target_location)
def copyArchive(self, to_archive, to_distroseries, from_archive=None, from_distroseries=None, from_pocket=None, to_pocket=None, to_component=None, packagesets=None, processors=None): """Use a PackageCloner to copy an archive.""" if from_distroseries is None: from_distroseries = to_distroseries if from_archive is None: from_archive = from_distroseries.distribution.main_archive if from_pocket is None: from_pocket = PackagePublishingPocket.RELEASE if to_pocket is None: to_pocket = PackagePublishingPocket.RELEASE if packagesets is None: packagesets = [] origin = PackageLocation( from_archive, from_distroseries.distribution, from_distroseries, from_pocket) destination = PackageLocation( to_archive, to_distroseries.distribution, to_distroseries, to_pocket) origin.packagesets = packagesets if to_component is not None: destination.component = to_component cloner = getUtility(IPackageCloner) cloner.clonePackages( origin, destination, distroarchseries_list=None, processors=processors) return cloner
def _copy_publishing_records(self, distroarchseries_lists): """Copy the publishing records from the parent arch series to the given arch series in ourselves. We copy all PENDING and PUBLISHED records as PENDING into our own publishing records. We copy only the RELEASE pocket in the PRIMARY archive. """ archive_set = getUtility(IArchiveSet) for parent in self.derivation_parents: spns = self.source_names_by_parent.get(parent.id, None) if spns is not None and len(spns) == 0: # Some packagesets where selected but not a single # source from this parent: we skip the copy since # calling copy with spns=[] would copy all the packagesets # from this parent. continue # spns=None means no packagesets selected so we need to consider # all sources. distroarchseries_list = distroarchseries_lists[parent] for archive in parent.distribution.all_distro_archives: if archive.purpose != ArchivePurpose.PRIMARY: continue target_archive = archive_set.getByDistroPurpose( self.distroseries.distribution, archive.purpose) if archive.purpose is ArchivePurpose.PRIMARY: assert target_archive is not None, ( "Target archive doesn't exist?") if self._use_cloner(target_archive, archive): origin = PackageLocation(archive, parent.distribution, parent, PackagePublishingPocket.RELEASE) destination = PackageLocation( target_archive, self.distroseries.distribution, self.distroseries, PackagePublishingPocket.RELEASE) processors = None if self.rebuild: processors = [ das[1].processor for das in distroarchseries_list ] distroarchseries_list = () getUtility(IPackageCloner).clonePackages( origin, destination, distroarchseries_list, processors, spns, self.rebuild) else: # There is only one available pocket in an unreleased # series. target_pocket = PackagePublishingPocket.RELEASE sources = archive.getPublishedSources( distroseries=parent, pocket=INIT_POCKETS, status=(PackagePublishingStatus.PENDING, PackagePublishingStatus.PUBLISHED), name=spns) # XXX: rvb 2011-06-23 bug=801112: do_copy is atomic (all # or none of the sources will be copied). This might # lead to a partially initialised series if there is a # single conflict in the destination series. try: sources_published = do_copy( sources, target_archive, self.distroseries, target_pocket, include_binaries=not self.rebuild, check_permissions=False, strict_binaries=False, close_bugs=False, create_dsd_job=False, person=None) if self.rebuild: rebuilds = [] for pubrec in sources_published: builds = pubrec.createMissingBuilds( list(self.distroseries.architectures)) rebuilds.extend(builds) self._rescore_rebuilds(rebuilds) except CannotCopy as error: raise InitializationError(error)