Пример #1
0
def plan_install_pkg_names(A):
    # try to construct a pisi graph of packages to
    # install / reinstall

    G_f = pgraph.PGraph(ctx.packagedb)  # construct G_f

    # find the "install closure" graph of G_f by package
    # set A using packagedb
    for x in A:
        G_f.add_package(x)
    B = A

    while len(B) > 0:
        Bp = set()
        for x in B:
            pkg = ctx.packagedb.get_package(x)
            for dep in pkg.runtimeDependencies():
                ctx.ui.debug('checking %s' % str(dep))
                # we don't deal with already *satisfied* dependencies
                if not dependency.installed_satisfies_dep(dep):
                    if not dep.package in G_f.vertices():
                        Bp.add(str(dep.package))
                    G_f.add_dep(x, dep)
        B = Bp
    if ctx.config.get_option('debug'):
        G_f.write_graphviz(sys.stdout)
    order = G_f.topological_sort()
    order.reverse()
    if not ctx.get_option('ignore_file_conflicts'):
        conflict.check_conflicts(order, ctx.packagedb)
    return G_f, order
Пример #2
0
def package_graph(A, repo=db.itembyrepo.installed, ignore_installed=False):
    """Construct a package relations graph, containing
    all dependencies of packages A, if ignore_installed
    option is True, then only uninstalled deps will
    be added."""

    ctx.ui.debug('A = %s' % str(A))

    # try to construct a pisi graph of packages to
    # install / reinstall

    G_f = pgraph.PGraph(ctx.packagedb, repo)  # construct G_f

    # find the "install closure" graph of G_f by package
    # set A using packagedb
    for x in A:
        G_f.add_package(x)
    B = A
    #state = {}
    while len(B) > 0:
        Bp = set()
        for x in B:
            pkg = ctx.packagedb.get_package(x, repo)
            #print pkg
            for dep in pkg.runtimeDependencies():
                if ignore_installed:
                    if dependency.installed_satisfies_dep(dep):
                        continue
                if not dep.package in G_f.vertices():
                    Bp.add(str(dep.package))
                G_f.add_dep(x, dep)
        B = Bp
    return G_f
Пример #3
0
def plan_remove(A):
    # try to construct a pisi graph of packages to
    # install / reinstall

    # construct G_f
    G_f = pgraph.PGraph(ctx.packagedb, pisi.db.itembyrepo.installed)

    # find the (install closure) graph of G_f by package
    # set A using packagedb
    for x in A:
        G_f.add_package(x)
    B = A
    while len(B) > 0:
        Bp = set()
        for x in B:
            pkg = ctx.packagedb.get_package(x, pisi.db.itembyrepo.installed)
            assert (pkg)
            rev_deps = ctx.packagedb.get_rev_deps(x,
                                                  pisi.db.itembyrepo.installed)
            for (rev_dep, depinfo) in rev_deps:
                # we don't deal with uninstalled rev deps
                # and unsatisfied dependencies (this is important, too)
                if ctx.packagedb.has_package(rev_dep, pisi.db.itembyrepo.installed) and \
                   dependency.installed_satisfies_dep(depinfo):
                    if not rev_dep in G_f.vertices():
                        Bp.add(rev_dep)
                        G_f.add_plain_dep(rev_dep, x)
        B = Bp
    if ctx.config.get_option('debug'):
        G_f.write_graphviz(sys.stdout)
    order = G_f.topological_sort()
    return G_f, order
Пример #4
0
 def process_dep(dep):
     if not dependency.installed_satisfies_dep(dep):
         if dependency.repo_satisfies_dep(dep):
             install_list.add(dep.package)
             return
         srcdep = pkgtosrc(dep.package)
         if not srcdep in G_f.vertices():
             Bp.add(srcdep)
             add_src(get_src(srcdep))
         if not src.name == srcdep: # firefox - firefox-devel thing
             G_f.add_edge(src.name, srcdep)
