Exemplo n.º 1
0
 def format(self):
     """Return the DSC format."""
     try:
         return SourcePackageFormat.getTermByToken(
             self._dict['Format']).value
     except LookupError:
         return None
Exemplo n.º 2
0
 def format(self):
     """Return the DSC format."""
     try:
         return SourcePackageFormat.getTermByToken(
             self._dict['Format']).value
     except LookupError:
         return None
Exemplo n.º 3
0
    def checkCopy(self,
                  source,
                  series,
                  pocket,
                  person=None,
                  check_permissions=True):
        """Check if the source can be copied to the given location.

        Check possible conflicting publications in the destination archive.
        See `_checkArchiveConflicts()`.

        Also checks if the version of the source being copied is equal or
        higher than any version of the same source present in the
        destination suite (series + pocket).

        If person is not None, check that this person has upload rights to
        the destination (archive, component, pocket).

        :param source: copy candidate, `ISourcePackagePublishingHistory`.
        :param series: destination `IDistroSeries`.
        :param pocket: destination `PackagePublishingPocket`.
        :param person: requester `IPerson`.
        :param check_permissions: boolean indicating whether or not the
            requester's permissions to copy should be checked.

        :raise CannotCopy when a copy is not allowed to be performed
            containing the reason of the error.
        """
        if check_permissions:
            check_copy_permissions(person, self.archive, series, pocket,
                                   [source])

        if series not in self.archive.distribution.series:
            raise CannotCopy(
                "No such distro series %s in distribution %s." %
                (series.name, source.distroseries.distribution.name))

        format = SourcePackageFormat.getTermByToken(
            source.sourcepackagerelease.dsc_format).value

        if not series.isSourcePackageFormatPermitted(format):
            raise CannotCopy(
                "Source format '%s' not supported by target series %s." %
                (source.sourcepackagerelease.dsc_format, series.name))

        # Deny copies of source publications containing files with an
        # expiration date set.
        for source_file in source.sourcepackagerelease.files:
            if source_file.libraryfile.expires is not None:
                raise CannotCopy('source contains expired files')

        if self.include_binaries and self.strict_binaries:
            built_binaries = source.getBuiltBinaries(want_files=True)
            if len(built_binaries) == 0:
                raise CannotCopy("source has no binaries to be copied")
            # Deny copies of binary publications containing files with
            # expiration date set. We only set such value for immediate
            # expiration of old superseded binaries, so no point in
            # checking its content, the fact it is set is already enough
            # for denying the copy.
            for binary_pub in built_binaries:
                for binary_file in binary_pub.binarypackagerelease.files:
                    if binary_file.libraryfile.expires is not None:
                        raise CannotCopy('source has expired binaries')
                    if (self.archive.is_main
                            and not self.archive.build_debug_symbols
                            and binary_file.filetype
                            == BinaryPackageFileType.DDEB):
                        raise CannotCopy(
                            "Cannot copy DDEBs to a primary archive")

        # Check if there is already a source with the same name and version
        # published in the destination archive.
        self._checkArchiveConflicts(source, series)

        ancestry = self.archive.getPublishedSources(
            name=source.source_package_name,
            exact_match=True,
            distroseries=series,
            pocket=pocket,
            status=active_publishing_status).first()
        if ancestry is not None:
            ancestry_version = ancestry.sourcepackagerelease.version
            copy_version = source.sourcepackagerelease.version
            apt_pkg.init_system()
            if apt_pkg.version_compare(copy_version, ancestry_version) < 0:
                raise CannotCopy(
                    "version older than the %s published in %s" %
                    (ancestry.displayname, ancestry.distroseries.name))

        requires_unembargo = (not self.archive.private
                              and has_restricted_files(source))

        if requires_unembargo and not self.unembargo:
            raise CannotCopy(
                "Cannot copy restricted files to a public archive without "
                "explicit unembargo option.")

        # Copy is approved, update the copy inventory.
        self.addCopy(source)
Exemplo n.º 4
0
    def checkCopy(self, source, series, pocket, person=None,
                  check_permissions=True):
        """Check if the source can be copied to the given location.

        Check possible conflicting publications in the destination archive.
        See `_checkArchiveConflicts()`.

        Also checks if the version of the source being copied is equal or
        higher than any version of the same source present in the
        destination suite (series + pocket).

        If person is not None, check that this person has upload rights to
        the destination (archive, component, pocket).

        :param source: copy candidate, `ISourcePackagePublishingHistory`.
        :param series: destination `IDistroSeries`.
        :param pocket: destination `PackagePublishingPocket`.
        :param person: requester `IPerson`.
        :param check_permissions: boolean indicating whether or not the
            requester's permissions to copy should be checked.

        :raise CannotCopy when a copy is not allowed to be performed
            containing the reason of the error.
        """
        if check_permissions:
            check_copy_permissions(
                person, self.archive, series, pocket, [source])

        if series not in self.archive.distribution.series:
            raise CannotCopy(
                "No such distro series %s in distribution %s." %
                (series.name, source.distroseries.distribution.name))

        format = SourcePackageFormat.getTermByToken(
            source.sourcepackagerelease.dsc_format).value

        if not series.isSourcePackageFormatPermitted(format):
            raise CannotCopy(
                "Source format '%s' not supported by target series %s." %
                (source.sourcepackagerelease.dsc_format, series.name))

        # Deny copies of source publications containing files with an
        # expiration date set.
        for source_file in source.sourcepackagerelease.files:
            if source_file.libraryfile.expires is not None:
                raise CannotCopy('source contains expired files')

        if self.include_binaries and self.strict_binaries:
            built_binaries = source.getBuiltBinaries(want_files=True)
            if len(built_binaries) == 0:
                raise CannotCopy("source has no binaries to be copied")
            # Deny copies of binary publications containing files with
            # expiration date set. We only set such value for immediate
            # expiration of old superseded binaries, so no point in
            # checking its content, the fact it is set is already enough
            # for denying the copy.
            for binary_pub in built_binaries:
                for binary_file in binary_pub.binarypackagerelease.files:
                    if binary_file.libraryfile.expires is not None:
                        raise CannotCopy('source has expired binaries')
                    if (self.archive.is_main and
                        not self.archive.build_debug_symbols and
                        binary_file.filetype == BinaryPackageFileType.DDEB):
                        raise CannotCopy(
                            "Cannot copy DDEBs to a primary archive")

        # Check if there is already a source with the same name and version
        # published in the destination archive.
        self._checkArchiveConflicts(source, series)

        ancestry = self.archive.getPublishedSources(
            name=source.source_package_name, exact_match=True,
            distroseries=series, pocket=pocket,
            status=active_publishing_status).first()
        if ancestry is not None:
            ancestry_version = ancestry.sourcepackagerelease.version
            copy_version = source.sourcepackagerelease.version
            apt_pkg.init_system()
            if apt_pkg.version_compare(copy_version, ancestry_version) < 0:
                raise CannotCopy(
                    "version older than the %s published in %s" %
                    (ancestry.displayname, ancestry.distroseries.name))

        requires_unembargo = (
            not self.archive.private and has_restricted_files(source))

        if requires_unembargo and not self.unembargo:
            raise CannotCopy(
                "Cannot copy restricted files to a public archive without "
                "explicit unembargo option.")

        # Copy is approved, update the copy inventory.
        self.addCopy(source)