Esempio n. 1
0
    def gen_metadata_xml(self, package, build_no=None):
        """Generate the metadata.xml file for build source.

        metadata.xml is composed of the information from specfile plus
        some additional information."""
        metadata = MetaData()
        metadata.from_spec(self.spec.source, package)

        metadata.package.distribution = ctx.config.values.general.distribution
        metadata.package.distributionRelease = ctx.config.values.general.distribution_release
        metadata.package.architecture = "Any"
        metadata.package.packageFormat = ctx.get_option('package_format')

        size = long(0)
        if package.debug_package:
            d = self.pkg_debug_dir()
        else:
            d = self.pkg_install_dir()

        for path in package.files:
            for p in glob.glob(util.join_path(d, path.path)):
                size += util.dir_size(p)

        metadata.package.installedSize = size

        metadata.package.build = build_no

        metadata_xml_path = util.join_path(self.pkg_dir(),
                                           ctx.const.metadata_xml)
        metadata.write(metadata_xml_path)
        self.metadata = metadata
Esempio n. 2
0
def configure_pending():
    # start with pending packages
    # configure them in reverse topological order of dependency
    A = ctx.installdb.list_pending()
    G_f = pgraph.PGraph(ctx.packagedb,
                        pisi.itembyrepodb.installed)  # construct G_f
    for x in A.keys():
        G_f.add_package(x)
    B = A
    while len(B) > 0:
        Bp = set()
        for x in B.keys():
            pkg = ctx.packagedb.get_package(x, pisi.itembyrepodb.installed)
            for dep in pkg.runtimeDependencies():
                if dep.package in G_f.vertices():
                    G_f.add_dep(x, dep)
        B = Bp
    if ctx.get_option('debug'):
        G_f.write_graphviz(sys.stdout)
    order = G_f.topological_sort()
    order.reverse()
    try:
        import pisi.comariface as comariface
        for x in order:
            if ctx.installdb.is_installed(x):
                pkginfo = A[x]
                pkgname = util.package_name(x, pkginfo.version,
                                            pkginfo.release, False, False)
                pkg_path = util.join_path(ctx.config.lib_dir(), 'package',
                                          pkgname)
                m = MetaData()
                metadata_path = util.join_path(pkg_path,
                                               ctx.const.metadata_xml)
                m.read(metadata_path)
                # FIXME: we need a full package info here!
                pkginfo.name = x
                ctx.ui.notify(pisi.ui.configuring, package=pkginfo, files=None)
                pisi.comariface.post_install(
                    pkginfo.name,
                    m.package.providesComar,
                    util.join_path(pkg_path, ctx.const.comar_dir),
                    util.join_path(pkg_path, ctx.const.metadata_xml),
                    util.join_path(pkg_path, ctx.const.files_xml),
                )
                ctx.ui.notify(pisi.ui.configured, package=pkginfo, files=None)
            ctx.installdb.clear_pending(x)
    except ImportError:
        raise Error(_("comar package is not fully installed"))
Esempio n. 3
0
def info_name(package_name, installed=False):
    """fetch package information for a package"""
    if installed:
        package = ctx.packagedb.get_package(package_name,
                                            db.itembyrepo.installed)
    else:
        package, repo = ctx.packagedb.get_package_repo(package_name,
                                                       db.itembyrepo.repos)

    from pisi.metadata import MetaData
    metadata = MetaData()
    metadata.package = package
    #FIXME: get it from sourcedb if available
    metadata.source = None
    #TODO: fetch the files from server if possible (wow, you maniac -- future exa)
    if installed and ctx.installdb.is_installed(package.name):
        try:
            files = ctx.installdb.files(package.name)
        except pisi.Error, e:
            ctx.ui.warning(e)
            files = None