示例#1
0
def getBinaryPackageDescriptions(results,
                                 use_names=False,
                                 max_title_length=50):
    """Return a dict of descriptions keyed by package name.

    See sourcepackage.py:getSourcePackageDescriptions, which is analogous.
    """
    if len(list(results)) < 1:
        return {}
    if use_names:
        clause = ("BinaryPackageName.name in %s" %
                  sqlvalues([pn.name for pn in results]))
    else:
        clause = ("BinaryPackageName.id in %s" %
                  sqlvalues([bpn.id for bpn in results]))

    descriptions = {}
    releases = BinaryPackageRelease.select(
        """BinaryPackageRelease.binarypackagename =
            BinaryPackageName.id AND
           %s""" % clause,
        clauseTables=["BinaryPackageRelease", "BinaryPackageName"],
        orderBy=["-BinaryPackageRelease.datecreated"])

    for release in releases:
        binarypackagename = release.binarypackagename.name
        if binarypackagename not in descriptions:
            description = release.description.strip().replace("\n", " ")
            if len(description) > max_title_length:
                description = (release.description[:max_title_length] + "...")
            descriptions[binarypackagename] = description
    return descriptions
def getBinaryPackageDescriptions(results, use_names=False,
                                 max_title_length=50):
    """Return a dict of descriptions keyed by package name.

    See sourcepackage.py:getSourcePackageDescriptions, which is analogous.
    """
    if len(list(results)) < 1:
        return {}
    if use_names:
        clause = ("BinaryPackageName.name in %s" %
                 sqlvalues([pn.name for pn in results]))
    else:
        clause = ("BinaryPackageName.id in %s" %
                 sqlvalues([bpn.id for bpn in results]))

    descriptions = {}
    releases = BinaryPackageRelease.select(
        """BinaryPackageRelease.binarypackagename =
            BinaryPackageName.id AND
           %s""" % clause,
        clauseTables=["BinaryPackageRelease", "BinaryPackageName"],
        orderBy=["-BinaryPackageRelease.datecreated"])

    for release in releases:
        binarypackagename = release.binarypackagename.name
        if binarypackagename not in descriptions:
            description = release.description.strip().replace("\n", " ")
            if len(description) > max_title_length:
                description = (release.description[:max_title_length]
                              + "...")
            descriptions[binarypackagename] = description
    return descriptions
 def binarypackages(self):
     """See `IBuild`."""
     return BinaryPackageRelease.select("""
         BinaryPackageRelease.build = %s AND
         BinaryPackageRelease.binarypackagename = BinaryPackageName.id
         """ % sqlvalues(self),
         clauseTables=["BinaryPackageName"],
         orderBy=["BinaryPackageName.name", "BinaryPackageRelease.id"],
         prejoins=["binarypackagename", "component", "section"])
示例#4
0
    def createBinaryPackage(self, bin, srcpkg, distroarchinfo, archtag):
        """Create a new binarypackage."""
        fdir, fname = os.path.split(bin.filename)
        to_upload = check_not_in_librarian(fname, bin.archive_root, fdir)
        fname, path = to_upload[0]

        componentID = self.distro_handler.getComponentByName(bin.component).id
        sectionID = self.distro_handler.ensureSection(bin.section).id
        architecturespecific = (bin.architecture != "all")

        bin_name = getUtility(IBinaryPackageNameSet).ensure(bin.package)
        build = self.ensureBuild(bin, srcpkg, distroarchinfo, archtag)

        # Create the binarypackage entry on lp db.
        binpkg = BinaryPackageRelease(
            binarypackagename=bin_name.id,
            component=componentID,
            version=bin.version,
            description=bin.description,
            summary=bin.summary,
            build=build.id,
            binpackageformat=getBinaryPackageFormat(bin.filename),
            section=sectionID,
            priority=prioritymap[bin.priority],
            shlibdeps=bin.shlibs,
            depends=bin.depends,
            suggests=bin.suggests,
            recommends=bin.recommends,
            conflicts=bin.conflicts,
            replaces=bin.replaces,
            provides=bin.provides,
            pre_depends=bin.pre_depends,
            enhances=bin.enhances,
            breaks=bin.breaks,
            essential=bin.essential,
            installedsize=bin.installed_size,
            architecturespecific=architecturespecific,
        )
        log.info('Binary Package Release %s (%s) created' %
                 (bin_name.name, bin.version))

        alias = getLibraryAlias(path, fname)
        BinaryPackageFile(binarypackagerelease=binpkg.id,
                          libraryfile=alias,
                          filetype=determine_binary_file_type(fname))
        log.info('Package file %s included into library' % fname)

        # Return the binarypackage object.
        return binpkg
