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))
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)
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)