def resolve(cls, *deps):
        """
        Return all dependencies which will be installed.
        Like a portage based implementation it just tries to get
        the best package available according a given spec.
        """
        import paludis

        logger.info('[paludis] Resolving dependencies ...')

        env = paludis.EnvironmentFactory.instance.create('')
        fltr = paludis.Filter.And(paludis.Filter.SupportsInstallAction(),
                                  paludis.Filter.NotMasked())
        to_install = set()
        for dep in deps:
            ds = paludis.parse_user_package_dep_spec(dep, env, paludis.UserPackageDepSpecOptions())
            gen = paludis.Generator.Matches(ds, paludis.MatchPackageOptions())
            fg = paludis.FilteredGenerator(gen, fltr)
            s = paludis.Selection.BestVersionOnly(fg)
            _to_install = set()
            for pkg in env[s]:
                _to_install.add(str(pkg))
            if _to_install:
                to_install += _to_install
            else:
                msg = 'Package not found: {pkg}'.format(pkg=dep)
                raise exceptions.DependencyException(msg)

        cls.throw_package_list(list(to_install))
示例#2
0
    def resolve(cls, *deps):
        """
        Return all dependencies which will be installed.
        Like a portage based implementation it just tries to get
        the best package available according a given spec.
        """
        import paludis

        logger.info('[paludis] Resolving dependencies ...')

        env = paludis.EnvironmentFactory.instance.create('')
        fltr = paludis.Filter.And(paludis.Filter.SupportsInstallAction(),
                                  paludis.Filter.NotMasked())
        to_install = set()
        for dep in deps:
            ds = paludis.parse_user_package_dep_spec(dep, env, paludis.UserPackageDepSpecOptions())
            gen = paludis.Generator.Matches(ds, paludis.MatchPackageOptions())
            fg = paludis.FilteredGenerator(gen, fltr)
            s = paludis.Selection.BestVersionOnly(fg)
            _to_install = set()
            for pkg in env[s]:
                _to_install.add(str(pkg))
            if _to_install:
                to_install += _to_install
            else:
                msg = 'Package not found: {pkg}'.format(pkg=dep)
                raise exceptions.DependencyException(msg)

        cls.throw_package_list(list(to_install))
示例#3
0
文件: atom.py 项目: floppym/gentoopm
    def _init_atom(self, s, env, wildcards=False):
        opts = paludis.UserPackageDepSpecOptions() \
          + paludis.UserPackageDepSpecOption.NO_DISAMBIGUATION
        if wildcards:
            opts += paludis.UserPackageDepSpecOption.ALLOW_WILDCARDS

        try:
            self._atom = paludis.parse_user_package_dep_spec(
                s, env, opts, paludis.Filter.All())
        except (paludis.BadVersionOperatorError, paludis.PackageDepSpecError,
                paludis.RepositoryNameError):
            raise InvalidAtomStringError('Incorrect atom: %s' % s)
示例#4
0
 def is_pkg_installed(cls, dep):
     """Is a package managed by this manager installed?"""
     import paludis
     env = paludis.EnvironmentFactory.instance.create('')
     installed = env.fetch_repository('installed')
     try:
         pkg = paludis.parse_user_package_dep_spec(dep, env, paludis.UserPackageDepSpecOptions())
         # TODO Compare package version!
         r = []
         for i in installed.package_ids(str(pkg.package), []):
             r.append(str(i))
         logger.debug('Checking is installed: {0} -> {1}'.format(pkg, repr(r)))
         return r
     except paludis.BaseException as e:
         msg = 'Dependency specification is invalid [{0}]: {1}'.format(dep, str(e))
         raise exceptions.DependencyException(msg)
 def is_pkg_installed(cls, dep):
     """Is a package managed by this manager installed?"""
     import paludis
     env = paludis.EnvironmentFactory.instance.create('')
     installed = env.fetch_repository('installed')
     try:
         pkg = paludis.parse_user_package_dep_spec(dep, env,
                                                   paludis.UserPackageDepSpecOptions())
         # TODO Compare package version!
         r = []
         for i in installed.package_ids(str(pkg.package), []):
             r.append(str(i))
         logger.debug('Checking is installed: {0} -> {1}'.format(pkg, repr(r)))
         return r
     except paludis.BaseException as e:
         msg = 'Dependency specification is invalid [{0}]: {1}'.format(dep, str(e))
         raise exceptions.DependencyException(msg)
示例#6
0
def get_ids(env, package, include_masked):
    if include_masked:
        pfilter = Filter.All()
    else:
        pfilter = Filter.NotMasked()

    pds = parse_user_package_dep_spec(package, env,
            [UserPackageDepSpecOption.ALLOW_WILDCARDS], pfilter)
    pids = env[Selection.BestVersionOnly(
        Generator.Matches(pds, MatchPackageOptions()) | pfilter
        )]
    for pid in pids:
        mkey = pid.find_metadata("REMOTE_IDS")
        if mkey is not None:
            values = mkey.parse_value()
            yield pid.name, pid.version, values
        else:
            Log.instance.message("e.no_remote_ids", LogLevel.WARNING,
                    LogContext.NO_CONTEXT,
                    "%s does not have a remote ids metadata key" % pid.name)
示例#7
0
def get_contents(
    package,
    env,
    source_repos=[],
    requested_instances=[object],
    selection=Selection.AllVersionsGroupedBySlot,
    fnpattern=None,
    regexp=None,
    ignore_case=False,
):
    """Get contents of package"""

    # {{{Pattern matching
    if regexp is not None:
        if ignore_case:
            pattern = re.compile(regexp, re.IGNORECASE)
        else:
            pattern = re.compile(regexp)
    # }}}

    # {{{Get PackageDepSpec
    filter_installed = Filter.InstalledAtRoot(env.system_root_key)
    allow_wildcards = UserPackageDepSpecOption.ALLOW_WILDCARDS
    package_dep_spec = parse_user_package_dep_spec(package, env, [allow_wildcards], filter_installed)
    # }}}

    # {{{Get CONTENTS
    ids = env[selection(Generator.Matches(package_dep_spec, MatchPackageOptions()) | filter_installed)]

    for package_id in ids:
        if package_id.contents_key() is None:
            Log.instance.message(
                "vdb.no_contents",
                LogLevel.WARNING,
                LogContext.NO_CONTEXT,
                "'%s' does not provide a contents key." % package_id.name,
            )
        else:
            # {{{Match by source repository
            if source_repos:
                if package_id.from_repositories_key() is None:
                    Log.instance.message(
                        "vdb.no_source_origin",
                        LogLevel.WARNING,
                        LogContext.NO_CONTEXT,
                        "'%s' does not provide a from repositories key." % package_id.name,
                    )
                else:
                    repo_origin = package_id.from_repositories_key()

                    if not any(repo in source_repos for repo in repo_origin.parse_value()):
                        continue
            # }}}

            requested_contents = list()
            for content in package_id.contents_key().parse_value():
                if not any([isinstance(content, i) for i in requested_instances]):
                    continue

                content_path = rootjoin(content.location_key().parse_value(), env.root)

                if fnpattern is not None:
                    if ignore_case:
                        if not fnmatch.fnmatchcase(content_path, fnpattern):
                            continue
                    else:
                        if not fnmatch.fnmatch(content_path, fnpattern):
                            continue
                if regexp is not None and pattern.search(content_path) is None:
                    continue
                requested_contents.append(content)

            yield package_id, requested_contents