Пример #5
0
def plan_upgrade(A, ignore_build=False):
    # try to construct a pisi graph of packages to
    # install / reinstall

    packagedb = ctx.packagedb

    G_f = pgraph.PGraph(packagedb)  # construct G_f

    # find the "install closure" graph of G_f by package
    # set A using packagedb
    for x in A:
        G_f.add_package(x)
    B = A

    # TODO: conflicts

    while len(B) > 0:
        Bp = set()
        for x in B:
            pkg = packagedb.get_package(x)
            for dep in pkg.runtimeDependencies():
                # add packages that can be upgraded
                if dependency.repo_satisfies_dep(dep):
                    if ctx.installdb.is_installed(dep.package):
                        if ctx.get_option('eager'):
                            if not is_upgradable(dep.package):
                                continue
                        else:
                            if dependency.installed_satisfies_dep(dep):
                                continue
                    if not dep.package in G_f.vertices():
                        Bp.add(str(dep.package))
                    G_f.add_dep(x, dep)
                else:
                    ctx.ui.error(
                        _('Dependency %s of %s cannot be satisfied') %
                        (dep, x))
                    raise Error(_("Upgrade is not possible."))
        B = Bp
    # now, search reverse dependencies to see if anything
    # should be upgraded
    B = A
    while len(B) > 0:
        Bp = set()
        for x in B:
            pkg = packagedb.get_package(x)
            rev_deps = packagedb.get_rev_deps(x)
            for (rev_dep, depinfo) in rev_deps:
                if ctx.get_option('eager'):
                    # add all upgradable reverse deps
                    if is_upgradable(rev_dep):
                        if not rev_dep in G_f.vertices():
                            Bp.add(rev_dep)
                            G_f.add_plain_dep(rev_dep, x)
                else:
                    # add only installed but unsatisfied reverse dependencies
                    if ctx.installdb.is_installed(rev_dep) and \
                       (not dependency.installed_satisfies_dep(depinfo)):
                        if not dependency.repo_satisfies_dep(depinfo):
                            raise Error(
                                _('Reverse dependency %s of %s cannot be satisfied'
                                  ) % (rev_dep, x))
                        if not rev_dep in G_f.vertices():
                            Bp.add(rev_dep)
                            G_f.add_plain_dep(rev_dep, x)
        B = Bp

    if ctx.config.get_option('debug'):
        G_f.write_graphviz(sys.stdout)
    order = G_f.topological_sort()
    order.reverse()
    if not ctx.get_option('ignore_file_conflicts'):
        conflict.check_conflicts(order, ctx.packagedb)
    return G_f, order
Пример #6
0
    def check_build_dependencies(self):
        """check and try to install build dependencies, otherwise fail."""

        build_deps = self.spec.source.buildDependencies

        if not ctx.get_option('bypass_safety'):
            if ctx.componentdb.has_component('system.devel'):
                build_deps_names = set([x.package for x in build_deps])
                devel_deps_names = set(
                    ctx.componentdb.get_component('system.devel').packages)
                extra_names = devel_deps_names - build_deps_names
                extra_names = filter(
                    lambda x: not ctx.installdb.is_installed(x), extra_names)
                if extra_names:
                    ctx.ui.warning(
                        _('Safety switch: following extra packages in system.devel will be installed: '
                          ) + util.strlist(extra_names))
                    extra_deps = [
                        dependency.Dependency(package=x) for x in extra_names
                    ]
                    build_deps.extend(extra_deps)
                else:
                    ctx.ui.warning(
                        _('Safety switch: system.devel is already installed'))
            else:
                ctx.ui.warning(
                    _('Safety switch: the component system.devel cannot be found'
                      ))

        # find out the build dependencies that are not satisfied...
        dep_unsatis = []
        for dep in build_deps:
            if not dependency.installed_satisfies_dep(dep):
                dep_unsatis.append(dep)

        if dep_unsatis:
            ctx.ui.info(
                _("Unsatisfied Build Dependencies:") + ' ' +
                util.strlist([str(x) for x in dep_unsatis]))

            def fail():
                raise Error(
                    _('Cannot build package due to unsatisfied build dependencies'
                      ))

            if ctx.config.get_option('no_install'):
                fail()

            if not ctx.config.get_option('ignore_dependency'):
                for dep in dep_unsatis:
                    if not dependency.repo_satisfies_dep(dep):
                        raise Error(
                            _('Build dependency %s cannot be satisfied') %
                            str(dep))
                if ctx.ui.confirm(
                        _('Do you want to install the unsatisfied build dependencies'
                          )):
                    ctx.ui.info(_('Installing build dependencies.'))
                    operations.install([dep.package for dep in dep_unsatis])
                else:
                    fail()
            else:
                ctx.ui.warning(_('Ignoring build dependencies.'))
Пример #7
0
 def satisfiesDep(dep):
     # is dependency satisfied among available packages
     # or packages to be installed?
     return dependency.installed_satisfies_dep(dep) \
            or dependency.dict_satisfies_dep(d_t, dep)