def binary_package_names(self):
     """See IDistributionSourcePackageRelease."""
     return BinaryPackageName.select("""
         BinaryPackageName.id =
             BinaryPackageRelease.binarypackagename AND
         BinaryPackageRelease.build = BinaryPackageBuild.id AND
         BinaryPackageBuild.source_package_release = %s
         """ % sqlvalues(self.sourcepackagerelease.id),
         clauseTables=['BinaryPackageRelease', 'BinaryPackageBuild'],
         orderBy='name',
         distinct=True)
    def removeOld(cls, distroseries, archive, log):
        """Delete any records that are no longer applicable.

        Consider all binarypackages marked as REMOVED.

        Also purges all existing cache records for disabled archives.

        :param archive: target `IArchive`.
        :param log: the context logger object able to print DEBUG level
            messages.
        """
        # get the set of package names that should be there
        bpns = set(BinaryPackageName.select("""
            BinaryPackagePublishingHistory.distroarchseries =
                DistroArchSeries.id AND
            DistroArchSeries.distroseries = %s AND
            Archive.id = %s AND
            BinaryPackagePublishingHistory.archive = Archive.id AND
            BinaryPackagePublishingHistory.binarypackagerelease =
                BinaryPackageRelease.id AND
            BinaryPackagePublishingHistory.binarypackagename =
                BinaryPackageName.id AND
            BinaryPackagePublishingHistory.dateremoved is NULL AND
            Archive.enabled = TRUE
            """ % sqlvalues(distroseries.id, archive.id),
            distinct=True,
            clauseTables=[
                'Archive',
                'DistroArchSeries',
                'BinaryPackagePublishingHistory',
                'BinaryPackageRelease']))

        # remove the cache entries for binary packages we no longer want
        for cache in cls._find(distroseries, archive):
            if cache.binarypackagename not in bpns:
                log.debug(
                    "Removing binary cache for '%s' (%s)"
                    % (cache.name, cache.id))
                cache.destroySelf()
    def removeOld(cls, distroseries, archive, log):
        """Delete any records that are no longer applicable.

        Consider all binarypackages marked as REMOVED.

        Also purges all existing cache records for disabled archives.

        :param archive: target `IArchive`.
        :param log: the context logger object able to print DEBUG level
            messages.
        """
        # get the set of package names that should be there
        bpns = set(
            BinaryPackageName.select("""
            BinaryPackagePublishingHistory.distroarchseries =
                DistroArchSeries.id AND
            DistroArchSeries.distroseries = %s AND
            Archive.id = %s AND
            BinaryPackagePublishingHistory.archive = Archive.id AND
            BinaryPackagePublishingHistory.binarypackagerelease =
                BinaryPackageRelease.id AND
            BinaryPackagePublishingHistory.binarypackagename =
                BinaryPackageName.id AND
            BinaryPackagePublishingHistory.dateremoved is NULL AND
            Archive.enabled = TRUE
            """ % sqlvalues(distroseries.id, archive.id),
                                     distinct=True,
                                     clauseTables=[
                                         'Archive', 'DistroArchSeries',
                                         'BinaryPackagePublishingHistory',
                                         'BinaryPackageRelease'
                                     ]))

        # remove the cache entries for binary packages we no longer want
        for cache in cls._find(distroseries, archive):
            if cache.binarypackagename not in bpns:
                log.debug("Removing binary cache for '%s' (%s)" %
                          (cache.name, cache.id))
                cache.destroySelf()