示例#5
0
    def checkBin(self, binarypackagedata, distroarchinfo):
        """Returns a binarypackage -- if it exists."""
        try:
            binaryname = BinaryPackageName.byName(binarypackagedata.package)
        except SQLObjectNotFound:
            # If the binary package's name doesn't exist, don't even
            # bother looking for a binary package.
            return None

        version = binarypackagedata.version
        architecture = binarypackagedata.architecture

        clauseTables = [
            "BinaryPackageRelease", "DistroSeries", "BinaryPackageBuild",
            "DistroArchSeries"
        ]
        distroseries = distroarchinfo['distroarchseries'].distroseries

        # When looking for binaries, we need to remember that they are
        # shared between distribution releases, so match on the
        # distribution and the architecture tag of the distroarchseries
        # they were built for
        query = (
            "BinaryPackageRelease.binarypackagename=%s AND "
            "BinaryPackageRelease.version=%s AND "
            "BinaryPackageRelease.build = BinaryPackageBuild.id AND "
            "BinaryPackageBuild.distro_arch_series = DistroArchSeries.id AND "
            "DistroArchSeries.distroseries = DistroSeries.id AND "
            "DistroSeries.distribution = %d" %
            (binaryname.id, quote(version), distroseries.distribution.id))

        if architecture != "all":
            query += ("AND DistroArchSeries.architecturetag = %s" %
                      quote(architecture))

        try:
            bpr = BinaryPackageRelease.selectOne(query,
                                                 clauseTables=clauseTables)
        except SQLObjectMoreThanOneResultError:
            # XXX kiko 2005-10-27: Untested
            raise MultiplePackageReleaseError(
                "Found more than one "
                "entry for %s (%s) for %s in %s" %
                (binaryname.name, version, architecture,
                 distroseries.distribution.name))
        return bpr
示例#6
0
    def checkBin(self, binarypackagedata, distroarchinfo):
        """Returns a binarypackage -- if it exists."""
        try:
            binaryname = BinaryPackageName.byName(binarypackagedata.package)
        except SQLObjectNotFound:
            # If the binary package's name doesn't exist, don't even
            # bother looking for a binary package.
            return None

        version = binarypackagedata.version
        architecture = binarypackagedata.architecture

        clauseTables = ["BinaryPackageRelease", "DistroSeries",
                        "BinaryPackageBuild", "DistroArchSeries"]
        distroseries = distroarchinfo['distroarchseries'].distroseries

        # When looking for binaries, we need to remember that they are
        # shared between distribution releases, so match on the
        # distribution and the architecture tag of the distroarchseries
        # they were built for
        query = (
            "BinaryPackageRelease.binarypackagename=%s AND "
            "BinaryPackageRelease.version=%s AND "
            "BinaryPackageRelease.build = BinaryPackageBuild.id AND "
            "BinaryPackageBuild.distro_arch_series = DistroArchSeries.id AND "
            "DistroArchSeries.distroseries = DistroSeries.id AND "
            "DistroSeries.distribution = %d" %
            (binaryname.id, quote(version), distroseries.distribution.id))

        if architecture != "all":
            query += ("AND DistroArchSeries.architecturetag = %s" %
                      quote(architecture))

        try:
            bpr = BinaryPackageRelease.selectOne(
                query, clauseTables=clauseTables)
        except SQLObjectMoreThanOneResultError:
            # XXX kiko 2005-10-27: Untested
            raise MultiplePackageReleaseError("Found more than one "
                    "entry for %s (%s) for %s in %s" %
                    (binaryname.name, version, architecture,
                     distroseries.distribution.name))
        return bpr
示例#7
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))