diff options
author | kitsunyan | 2018-06-02 07:08:15 +0000 |
---|---|---|
committer | kitsunyan | 2018-06-02 07:08:15 +0000 |
commit | 3d420e1b546c5636e38653cb21d5dc0f4306a30a (patch) | |
tree | 81e36d88d29ec1114a908e81769ecb066830e2c4 /src/feature/localquery.nim | |
parent | 3edef649597b7669bd67b1e42680ac25068debc7 (diff) |
Allow to query virtual packages using "-Qdttt"
Diffstat (limited to 'src/feature/localquery.nim')
-rw-r--r-- | src/feature/localquery.nim | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim index f8436cd..4a21fa9 100644 --- a/src/feature/localquery.nim +++ b/src/feature/localquery.nim @@ -4,16 +4,28 @@ import "../wrapper/alpm" proc handleQueryOrphans*(args: seq[Argument], config: Config): int = - let (installed, orphans, _) = withAlpmConfig(config, false, handle, dbs, errors): + let (installed, orphans, _, alternatives) = withAlpmConfig(config, false, handle, dbs, errors): for e in errors: printError(config.color, e) queryUnrequired(handle, true, false, initSet[string]()) - let targets = args.targets.map(t => (if t[0 .. 5] == "local/": t[6 .. ^1] else: t)) + let targets = args.packageTargets(false) + + proc isOrphanOrNotFound(reference: PackageReference): bool = + for r in installed: + if reference.isProvidedBy(r, true): + return reference.name in orphans + for name, references in alternatives: + for r in references: + let hasConstraint = r.constraint.isSome and not r.constraint.unsafeGet.impliedVersion + if (not hasConstraint and reference.constraint.isNone and r.name == reference.name) or + (hasConstraint and reference.isProvidedBy(r, true)): + return name in orphans + return true # Provide similar output for not installed packages - let unknownTargets = targets.toSet - installed let results = if targets.len > 0: - targets.filter(t => t in orphans or t in unknownTargets) + targets.filter(t => (t.repo.isNone or t.repo == some("local")) and + t.reference.isOrphanOrNotFound).map(t => $t) else: toSeq(orphans.items).sorted(cmp) |