예제 #1
0
    def _getSource(self, sourcepackagename, version, distroseries):
        """Returns a sourcepackagerelease by its name and version."""
        # XXX kiko 2005-11-05: we use the source package publishing tables
        # here, but I think that's a bit flawed. We should have a way of
        # saying "my distroseries overlays the version namespace of that
        # distroseries" and use that to decide on whether we've seen
        # this package before or not. The publishing tables may be
        # wrong, for instance, in the context of proper derivation.

        # Check here to see if this release has ever been published in
        # the distribution, no matter what status.
        query = """
                SourcePackageRelease.sourcepackagename = %s AND
                SourcePackageRelease.version = %s AND
                SourcePackagePublishingHistory.sourcepackagerelease =
                    SourcePackageRelease.id AND
                SourcePackagePublishingHistory.distroseries =
                    DistroSeries.id AND
                SourcePackagePublishingHistory.archive = %s AND
                DistroSeries.distribution = %s
                """ % sqlvalues(sourcepackagename, version,
                                distroseries.main_archive,
                                distroseries.distribution)
        ret = SourcePackageRelease.select(
            query,
            clauseTables=['SourcePackagePublishingHistory', 'DistroSeries'],
            orderBy=["-SourcePackagePublishingHistory.datecreated"])
        if not ret:
            return None
        return ret[0]
예제 #2
0
    def _getSource(self, sourcepackagename, version, distroseries):
        """Returns a sourcepackagerelease by its name and version."""
        # XXX kiko 2005-11-05: we use the source package publishing tables
        # here, but I think that's a bit flawed. We should have a way of
        # saying "my distroseries overlays the version namespace of that
        # distroseries" and use that to decide on whether we've seen
        # this package before or not. The publishing tables may be
        # wrong, for instance, in the context of proper derivation.

        # Check here to see if this release has ever been published in
        # the distribution, no matter what status.
        query = """
                SourcePackageRelease.sourcepackagename = %s AND
                SourcePackageRelease.version = %s AND
                SourcePackagePublishingHistory.sourcepackagerelease =
                    SourcePackageRelease.id AND
                SourcePackagePublishingHistory.distroseries =
                    DistroSeries.id AND
                SourcePackagePublishingHistory.archive = %s AND
                DistroSeries.distribution = %s
                """ % sqlvalues(sourcepackagename, version,
                                distroseries.main_archive,
                                distroseries.distribution)
        ret = SourcePackageRelease.select(query,
            clauseTables=['SourcePackagePublishingHistory', 'DistroSeries'],
            orderBy=["-SourcePackagePublishingHistory.datecreated"])
        if not ret:
            return None
        return ret[0]
예제 #3
0
    def _update(cls, distro, sourcepackagename, archive, log):
        """Update cached source package details.

        Update cache details for a given ISourcePackageName, including
        generated binarypackage names, summary and description fti.
        'log' is required and only prints debug level information.
        """

        # Get the set of published sourcepackage releases.
        sprs = list(SourcePackageRelease.select("""
            SourcePackageRelease.id =
                SourcePackagePublishingHistory.sourcepackagerelease AND
            SourcePackagePublishingHistory.sourcepackagename = %s AND
            SourcePackagePublishingHistory.distroseries =
                DistroSeries.id AND
            DistroSeries.distribution = %s AND
            SourcePackagePublishingHistory.archive = %s AND
            SourcePackagePublishingHistory.dateremoved is NULL
            """ % sqlvalues(sourcepackagename, distro, archive),
            orderBy='id',
            clauseTables=['SourcePackagePublishingHistory', 'DistroSeries'],
            distinct=True))

        if len(sprs) == 0:
            log.debug("No sources releases found.")
            return

        # Find or create the cache entry.
        cache = DistributionSourcePackageCache.selectOne("""
            distribution = %s AND
            archive = %s AND
            sourcepackagename = %s
            """ % sqlvalues(distro, archive, sourcepackagename))
        if cache is None:
            log.debug("Creating new source cache entry.")
            cache = DistributionSourcePackageCache(
                archive=archive,
                distribution=distro,
                sourcepackagename=sourcepackagename)

        # Make sure the name is correct.
        cache.name = sourcepackagename.name

        # Get the sets of binary package names, summaries, descriptions.

        # XXX Julian 2007-04-03:
        # This bit of code needs fixing up, it is doing stuff that
        # really needs to be done in SQL, such as sorting and uniqueness.
        # This would also improve the performance.
        binpkgnames = set()
        binpkgsummaries = set()
        binpkgdescriptions = set()
        sprchangelog = set()
        for spr in sprs:
            log.debug("Considering source version %s" % spr.version)
            # changelog may be empty, in which case we don't want to add it
            # to the set as the join would fail below.
            if spr.changelog_entry is not None:
                sprchangelog.add(spr.changelog_entry)
            binpkgs = BinaryPackageRelease.select("""
                BinaryPackageRelease.build = BinaryPackageBuild.id AND
                BinaryPackageBuild.source_package_release = %s
                """ % sqlvalues(spr.id),
                clauseTables=['BinaryPackageBuild'])
            for binpkg in binpkgs:
                log.debug("Considering binary '%s'" % binpkg.name)
                binpkgnames.add(binpkg.name)
                binpkgsummaries.add(binpkg.summary)
                binpkgdescriptions.add(binpkg.description)

        # Update the caches.
        cache.binpkgnames = ' '.join(sorted(binpkgnames))
        cache.binpkgsummaries = ' '.join(sorted(binpkgsummaries))
        cache.binpkgdescriptions = ' '.join(sorted(binpkgdescriptions))
        cache.changelog = ' '.join(sorted(sprchangelog))