def test_copyUpload_accepts_upload(self):
     # Uploads created by copyUpload are automatically accepted.
     original_upload = self.makeUpload()
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
Exemplo n.º 2
0
 def test_copyUpload_accepts_upload(self):
     # Uploads created by copyUpload are automatically accepted.
     original_upload = self.makeUpload()
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
 def test_copyUpload_approves_uefi_from_same_archive(self):
     # Copies of UEFI custom uploads within the same archive are
     # automatically accepted, since they have already been signed.
     original_upload = self.makeUpload(
         custom_type=PackageUploadCustomFormat.UEFI)
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
Exemplo n.º 4
0
 def test_copyUpload_approves_uefi_from_same_archive(self):
     # Copies of UEFI custom uploads within the same archive are
     # automatically accepted, since they have already been signed.
     original_upload = self.makeUpload(
         custom_type=PackageUploadCustomFormat.UEFI)
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
 def test_copyUpload_to_updates_pocket(self):
     # copyUpload copies an upload between pockets in the same series if
     # requested.
     series = self.factory.makeDistroSeries(status=SeriesStatus.CURRENT)
     original_upload = self.makeUpload(
         distroseries=series, pocket=PackagePublishingPocket.PROPOSED)
     copier = CustomUploadsCopier(
         series, target_pocket=PackagePublishingPocket.UPDATES)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackagePublishingPocket.UPDATES, copied_pu.pocket)
 def test_copyUpload_from_ppa_to_main_archive(self):
     # copyUpload can copy uploads from a PPA to the main archive.
     series = self.factory.makeDistroSeries()
     archive = self.factory.makeArchive(distribution=series.distribution)
     original_upload = self.makeUpload(distroseries=series, archive=archive)
     copier = CustomUploadsCopier(
         series, target_archive=series.main_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(series.main_archive, copied_pu.archive)
Exemplo n.º 7
0
 def test_copyUpload_to_specified_archive(self):
     # If CustomUploadsCopier was created with a target archive,
     # copyUpload copies an upload to that archive.
     series = self.factory.makeDistroSeries()
     original_upload = self.makeUpload(distroseries=series)
     archive = self.factory.makeArchive(distribution=series.distribution)
     copier = CustomUploadsCopier(series, target_archive=archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(archive, copied_pu.archive)
Exemplo n.º 8
0
 def test_copyUpload_copies_into_release_pocket(self):
     # copyUpload copies the original upload into the release pocket,
     # even though the original is more likely to be in another
     # pocket.
     original_upload = self.makeUpload(
         pocket=PackagePublishingPocket.UPDATES)
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackagePublishingPocket.RELEASE, copied_pu.pocket)
Exemplo n.º 9
0
 def test_copyUpload_to_updates_pocket(self):
     # copyUpload copies an upload between pockets in the same series if
     # requested.
     series = self.factory.makeDistroSeries(status=SeriesStatus.CURRENT)
     original_upload = self.makeUpload(
         distroseries=series, pocket=PackagePublishingPocket.PROPOSED)
     copier = CustomUploadsCopier(
         series, target_pocket=PackagePublishingPocket.UPDATES)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackagePublishingPocket.UPDATES, copied_pu.pocket)
 def test_copyUpload_copies_into_release_pocket(self):
     # copyUpload copies the original upload into the release pocket,
     # even though the original is more likely to be in another
     # pocket.
     original_upload = self.makeUpload(
         pocket=PackagePublishingPocket.UPDATES)
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackagePublishingPocket.RELEASE, copied_pu.pocket)
Exemplo n.º 11
0
 def test_copyUpload_from_ppa_to_main_archive(self):
     # copyUpload can copy uploads from a PPA to the main archive.
     series = self.factory.makeDistroSeries()
     archive = self.factory.makeArchive(distribution=series.distribution)
     original_upload = self.makeUpload(distroseries=series, archive=archive)
     copier = CustomUploadsCopier(series,
                                  target_archive=series.main_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(series.main_archive, copied_pu.archive)
 def test_copyUpload_to_specified_archive(self):
     # If CustomUploadsCopier was created with a target archive,
     # copyUpload copies an upload to that archive.
     series = self.factory.makeDistroSeries()
     original_upload = self.makeUpload(distroseries=series)
     archive = self.factory.makeArchive(distribution=series.distribution)
     copier = CustomUploadsCopier(series, target_archive=archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(archive, copied_pu.archive)
Exemplo n.º 13
0
 def test_copyUpload_archive_None_copies_within_archive(self):
     # If CustomUploadsCopier was created with no target archive,
     # copyUpload copies an upload to the same archive as the original
     # upload.
     original_upload = self.makeUpload()
     original_pu = original_upload.packageupload
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(original_pu.archive, copied_pu.archive)
 def test_copyUpload_archive_None_copies_within_archive(self):
     # If CustomUploadsCopier was created with no target archive,
     # copyUpload copies an upload to the same archive as the original
     # upload.
     original_upload = self.makeUpload()
     original_pu = original_upload.packageupload
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
     self.assertEqual(original_pu.archive, copied_pu.archive)
 def test_copyUpload_unapproves_uefi_from_different_archive(self):
     # Copies of UEFI custom uploads to a primary archive are set to
     # UNAPPROVED, since they will normally end up being signed.
     target_series = self.factory.makeDistroSeries()
     archive = self.factory.makeArchive(
         distribution=target_series.distribution)
     original_upload = self.makeUpload(
         archive=archive, custom_type=PackageUploadCustomFormat.UEFI)
     copier = CustomUploadsCopier(
         target_series, target_archive=target_series.main_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.UNAPPROVED, copied_pu.status)
Exemplo n.º 16
0
 def test_copyUpload_unapproves_uefi_from_different_archive(self):
     # Copies of UEFI custom uploads to a primary archive are set to
     # UNAPPROVED, since they will normally end up being signed.
     target_series = self.factory.makeDistroSeries()
     archive = self.factory.makeArchive(
         distribution=target_series.distribution)
     original_upload = self.makeUpload(
         archive=archive, custom_type=PackageUploadCustomFormat.UEFI)
     copier = CustomUploadsCopier(target_series,
                                  target_archive=target_series.main_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.UNAPPROVED, copied_pu.status)
Exemplo n.º 17
0
 def test_copyUpload_approves_uefi_to_ppa(self):
     # Copies of UEFI custom uploads to a PPA are automatically accepted,
     # since PPAs have much more limited upload permissions than the main
     # archive, and in any case PPAs do not have an upload approval
     # workflow.
     original_upload = self.makeUpload(
         custom_type=PackageUploadCustomFormat.UEFI)
     target_series = self.factory.makeDistroSeries()
     target_archive = self.factory.makeArchive(
         distribution=target_series.distribution)
     copier = CustomUploadsCopier(target_series,
                                  target_archive=target_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
 def test_copyUpload_approves_uefi_to_ppa(self):
     # Copies of UEFI custom uploads to a PPA are automatically accepted,
     # since PPAs have much more limited upload permissions than the main
     # archive, and in any case PPAs do not have an upload approval
     # workflow.
     original_upload = self.makeUpload(
         custom_type=PackageUploadCustomFormat.UEFI)
     target_series = self.factory.makeDistroSeries()
     target_archive = self.factory.makeArchive(
         distribution=target_series.distribution)
     copier = CustomUploadsCopier(
         target_series, target_archive=target_archive)
     copied_pu = copier.copyUpload(original_upload).packageupload
     self.assertEqual(PackageUploadStatus.ACCEPTED, copied_pu.status)
Exemplo n.º 19
0
 def test_copyUpload_creates_upload(self):
     # copyUpload creates a new upload that's very similar to the
     # original, but for the target series.
     original_upload = self.makeUpload()
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(target_series,
                                  target_archive=target_series.main_archive)
     copied_upload = copier.copyUpload(original_upload)
     self.assertEqual([copied_upload], list_custom_uploads(target_series))
     original_pu = original_upload.packageupload
     copied_pu = copied_upload.packageupload
     self.assertNotEqual(original_pu, copied_pu)
     self.assertEqual(original_upload.customformat,
                      copied_upload.customformat)
     self.assertEqual(original_upload.libraryfilealias,
                      copied_upload.libraryfilealias)
     self.assertEqual(original_pu.changesfile, copied_pu.changesfile)
 def test_copyUpload_creates_upload(self):
     # copyUpload creates a new upload that's very similar to the
     # original, but for the target series.
     original_upload = self.makeUpload()
     target_series = self.factory.makeDistroSeries()
     copier = CustomUploadsCopier(
         target_series, target_archive=target_series.main_archive)
     copied_upload = copier.copyUpload(original_upload)
     self.assertEqual([copied_upload], list_custom_uploads(target_series))
     original_pu = original_upload.packageupload
     copied_pu = copied_upload.packageupload
     self.assertNotEqual(original_pu, copied_pu)
     self.assertEqual(
         original_upload.customformat, copied_upload.customformat)
     self.assertEqual(
         original_upload.libraryfilealias, copied_upload.libraryfilealias)
     self.assertEqual(original_pu.changesfile, copied_pu.changesfile)
Exemplo n.º 21
0
def _do_direct_copy(source,
                    archive,
                    series,
                    pocket,
                    include_binaries,
                    override=None,
                    close_bugs=True,
                    create_dsd_job=True,
                    close_bugs_since_version=None,
                    creator=None,
                    sponsor=None,
                    packageupload=None,
                    phased_update_percentage=None,
                    logger=None):
    """Copy publishing records to another location.

    Copy each item of the given list of `SourcePackagePublishingHistory`
    to the given destination if they are not yet available (previously
    copied).

    Also copy published binaries for each source if requested to. Again,
    only copy binaries that were not yet copied before.

    :param source: an `ISourcePackagePublishingHistory`.
    :param archive: the target `IArchive`.
    :param series: the target `IDistroSeries`, if None is given the same
        current source distroseries will be used as destination.
    :param pocket: the target `PackagePublishingPocket`.
    :param include_binaries: optional boolean, controls whether or
        not the published binaries for each given source should be also
        copied along with the source.
    :param override: An `IOverride` as per do_copy().
    :param close_bugs: A boolean indicating whether or not bugs on the
        copied publication should be closed.
    :param create_dsd_job: A boolean indicating whether or not a dsd job
         should be created for the new source publication.
    :param close_bugs_since_version: If close_bugs is True,
        then this parameter says which changelog entries to parse looking
        for bugs to close.  See `close_bugs_for_sourcepackagerelease`.
    :param creator: the requester `IPerson`.
    :param sponsor: the sponsor `IPerson`, if this copy is being sponsored.
    :param packageupload: The `IPackageUpload` that caused this publication
        to be created.
    :param phased_update_percentage: The phased update percentage to apply
        to the copied publication.
    :param logger: An optional logger.

    :return: a list of `ISourcePackagePublishingHistory` and
        `BinaryPackagePublishingHistory` corresponding to the copied
        publications.
    """
    from lp.soyuz.scripts.processaccepted import (
        close_bugs_for_sourcepublication)

    copies = []
    custom_files = []

    # Copy source if it's not yet copied.
    source_in_destination = archive.getPublishedSources(
        name=source.sourcepackagerelease.name,
        exact_match=True,
        version=source.sourcepackagerelease.version,
        status=active_publishing_status,
        distroseries=series,
        pocket=pocket)
    policy = archive.getOverridePolicy(
        phased_update_percentage=phased_update_percentage)
    if source_in_destination.is_empty():
        # If no manual overrides were specified and the archive has an
        # override policy then use that policy to get overrides.
        if override is None and policy is not None:
            package_names = (source.sourcepackagerelease.sourcepackagename, )
            # Only one override can be returned so take the first
            # element of the returned list.
            overrides = policy.calculateSourceOverrides(
                archive, series, pocket, package_names)
            # Only one override can be returned so take the first
            # element of the returned list.
            assert len(overrides) == 1, (
                "More than one override encountered, something is wrong.")
            override = overrides[0]
        source_copy = source.copyTo(series,
                                    pocket,
                                    archive,
                                    override,
                                    create_dsd_job=create_dsd_job,
                                    creator=creator,
                                    sponsor=sponsor,
                                    packageupload=packageupload)
        if close_bugs:
            close_bugs_for_sourcepublication(source_copy,
                                             close_bugs_since_version)
        copies.append(source_copy)
    else:
        source_copy = source_in_destination.first()
    if source_copy.packageupload is not None:
        custom_files.extend(source_copy.packageupload.customfiles)

    if include_binaries:
        # Copy missing binaries for the matching architectures in the
        # destination series. ISPPH.getBuiltBinaries() return only unique
        # publication per binary package releases (i.e. excludes irrelevant
        # arch-indep publications) and IBPPH.copy is prepared to expand
        # arch-indep publications.
        binary_copies = getUtility(IPublishingSet).copyBinaries(
            archive, series, pocket, source.getBuiltBinaries(), policy=policy)

        if binary_copies is not None:
            copies.extend(binary_copies)
            binary_uploads = set(bpph.binarypackagerelease.build.package_upload
                                 for bpph in binary_copies)
            for binary_upload in binary_uploads:
                if binary_upload is not None:
                    custom_files.extend(binary_upload.customfiles)

    if custom_files:
        # Custom uploads aren't modelled as publication history records, so
        # we have to send these through the upload queue.
        custom_copier = CustomUploadsCopier(series,
                                            target_pocket=pocket,
                                            target_archive=archive)
        for custom in custom_files:
            if custom_copier.isCopyable(custom):
                custom_copier.copyUpload(custom)

    # Always ensure the needed builds exist in the copy destination
    # after copying the binaries.
    # XXX cjwatson 2012-06-22 bug=869308: Fails to honour P-a-s.
    source_copy.createMissingBuilds(logger=logger)

    return copies
Exemplo n.º 22
0
def _do_direct_copy(source, archive, series, pocket, include_binaries,
                    override=None, close_bugs=True, create_dsd_job=True,
                    close_bugs_since_version=None, creator=None,
                    sponsor=None, packageupload=None,
                    phased_update_percentage=None, logger=None):
    """Copy publishing records to another location.

    Copy each item of the given list of `SourcePackagePublishingHistory`
    to the given destination if they are not yet available (previously
    copied).

    Also copy published binaries for each source if requested to. Again,
    only copy binaries that were not yet copied before.

    :param source: an `ISourcePackagePublishingHistory`.
    :param archive: the target `IArchive`.
    :param series: the target `IDistroSeries`, if None is given the same
        current source distroseries will be used as destination.
    :param pocket: the target `PackagePublishingPocket`.
    :param include_binaries: optional boolean, controls whether or
        not the published binaries for each given source should be also
        copied along with the source.
    :param override: An `IOverride` as per do_copy().
    :param close_bugs: A boolean indicating whether or not bugs on the
        copied publication should be closed.
    :param create_dsd_job: A boolean indicating whether or not a dsd job
         should be created for the new source publication.
    :param close_bugs_since_version: If close_bugs is True,
        then this parameter says which changelog entries to parse looking
        for bugs to close.  See `close_bugs_for_sourcepackagerelease`.
    :param creator: the requester `IPerson`.
    :param sponsor: the sponsor `IPerson`, if this copy is being sponsored.
    :param packageupload: The `IPackageUpload` that caused this publication
        to be created.
    :param phased_update_percentage: The phased update percentage to apply
        to the copied publication.
    :param logger: An optional logger.

    :return: a list of `ISourcePackagePublishingHistory` and
        `BinaryPackagePublishingHistory` corresponding to the copied
        publications.
    """
    from lp.soyuz.scripts.processaccepted import (
        close_bugs_for_sourcepublication)

    copies = []
    custom_files = []

    # Copy source if it's not yet copied.
    source_in_destination = archive.getPublishedSources(
        name=source.sourcepackagerelease.name, exact_match=True,
        version=source.sourcepackagerelease.version,
        status=active_publishing_status,
        distroseries=series, pocket=pocket)
    policy = archive.getOverridePolicy(
        phased_update_percentage=phased_update_percentage)
    if source_in_destination.is_empty():
        # If no manual overrides were specified and the archive has an
        # override policy then use that policy to get overrides.
        if override is None and policy is not None:
            package_names = (source.sourcepackagerelease.sourcepackagename,)
            # Only one override can be returned so take the first
            # element of the returned list.
            overrides = policy.calculateSourceOverrides(
                archive, series, pocket, package_names)
            # Only one override can be returned so take the first
            # element of the returned list.
            assert len(overrides) == 1, (
                "More than one override encountered, something is wrong.")
            override = overrides[0]
        source_copy = source.copyTo(
            series, pocket, archive, override, create_dsd_job=create_dsd_job,
            creator=creator, sponsor=sponsor, packageupload=packageupload)
        if close_bugs:
            close_bugs_for_sourcepublication(
                source_copy, close_bugs_since_version)
        copies.append(source_copy)
    else:
        source_copy = source_in_destination.first()
    if source_copy.packageupload is not None:
        custom_files.extend(source_copy.packageupload.customfiles)

    if include_binaries:
        # Copy missing binaries for the matching architectures in the
        # destination series. ISPPH.getBuiltBinaries() return only unique
        # publication per binary package releases (i.e. excludes irrelevant
        # arch-indep publications) and IBPPH.copy is prepared to expand
        # arch-indep publications.
        binary_copies = getUtility(IPublishingSet).copyBinaries(
            archive, series, pocket, source.getBuiltBinaries(), policy=policy)

        if binary_copies is not None:
            copies.extend(binary_copies)
            binary_uploads = set(
                bpph.binarypackagerelease.build.package_upload
                for bpph in binary_copies)
            for binary_upload in binary_uploads:
                if binary_upload is not None:
                    custom_files.extend(binary_upload.customfiles)

    if custom_files:
        # Custom uploads aren't modelled as publication history records, so
        # we have to send these through the upload queue.
        custom_copier = CustomUploadsCopier(
            series, target_pocket=pocket, target_archive=archive)
        for custom in custom_files:
            if custom_copier.isCopyable(custom):
                custom_copier.copyUpload(custom)

    # Always ensure the needed builds exist in the copy destination
    # after copying the binaries.
    # XXX cjwatson 2012-06-22 bug=869308: Fails to honour P-a-s.
    source_copy.createMissingBuilds(logger=logger)

    return copies